[DebianGIS-dev] [SCM] saga branch, upstream, updated. 07db935aa4b3c93f56dafa37400c9fa7951ff32c
Johan Van de Wauw
johan.vandewauw at gmail.com
Wed Sep 29 11:35:04 UTC 2010
The following commit has been merged in the upstream branch:
commit 07db935aa4b3c93f56dafa37400c9fa7951ff32c
Author: Johan Van de Wauw <johan.vandewauw at gmail.com>
Date: Wed Sep 29 13:23:02 2010 +0200
New upstream version 2.0.5
Upstream tarball: http://sourceforge.net/projects/saga-gis/files/SAGA -
2.0/SAGA 2.0.5/saga_2.0.5_src.tar.gz
diff --git a/Makefile.in b/Makefile.in
index 9bbb4df..0d508e3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -35,9 +35,9 @@ build_triplet = @build@
host_triplet = @host@
subdir = .
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
- $(srcdir)/Makefile.in $(srcdir)/config.h.in \
- $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
- config.guess config.sub depcomp install-sh ltmain.sh missing
+ $(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \
+ ChangeLog INSTALL NEWS config.guess config.sub depcomp \
+ install-sh ltmain.sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
@@ -45,7 +45,6 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
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 =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -120,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -129,6 +129,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -220,8 +221,7 @@ top_srcdir = @top_srcdir@
SUBDIRS = . src
@DEBUG_TRUE at AM_CFLAGS = -g -DDEBUG
@DEBUG_TRUE at AM_CXXFLAGS = -g -DDEBUG
-all: config.h
- $(MAKE) $(AM_MAKEFLAGS) all-recursive
+all: all-recursive
.SUFFIXES:
am--refresh:
@@ -259,23 +259,6 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps)
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
$(am__aclocal_m4_deps):
-config.h: stamp-h1
- @if test ! -f $@; then \
- rm -f stamp-h1; \
- $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
- else :; fi
-
-stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
- @rm -f stamp-h1
- cd $(top_builddir) && $(SHELL) ./config.status config.h
-$(srcdir)/config.h.in: $(am__configure_deps)
- ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
- rm -f stamp-h1
- touch $@
-
-distclean-hdr:
- -rm -f config.h stamp-h1
-
mostlyclean-libtool:
-rm -f *.lo
@@ -365,7 +348,7 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
mkid -fID $$unique
tags: TAGS
-TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
@@ -382,7 +365,7 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
- list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
@@ -400,9 +383,9 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
fi; \
fi
ctags: CTAGS
-CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
- list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
@@ -596,7 +579,7 @@ distcleancheck: distclean
exit 1; } >&2
check-am: all-am
check: check-recursive
-all-am: Makefile config.h
+all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
@@ -631,8 +614,8 @@ clean-am: clean-generic clean-libtool mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
-distclean-am: clean-am distclean-generic distclean-hdr \
- distclean-libtool distclean-tags
+distclean-am: clean-am distclean-generic distclean-libtool \
+ distclean-tags
dvi: dvi-recursive
@@ -694,24 +677,24 @@ ps-am:
uninstall-am:
-.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
- ctags-recursive install-am install-strip tags-recursive
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+ install-am install-strip tags-recursive
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am am--refresh check check-am clean clean-generic \
clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
- distcheck distclean distclean-generic distclean-hdr \
- distclean-libtool distclean-tags distcleancheck distdir \
- distuninstallcheck dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf install-pdf-am 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-recursive uninstall uninstall-am
+ distcheck distclean distclean-generic distclean-libtool \
+ distclean-tags distcleancheck distdir distuninstallcheck dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am 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-recursive uninstall uninstall-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/configure b/configure
index 69cdb3c..1afd9fb 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.63 for saga 2.0.
+# Generated by GNU Autoconf 2.63 for saga 2.0.5.
#
# Report bugs to <BUG-REPORT-ADDRESS>.
#
@@ -745,8 +745,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='saga'
PACKAGE_TARNAME='saga'
-PACKAGE_VERSION='2.0'
-PACKAGE_STRING='saga 2.0'
+PACKAGE_VERSION='2.0.5'
+PACKAGE_STRING='saga 2.0.5'
PACKAGE_BUGREPORT='BUG-REPORT-ADDRESS'
ac_unique_file="src/saga_core/saga_gui/wksp_data_menu_files.cpp"
@@ -789,6 +789,8 @@ ac_includes_default="\
ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
+DISABLELIBHARU
+HARU_LIB
SAGA_UNICODE_FALSE
SAGA_UNICODE_TRUE
DEBUG_FALSE
@@ -1484,7 +1486,7 @@ 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 saga 2.0 to adapt to many kinds of systems.
+\`configure' configures saga 2.0.5 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1554,7 +1556,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of saga 2.0:";;
+ short | recursive ) echo "Configuration of saga 2.0.5:";;
esac
cat <<\_ACEOF
@@ -1658,7 +1660,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-saga configure 2.0
+saga configure 2.0.5
generated by GNU Autoconf 2.63
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1672,7 +1674,7 @@ 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 saga $as_me 2.0, which was
+It was created by saga $as_me 2.0.5, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ $0 $@
@@ -2041,8 +2043,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
-ac_config_headers="$ac_config_headers config.h"
-
+#AC_CONFIG_HEADER([config.h])
#AM_INIT_AUTOMAKE(saga, 2.0beta)
am__api_version='1.11'
@@ -2525,7 +2526,7 @@ fi
# Define the identity of the package.
PACKAGE='saga'
- VERSION='2.0'
+ VERSION='2.0.5'
cat >>confdefs.h <<_ACEOF
@@ -5064,13 +5065,13 @@ if test "${lt_cv_nm_interface+set}" = set; then
else
lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
- (eval echo "\"\$as_me:5067: $ac_compile\"" >&5)
+ (eval echo "\"\$as_me:5068: $ac_compile\"" >&5)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&5
- (eval echo "\"\$as_me:5070: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+ (eval echo "\"\$as_me:5071: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&5
- (eval echo "\"\$as_me:5073: output\"" >&5)
+ (eval echo "\"\$as_me:5074: output\"" >&5)
cat conftest.out >&5
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
@@ -6276,7 +6277,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 6279 "configure"' > conftest.$ac_ext
+ echo '#line 6280 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -8867,11 +8868,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:8870: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:8871: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:8874: \$? = $ac_status" >&5
+ echo "$as_me:8875: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -9206,11 +9207,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:9209: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:9210: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:9213: \$? = $ac_status" >&5
+ echo "$as_me:9214: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -9311,11 +9312,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:9314: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:9315: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:9318: \$? = $ac_status" >&5
+ echo "$as_me:9319: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -9366,11 +9367,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:9369: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:9370: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:9373: \$? = $ac_status" >&5
+ echo "$as_me:9374: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -12166,7 +12167,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12169 "configure"
+#line 12170 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12262,7 +12263,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12265 "configure"
+#line 12266 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -14282,11 +14283,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14285: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14286: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:14289: \$? = $ac_status" >&5
+ echo "$as_me:14290: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -14381,11 +14382,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14384: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14385: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:14388: \$? = $ac_status" >&5
+ echo "$as_me:14389: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -14433,11 +14434,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:14436: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:14437: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:14440: \$? = $ac_status" >&5
+ echo "$as_me:14441: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -17691,10 +17692,93 @@ fi
#AM_CONDITIONAL(X86_64, test "`uname -m`" = "x86_64")
+{ $as_echo "$as_me:$LINENO: checking for HPDF_Pages_New in -lhpdf" >&5
+$as_echo_n "checking for HPDF_Pages_New in -lhpdf... " >&6; }
+if test "${ac_cv_lib_hpdf_HPDF_Pages_New+set}" = set; then
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lhpdf $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char HPDF_Pages_New ();
+int
+main ()
+{
+return HPDF_Pages_New ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+ (eval "$ac_link") 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ $as_test_x conftest$ac_exeext
+ }; then
+ ac_cv_lib_hpdf_HPDF_Pages_New=yes
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_cv_lib_hpdf_HPDF_Pages_New=no
+fi
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_hpdf_HPDF_Pages_New" >&5
+$as_echo "$ac_cv_lib_hpdf_HPDF_Pages_New" >&6; }
+if test "x$ac_cv_lib_hpdf_HPDF_Pages_New" = x""yes; then
+ HARUFOUND=1
+fi
+
+ if test -n "$HARUFOUND" ; then
+ { $as_echo "$as_me:$LINENO: result: using lhpdf (libharu) from system libs." >&5
+$as_echo " using lhpdf (libharu) from system libs." >&6; }
+ DISABLELIBHARU=""
+ HARU_LIB="-lhpdf"
+ else
+ { $as_echo "$as_me:$LINENO: result: libharu was not found, pdf creation will be disabled" >&5
+$as_echo " libharu was not found, pdf creation will be disabled" >&6; }
+ DISABLELIBHARU="-D_SAGA_DONOTUSE_HARU"
+ HARU_LIB=""
+ fi
+
+
+
#AC_CONFIG_FILES([Makefile])
-ac_config_files="$ac_config_files Makefile src/Makefile src/saga_core/Makefile src/saga_core/saga_api/Makefile src/saga_core/saga_gdi/Makefile src/saga_core/saga_cmd/Makefile src/saga_core/saga_gui/Makefile src/modules/Makefile src/modules/grid/Makefile src/modules/grid/grid_analysis/Makefile src/modules/grid/grid_calculus/Makefile src/modules/grid/grid_discretisation/Makefile src/modules/grid/grid_filter/Makefile src/modules/grid/grid_gridding/Makefile src/modules/grid/grid_spline/Makefile src/modules/grid/grid_tools/Makefile src/modules/grid/grid_visualisation/Makefile src/modules/pointcloud/Makefile src/modules/pointcloud/pointcloud_tools/Makefile src/modules/pointcloud/pointcloud_viewer/Makefile src/modules/shapes/Makefile src/modules/shapes/shapes_grid/Makefile src/modules/shapes/shapes_lines/Makefile src/modules/shapes/shapes_points/Makefile src/modules/shapes/shapes_polygons/Makefile src/modules/shapes/shapes_tools/Makefile src/modules/table/Makefile src/modules/table/table_calculus/Makefile src/modules/table/table_tools/Makefile src/modules/tin/Makefile src/modules/tin/tin_tools/Makefile src/modules_contrib/Makefile src/modules_contrib/contrib_a_perego/Makefile src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile src/modules_geostatistics/Makefile src/modules_geostatistics/geostatistics/Makefile src/modules_geostatistics/geostatistics/geostatistics_points/Makefile src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile src/modules_io/Makefile src/modules_io/esri_e00/Makefile src/modules_io/esri_e00/io_esri_e00/Makefile src/modules_io/shapes/Makefile src/modules_io/shapes/io_shapes/Makefile src/modules_io/shapes/io_shapes_dxf/Makefile src/modules_io/grid/Makefile src/modules_io/grid/io_grid/Makefile src/modules_io/grid/io_grid_image/Makefile src/modules_io/grid/io_grid_grib2/Makefile src/modules_io/gps/Makefile src/modules_io/gps/io_gps/Makefile src/modules_io/table/Makefile src/modules_io/table/io_table/Makefile src/modules_io/gdal/Makefile src/modules_io/gdal/io_gdal/Makefile src/modules_lectures/Makefile src/modules_lectures/lectures/Makefile src/modules_lectures/lectures/lectures_introduction/Makefile src/modules_projection/Makefile src/modules_projection/pj_georeference/Makefile src/modules_projection/pj_georeference/pj_georeference/Makefile src/modules_projection/pj_proj4/Makefile src/modules_projection/pj_proj4/pj_proj4/Makefile src/modules_recreations/Makefile src/modules_recreations/recreations/Makefile src/modules_recreations/recreations/recreations_fractals/Makefile src/modules_recreations/recreations/recreations_games/Makefile src/modules_simulation/Makefile src/modules_simulation/hydrology/Makefile src/modules_simulation/hydrology/sim_hydrology/Makefile src/modules_simulation/cellular_automata/Makefile src/modules_simulation/cellular_automata/sim_cellular_automata/Makefile src/modules_simulation/ecosystems/Makefile src/modules_simulation/ecosystems/sim_ecosystems_hugget/Makefile src/modules_simulation/fire/Makefile src/modules_simulation/fire/sim_fire_spreading/Makefile src/modules_terrain_analysis/Makefile src/modules_terrain_analysis/terrain_analysis/Makefile src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Makefile src/modules_terrain_analysis/terrain_analysis/ta_profiles/Makefile"
+ac_config_files="$ac_config_files Makefile src/Makefile src/saga_core/Makefile src/saga_core/saga_api/Makefile src/saga_core/saga_gdi/Makefile src/saga_core/saga_odbc/Makefile src/saga_core/saga_cmd/Makefile src/saga_core/saga_cmd/man/Makefile src/saga_core/saga_gui/Makefile src/saga_core/saga_gui/man/Makefile src/modules/Makefile src/modules/grid/Makefile src/modules/grid/grid_analysis/Makefile src/modules/grid/grid_calculus/Makefile src/modules/grid/grid_calculus_bsl/Makefile src/modules/grid/grid_discretisation/Makefile src/modules/grid/grid_filter/Makefile src/modules/grid/grid_gridding/Makefile src/modules/grid/grid_spline/Makefile src/modules/grid/grid_tools/Makefile src/modules/grid/grid_visualisation/Makefile src/modules/pointcloud/Makefile src/modules/pointcloud/pointcloud_tools/Makefile src/modules/pointcloud/pointcloud_viewer/Makefile src/modules/shapes/Makefile src/modules/shapes/shapes_grid/Makefile src/modules/shapes/shapes_lines/Makefile src/modules/shapes/shapes_points/Makefile src/modules/shapes/shapes_polygons/Makefile src/modules/shapes/shapes_tools/Makefile src/modules/shapes/shapes_transect/Makefile src/modules/table/Makefile src/modules/table/table_calculus/Makefile src/modules/table/table_tools/Makefile src/modules/tin/Makefile src/modules/tin/tin_tools/Makefile src/modules_contrib/Makefile src/modules_contrib/contrib_a_perego/Makefile src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile src/modules_contrib/contrib_s_liersch/Makefile src/modules_contrib/contrib_s_liersch/ihacres/Makefile src/modules_geostatistics/Makefile src/modules_geostatistics/geostatistics/Makefile src/modules_geostatistics/geostatistics/geostatistics_points/Makefile src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile src/modules_geostatistics/geostatistics/geostatistics_regression/Makefile src/modules_io/Makefile src/modules_io/esri_e00/Makefile src/modules_io/esri_e00/io_esri_e00/Makefile src/modules_io/db/Makefile src/modules_io/db/io_odbc/Makefile src/modules_io/gdal/Makefile src/modules_io/gdal/io_gdal/Makefile src/modules_io/grid/Makefile src/modules_io/grid/io_grid/Makefile src/modules_io/grid/io_grid_image/Makefile src/modules_io/grid/io_grid_grib2/Makefile src/modules_io/gps/Makefile src/modules_io/gps/io_gps/Makefile src/modules_io/shapes/Makefile src/modules_io/shapes/io_shapes/Makefile src/modules_io/shapes/io_shapes_dxf/Makefile src/modules_io/table/Makefile src/modules_io/table/io_table/Makefile src/modules_lectures/Makefile src/modules_lectures/lectures/Makefile src/modules_lectures/lectures/lectures_introduction/Makefile src/modules_projection/Makefile src/modules_projection/pj_georeference/Makefile src/modules_projection/pj_georeference/pj_georeference/Makefile src/modules_projection/pj_proj4/Makefile src/modules_projection/pj_proj4/pj_proj4/Makefile src/modules_recreations/Makefile src/modules_recreations/recreations/Makefile src/modules_recreations/recreations/recreations_fractals/Makefile src/modules_recreations/recreations/recreations_games/Makefile src/modules_simulation/Makefile src/modules_simulation/hydrology/Makefile src/modules_simulation/hydrology/sim_hydrology/Makefile src/modules_simulation/cellular_automata/Makefile src/modules_simulation/cellular_automata/sim_cellular_automata/Makefile src/modules_simulation/ecosystems/Makefile src/modules_simulation/ecosystems/sim_ecosystems_hugget/Makefile src/modules_simulation/fire/Makefile src/modules_simulation/fire/sim_fire_spreading/Makefile src/modules_terrain_analysis/Makefile src/modules_terrain_analysis/terrain_analysis/Makefile src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile src/modules_terrain_analysis/terrain_analysis/ta_compound/Makefile src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Makefile src/modules_terrain_analysis/terrain_analysis/ta_profiles/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -17775,7 +17859,43 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-DEFS=-DHAVE_CONFIG_H
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+#
+# If the first sed substitution is executed (which looks for macros that
+# take arguments), then branch to the quote section. Otherwise,
+# look for a macro that doesn't take arguments.
+ac_script='
+:mline
+/\\$/{
+ N
+ s,\\\n,,
+ b mline
+}
+t clear
+:clear
+s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g
+t quote
+s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g
+t quote
+b any
+:quote
+s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g
+s/\[/\\&/g
+s/\]/\\&/g
+s/\$/$$/g
+H
+:any
+${
+ g
+ s/^\n//
+ s/\n/ /g
+ p
+}
+'
+DEFS=`sed -n "$ac_script" confdefs.h`
+
ac_libobjs=
ac_ltlibobjs=
@@ -18165,7 +18285,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by saga $as_me 2.0, which was
+This file was extended by saga $as_me 2.0.5, which was
generated by GNU Autoconf 2.63. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -18183,15 +18303,11 @@ case $ac_config_files in *"
"*) set x $ac_config_files; shift; ac_config_files=$*;;
esac
-case $ac_config_headers in *"
-"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
-esac
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
# Files that config.status was made for.
config_files="$ac_config_files"
-config_headers="$ac_config_headers"
config_commands="$ac_config_commands"
_ACEOF
@@ -18211,15 +18327,10 @@ Usage: $0 [OPTION]... [FILE]...
--recheck update $as_me by reconfiguring in the same conditions
--file=FILE[:TEMPLATE]
instantiate the configuration file FILE
- --header=FILE[:TEMPLATE]
- instantiate the configuration header FILE
Configuration files:
$config_files
-Configuration headers:
-$config_headers
-
Configuration commands:
$config_commands
@@ -18228,7 +18339,7 @@ Report bugs to <bug-autoconf at gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
-saga config.status 2.0
+saga config.status 2.0.5
configured by $0, generated by GNU Autoconf 2.63,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
@@ -18277,19 +18388,7 @@ do
esac
CONFIG_FILES="$CONFIG_FILES '$ac_optarg'"
ac_need_defaults=false;;
- --header | --heade | --head | --hea )
- $ac_shift
- case $ac_optarg in
- *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
- esac
- CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'"
- ac_need_defaults=false;;
- --he | --h)
- # Conflict between --help and --header
- { $as_echo "$as_me: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&2
- { (exit 1); exit 1; }; };;
- --help | --hel | -h )
+ --he | --h | --help | --hel | -h )
$as_echo "$ac_cs_usage"; exit ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil | --si | --s)
@@ -18702,7 +18801,6 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
- "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
"depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
"libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
@@ -18710,12 +18808,16 @@ do
"src/saga_core/Makefile") CONFIG_FILES="$CONFIG_FILES src/saga_core/Makefile" ;;
"src/saga_core/saga_api/Makefile") CONFIG_FILES="$CONFIG_FILES src/saga_core/saga_api/Makefile" ;;
"src/saga_core/saga_gdi/Makefile") CONFIG_FILES="$CONFIG_FILES src/saga_core/saga_gdi/Makefile" ;;
+ "src/saga_core/saga_odbc/Makefile") CONFIG_FILES="$CONFIG_FILES src/saga_core/saga_odbc/Makefile" ;;
"src/saga_core/saga_cmd/Makefile") CONFIG_FILES="$CONFIG_FILES src/saga_core/saga_cmd/Makefile" ;;
+ "src/saga_core/saga_cmd/man/Makefile") CONFIG_FILES="$CONFIG_FILES src/saga_core/saga_cmd/man/Makefile" ;;
"src/saga_core/saga_gui/Makefile") CONFIG_FILES="$CONFIG_FILES src/saga_core/saga_gui/Makefile" ;;
+ "src/saga_core/saga_gui/man/Makefile") CONFIG_FILES="$CONFIG_FILES src/saga_core/saga_gui/man/Makefile" ;;
"src/modules/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/Makefile" ;;
"src/modules/grid/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/grid/Makefile" ;;
"src/modules/grid/grid_analysis/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/grid/grid_analysis/Makefile" ;;
"src/modules/grid/grid_calculus/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/grid/grid_calculus/Makefile" ;;
+ "src/modules/grid/grid_calculus_bsl/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/grid/grid_calculus_bsl/Makefile" ;;
"src/modules/grid/grid_discretisation/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/grid/grid_discretisation/Makefile" ;;
"src/modules/grid/grid_filter/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/grid/grid_filter/Makefile" ;;
"src/modules/grid/grid_gridding/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/grid/grid_gridding/Makefile" ;;
@@ -18731,6 +18833,7 @@ do
"src/modules/shapes/shapes_points/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/shapes/shapes_points/Makefile" ;;
"src/modules/shapes/shapes_polygons/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/shapes/shapes_polygons/Makefile" ;;
"src/modules/shapes/shapes_tools/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/shapes/shapes_tools/Makefile" ;;
+ "src/modules/shapes/shapes_transect/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/shapes/shapes_transect/Makefile" ;;
"src/modules/table/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/table/Makefile" ;;
"src/modules/table/table_calculus/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/table/table_calculus/Makefile" ;;
"src/modules/table/table_tools/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules/table/table_tools/Makefile" ;;
@@ -18739,27 +18842,32 @@ do
"src/modules_contrib/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_contrib/Makefile" ;;
"src/modules_contrib/contrib_a_perego/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_contrib/contrib_a_perego/Makefile" ;;
"src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile" ;;
+ "src/modules_contrib/contrib_s_liersch/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_contrib/contrib_s_liersch/Makefile" ;;
+ "src/modules_contrib/contrib_s_liersch/ihacres/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_contrib/contrib_s_liersch/ihacres/Makefile" ;;
"src/modules_geostatistics/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_geostatistics/Makefile" ;;
"src/modules_geostatistics/geostatistics/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_geostatistics/geostatistics/Makefile" ;;
"src/modules_geostatistics/geostatistics/geostatistics_points/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_geostatistics/geostatistics/geostatistics_points/Makefile" ;;
"src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile" ;;
"src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile" ;;
+ "src/modules_geostatistics/geostatistics/geostatistics_regression/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_geostatistics/geostatistics/geostatistics_regression/Makefile" ;;
"src/modules_io/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/Makefile" ;;
"src/modules_io/esri_e00/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/esri_e00/Makefile" ;;
"src/modules_io/esri_e00/io_esri_e00/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/esri_e00/io_esri_e00/Makefile" ;;
- "src/modules_io/shapes/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/shapes/Makefile" ;;
- "src/modules_io/shapes/io_shapes/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/shapes/io_shapes/Makefile" ;;
- "src/modules_io/shapes/io_shapes_dxf/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/shapes/io_shapes_dxf/Makefile" ;;
+ "src/modules_io/db/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/db/Makefile" ;;
+ "src/modules_io/db/io_odbc/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/db/io_odbc/Makefile" ;;
+ "src/modules_io/gdal/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/gdal/Makefile" ;;
+ "src/modules_io/gdal/io_gdal/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/gdal/io_gdal/Makefile" ;;
"src/modules_io/grid/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/grid/Makefile" ;;
"src/modules_io/grid/io_grid/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/grid/io_grid/Makefile" ;;
"src/modules_io/grid/io_grid_image/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/grid/io_grid_image/Makefile" ;;
"src/modules_io/grid/io_grid_grib2/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/grid/io_grid_grib2/Makefile" ;;
"src/modules_io/gps/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/gps/Makefile" ;;
"src/modules_io/gps/io_gps/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/gps/io_gps/Makefile" ;;
+ "src/modules_io/shapes/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/shapes/Makefile" ;;
+ "src/modules_io/shapes/io_shapes/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/shapes/io_shapes/Makefile" ;;
+ "src/modules_io/shapes/io_shapes_dxf/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/shapes/io_shapes_dxf/Makefile" ;;
"src/modules_io/table/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/table/Makefile" ;;
"src/modules_io/table/io_table/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/table/io_table/Makefile" ;;
- "src/modules_io/gdal/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/gdal/Makefile" ;;
- "src/modules_io/gdal/io_gdal/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_io/gdal/io_gdal/Makefile" ;;
"src/modules_lectures/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_lectures/Makefile" ;;
"src/modules_lectures/lectures/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_lectures/lectures/Makefile" ;;
"src/modules_lectures/lectures/lectures_introduction/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_lectures/lectures/lectures_introduction/Makefile" ;;
@@ -18784,6 +18892,7 @@ do
"src/modules_terrain_analysis/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_terrain_analysis/Makefile" ;;
"src/modules_terrain_analysis/terrain_analysis/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_terrain_analysis/terrain_analysis/Makefile" ;;
"src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile" ;;
+ "src/modules_terrain_analysis/terrain_analysis/ta_compound/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_terrain_analysis/terrain_analysis/ta_compound/Makefile" ;;
"src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile" ;;
"src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile" ;;
"src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile") CONFIG_FILES="$CONFIG_FILES src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile" ;;
@@ -18803,7 +18912,6 @@ done
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
- test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
fi
@@ -18988,120 +19096,8 @@ fi
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
fi # test -n "$CONFIG_FILES"
-# Set up the scripts for CONFIG_HEADERS section.
-# No need to generate them if there are no CONFIG_HEADERS.
-# This happens for instance with `./config.status Makefile'.
-if test -n "$CONFIG_HEADERS"; then
-cat >"$tmp/defines.awk" <<\_ACAWK ||
-BEGIN {
-_ACEOF
-
-# Transform confdefs.h into an awk script `defines.awk', embedded as
-# here-document in config.status, that substitutes the proper values into
-# config.h.in to produce config.h.
-
-# Create a delimiter string that does not exist in confdefs.h, to ease
-# handling of long lines.
-ac_delim='%!_!# '
-for ac_last_try in false false :; do
- ac_t=`sed -n "/$ac_delim/p" confdefs.h`
- if test -z "$ac_t"; then
- break
- elif $ac_last_try; then
- { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5
-$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;}
- { (exit 1); exit 1; }; }
- else
- ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
- fi
-done
-
-# For the awk script, D is an array of macro values keyed by name,
-# likewise P contains macro parameters if any. Preserve backslash
-# newline sequences.
-
-ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
-sed -n '
-s/.\{148\}/&'"$ac_delim"'/g
-t rset
-:rset
-s/^[ ]*#[ ]*define[ ][ ]*/ /
-t def
-d
-:def
-s/\\$//
-t bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3"/p
-s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
-d
-:bsnl
-s/["\\]/\\&/g
-s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
-D["\1"]=" \3\\\\\\n"\\/p
-t cont
-s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
-t cont
-d
-:cont
-n
-s/.\{148\}/&'"$ac_delim"'/g
-t clear
-:clear
-s/\\$//
-t bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/"/p
-d
-:bsnlc
-s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
-b cont
-' <confdefs.h | sed '
-s/'"$ac_delim"'/"\\\
-"/g' >>$CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
- for (key in D) D_is_set[key] = 1
- FS = ""
-}
-/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
- line = \$ 0
- split(line, arg, " ")
- if (arg[1] == "#") {
- defundef = arg[2]
- mac1 = arg[3]
- } else {
- defundef = substr(arg[1], 2)
- mac1 = arg[2]
- }
- split(mac1, mac2, "(") #)
- macro = mac2[1]
- prefix = substr(line, 1, index(line, defundef) - 1)
- if (D_is_set[macro]) {
- # Preserve the white space surrounding the "#".
- print prefix "define", macro P[macro] D[macro]
- next
- } else {
- # Replace #undef with comments. This is necessary, for example,
- # in the case of _POSIX_SOURCE, which is predefined and required
- # on some systems where configure will not decide to define it.
- if (defundef == "undef") {
- print "/*", prefix defundef, macro, "*/"
- next
- }
- }
-}
-{ print }
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
- { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5
-$as_echo "$as_me: error: could not setup config headers machinery" >&2;}
- { (exit 1); exit 1; }; }
-fi # test -n "$CONFIG_HEADERS"
-
-eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS"
+eval set X " :F $CONFIG_FILES :C $CONFIG_COMMANDS"
shift
for ac_tag
do
@@ -19371,70 +19367,7 @@ which seems to be undefined. Please make sure it is defined." >&2;}
$as_echo "$as_me: error: could not create $ac_file" >&2;}
{ (exit 1); exit 1; }; }
;;
- :H)
- #
- # CONFIG_HEADER
- #
- if test x"$ac_file" != x-; then
- {
- $as_echo "/* $configure_input */" \
- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
- } >"$tmp/config.h" \
- || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
-$as_echo "$as_me: error: could not create $ac_file" >&2;}
- { (exit 1); exit 1; }; }
- if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
- { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5
-$as_echo "$as_me: $ac_file is unchanged" >&6;}
- else
- rm -f "$ac_file"
- mv "$tmp/config.h" "$ac_file" \
- || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5
-$as_echo "$as_me: error: could not create $ac_file" >&2;}
- { (exit 1); exit 1; }; }
- fi
- else
- $as_echo "/* $configure_input */" \
- && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
- || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5
-$as_echo "$as_me: error: could not create -" >&2;}
- { (exit 1); exit 1; }; }
- fi
-# Compute "$ac_file"'s index in $config_headers.
-_am_arg="$ac_file"
-_am_stamp_count=1
-for _am_header in $config_headers :; do
- case $_am_header in
- $_am_arg | $_am_arg:* )
- break ;;
- * )
- _am_stamp_count=`expr $_am_stamp_count + 1` ;;
- esac
-done
-echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
-$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$_am_arg" : 'X\(//\)[^/]' \| \
- X"$_am_arg" : 'X\(//\)$' \| \
- X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$_am_arg" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'`/stamp-h$_am_stamp_count
- ;;
+
:C) { $as_echo "$as_me:$LINENO: executing $ac_file commands" >&5
$as_echo "$as_me: executing $ac_file commands" >&6;}
diff --git a/configure.in b/configure.in
index 0aced17..59a5082 100755
--- a/configure.in
+++ b/configure.in
@@ -1,11 +1,11 @@
-# $Id: configure.in,v 1.15 2009/09/01 14:47:39 oconrad Exp $
+# $Id: configure.in,v 1.27 2010/07/22 12:47:12 johanvdw Exp $
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
-AC_INIT(saga, 2.0, BUG-REPORT-ADDRESS)
+AC_INIT(saga, 2.0.5, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([src/saga_core/saga_gui/wksp_data_menu_files.cpp])
-AC_CONFIG_HEADER([config.h])
+#AC_CONFIG_HEADER([config.h])
#AM_INIT_AUTOMAKE(saga, 2.0beta)
AM_INIT_AUTOMAKE(tar-ustar)
@@ -57,6 +57,19 @@ AC_ARG_ENABLE(unicode,
AM_CONDITIONAL(SAGA_UNICODE, test "`wx-config --list | grep unicode`" != "" -a x$unicode = xtrue )
#AM_CONDITIONAL(X86_64, test "`uname -m`" = "x86_64")
+AC_CHECK_LIB(hpdf, HPDF_Pages_New, HARUFOUND=1,,)
+ if test -n "$HARUFOUND" ; then
+ AC_MSG_RESULT([ using lhpdf (libharu) from system libs.])
+ DISABLELIBHARU=""
+ HARU_LIB="-lhpdf"
+ else
+ AC_MSG_RESULT([ libharu was not found, pdf creation will be disabled])
+ DISABLELIBHARU="-D_SAGA_DONOTUSE_HARU"
+ HARU_LIB=""
+ fi
+
+AC_SUBST(HARU_LIB)
+AC_SUBST(DISABLELIBHARU)
#AC_CONFIG_FILES([Makefile])
@@ -65,12 +78,16 @@ AC_OUTPUT(Makefile \
src/saga_core/Makefile \
src/saga_core/saga_api/Makefile \
src/saga_core/saga_gdi/Makefile \
+ src/saga_core/saga_odbc/Makefile \
src/saga_core/saga_cmd/Makefile \
+ src/saga_core/saga_cmd/man/Makefile \
src/saga_core/saga_gui/Makefile \
+ src/saga_core/saga_gui/man/Makefile \
src/modules/Makefile \
src/modules/grid/Makefile \
src/modules/grid/grid_analysis/Makefile \
src/modules/grid/grid_calculus/Makefile \
+ src/modules/grid/grid_calculus_bsl/Makefile \
src/modules/grid/grid_discretisation/Makefile \
src/modules/grid/grid_filter/Makefile \
src/modules/grid/grid_gridding/Makefile \
@@ -86,6 +103,7 @@ AC_OUTPUT(Makefile \
src/modules/shapes/shapes_points/Makefile \
src/modules/shapes/shapes_polygons/Makefile \
src/modules/shapes/shapes_tools/Makefile \
+ src/modules/shapes/shapes_transect/Makefile \
src/modules/table/Makefile \
src/modules/table/table_calculus/Makefile \
src/modules/table/table_tools/Makefile \
@@ -94,27 +112,32 @@ AC_OUTPUT(Makefile \
src/modules_contrib/Makefile \
src/modules_contrib/contrib_a_perego/Makefile \
src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile \
+ src/modules_contrib/contrib_s_liersch/Makefile \
+ src/modules_contrib/contrib_s_liersch/ihacres/Makefile \
src/modules_geostatistics/Makefile \
src/modules_geostatistics/geostatistics/Makefile \
src/modules_geostatistics/geostatistics/geostatistics_points/Makefile \
src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile \
src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile \
+ src/modules_geostatistics/geostatistics/geostatistics_regression/Makefile \
src/modules_io/Makefile \
src/modules_io/esri_e00/Makefile \
src/modules_io/esri_e00/io_esri_e00/Makefile \
- src/modules_io/shapes/Makefile \
- src/modules_io/shapes/io_shapes/Makefile \
- src/modules_io/shapes/io_shapes_dxf/Makefile \
+ src/modules_io/db/Makefile \
+ src/modules_io/db/io_odbc/Makefile \
+ src/modules_io/gdal/Makefile \
+ src/modules_io/gdal/io_gdal/Makefile \
src/modules_io/grid/Makefile \
src/modules_io/grid/io_grid/Makefile \
src/modules_io/grid/io_grid_image/Makefile \
src/modules_io/grid/io_grid_grib2/Makefile \
src/modules_io/gps/Makefile \
src/modules_io/gps/io_gps/Makefile \
+ src/modules_io/shapes/Makefile \
+ src/modules_io/shapes/io_shapes/Makefile \
+ src/modules_io/shapes/io_shapes_dxf/Makefile \
src/modules_io/table/Makefile \
src/modules_io/table/io_table/Makefile \
- src/modules_io/gdal/Makefile \
- src/modules_io/gdal/io_gdal/Makefile \
src/modules_lectures/Makefile \
src/modules_lectures/lectures/Makefile \
src/modules_lectures/lectures/lectures_introduction/Makefile \
@@ -139,8 +162,10 @@ AC_OUTPUT(Makefile \
src/modules_terrain_analysis/Makefile \
src/modules_terrain_analysis/terrain_analysis/Makefile \
src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile \
+ src/modules_terrain_analysis/terrain_analysis/ta_compound/Makefile \
src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile \
src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile \
src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile \
src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Makefile \
- src/modules_terrain_analysis/terrain_analysis/ta_profiles/Makefile)
+ src/modules_terrain_analysis/terrain_analysis/ta_profiles/Makefile \
+)
diff --git a/src/Makefile.am b/src/Makefile.am
index 4e72df6..d387c96 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1 +1 @@
-SUBDIRS = saga_core modules modules_contrib modules_geostatistics modules_projection modules_io modules_recreations modules_simulation modules_terrain_analysis modules_lectures
+SUBDIRS = saga_core modules modules_contrib modules_geostatistics modules_io modules_projection modules_recreations modules_simulation modules_terrain_analysis modules_lectures
diff --git a/src/Makefile.in b/src/Makefile.in
index 3783686..99e13ea 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -202,7 +203,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = saga_core modules modules_contrib modules_geostatistics modules_projection modules_io modules_recreations modules_simulation modules_terrain_analysis modules_lectures
+SUBDIRS = saga_core modules modules_contrib modules_geostatistics modules_io modules_projection modules_recreations modules_simulation modules_terrain_analysis modules_lectures
all: all-recursive
.SUFFIXES:
diff --git a/src/modules/Makefile.in b/src/modules/Makefile.in
index 92bbcd2..5d487c4 100644
--- a/src/modules/Makefile.in
+++ b/src/modules/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules/grid/Makefile.am b/src/modules/grid/Makefile.am
index 006477e..a71a690 100644
--- a/src/modules/grid/Makefile.am
+++ b/src/modules/grid/Makefile.am
@@ -1 +1 @@
-SUBDIRS = grid_visualisation grid_tools grid_spline grid_gridding grid_filter grid_discretisation grid_calculus grid_analysis
+SUBDIRS = grid_visualisation grid_tools grid_spline grid_gridding grid_filter grid_discretisation grid_calculus grid_calculus_bsl grid_analysis
diff --git a/src/modules/grid/Makefile.in b/src/modules/grid/Makefile.in
index bd07ab3..e8249f4 100644
--- a/src/modules/grid/Makefile.in
+++ b/src/modules/grid/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -202,7 +203,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = grid_visualisation grid_tools grid_spline grid_gridding grid_filter grid_discretisation grid_calculus grid_analysis
+SUBDIRS = grid_visualisation grid_tools grid_spline grid_gridding grid_filter grid_discretisation grid_calculus grid_calculus_bsl grid_analysis
all: all-recursive
.SUFFIXES:
diff --git a/src/modules/grid/grid_analysis/Makefile.am b/src/modules/grid/grid_analysis/Makefile.am
index 7f51edc..c2fef8d 100644
--- a/src/modules/grid/grid_analysis/Makefile.am
+++ b/src/modules/grid/grid_analysis/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.8 2009/09/01 14:12:30 oconrad Exp $
+# $Id: Makefile.am,v 1.9 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_analysis.la
libgrid_analysis_la_SOURCES =\
Cost_Anisotropic.cpp\
diff --git a/src/modules/grid/grid_analysis/Makefile.in b/src/modules/grid/grid_analysis/Makefile.in
index 6d0b2f5..c46532b 100644
--- a/src/modules/grid/grid_analysis/Makefile.in
+++ b/src/modules/grid/grid_analysis/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -79,7 +78,7 @@ am_libgrid_analysis_la_OBJECTS = Cost_Anisotropic.lo Cost_Isotropic.lo \
Image_VI_Distance.lo Image_VI_Slope.lo LeastCostPathProfile.lo \
MLB_Interface.lo owa.lo PointsEx.lo Soil_Texture.lo
libgrid_analysis_la_OBJECTS = $(am_libgrid_analysis_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -125,6 +124,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -134,6 +134,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -224,14 +225,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.8 2009/09/01 14:12:30 oconrad Exp $
+# $Id: Makefile.am,v 1.9 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_analysis.la
libgrid_analysis_la_SOURCES = \
Cost_Anisotropic.cpp\
diff --git a/src/modules/grid/grid_calculus/Grid_Calculator.cpp b/src/modules/grid/grid_calculus/Grid_Calculator.cpp
index 2e9270c..70f4d02 100644
--- a/src/modules/grid/grid_calculus/Grid_Calculator.cpp
+++ b/src/modules/grid/grid_calculus/Grid_Calculator.cpp
@@ -48,12 +48,41 @@
// //
///////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
+#include <float.h>
#include "Grid_Calculator.h"
-#include <float.h>
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#if defined(_SAGA_LINUX)
+bool _finite(double val)
+{
+ return( true );
+}
+#endif
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
CGrid_Calculator::CGrid_Calculator(void)
{
//-----------------------------------------------------
@@ -75,7 +104,7 @@ CGrid_Calculator::CGrid_Calculator(void)
//-----------------------------------------------------
Parameters.Add_Grid_List(
- NULL, "INPUT" , _TL("Grids"),
+ NULL, "GRIDS" , _TL("Grids"),
_TL(""), PARAMETER_INPUT
);
@@ -86,121 +115,111 @@ CGrid_Calculator::CGrid_Calculator(void)
);
Parameters.Add_String(
- NULL, "FORMUL" , _TL("Formula"),
+ NULL, "FORMULA" , _TL("Formula"),
_TL(""),
SG_T("(a - b) / (a + b)")
);
}
-//---------------------------------------------------------
-CGrid_Calculator::~CGrid_Calculator(void)
-{}
-//---------------------------------------------------------
-#if defined(_SAGA_LINUX)
-bool _finite(double val)
-{
- return( true );
-}
-#endif
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
//---------------------------------------------------------
bool CGrid_Calculator::On_Execute(void)
{
- char vars[27];
- bool bContinue;
-
- int i, x, y;
+ double Result, *Values;
+ CSG_Formula Formula;
+ CSG_Parameter_Grid_List *pGrids;
+ CSG_Grid *pResult;
+
+ //-----------------------------------------------------
+ pResult = Parameters("RESULT") ->asGrid();
+ pGrids = Parameters("GRIDS") ->asGridList();
- if (Parameters("INPUT")->asInt() <= 0) // Gr� von O.C...
+ //-----------------------------------------------------
+ if( pGrids->Get_Count() <= 0 )
{
- Error_Set(_TL("No grid in list - Cannot execute calculator"));
- return (false);
+ Message_Add(_TL("No grid in list"));
+
+ return( false );
}
-
- pResult = Parameters("RESULT")->asGrid();
- pResult->Set_Name(Parameters("FORMUL")->asString());
-
- nGrids = Parameters("INPUT")->asInt();
- Grids =(CSG_Grid **)Parameters("INPUT")->asPointer();
-
- for (i = 0, bContinue = true; i < nGrids - 1 && bContinue; i++)
+
+ //-----------------------------------------------------
+ if( !Formula.Set_Formula(Parameters("FORMULA")->asString()) )
{
- if( (Grids[i]->Get_System() == Grids[i + 1]->Get_System()) == false )
+ int Position;
+ CSG_String Message, s;
+
+ s += _TL("Error in formula");
+ s += SG_T("\n") + Formula.Get_Formula();
+
+ if( Formula.Get_Error(&Position, &Message) )
{
- bContinue = false;
+ s += SG_T("\n") + Message;
+ s += CSG_String::Format(SG_T("\n%s: %d"), _TL("Position") , Position);
+
+ if( Position >= 0 && Position < (int)Formula.Get_Formula().Length() )
+ {
+ s += SG_T("\n")
+ + Formula.Get_Formula().Left(Position - 1) + SG_T("[")
+ + Formula.Get_Formula()[Position] + SG_T("]")
+ + Formula.Get_Formula().Right(Formula.Get_Formula().Length() - (Position + 1));
+ }
}
+
+ Message_Add(s, false);
+
+ return( false );
}
-
- CSG_Grid MissingMap(Grids[0], SG_DATATYPE_Byte);
-
- for (y = 0; y < Get_NY() && Set_Progress(y); y++)
- for (x = 0; x < Get_NX(); x++)
+
+ //-----------------------------------------------------
+ pResult->Set_Name(Formula.Get_Formula());
+
+ Values = new double[pGrids->Get_Count()];
+
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
{
- int missing = 1;
- for (i = 0; i < nGrids; i++)
+ bool bNoData = false;
+
+ for(int i=0; i<pGrids->Get_Count() && !bNoData; i++)
{
- //if (fabs(Grids[i]->asFloat(x, y) - Grids[0]->Get_NoData_Value()) < 0.0001)
- // this was not a very robust way of cheking nodata values, was it?
- if (Grids[i]->is_NoData(x,y))
+ if( pGrids->asGrid(i)->is_NoData(x, y) )
{
- //I think this works better, specially if you use a range of nodata values, not a single value
- missing = 0;
+ bNoData = true;
}
- }
- MissingMap.Set_Value(x, y, missing);
- }
-
- pResult->Set_NoData_Value(Grids[0]->Get_NoData_Value());
- for (char c = 'a'; c<'a'+(char) nGrids; c++)
-
- vars[c - 'a'] = c;
-
- CSG_Formula Formel;
-
- Formel.Set_Formula(Parameters("FORMUL")->asString());
-
- int Pos;
- CSG_String Msg;
- if (Formel.Get_Error(&Pos, &Msg))
- {
- CSG_String msg;
-
- msg.Printf(_TL("Error at character #%d of the function: \n%s\n"), Pos, Parameters("FORMUL")->asString());
-
- Message_Add(msg);
-
- msg.Printf(SG_T("\n%s\n"), Msg.c_str());
-
- Message_Add(msg);
-
- return false;
- }
-
- double *Grid_Vals= new double[nGrids];
- double val;
-
- for (y = 0; y < Get_NY() && Set_Progress(y); y++)
- for (x = 0; x < Get_NX(); x++)
- {
- for (i = 0; i < nGrids; i++)
+ else
{
- Grid_Vals[i]=Grids[i]->asDouble(x,y);
+ Values[i] = pGrids->asGrid(i)->asDouble(x, y);
}
-
- val = Formel.Get_Value(Grid_Vals, nGrids);
+ }
- if (_finite(val) && MissingMap.asByte(x, y))
- pResult->Set_Value(x, y, val);
- else
- pResult->Set_Value(x, y, Grids[0]->Get_NoData_Value());
+ if( bNoData || _finite(Result = Formula.Get_Value(Values, pGrids->Get_Count())) == false )
+ {
+ pResult->Set_NoData(x, y);
+ }
+ else
+ {
+ pResult->Set_Value(x, y, Result);
}
+ }
+ }
+
+ delete[](Values);
- delete[] Grid_Vals;
- return (true);
+ //-----------------------------------------------------
+ return( true );
}
-// MinGW ERROR:
-// Grid_Calculator.cpp: In member function `virtual bool CGrid_Calculator::On_Execute()':
-// Grid_Calculator.cpp:187: error: name lookup of `y' changed for new ISO `for' scoping
-// Grid_Calculator.cpp:145: error: using obsolete binding at `y'
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_calculus/Grid_Calculator.h b/src/modules/grid/grid_calculus/Grid_Calculator.h
index 597c180..52e8d8d 100644
--- a/src/modules/grid/grid_calculus/Grid_Calculator.h
+++ b/src/modules/grid/grid_calculus/Grid_Calculator.h
@@ -65,25 +65,31 @@
#include "MLB_Interface.h"
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
class CGrid_Calculator : public CSG_Module_Grid
{
public:
CGrid_Calculator(void);
- virtual ~CGrid_Calculator(void);
protected:
- virtual bool On_Execute(void);
-
-
-private:
+ virtual bool On_Execute (void);
- int nGrids;
+};
- CSG_Grid **Grids, *pResult;
-
-};
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+//---------------------------------------------------------
#endif // #ifndef HEADER_INCLUDED__Grid_Calculator_H
diff --git a/src/modules/grid/grid_calculus/Makefile.am b/src/modules/grid/grid_calculus/Makefile.am
index 2e94951..ff00891 100644
--- a/src/modules/grid/grid_calculus/Makefile.am
+++ b/src/modules/grid/grid_calculus/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.6 2009/05/27 17:30:18 oconrad Exp $
+# $Id: Makefile.am,v 1.7 2010/07/08 14:11:50 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_calculus.la
libgrid_calculus_la_SOURCES =\
Grid_Calculator.cpp\
diff --git a/src/modules/grid/grid_calculus/Makefile.in b/src/modules/grid/grid_calculus/Makefile.in
index 432a8d4..4c3760c 100644
--- a/src/modules/grid/grid_calculus/Makefile.in
+++ b/src/modules/grid/grid_calculus/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -74,7 +73,7 @@ am_libgrid_calculus_la_OBJECTS = Grid_Calculator.lo grid_difference.lo \
Grid_Random_Field.lo Grid_Random_Terrain.lo Grid_Volume.lo \
MLB_Interface.lo
libgrid_calculus_la_OBJECTS = $(am_libgrid_calculus_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -120,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -129,6 +129,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -219,14 +220,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.6 2009/05/27 17:30:18 oconrad Exp $
+# $Id: Makefile.am,v 1.7 2010/07/08 14:11:50 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_calculus.la
libgrid_calculus_la_SOURCES = \
Grid_Calculator.cpp\
diff --git a/src/modules/grid/grid_calculus_bsl/MLB_Interface.cpp b/src/modules/grid/grid_calculus_bsl/MLB_Interface.cpp
new file mode 100644
index 0000000..0fa66c8
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/MLB_Interface.cpp
@@ -0,0 +1,60 @@
+
+///////////////////////////////////////////////////////////
+// //
+// The Module Link Library Interface //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+//---------------------------------------------------------
+const SG_Char * Get_Info(int i)
+{
+ switch( i )
+ {
+ case MLB_INFO_Name: default:
+ return( _TL("Grid - Calculus BSL") );
+
+ case MLB_INFO_Author:
+ return( SG_T("SAGA User Group Associaton (c) 2009") );
+
+ case MLB_INFO_Description:
+ return( _TL("Boehner's Simple Language (BSL) is a macro script language for grid based calculations.") );
+
+ case MLB_INFO_Version:
+ return( SG_T("1.0") );
+
+ case MLB_INFO_Menu_Path:
+ return( _TL("Grid|Calculus") );
+ }
+}
+
+//---------------------------------------------------------
+#include "bsl_interpreter.h"
+
+//---------------------------------------------------------
+CSG_Module * Create_Module(int i)
+{
+ switch( i )
+ {
+ case 0: return( new CBSL_Interpreter(false) );
+ case 1: return( new CBSL_Interpreter(true) );
+ }
+
+ return( NULL );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+//{{AFX_SAGA
+
+ MLB_INTERFACE
+
+//}}AFX_SAGA
diff --git a/src/modules/grid/grid_calculus_bsl/MLB_Interface.h b/src/modules/grid/grid_calculus_bsl/MLB_Interface.h
new file mode 100644
index 0000000..3918cd5
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/MLB_Interface.h
@@ -0,0 +1,17 @@
+
+///////////////////////////////////////////////////////////
+// //
+// Include the SAGA-API here //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__grid_calculus_bsl_H
+#define HEADER_INCLUDED__grid_calculus_bsl_H
+
+//---------------------------------------------------------
+#include <saga_api/saga_api.h>
+
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__grid_calculus_bsl_H
diff --git a/src/modules/grid/grid_calculus_bsl/Makefile.am b/src/modules/grid/grid_calculus_bsl/Makefile.am
new file mode 100644
index 0000000..4a4aa31
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/Makefile.am
@@ -0,0 +1,56 @@
+#
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:49 johanvdw Exp $
+#
+if DEBUG
+DBGFLAGS = -g -DDEBUG
+endif
+if SAGA_UNICODE
+UC_DEFS = -D_SAGA_UNICODE
+endif
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -avoid-version
+pkglib_LTLIBRARIES = libgrid_calculus_bsl.la
+libgrid_calculus_bsl_la_SOURCES =\
+ausdruck.cpp\
+auswert_anweisung.cpp\
+auswert_foreach.cpp\
+auswert_if.cpp\
+auswert_zuweisung.cpp\
+basistypen.cpp\
+bedingung.cpp\
+diverses.cpp\
+foreach.cpp\
+funktion.cpp\
+grid_bsl.cpp\
+interpolation.cpp\
+bsl_interpreter.cpp\
+MLB_Interface.cpp\
+pars_all.cpp\
+vector.cpp\
+zuweisung.cpp\
+ausdruck.h\
+auswert_anweisung.h\
+auswert_foreach.h\
+auswert_if.h\
+auswert_zuweisung.h\
+basistypen.h\
+bedingung.h\
+diverses.h\
+foreach.h\
+funktion.h\
+funktion_numerisch.h\
+funktion_statistisch.h\
+grid_bsl.h\
+gr_def.h\
+gr_syst.h\
+interpolation.h\
+bsl_interpreter.h\
+MLB_Interface.h\
+pars_all.h\
+vector.h\
+zuweisung.h
+
+libgrid_calculus_bsl_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+
diff --git a/src/modules/grid/grid_calculus_bsl/Makefile.in b/src/modules/grid/grid_calculus_bsl/Makefile.in
new file mode 100644
index 0000000..ac7d4f5
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/Makefile.in
@@ -0,0 +1,598 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/modules/grid/grid_calculus_bsl
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+libgrid_calculus_bsl_la_DEPENDENCIES = \
+ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+am_libgrid_calculus_bsl_la_OBJECTS = ausdruck.lo auswert_anweisung.lo \
+ auswert_foreach.lo auswert_if.lo auswert_zuweisung.lo \
+ basistypen.lo bedingung.lo diverses.lo foreach.lo funktion.lo \
+ grid_bsl.lo interpolation.lo bsl_interpreter.lo \
+ MLB_Interface.lo pars_all.lo vector.lo zuweisung.lo
+libgrid_calculus_bsl_la_OBJECTS = \
+ $(am_libgrid_calculus_bsl_la_OBJECTS)
+DEFAULT_INCLUDES = -I. at am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libgrid_calculus_bsl_la_SOURCES)
+DIST_SOURCES = $(libgrid_calculus_bsl_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+HARU_LIB = @HARU_LIB@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POW_LIB = @POW_LIB@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:49 johanvdw Exp $
+#
+ at DEBUG_TRUE@DBGFLAGS = -g -DDEBUG
+ at SAGA_UNICODE_TRUE@UC_DEFS = -D_SAGA_UNICODE
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -avoid-version
+pkglib_LTLIBRARIES = libgrid_calculus_bsl.la
+libgrid_calculus_bsl_la_SOURCES = \
+ausdruck.cpp\
+auswert_anweisung.cpp\
+auswert_foreach.cpp\
+auswert_if.cpp\
+auswert_zuweisung.cpp\
+basistypen.cpp\
+bedingung.cpp\
+diverses.cpp\
+foreach.cpp\
+funktion.cpp\
+grid_bsl.cpp\
+interpolation.cpp\
+bsl_interpreter.cpp\
+MLB_Interface.cpp\
+pars_all.cpp\
+vector.cpp\
+zuweisung.cpp\
+ausdruck.h\
+auswert_anweisung.h\
+auswert_foreach.h\
+auswert_if.h\
+auswert_zuweisung.h\
+basistypen.h\
+bedingung.h\
+diverses.h\
+foreach.h\
+funktion.h\
+funktion_numerisch.h\
+funktion_statistisch.h\
+grid_bsl.h\
+gr_def.h\
+gr_syst.h\
+interpolation.h\
+bsl_interpreter.h\
+MLB_Interface.h\
+pars_all.h\
+vector.h\
+zuweisung.h
+
+libgrid_calculus_bsl_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/modules/grid/grid_calculus_bsl/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/modules/grid/grid_calculus_bsl/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \
+ }
+
+uninstall-pkglibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \
+ done
+
+clean-pkglibLTLIBRARIES:
+ -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+ @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libgrid_calculus_bsl.la: $(libgrid_calculus_bsl_la_OBJECTS) $(libgrid_calculus_bsl_la_DEPENDENCIES)
+ $(CXXLINK) -rpath $(pkglibdir) $(libgrid_calculus_bsl_la_OBJECTS) $(libgrid_calculus_bsl_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ausdruck.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/auswert_anweisung.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/auswert_foreach.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/auswert_if.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/auswert_zuweisung.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/basistypen.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/bedingung.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/bsl_interpreter.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/diverses.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/foreach.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/funktion.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/grid_bsl.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/interpolation.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pars_all.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/vector.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/zuweisung.Plo at am__quote@
+
+.cpp.o:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+ at am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(pkglibdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+ 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 uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+
+# 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:
diff --git a/src/modules/grid/grid_calculus_bsl/ausdruck.cpp b/src/modules/grid/grid_calculus_bsl/ausdruck.cpp
new file mode 100644
index 0000000..e78c44b
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/ausdruck.cpp
@@ -0,0 +1,804 @@
+
+//#include "..\stdafx.h"
+#include <iostream>
+
+#include <vector>
+#include "ausdruck.h"
+#include "funktion.h"
+
+
+
+using namespace std;
+
+
+class compare_BB_Funktion : public greater<BBFunktion *>
+{
+public:
+ bool operator()(const BBFunktion * &x, const BBFunktion * &y) const
+ {
+ return x->name < y->name;
+ };
+};
+
+BBBaumInteger::BBBaumInteger()
+{
+ typ = NoOp;
+ memset(&k, 0, sizeof(BBKnoten));
+}
+
+BBBaumInteger::~BBBaumInteger()
+{
+ if (typ == NoOp)
+ return;
+ switch(typ)
+ {
+ case BIOperator:
+ if (k.BiOperator.links != NULL)
+ delete k.BiOperator.links;
+ if (k.BiOperator.rechts != NULL)
+ delete k.BiOperator.rechts;
+ break;
+ case UniOperator:
+ if (k.UniOperator.rechts != NULL)
+ delete k.UniOperator.rechts;
+ break;
+ case MIndex:
+ if (k.MatrixIndex.P != NULL)
+ delete k.MatrixIndex.P;
+ break;
+ case Funktion:
+ if (k.func != NULL)
+ delete k.func;
+ break;
+ case IZahl:
+ case FZahl:
+ case IVar:
+ case FVar:
+ break;
+ }
+ memset(&k, 0, sizeof(BBKnoten));
+}
+
+BBBaumMatrixPoint::BBBaumMatrixPoint() : typ(NoOp) , isMatrix(true)
+{
+ memset(&k, 0, sizeof(BBKnoten));
+}
+
+BBBaumMatrixPoint::~BBBaumMatrixPoint()
+{
+ if (typ == NoOp)
+ return;
+ switch(typ)
+ {
+ case BIOperator:
+ if (k.BiOperator.links != NULL)
+ delete k.BiOperator.links;
+ if (k.BiOperator.rechts != NULL)
+ delete k.BiOperator.rechts;
+ break;
+ case UniOperator:
+ if (k.UniOperator.rechts != NULL)
+ delete k.UniOperator.rechts;
+ break;
+ case IFAusdruck:
+ if (k.IntFloatAusdruck.b != NULL)
+ delete k.IntFloatAusdruck.b;
+ break;
+ case MVar:
+ case PVar:
+ break;
+ }
+ memset(&k, 0, sizeof(BBKnoten));
+}
+
+bool getFirstCharKlammer(const string& statement, const string& cmp, char& c, int& pos)
+{
+ if (statement.empty())
+ return false;
+
+ int klammer_ebene = 0, klammerE_ebene = 0;
+ for (int i=0; i<statement.size()-1; i++)
+ {
+ if (statement[i] == '(')
+ klammer_ebene++;
+ if (statement[i] == ')')
+ klammer_ebene--;
+ if (statement[i] == '[')
+ klammerE_ebene++;
+ if (statement[i] == ']')
+ klammerE_ebene--;
+ if (klammer_ebene == 0 && klammerE_ebene == 0 && i != statement.size() -1 && i != 0)
+ {
+
+ //int p = cmp.find_first_of(statement[i]);
+ //if (cmp.find_first_of(statement[i]) >= 0)
+ int j;
+ for (j=0; j<cmp.size(); j++)
+ if (cmp[j] == statement[i])
+ break;
+ if (j < cmp.size())
+ {
+ c = statement[i];
+ pos = i;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+bool getLastCharKlammer(const string& statement, const string& cmp, char& c, int& pos)
+{
+ if (statement.empty())
+ return false;
+
+ int char_found = -1;
+ int klammer_ebene = 0, klammerE_ebene = 0;
+ for (int i=0; i<statement.size()-1; i++)
+ {
+ if (statement[i] == '(')
+ klammer_ebene++;
+ if (statement[i] == ')')
+ klammer_ebene--;
+ if (statement[i] == '[')
+ klammerE_ebene++;
+ if (statement[i] == ']')
+ klammerE_ebene--;
+ if (klammer_ebene == 0 && klammerE_ebene == 0 && i != statement.size() -1 && i != 0)
+ {
+ int j;
+ for (j=0; j<cmp.size(); j++)
+ if (cmp[j] == statement[i])
+ char_found = i;
+ }
+ }
+ if (char_found > 0)
+ {
+ c = statement[char_found];
+ pos = char_found;
+ return true;
+ }
+ return false;
+}
+
+bool isKlammer(const string& statement)
+{
+ // klammer-Level zählen
+ if (statement.empty())
+ return false;
+
+ if (statement[0] != '(' || statement[statement.size()-1] != ')')
+ return false;
+ int klammer_ebene = 0;
+ for (int i=0; i<statement.size()-1; i++)
+ {
+ if (statement[i] == '(')
+ klammer_ebene++;
+ if (statement[i] == ')')
+ klammer_ebene--;
+ if (klammer_ebene == 0 && i != statement.size() -1)
+ return false;
+ }
+ return true;
+}
+
+//++++++++++++++ Integer/ Float ++++++++++++++++++++++++++
+
+bool isBiOperator(const string& statement, char& c, int& pos)
+{
+ // Klammern zählen, da nur zwischen Klammer-Level NULL
+ // ein Operator stehen darf
+
+ // den Operator mit der niedrigsten Priorität zuerst ausführen, da er
+ // in der Baum-Struktur "oben" stehen muß !
+ if (getFirstCharKlammer(statement, "+", c, pos))
+ return true;
+ if (getLastCharKlammer(statement, "-", c, pos))
+ return true;
+ if (getFirstCharKlammer(statement, "*", c, pos))
+ return true;
+ if (getLastCharKlammer(statement, "/", c, pos))
+ return true;
+ if (getFirstCharKlammer(statement, "^", c, pos))
+ return true;
+//-->
+ if (getFirstCharKlammer(statement, "%", c, pos))
+ return true;
+//<--
+ return false;
+}
+
+bool isUniOperator(const string& statement, char& c)
+{
+ c = statement[0];
+ return (c == '-' || c == '+');
+}
+
+bool isMatrixIndex(const string& statement, BBMatrix *& bm, BBBaumMatrixPoint *& bp, bool getMem /* = true */)
+{
+ // wenn X[p] enthält und X = Matrix und p = Point
+ if (statement.empty())
+ return false;
+ string s(statement);
+ int pos1, pos2;
+ pos1 = s.find('[');
+ if (pos1 > 0)
+ {
+ pos2 = s.find(']');
+ if ( pos2 > pos1 && pos2 == s.size()-1 )
+ {
+ // ersten Teil
+ string m, p;
+ m = s.substr(0, pos1);
+ p = s.substr(pos1+1, pos2-pos1-1);
+ BBTyp *tm;
+ BBBaumMatrixPoint *bmp;
+ if (isMVar(m, tm))
+ {
+ try
+ {
+ // erst Testen
+ pars_matrix_point(p, bmp, false, false);
+ }
+ catch (BBFehlerException)
+ {
+ return false;
+ }
+ if (!getMem) // falls nichts allokieren -> test erfolgreich
+ return true;
+ try
+ {
+ // dann allokieren
+ pars_matrix_point(p, bmp, false);
+ }
+ catch (BBFehlerException)
+ {
+ return false;
+ }
+
+ bm = (BBMatrix *) tm;
+ bp = bmp;
+ return true;
+ }
+
+/* if (isMVar(m, tm) && isPVar(p, tp))
+ {
+ bm = (BBMatrix *) tm;
+ bp = (BBPoint *) tp;
+ return true;
+ }
+ */
+ }
+ }
+ return false;
+}
+
+bool isFZahl(const string& statement)
+{
+ // Format: [+-]d[d][.[d[dd]][e|E +|- d[d]]]
+ if (statement .size() > 50)
+ return false;
+ char buff[100];
+ double f;
+ int anz = sscanf(statement.data(), "%f%s", &f, buff);
+ return (anz == 1);
+}
+
+bool isIZahl(const string& statement)
+{
+ if (statement.empty())
+ return false;
+
+ string s(statement);
+
+ // eventuel voranstehenden +-
+ if (s[0] == '+')
+ s.erase(s.begin());
+ else if (s[0] == '-')
+ s.erase(s.begin());
+
+ if (s.empty())
+ return false;
+ int p = s.find_first_not_of("1234567890");
+ if (p >= 0)
+ return false;
+
+ return true;
+}
+
+bool isFVar(const string& statement, BBTyp * & b)
+{
+ b = isVar(statement);
+ if (b == NULL)
+ return false;
+ if (b->type == BBTyp::FType)
+ return true;
+ return false;
+}
+
+bool isIVar(const string& statement, BBTyp * & b)
+{
+ b = isVar(statement);
+ if (b == NULL)
+ return false;
+ if (b->type == BBTyp::IType)
+ return true;
+ return false;
+}
+
+bool isPVar(const string& statement, BBTyp * & b)
+{
+ b = isVar(statement);
+ if (b == NULL)
+ return false;
+ if (b->type == BBTyp::PType)
+ return true;
+ return false;
+}
+
+bool isMVar(const string& statement, BBTyp * & b)
+{
+ b = isVar(statement);
+ if (b == NULL)
+ return false;
+ if (b->type == BBTyp::MType)
+ return true;
+ return false;
+}
+
+BBFunktion *isFktName(const string& s)
+{
+ if (FunktionList.empty())
+ return NULL;
+ T_FunktionList::iterator it;
+ for (it = FunktionList.begin(); it != FunktionList.end(); it++)
+ {
+ if ((*it)->name == s)
+ return (*it);
+ }
+ return NULL;
+}
+
+bool getNextFktToken(const string& s, int& pos, string& erg)
+{
+ // Syntax xx[,xx[,xx...]]
+ if (pos >= s.size())
+ return false;
+ string ss(s.substr(pos));
+ int pos1 = ss.find_first_of(',');
+ if (pos1 >= 0)
+ {
+ erg = ss.substr(0, pos1);
+ pos += pos1;
+ }
+ else
+ {
+ erg = ss;
+ pos = s.size();
+ }
+ if (erg.empty())
+ return false;
+ return true;
+}
+
+bool isFunktion (const string& statement, BBFktExe * & fktexe, bool getMem /* = true */, bool AlleFunktionen /* = true */)
+{
+ // Syntax: fktname([arg1[, arg2]])
+ string s(statement);
+ int pos1, pos2;
+ pos1 = s.find_first_of('(');
+ pos2 = s.find_last_of(')');
+ if (pos1 <= 0 || pos2 != s.size()-1)
+ return false;
+
+ // Variablen-Name
+ string sub1, sub2;
+ sub1 = s.substr(0, pos1);
+ trim(sub1);
+ sub2 = s.substr(pos1+1, pos2-pos1-1);
+ trim(sub2);
+ if (sub1.empty())
+ return false;
+ BBFunktion *fkt = isFktName(sub1);
+ if (fkt == NULL)
+ return false;
+
+ if (!AlleFunktionen)
+ { // nur diejenigen Funktionen mit Return-Typ
+ if (fkt->ret.typ == BBArgumente::NoOp) // kein Return-Typ
+ return false;
+ }
+ if (sub2.empty()) // keine Argumente
+ {
+ if (!fkt->args.empty())
+ return false;
+ if (getMem)
+ {
+ fktexe = new BBFktExe;
+ fktexe->args = fkt->args;
+ fktexe->f = fkt; // vorher ... = NULL;
+ }
+ return true;
+ }
+ else
+ {
+ // Argumente zählen
+ // 1. Float/Integer lassen sich konvertieren
+ // 2. Matrix
+ // 3. Point
+ if (getMem)
+ {
+ fktexe = new BBFktExe;
+ fktexe->args = fkt->args; // vector kopieren
+ fktexe->f = fkt;
+ }
+ int anz = fkt->args.size();
+ int possub2 = 0;
+ for (int i=0; i<anz; i++)
+ {
+ // finde Token
+ string ss;
+ if (!getNextFktToken(sub2, possub2, ss))
+ return false;
+// BBTyp *bt = isVar(ss);
+// if (bt == NULL)
+// return false;
+ if (fkt->args[i].typ == BBArgumente::ITyp ||
+ fkt->args[i].typ == BBArgumente::FTyp)
+ {
+// if (bt->type != BBTyp::IType ||
+// bt->type != BBTyp::FType)
+// return false;
+ try
+ {
+ BBBaumInteger *b;
+ pars_integer_float(ss, b, getMem);
+ if (getMem)
+ fktexe->args[i].ArgTyp.IF = b;
+
+ }
+ catch (BBFehlerException)
+ {
+ if (getMem)
+ delete fktexe;
+ return false;
+ }
+ }
+ else
+ {
+/* if (fkt->args[i].typ == BBArgumente::MTyp &&
+ bt->type != BBTyp::MType)
+ return false;
+ if (fkt->args[i].typ == BBArgumente::PTyp &&
+ bt->type != BBTyp::PType)
+ return false;
+*/
+ try
+ {
+ BBBaumMatrixPoint *b;
+ pars_matrix_point(ss, b, fkt->args[i].typ == BBArgumente::MTyp, getMem);
+ if (getMem)
+ fktexe->args[i].ArgTyp.MP = b;
+ }
+ catch (BBFehlerException)
+ {
+ if (getMem)
+ delete fktexe;
+ return false;
+ }
+ }
+ possub2++; // Komma entfernen
+ }
+ if (possub2 < sub2.size()) // zuviel Parameter angegeben
+ {
+ if (getMem)
+ delete fktexe;
+ return false;
+ }
+ }
+ return true;
+}
+
+// ------------- Hauptroutine -------------------
+
+static char c;
+static BBTyp *b;
+static BBMatrix *bm;
+static BBPoint *bp;
+static BBBaumMatrixPoint *bmp;
+static int pos;
+static BBFktExe *bfkt;
+
+void pars_integer_float(const string& statement, BBBaumInteger * & Knoten, int getMem /* = true */)
+{
+ string s(statement);
+ trim(s);
+ if (s.empty())
+ throw BBFehlerException();
+ if (isKlammer(s))
+ {
+ s.erase(s.begin());
+ s.erase(s.end()-1);
+
+ pars_integer_float(s, Knoten, getMem);
+ }
+ else if (isMatrixIndex(s, bm, bmp, getMem!=0))
+ {
+ if (getMem)
+ {
+ Knoten = new BBBaumInteger;
+ Knoten->typ = BBBaumInteger::MIndex;
+ Knoten->k.MatrixIndex.M = bm;
+ Knoten->k.MatrixIndex.P = bmp;
+ }
+ }
+ else if (isBiOperator(s, c, pos))
+ {
+ string links = s.substr(0, pos);
+ string rechts = s.substr(pos+1, s.size()-pos-1);
+ if (links.empty() || rechts.empty())
+ throw BBFehlerException();
+
+ if (getMem)
+ {
+ Knoten = new BBBaumInteger;
+ Knoten->typ = BBBaumInteger::BIOperator;
+ switch(c)
+ {
+ case '+':
+ Knoten->k.BiOperator.OpTyp = BBBaumInteger::BBKnoten::BBBiOperator::Plus;
+ break;
+ case '-':
+ Knoten->k.BiOperator.OpTyp = BBBaumInteger::BBKnoten::BBBiOperator::Minus;
+ break;
+ case '*':
+ Knoten->k.BiOperator.OpTyp = BBBaumInteger::BBKnoten::BBBiOperator::Mal;
+ break;
+ case '/':
+ Knoten->k.BiOperator.OpTyp = BBBaumInteger::BBKnoten::BBBiOperator::Geteilt;
+ break;
+ case '^':
+ Knoten->k.BiOperator.OpTyp = BBBaumInteger::BBKnoten::BBBiOperator::Hoch;
+ break;
+//-->
+ case '%':
+ Knoten->k.BiOperator.OpTyp = BBBaumInteger::BBKnoten::BBBiOperator::Modulo;
+ break;
+//<--
+ }
+ pars_integer_float(links, Knoten->k.BiOperator.links);
+ pars_integer_float(rechts, Knoten->k.BiOperator.rechts);
+ }
+ else
+ {
+ pars_integer_float(links, Knoten, getMem);
+ pars_integer_float(rechts, Knoten, getMem);
+ }
+ }
+ else if (isUniOperator(s, c))
+ {
+ s.erase(s.begin());
+ if (getMem)
+ {
+ Knoten = new BBBaumInteger;
+ Knoten->typ = BBBaumInteger::UniOperator;
+ Knoten->k.UniOperator.OpTyp = (c == '+' ? BBBaumInteger::BBKnoten::BBUniOperator::Plus : BBBaumInteger::BBKnoten::BBUniOperator::Minus);
+ pars_integer_float(s, Knoten->k.UniOperator.rechts);
+ }
+ else
+ pars_integer_float(s, Knoten->k.UniOperator.rechts, getMem);
+
+ }
+ else if (isFZahl(s))
+ {
+ if (getMem)
+ {
+ Knoten = new BBBaumInteger;
+ Knoten->typ = BBBaumInteger::FZahl;
+ Knoten->k.FZahl = atof(s.data());
+ }
+ }
+ else if (isIZahl(s))
+ {
+ if (getMem)
+ {
+ Knoten = new BBBaumInteger;
+ Knoten->typ = BBBaumInteger::IZahl;
+ Knoten->k.IZahl = (int)atof(s.data());
+ }
+ }
+
+ else if (isFVar(s, b))
+ {
+ if (getMem)
+ {
+ Knoten = new BBBaumInteger;
+ Knoten->typ = BBBaumInteger::FVar;
+ Knoten->k.FVar = getVarF(b);
+ }
+ }
+ else if (isIVar(s, b))
+ {
+ if (getMem)
+ {
+ Knoten = new BBBaumInteger;
+ Knoten->typ = BBBaumInteger::IVar;
+ Knoten->k.IVar = getVarI(b);
+ }
+ }
+ else if (isFunktion (s, bfkt, getMem!=0, false)) // nur die Funktionen mit Return-Typ
+ {
+ if (getMem)
+ {
+ Knoten = new BBBaumInteger;
+ Knoten->typ = BBBaumInteger::Funktion;
+ Knoten->k.func = bfkt;
+ }
+ }
+ else
+ throw BBFehlerException();
+}
+
+bool isIntFloatAusdruck(const string& s)
+{
+ try
+ {
+ BBBaumInteger *knoten = NULL;
+ pars_integer_float(s, knoten, false);
+ }
+ catch (BBFehlerException)
+ {
+ return false;
+ }
+ return true;
+}
+
+//++++++++++++++ Point ++++++++++++++++++++++++++
+// Operator p/p + -
+// Operator p/i i/p p/f f/p * /
+
+//++++++++++++++ Matrix ++++++++++++++++++++++++++
+// Operator M/M + -
+// Operator M/i i/M M/f f/M * /
+
+void pars_matrix_point(const string& statement, BBBaumMatrixPoint * &Knoten, bool matrix, bool getMem /* = true */)
+{
+ string s(statement);
+ trim(s);
+ if (s.empty())
+ throw BBFehlerException();
+ if (isKlammer(s))
+ {
+ s.erase(s.begin());
+ s.erase(s.end()-1);
+
+ pars_matrix_point(s, Knoten, matrix, getMem);
+ }
+ else if (isUniOperator(s, c))
+ {
+ s.erase(s.begin());
+ if (getMem)
+ {
+ Knoten = new BBBaumMatrixPoint;
+ Knoten->typ = BBBaumMatrixPoint::UniOperator;
+ Knoten->k.UniOperator.OpTyp = (c == '+' ? BBBaumMatrixPoint::BBKnoten::BBUniOperator::Plus : BBBaumMatrixPoint::BBKnoten::BBUniOperator::Minus);
+ Knoten->isMatrix = matrix;
+ pars_matrix_point(s, Knoten->k.UniOperator.rechts, matrix);
+ }
+ else
+ pars_matrix_point(s, Knoten, matrix, getMem);
+ }
+ else if (isBiOperator(s, c, pos))
+ {
+ string links = s.substr(0, pos);
+ string rechts = s.substr(pos+1, s.size()-pos-1);
+ if (links.empty() || rechts.empty())
+ throw BBFehlerException();
+ if (getMem)
+ {
+ Knoten = new BBBaumMatrixPoint;
+ Knoten->typ = BBBaumMatrixPoint::BIOperator;
+ Knoten->isMatrix = matrix;
+ switch(c)
+ {
+ case '+':
+ Knoten->k.BiOperator.OpTyp = BBBaumMatrixPoint::BBKnoten::BBBiOperator::Plus;
+ break;
+ case '-':
+ Knoten->k.BiOperator.OpTyp = BBBaumMatrixPoint::BBKnoten::BBBiOperator::Minus;
+ break;
+ case '*':
+ Knoten->k.BiOperator.OpTyp = BBBaumMatrixPoint::BBKnoten::BBBiOperator::Mal;
+ break;
+ case '/':
+ Knoten->k.BiOperator.OpTyp = BBBaumMatrixPoint::BBKnoten::BBBiOperator::Geteilt;
+ break;
+ case '^':
+ throw BBFehlerException();
+ break;
+ case '%':
+ throw BBFehlerException();
+ break;
+ }
+ pars_matrix_point(links, Knoten->k.BiOperator.links, matrix);
+ pars_matrix_point(rechts, Knoten->k.BiOperator.rechts, matrix);
+ if (c == '+' || c == '-')
+ {
+ // Operator nur zwischen zwei Points
+ if (matrix && ( (Knoten->k.BiOperator.rechts)->typ != BBBaumMatrixPoint::MVar ||
+ (Knoten->k.BiOperator.links )->typ != BBBaumMatrixPoint::MVar ))
+ {
+ throw BBFehlerException();
+ }
+ if (!matrix && ((Knoten->k.BiOperator.rechts)->typ != BBBaumMatrixPoint::PVar ||
+ (Knoten->k.BiOperator.links )->typ != BBBaumMatrixPoint::PVar ))
+ {
+ throw BBFehlerException();
+ }
+ }
+ if (c == '*' || c == '/')
+ {
+ // Operator nur zwischen i/f und p, Reihenfolge egal
+ int pvar = 0;
+ int mvar = 0;
+
+ if ((Knoten->k.BiOperator.rechts)->typ == BBBaumMatrixPoint::PVar)
+ pvar++;
+ if ((Knoten->k.BiOperator.rechts)->typ == BBBaumMatrixPoint::MVar)
+ mvar++;
+ if ((Knoten->k.BiOperator.links)->typ == BBBaumMatrixPoint::PVar)
+ pvar++;
+ if ((Knoten->k.BiOperator.links)->typ == BBBaumMatrixPoint::MVar)
+ mvar++;
+
+ if (matrix && (mvar != 1 || pvar != 0))
+ throw BBFehlerException();
+ if (!matrix && (pvar != 1 || mvar != 0))
+ throw BBFehlerException();
+ }
+ }
+ else
+ {
+ pars_matrix_point(links, Knoten, matrix, getMem);
+ pars_matrix_point(rechts, Knoten, matrix, getMem);
+ }
+ }
+ else if (matrix && isMVar(s, b))
+ {
+ if (getMem)
+ {
+ Knoten = new BBBaumMatrixPoint;
+ Knoten->typ = BBBaumMatrixPoint::MVar;
+ Knoten->k.M = getVarM(b);
+ Knoten->isMatrix = matrix;
+ }
+ }
+ else if (!matrix && isPVar(s, b))
+ {
+ if (getMem)
+ {
+ Knoten = new BBBaumMatrixPoint;
+ Knoten->typ = BBBaumMatrixPoint::PVar;
+ Knoten->k.P = getVarP(b);
+ Knoten->isMatrix = matrix;
+ }
+ }
+ else if (isIntFloatAusdruck(s))
+ {
+ if (getMem)
+ {
+ Knoten = new BBBaumMatrixPoint;
+ Knoten->typ = BBBaumMatrixPoint::IFAusdruck;
+ Knoten->isMatrix = matrix;
+ pars_integer_float(s, Knoten->k.IntFloatAusdruck.b);
+ }
+ else
+ {
+ BBBaumInteger *k = NULL;
+ pars_integer_float(s, k, getMem);
+ }
+ }
+ else
+ throw BBFehlerException();
+}
+
diff --git a/src/modules/grid/grid_calculus_bsl/ausdruck.h b/src/modules/grid/grid_calculus_bsl/ausdruck.h
new file mode 100644
index 0000000..b442619
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/ausdruck.h
@@ -0,0 +1,133 @@
+#ifndef __AUSDRUCK_H
+#define __AUSDRUCK_H
+
+
+#include "basistypen.h"
+
+// Baum-Struktur für Integer
+class BBFunktion;
+struct BBFktExe;
+class BBBaumMatrixPoint;
+
+class BBBaumInteger
+{
+public:
+ enum KnotenTyp { NoOp, BIOperator, UniOperator, MIndex, IZahl, FZahl,
+ Funktion, IVar, FVar } typ;
+ BBBaumInteger();
+ ~BBBaumInteger();
+
+ union BBKnoten
+ {
+ struct BBBiOperator
+ {
+ enum OperatorType {Plus, Minus, Mal, Geteilt, Hoch, Modulo} OpTyp;
+ BBBaumInteger *links;
+ BBBaumInteger *rechts;
+ } BiOperator;
+
+ struct BBUniOperator
+ {
+ enum OperatorType {Plus, Minus } OpTyp;
+ BBBaumInteger *rechts;
+ } UniOperator;
+
+ struct BBMatrixIndex
+ {
+ BBMatrix *M;
+ //BBPoint *P;
+ BBBaumMatrixPoint *P;
+ } MatrixIndex;
+
+ int IZahl;
+ double FZahl;
+ BBFktExe *func;
+ BBInteger *IVar;
+ BBFloat *FVar;
+
+ } k;
+ // bi-operator + - * / ^
+
+ // uni-operator - +
+ // Integer-Zahl
+ // double-Zahl
+ // Integer-Variable
+ // Float-Variable
+
+ // kommt später:
+ // Funktion (später) mit Rückgabewerte Int oder Float
+
+};
+
+bool isKlammer(const std::string& statement);
+bool isBiOperator(const std::string& statement, char& c, int& pos);
+bool isUniOperator(const std::string& statement, char& c);
+bool isMatrixIndex(const std::string& statement, BBMatrix *& bm, BBBaumMatrixPoint *& bp, bool getMem = true);
+bool isFZahl(const std::string& statement);
+bool isIZahl(const std::string& statement);
+bool isFVar (const std::string& statement, BBTyp * &b);
+bool isIVar (const std::string& statement, BBTyp * &b);
+bool isPVar (const std::string& statement, BBTyp * &b);
+bool isMVar (const std::string& statement, BBTyp * &b);
+BBFunktion *isFktName(const std::string& s);
+bool isFunktion (const std::string& statement, BBFktExe * &b, bool getMem = true, bool AlleFunktionen = true);
+
+void pars_integer_float(const std::string& statement, BBBaumInteger * &Knoten, int getmem = true);
+
+
+
+//***************** Punkt und Matrix *****************
+// Operator p/p -> + -
+// Operator p/i i/p p/f f/p -> * /
+// uni - Operator nur für p/f/i
+//++++++++++++++ Matrix ++++++++++++++++++++++++++
+// Operator M/M + -
+// Operator M/i i/M M/f f/M * /
+// uni - Operator nur für f/i
+
+
+
+class BBBaumMatrixPoint
+{
+public:
+ enum KnotenTyp { NoOp, BIOperator, UniOperator, IFAusdruck,
+ MVar, PVar} typ;
+ BBBaumMatrixPoint();
+ ~BBBaumMatrixPoint();
+
+ union BBKnoten
+ {
+ struct BBBiOperator
+ {
+ enum OperatorType {Plus, Minus, Mal, Geteilt} OpTyp;
+ BBBaumMatrixPoint *links;
+ BBBaumMatrixPoint *rechts;
+ } BiOperator;
+
+ struct BBUniOperator
+ {
+ enum OperatorType {Plus, Minus } OpTyp;
+ BBBaumMatrixPoint *rechts;
+ } UniOperator;
+
+ struct BBIntFloatAusdruck
+ {
+ BBBaumInteger *b;
+ } IntFloatAusdruck;
+
+ BBMatrix *M;
+ BBPoint *P;
+ } k;
+ bool isMatrix;
+ // bi-operator + - * / ^
+};
+
+
+void pars_matrix_point(const std::string& statement,
+ BBBaumMatrixPoint * &Knoten,
+ bool matrix = true,
+ bool getMem = true );
+
+
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/auswert_anweisung.cpp b/src/modules/grid/grid_calculus_bsl/auswert_anweisung.cpp
new file mode 100644
index 0000000..4143031
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/auswert_anweisung.cpp
@@ -0,0 +1,29 @@
+
+//#include "..\stdafx.h"
+
+#include "auswert_anweisung.h"
+
+
+
+void ausfuehren_anweisung(T_AnweisungList& a)
+{
+ T_AnweisungList::iterator it;
+ for (it = a.begin(); it != a.end(); it++)
+ {
+ switch((*it)->typ)
+ {
+ case BBAnweisung::ForEach:
+ ausfuehren_foreach(*((*it)->AnweisungVar.For));
+ break;
+ case BBAnweisung::IF:
+ ausfueren_bedingung(*((*it)->AnweisungVar.IF));
+ break;
+ case BBAnweisung::Zuweisung:
+ ausfuehren_zuweisung(*((*it)->AnweisungVar.Zu));
+ break;
+ case BBAnweisung::Funktion:
+ auswert_funktion_integer((*it)->AnweisungVar.Fkt);
+ break;
+ }
+ }
+}
diff --git a/src/modules/grid/grid_calculus_bsl/auswert_anweisung.h b/src/modules/grid/grid_calculus_bsl/auswert_anweisung.h
new file mode 100644
index 0000000..7029b8f
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/auswert_anweisung.h
@@ -0,0 +1,10 @@
+#ifndef __AUSWERT_ANWEISUNG_H
+#define __AUSWERT_ANWEISUNG_H
+
+
+#include "auswert_if.h"
+
+void ausfuehren_anweisung(T_AnweisungList& a);
+
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/auswert_foreach.cpp b/src/modules/grid/grid_calculus_bsl/auswert_foreach.cpp
new file mode 100644
index 0000000..cfca07c
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/auswert_foreach.cpp
@@ -0,0 +1,58 @@
+
+#include "auswert_foreach.h"
+
+#include "bsl_interpreter.h"
+
+
+void ausfuehren_foreach(BBForEach& f)
+{
+ int x, y;
+ y = f.M->M->yanz;
+ x = f.M->M->xanz;
+ if (f.type == BBForEach::Point)
+ {
+ // foreach p in M do
+ for (f.P->v.y=0; f.P->v.y<y; (f.P->v.y)++)
+ {
+ if( g_Set_Progress(f.P->v.y, y) == false )
+ {
+ throw BBFehlerUserbreak("User Break");
+ }
+ for (f.P->v.x=0; f.P->v.x<x; (f.P->v.x)++)
+ {
+ // P setzen
+ //f.P->v.x = j;
+ //f.P->v.y = i;
+
+ // Anweisungen ausführen
+ ausfuehren_anweisung(f.z);
+ }
+ }
+ }
+ else
+ {
+ // foreachn n of p in M do
+ for (int i=-1; i<=1; i++)
+ {
+ for (int j=-1; j<=1; j++)
+ {
+ if (i != 0 || j != 0)
+ {
+ int vx, vy;
+ vx = j+f.P->v.x;
+ vy = i+f.P->v.y;
+ if (vx < 0 || vx >= f.M->M->xanz ||
+ vy < 0 || vy >= f.M->M->yanz)
+ continue;
+
+ // n setzen
+ f.N->v.x = vx;
+ f.N->v.y = vy;
+
+ // Anweisungen ausführen
+ ausfuehren_anweisung(f.z);
+ }
+ }
+ }
+ }
+}
diff --git a/src/modules/grid/grid_calculus_bsl/auswert_foreach.h b/src/modules/grid/grid_calculus_bsl/auswert_foreach.h
new file mode 100644
index 0000000..014512b
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/auswert_foreach.h
@@ -0,0 +1,16 @@
+#ifndef __AUSWERT_FOREACH_H
+#define __AUSWERT_FOREACH_H
+
+
+#include "auswert_zuweisung.h"
+
+
+
+extern void ausfuehren_anweisung(T_AnweisungList& a);
+
+void ausfuehren_foreach(BBForEach& f);
+
+
+
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/auswert_if.cpp b/src/modules/grid/grid_calculus_bsl/auswert_if.cpp
new file mode 100644
index 0000000..1f348dd
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/auswert_if.cpp
@@ -0,0 +1,135 @@
+
+//#include <..\stdafx.h>
+
+#include "auswert_if.h"
+#include <assert.h>
+
+
+
+bool auswert_bool_IFVar(BBBaumInteger *IF1, BBBaumInteger *IF2, BBBool::T_booloperator b)
+{
+ switch (b)
+ {
+ case BBBool::Gleich:
+ return auswert_float(*IF1) == auswert_float(*IF2);
+ case BBBool::Ungleich:
+ return auswert_float(*IF1) != auswert_float(*IF2);
+ case BBBool::Kleiner:
+ return auswert_float(*IF1) < auswert_float(*IF2);
+ case BBBool::Groesser:
+ return auswert_float(*IF1) > auswert_float(*IF2);
+ case BBBool::KleinerG:
+ return auswert_float(*IF1) <= auswert_float(*IF2);
+ case BBBool::GroesserG:
+ return auswert_float(*IF1) >= auswert_float(*IF2);
+ }
+ return false;
+}
+
+bool auswert_bool_PVar(BBBaumMatrixPoint *P1, BBBaumMatrixPoint *P2, BBBool::T_booloperator b)
+{
+ T_Point v1, v2;
+ double f;
+ int ret1 = auswert_point(*P1, v1, f);
+ int ret2 = auswert_point(*P2, v2, f);
+ assert(ret1 && ret2);
+
+ switch (b)
+ {
+ case BBBool::Gleich:
+ return (v1.x == v2.x && v1.y == v2.y);
+ case BBBool::Ungleich:
+ return (v1.x != v2.x || v1.y != v2.y);
+ case BBBool::Kleiner:
+ return (v1.x < v2.x);
+ case BBBool::Groesser:
+ return (v1.x > v2.x);
+ case BBBool::KleinerG:
+ return (v1.x <= v2.x);
+ case BBBool::GroesserG:
+ return (v1.x >= v2.x);
+ }
+ return false;
+}
+
+bool auswert_bool_MVar(BBBaumMatrixPoint *M1, BBBaumMatrixPoint *M2, BBBool::T_booloperator b)
+{
+ GridWerte v1, v2;
+ double f;
+ int ret1 = auswert_matrix(*M1, v1, f);
+ int ret2 = auswert_matrix(*M2, v2, f);
+ assert(ret1 && ret2);
+
+ switch (b)
+ {
+ case BBBool::Gleich:
+ return (v1.xanz == v2.xanz && v1.yanz == v2.yanz);
+ case BBBool::Ungleich:
+ return (v1.xanz != v2.xanz || v1.yanz != v2.yanz);
+ case BBBool::Kleiner:
+ return (v1.xanz < v2.xanz);
+ case BBBool::Groesser:
+ return (v1.xanz > v2.xanz);
+ case BBBool::KleinerG:
+ return (v1.xanz <= v2.xanz);
+ case BBBool::GroesserG:
+ return (v1.xanz >= v2.xanz);
+ }
+ return false;
+}
+
+bool auswert_bool(BBBool& b)
+{
+ assert(b.type != BBBool::Nothing);
+
+ switch(b.type)
+ {
+ case BBBool::IFVar:
+ return auswert_bool_IFVar(b.BoolVar1.IF, b.BoolVar2.IF, b.BoolOp);
+ case BBBool::PVar:
+ return auswert_bool_PVar(b.BoolVar1.MP, b.BoolVar2.MP, b.BoolOp);
+ case BBBool::MVar:
+ return auswert_bool_MVar(b.BoolVar1.MP, b.BoolVar2.MP, b.BoolOp);
+ }
+ return false;
+}
+
+bool auswert_bedingung(BBBedingung *b)
+{
+ assert(b->type != BBBedingung::Nothing);
+ int ret1, ret2;
+
+ switch (b->type)
+ {
+ case BBBedingung::Bool:
+ return auswert_bool(*(b->BedingungVar.BoolVar.b));
+ case BBBedingung::Und:
+ return auswert_bedingung(b->BedingungVar.BoolBiOp.b1) &&
+ auswert_bedingung(b->BedingungVar.BoolBiOp.b2);
+ case BBBedingung::Oder:
+ return auswert_bedingung(b->BedingungVar.BoolBiOp.b1) ||
+ auswert_bedingung(b->BedingungVar.BoolBiOp.b2);
+ case BBBedingung::XOder:
+ ret1 = auswert_bedingung(b->BedingungVar.BoolBiOp.b1);
+ ret2 = auswert_bedingung(b->BedingungVar.BoolBiOp.b2);
+ return ((ret1 && !ret2) || (!ret1 && ret2));
+ case BBBedingung::Not:
+ return ! auswert_bedingung(b->BedingungVar.BoolUniOp.b);
+ }
+ assert(false);
+ return false;
+}
+
+void ausfueren_bedingung(BBIf& b)
+{
+
+ if (auswert_bedingung(b.b))
+ {
+ ausfuehren_anweisung(b.z);
+ }
+ else
+ {
+ if (b.isElse)
+ ausfuehren_anweisung(b.zelse);
+ }
+}
diff --git a/src/modules/grid/grid_calculus_bsl/auswert_if.h b/src/modules/grid/grid_calculus_bsl/auswert_if.h
new file mode 100644
index 0000000..b831ff1
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/auswert_if.h
@@ -0,0 +1,12 @@
+#ifndef __AUSWERT_IF_H
+#define __AUSWERT_IF_H
+
+
+#include "auswert_foreach.h"
+
+bool auswert_bedingung(BBBedingung *b);
+void ausfueren_bedingung(BBIf& b);
+
+
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/auswert_zuweisung.cpp b/src/modules/grid/grid_calculus_bsl/auswert_zuweisung.cpp
new file mode 100644
index 0000000..b35f38a
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/auswert_zuweisung.cpp
@@ -0,0 +1,477 @@
+
+#include "pars_all.h"
+#include "auswert_zuweisung.h"
+#include "diverses.h"
+#include <assert.h>
+
+
+int auswert_integer(BBBaumInteger& b)
+{
+ if (b.typ == BBBaumInteger::NoOp)
+ throw BBFehlerAusfuehren();
+ double f;
+ T_Point p;
+
+ switch(b.typ)
+ {
+ case BBBaumInteger::BIOperator:
+ switch(b.k.BiOperator.OpTyp)
+ {
+ case BBBaumInteger::BBKnoten::BBBiOperator::Plus:
+ return auswert_integer(*b.k.BiOperator.links) +
+ auswert_integer(*b.k.BiOperator.rechts);
+ case BBBaumInteger::BBKnoten::BBBiOperator::Minus:
+ return auswert_integer(*b.k.BiOperator.links) -
+ auswert_integer(*b.k.BiOperator.rechts);
+ case BBBaumInteger::BBKnoten::BBBiOperator::Mal:
+ return auswert_integer(*b.k.BiOperator.links) *
+ auswert_integer(*b.k.BiOperator.rechts);
+ case BBBaumInteger::BBKnoten::BBBiOperator::Geteilt:
+ return auswert_integer(*b.k.BiOperator.links) /
+ auswert_integer(*b.k.BiOperator.rechts);
+ case BBBaumInteger::BBKnoten::BBBiOperator::Hoch:
+ return fround(pow( (double)auswert_integer(*b.k.BiOperator.links),
+ (double)auswert_integer(*b.k.BiOperator.rechts)));
+//-->
+ case BBBaumInteger::BBKnoten::BBBiOperator::Modulo:
+ return auswert_integer(*b.k.BiOperator.links) %
+ auswert_integer(*b.k.BiOperator.rechts) ;
+//<--
+ }
+ break;
+ case BBBaumInteger::UniOperator:
+ switch (b.k.UniOperator.OpTyp)
+ {
+ case BBBaumInteger::BBKnoten::BBUniOperator::Plus:
+ return auswert_integer(*b.k.UniOperator.rechts);
+ case BBBaumInteger::BBKnoten::BBUniOperator::Minus:
+ return (- auswert_integer(*b.k.UniOperator.rechts));
+ }
+ break;
+ case BBBaumInteger::MIndex:
+ if (b.k.MatrixIndex.P->isMatrix) //muss Point sein
+ {
+ assert(false);
+ break;
+ }
+ auswert_point(*b.k.MatrixIndex.P, p, f);
+
+ return fround( (double)(*b.k.MatrixIndex.M->M)(p.x,p.y) );
+
+
+
+ case BBBaumInteger::IZahl:
+ return b.k.IZahl;
+ case BBBaumInteger::FZahl:
+ return fround(b.k.FZahl);
+ case BBBaumInteger::Funktion:
+ if (b.k.func->f->ret.typ == BBArgumente::ITyp)
+ return auswert_funktion_integer(b.k.func);
+ else if (b.k.func->f->ret.typ == BBArgumente::FTyp)
+ return fround(auswert_funktion_float(b.k.func));
+ else if (b.k.func->f->ret.typ == BBArgumente::NoOp)
+ {
+ auswert_funktion_integer(b.k.func);
+ return 0;
+ }
+ assert(false);
+ break;
+ case BBBaumInteger::IVar:
+ return *(b.k.IVar->i);
+ case BBBaumInteger::FVar:
+ return fround(*(b.k.FVar->f));
+ }
+ assert(false);
+ return 0;
+}
+
+// ************ Float *******************
+double auswert_float(BBBaumInteger& b)
+{
+ if (b.typ == BBBaumInteger::NoOp)
+ throw BBFehlerAusfuehren();
+
+ double f;
+ T_Point p;
+
+ switch(b.typ)
+ {
+ case BBBaumInteger::BIOperator:
+ switch(b.k.BiOperator.OpTyp)
+ {
+ case BBBaumInteger::BBKnoten::BBBiOperator::Plus:
+ return auswert_float(*b.k.BiOperator.links) +
+ auswert_float(*b.k.BiOperator.rechts);
+ case BBBaumInteger::BBKnoten::BBBiOperator::Minus:
+ return auswert_float(*b.k.BiOperator.links) -
+ auswert_float(*b.k.BiOperator.rechts);
+ case BBBaumInteger::BBKnoten::BBBiOperator::Mal:
+ return auswert_float(*b.k.BiOperator.links) *
+ auswert_float(*b.k.BiOperator.rechts);
+ case BBBaumInteger::BBKnoten::BBBiOperator::Geteilt:
+ return auswert_float(*b.k.BiOperator.links) /
+ auswert_float(*b.k.BiOperator.rechts);
+ case BBBaumInteger::BBKnoten::BBBiOperator::Hoch:
+ return pow( auswert_float(*b.k.BiOperator.links),
+ auswert_float(*b.k.BiOperator.rechts));
+ case BBBaumInteger::BBKnoten::BBBiOperator::Modulo:
+ return fmod( auswert_float(*b.k.BiOperator.links),
+ auswert_float(*b.k.BiOperator.rechts));
+ }
+ break;
+ case BBBaumInteger::UniOperator:
+ switch (b.k.UniOperator.OpTyp)
+ {
+ case BBBaumInteger::BBKnoten::BBUniOperator::Plus:
+ return auswert_float(*b.k.UniOperator.rechts);
+ case BBBaumInteger::BBKnoten::BBUniOperator::Minus:
+ return (- auswert_float(*b.k.UniOperator.rechts));
+ }
+ break;
+ case BBBaumInteger::MIndex:
+ if (b.k.MatrixIndex.P->isMatrix) //muss Point sein
+ {
+ assert(false);
+ break;
+ }
+ auswert_point(*b.k.MatrixIndex.P, p, f);
+
+ return (*b.k.MatrixIndex.M->M)(p.x,p.y);
+
+ //return b.k.MatrixIndex.M->M->Z[p.y][p.x];
+
+
+ case BBBaumInteger::IZahl:
+ return b.k.IZahl;
+ case BBBaumInteger::FZahl:
+ return b.k.FZahl;
+ case BBBaumInteger::Funktion:
+ if (b.k.func->f->ret.typ == BBArgumente::ITyp)
+ return auswert_funktion_integer(b.k.func);
+ else if (b.k.func->f->ret.typ == BBArgumente::FTyp)
+ return auswert_funktion_float(b.k.func);
+ else if (b.k.func->f->ret.typ == BBArgumente::NoOp)
+ {
+ auswert_funktion_integer(b.k.func);
+ return 0;
+ }
+ assert(false);
+ break;
+ case BBBaumInteger::IVar:
+ return *(b.k.IVar->i);
+ case BBBaumInteger::FVar:
+ return *(b.k.FVar->f);
+ }
+ assert(false);
+ return 0;
+}
+
+// ************ Point *******************
+bool auswert_point(BBBaumMatrixPoint& b, T_Point& vret, double& fret)
+{
+ if (b.typ == BBBaumInteger::NoOp)
+ throw BBFehlerAusfuehren();
+ if (b.isMatrix)
+ throw BBFehlerAusfuehren();
+
+ T_Point v, v2;
+ double f, f2;
+ bool ret1, ret2;
+ switch(b.typ)
+ {
+ case BBBaumMatrixPoint::BIOperator:
+ switch (b.k.BiOperator.OpTyp)
+ {
+ case BBBaumMatrixPoint::BBKnoten::BBBiOperator::Plus:
+ ret1 = auswert_point(*b.k.BiOperator.links, v, f);
+ ret2 = auswert_point(*b.k.BiOperator.rechts, v2, f);
+ assert(ret1 && ret2);
+ v.x += v2.x;
+ v.y += v2.y;
+ vret = v;
+ return true;
+ case BBBaumMatrixPoint::BBKnoten::BBBiOperator::Minus:
+ ret1 = auswert_point(*b.k.BiOperator.links, v, f);
+ ret2= auswert_point(*b.k.BiOperator.rechts, v2, f);
+ assert(ret1 && ret2);
+ v.x -= v2.x;
+ v.y -= v2.y;
+ vret = v;
+ return true;
+ case BBBaumMatrixPoint::BBKnoten::BBBiOperator::Mal:
+ ret1 = auswert_point(*b.k.BiOperator.links, v, f);
+ ret2= auswert_point(*b.k.BiOperator.rechts, v2, f2);
+ assert((ret1 && !ret2) || (!ret1 && ret2));
+ if (ret1)
+ {
+ v.x *= f2;
+ v.y *= f2;
+ }
+ else
+ {
+ v.x = v2.x * f;
+ v.y = v2.y * f;
+ }
+ vret = v;
+ return true;
+ case BBBaumMatrixPoint::BBKnoten::BBBiOperator::Geteilt:
+ ret1 = auswert_point(*b.k.BiOperator.links, v, f);
+ ret2= auswert_point(*b.k.BiOperator.rechts, v2, f2);
+ assert((ret1 && !ret2) || (!ret1 && ret2));
+ if (ret1)
+ {
+ v.x /= f2;
+ v.y /= f2;
+ }
+ else
+ {
+ v.x = v2.x / f;
+ v.y = v2.y / f;
+ }
+ vret = v;
+ return true;
+ }
+ break;
+ case BBBaumMatrixPoint::UniOperator:
+ switch (b.k.UniOperator.OpTyp)
+ {
+ case BBBaumMatrixPoint::BBKnoten::BBUniOperator::Plus:
+ ret1 = auswert_point(*b.k.UniOperator.rechts, v, f);
+ assert(ret1);
+ vret = v;
+ return true;
+ case BBBaumMatrixPoint::BBKnoten::BBUniOperator::Minus:
+ ret1 = auswert_point(*b.k.UniOperator.rechts, v, f);
+ assert(ret1);
+ vret.x = -v.x;
+ vret.y = -v.y;
+ return true;
+ }
+ break;
+ case BBBaumMatrixPoint::IFAusdruck:
+ fret = auswert_float(*b.k.IntFloatAusdruck.b);
+ return false;
+ case BBBaumMatrixPoint::MVar:
+ assert(false);
+ break;
+ case BBBaumMatrixPoint::PVar:
+ vret = b.k.P->v;
+ return true;
+ }
+ assert(false);
+ return false;
+}
+
+// ************ Matrix *******************
+// Groesse von mret bestimmen !!
+// Aufruf M = m+3*m2; ??
+bool auswert_matrix(BBBaumMatrixPoint& b, GridWerte& mret, double& fret)
+{
+ if (b.typ == BBBaumInteger::NoOp)
+ throw BBFehlerAusfuehren();
+ if (!b.isMatrix) // ?????
+ throw BBFehlerAusfuehren();
+
+ GridWerte m, m2;
+ double f, f2;
+ bool ret1, ret2;
+ switch(b.typ)
+ {
+ case BBBaumMatrixPoint::BIOperator:
+ switch (b.k.BiOperator.OpTyp)
+ {
+ case BBBaumMatrixPoint::BBKnoten::BBBiOperator::Plus:
+ ret1 = auswert_matrix(*b.k.BiOperator.links, m, f);
+ ret2 = auswert_matrix(*b.k.BiOperator.rechts, m2, f);
+ assert(ret1 && ret2);
+
+ mret = m;
+ mret.getMem();
+
+
+ if (!(m.xanz == m2.xanz &&
+ m.yanz == m2.yanz &&
+ mret.xanz == m2.xanz &&
+ mret.yanz == m2.yanz ))
+ throw BBFehlerMatrixNotEqual();
+ {
+ for (int i=0; i<m.yanz; i++)
+ for (int j=0; j<m.xanz; j++)
+ mret.Set_Value(j,i, m(j,i) + m2(j,i));
+ }
+ return true;
+ case BBBaumMatrixPoint::BBKnoten::BBBiOperator::Minus:
+ ret1 = auswert_matrix(*b.k.BiOperator.links, m, f);
+ ret2= auswert_matrix(*b.k.BiOperator.rechts, m2, f);
+ assert(ret1 && ret2);
+ if (!(m.xanz == m2.xanz &&
+ m.yanz == m2.yanz &&
+ mret.xanz == m2.xanz &&
+ mret.yanz == m2.yanz ))
+ throw BBFehlerMatrixNotEqual();
+ {
+ for (int i=0; i<m.yanz; i++)
+ for (int j=0; j<m.xanz; j++)
+ mret.Set_Value(j,i, m(j,i) - m2(j,i));
+ }
+ return true;
+ case BBBaumMatrixPoint::BBKnoten::BBBiOperator::Mal:
+ ret1 = auswert_matrix(*b.k.BiOperator.links, m, f);
+ ret2= auswert_matrix(*b.k.BiOperator.rechts, m2, f2);
+ assert((ret1 && !ret2) || (!ret1 && ret2));
+ if (ret1)
+ {
+ if (!(mret.xanz == m.xanz &&
+ mret.yanz == m.yanz))
+ throw BBFehlerMatrixNotEqual();
+ for (int i=0; i<m.yanz; i++)
+ for (int j=0; j<m.xanz; j++)
+ mret.Set_Value(j,i, m(j,i) * f2);
+ }
+ else
+ {
+ if (!(mret.xanz == m2.xanz &&
+ mret.yanz == m2.yanz))
+ throw BBFehlerMatrixNotEqual();
+ for (int i=0; i<m2.yanz; i++)
+ for (int j=0; j<m2.xanz; j++)
+ mret.Set_Value(j,i, m2(j,i) * f);
+ }
+ return true;
+ case BBBaumMatrixPoint::BBKnoten::BBBiOperator::Geteilt:
+ ret1 = auswert_matrix(*b.k.BiOperator.links, m, f);
+ ret2= auswert_matrix(*b.k.BiOperator.rechts, m2, f2);
+ assert((ret1 && !ret2) || (!ret1 && ret2));
+ if (ret1)
+ {
+ if (!(mret.xanz == m.xanz &&
+ mret.yanz == m.yanz))
+ throw BBFehlerMatrixNotEqual();
+ for (int i=0; i<m.yanz; i++)
+ for (int j=0; j<m.xanz; j++)
+ mret.Set_Value(j,i, m(j,i) / f2);
+ }
+ else
+ {
+ if (!(mret.xanz == m2.xanz &&
+ mret.yanz == m2.yanz))
+ throw BBFehlerMatrixNotEqual();
+ for (int i=0; i<m2.yanz; i++)
+ for (int j=0; j<m2.xanz; j++)
+ mret.Set_Value(j,i, m2(j,i) / f);
+ }
+ return true;
+ }
+ break;
+ case BBBaumMatrixPoint::UniOperator:
+ switch (b.k.UniOperator.OpTyp)
+ {
+ case BBBaumMatrixPoint::BBKnoten::BBUniOperator::Plus:
+ ret1 = auswert_matrix(*b.k.UniOperator.rechts, mret, f);
+ assert(ret1);
+ return true;
+ case BBBaumMatrixPoint::BBKnoten::BBUniOperator::Minus:
+ ret1 = auswert_matrix(*b.k.UniOperator.rechts, mret, f);
+ assert(ret1);
+ {
+ for (int i=0; i<mret.yanz; i++)
+ for (int j=0; j<mret.xanz; j++)
+ mret.Set_Value(j,i, -mret(j,i));
+ }
+ return true;
+ }
+ break;
+ case BBBaumMatrixPoint::IFAusdruck:
+ fret = auswert_float(*b.k.IntFloatAusdruck.b);
+ return true; // ?????? false;
+ case BBBaumMatrixPoint::MVar:
+ copyGrid(mret, *(b.k.M->M), true);
+ return true;
+ // ???? break;
+ case BBBaumMatrixPoint::PVar:
+ assert(false);
+ return true;
+ }
+ assert(false);
+ return false;
+}
+
+// ************ Funktion Integer *******************
+
+int auswert_funktion_integer(BBFktExe *func)
+{
+ // Argumente kopieren
+ assert(func->f->ret.typ == BBArgumente::ITyp ||
+ func->f->ret.typ == BBArgumente::NoOp );
+
+ int l;
+ l = func->f->args.size();
+ for (int i=0; i<l; i++)
+ func->f->args[i].ArgTyp = func->args[i].ArgTyp;
+ func->f->fkt();
+
+ // falls kein Argument angegeben
+ if (func->f->ret.typ == BBArgumente::NoOp)
+ return 0;
+
+ // sonst auswerten
+ return auswert_integer(*(func->f->ret.ArgTyp.IF));
+}
+
+// ************ Funktion Float *******************
+
+double auswert_funktion_float(BBFktExe *func)
+{
+ // Argumente kopieren
+ assert(func->f->ret.typ == BBArgumente::FTyp);
+
+ int l;
+ l = func->f->args.size();
+ for (int i=0; i<l; i++)
+ func->f->args[i].ArgTyp = func->args[i].ArgTyp;
+ func->f->fkt();
+ return auswert_float(*(func->f->ret.ArgTyp.IF));
+}
+
+int fround(double f)
+{
+ return (floor(f+0.5f));
+}
+
+// ************ ZUWEISUNG *******************
+
+void ausfuehren_zuweisung(BBZuweisung& z)
+{
+ double f;
+ if (z.typ == BBZuweisung::NoTyp)
+ throw BBFehlerAusfuehren();
+ switch(z.typ)
+ {
+ case BBZuweisung::FTyp:
+ *(z.ZuVar.FVar->f) = auswert_float(*z.ZuArt.IF);
+ break;
+ case BBZuweisung::ITyp:
+ *(z.ZuVar.IVar->i) = auswert_integer(*z.ZuArt.IF);
+ break;
+ case BBZuweisung::PTyp:
+ if (!auswert_point(*z.ZuArt.MP, z.ZuVar.PVar->v, f))
+ throw BBFehlerAusfuehren();
+ break;
+ case BBZuweisung::MTyp:
+ if (!auswert_matrix(*z.ZuArt.MP, *(z.ZuVar.MVar->M), f))
+ throw BBFehlerAusfuehren();
+ break;
+ case BBZuweisung::MIndex:
+ {
+ T_Point p;
+ if (!auswert_point(*z.ZuVar.MatrixIndex.PVar, p, f))
+ throw BBFehlerAusfuehren();
+
+ // z.ZuVar.MatrixIndex.MVar->M->Z[p.y][p.x] = auswert_float(*z.ZuArt.IF);
+
+ (*z.ZuVar.MatrixIndex.MVar->M).Set_Value(p.x,p.y, auswert_float(*z.ZuArt.IF));
+
+ }
+ break;
+ }
+}
diff --git a/src/modules/grid/grid_calculus_bsl/auswert_zuweisung.h b/src/modules/grid/grid_calculus_bsl/auswert_zuweisung.h
new file mode 100644
index 0000000..fe73c22
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/auswert_zuweisung.h
@@ -0,0 +1,47 @@
+#ifndef __AUSWERT_ZUWEISUNG_H
+#define __AUSWERT_ZUWEISUNG_H
+
+#include "pars_all.h"
+
+class BBFehlerAusfuehren
+{
+public:
+ BBFehlerAusfuehren() { Text = ""; };
+ BBFehlerAusfuehren(std::string s) { Text = s; };
+ ~BBFehlerAusfuehren() {};
+ std::string Text;
+};
+
+
+class BBFehlerUserbreak
+{
+public:
+ BBFehlerUserbreak() { Text = ""; };
+ BBFehlerUserbreak(std::string s) { Text = s; };
+ ~BBFehlerUserbreak() {};
+ std::string Text;
+};
+
+class BBFehlerMatrixNotEqual
+{
+public:
+ BBFehlerMatrixNotEqual() {};
+ ~BBFehlerMatrixNotEqual() {};
+
+};
+
+int fround(double f);
+int auswert_funktion_integer(BBFktExe *func);
+double auswert_funktion_float(BBFktExe *func);
+
+
+int auswert_integer(BBBaumInteger& b);
+double auswert_float(BBBaumInteger& b);
+bool auswert_point(BBBaumMatrixPoint& b, T_Point& vret, double& fret);
+bool auswert_matrix(BBBaumMatrixPoint& b, GridWerte& mret, double& fret);
+
+void ausfuehren_zuweisung(BBZuweisung& z);
+
+
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/basistypen.cpp b/src/modules/grid/grid_calculus_bsl/basistypen.cpp
new file mode 100644
index 0000000..4d29e52
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/basistypen.cpp
@@ -0,0 +1,628 @@
+
+#include <iostream>
+#include <algorithm>
+#include <sstream>
+#include <sstream>
+#include <locale>
+
+#include "basistypen.h"
+
+#include <assert.h>
+
+#define WHITE_SP " \t\n"
+#define WHITE_SP_TRENNER " ,;\t\n"
+
+using namespace std;
+
+T_VarList VarList;
+T_InputText InputText;
+T_InputText InputGrids;
+int FehlerZeile;
+int FehlerPos1;
+int FehlerPos2;
+string FehlerString("");
+bool isSyntaxCheck;
+
+class compare_BB_greater : public greater<BBTyp *>
+{
+public:
+// o.c. bool operator()(const BBTyp * &x, const BBTyp * &y) const
+ bool operator()(BBTyp *x, BBTyp *y) const
+ {
+ return x->name < y->name;
+ };
+};/**/
+
+class compare_BBType
+{
+public:
+ bool operator() (const BBTyp *x, const BBTyp *y)
+ {
+ return x->name < y->name;
+ }
+};
+
+class compare_BBType2
+{
+public:
+ bool operator() (BBTyp *x, BBTyp y)
+ {
+ return x->name < y.name;
+ }
+};
+
+class compare_BBType3
+{
+public:
+ bool operator() (BBTyp x, BBTyp y)
+ {
+ return x.name < y.name;
+ }
+};
+
+void GetInputText(string bsl )
+// wandelt EditControl-Text in Vector von Strings um
+{
+/* size = e.GetLineCount();
+ char *lpszBuffer = new char [1000];
+ int buffanz = 1000;
+ lpszBuffer[0] = 0;
+ InputText.clear();
+ for (int i=0; i<size; i++)
+ {
+ l= e.LineLength(i);
+ if (l > buffanz-2)
+ {
+ delete [] lpszBuffer;
+ buffanz = l+2;
+ lpszBuffer = new char [buffanz];
+ }
+ lpszBuffer[0] = buffanz;
+ charcopied = e.GetLine( i, lpszBuffer );
+ lpszBuffer[charcopied] = 0;
+ string s(lpszBuffer);
+ InputText.push_back(s);
+ }
+ delete [] lpszBuffer;*/
+}
+
+void WhiteSpace(string& s, int& pos, bool vorn/* = true*/)
+// entfertn entweder vorne die Wildcards oder schneidet ab dem
+// ersten Whitespace/Trenner den Rest ab
+//
+// Funktionweise:
+// vorn == true (default):
+// Es werden soviele Stellen zu "pos" addiert, wie Wildcards
+// am Anfang von "s" stehen
+// vorn == false:
+// Es wird der String s ab dem ersten vorkommenden Wildcard abgeschnitten
+//
+//
+{
+ if (vorn)
+ {
+ int pos1 = s.find_first_not_of(WHITE_SP);
+ if (pos1 > 0)
+ {
+ s.erase(s.begin(), s.begin() + pos1); // o.c
+ // o.c s.erase(s.begin(), &s[pos1]);
+ pos += pos1;
+ }
+ }
+ else
+ {
+ int pos1 = s.find_first_of(WHITE_SP_TRENNER);
+ if (pos1 > 0)
+ {
+ s.erase(s.begin() + pos1, s.end()); // o.c
+ // o.c s.erase(&s[pos1], s.end());
+ }
+ }
+}
+
+void trim(string& s)
+{
+ // vorne Whitespaces entfernen
+ int pos1 = s.find_first_not_of(WHITE_SP);
+ if (pos1 > 0)
+ {
+ s.erase(s.begin(), s.begin() + pos1);
+ }
+
+ // hinter Whitespaces entfernen
+ pos1 = s.find_last_not_of(WHITE_SP);
+ if (pos1 >= 0)
+ {
+ s.erase(s.begin() + pos1+1, s.end()); // o.c.
+ }
+}
+
+bool isNextToken(int zeile, int pos, string& cmp)
+{
+ string s = InputText[zeile].substr(pos);
+ if (!isNotEnd(zeile, pos, s))
+ return false;
+
+ WhiteSpace(s, pos);
+ return s == cmp;
+}
+
+bool isNextChar(int zeile, int pos, const char c)
+{
+ string s = InputText[zeile].substr(pos);
+ if (!isNotEnd(zeile, pos, s))
+ return false;
+
+ WhiteSpace(s, pos);
+ return s[0] == c;
+}
+
+bool getNextToken(int &zeile, int& pos, string& erg)
+{
+
+ string s = InputText[zeile];
+ erg = InputText[zeile].substr(pos);
+ if (!isNotEnd(zeile, pos, erg))
+ return false;
+
+ WhiteSpace(erg, pos);
+ WhiteSpace(erg, pos, false);
+ pos += erg.size();
+ return true;
+}
+
+bool getNextZeile(int &zeile, int& pos, string& erg)
+{
+ // Erstellt string von (zeile, pos) bis zum nächsten Komma
+ if (zeile >= (int)InputText.size())
+ return false;
+ string sub = InputText[zeile].substr(pos);
+ erg = "";
+ int p;
+ do
+ {
+ if ((p = sub.find_first_of(';')) >= 0)
+ {
+ sub.erase(p, sub.size());
+ pos = p;
+ erg += sub;
+ return true;
+ }
+ erg += sub;
+ p = sub.size()+pos;
+ if (!isNotEnd(zeile,p, sub))
+ return false;
+ } while (true);
+ return false;
+}
+
+bool getNextChar(int& zeile, int& pos, char& c)
+{
+ string s = InputText[zeile].substr(pos);
+ if (!isNotEnd(zeile, pos, s))
+ return false;
+
+ WhiteSpace(s, pos);
+ pos++;
+ c = s[0];
+ return true;
+}
+
+
+bool isNotEnd(int& zeile, int& pos, string& s)
+{
+ if (zeile >= (int)InputText.size())
+ return false;
+ int pos1;
+ if (pos >= (int)InputText[zeile].size() || (pos1 = InputText[zeile].substr(pos).find_first_not_of(WHITE_SP)) < 0)
+ {
+ int p;
+ do
+ {
+ zeile++;
+ if (zeile >= (int)InputText.size())
+ return false;
+ p = InputText[zeile].find_first_not_of(WHITE_SP);
+ }
+ while (p < 0);
+
+ pos = 0;
+ s = InputText[zeile];
+ }
+ else
+ {
+ // überprüfen, ob s nur aus Whitespaces besteht
+
+ }
+ return true;
+}
+
+void DeleteVarList(void)
+{
+ if (VarList.empty())
+ return;
+ T_VarList::iterator it;
+ for (it = VarList.begin(); it != VarList.end(); it++)
+ {
+ delete (*it);
+ }
+ VarList.clear();
+}
+
+// wandelt Strings in Variablen um (aus InputText wird VarList)
+void ParseVars(int& zeile, int& pos)
+{
+ // Syntax: Type varname [, varname [...] ] ;
+ string subz;
+ BBTyp::T_type t;
+ char c;
+ DeleteVarList();
+ int zeile_old = zeile;
+ int pos_old = pos;
+ FehlerZeile = zeile;
+ while (getNextToken(zeile, pos, subz))
+ {
+ // Typ angeben
+ if (subz == "Integer")
+ t = BBTyp::IType;
+ else if (subz == "Float")
+ t = BBTyp::FType;
+ else if (subz == "Point")
+ t = BBTyp::PType;
+ else if (subz == "Matrix")
+ t = BBTyp::MType;
+ else
+ {
+ zeile = zeile_old;
+ pos = pos_old;
+ break;
+ }
+
+ // Variablen-Name, durch Komma getrennt
+ while (getNextToken(zeile, pos, subz))
+ {
+ FehlerZeile = zeile;
+ // einfügen in VarList
+ BBTyp *bt;
+ switch(t)
+ {
+ case BBTyp::IType:
+ bt = new BBInteger;
+ bt->name = subz;
+ bt->type = t;
+ break;
+ case BBTyp::FType:
+ bt = new BBFloat;
+ bt->name = subz;
+ bt->type = t;
+ break;
+ case BBTyp::PType:
+ bt = new BBPoint;
+ bt->name = subz;
+ bt->type = t;
+ break;
+ case BBTyp::MType:
+ // falls Name ()
+ {
+ int l = subz.size();
+ if (subz[l-1] == ')' && subz[l-2] == '(')
+ {
+ // Matrix: M()
+ subz.erase(l-2, 2);
+ bt = new BBMatrix(NULL);
+ }
+ else if (subz[l-1] == ')')
+ {
+ printf("loadig files not suported");
+ return;
+ /*
+ int posk;
+ // Matrix: M("filename")
+ if ((posk = subz.find('(')) <= 0)
+ throw BBFehlerException(zeile);
+ // Filename herausfinden
+ string filename;
+ filename = subz.substr(posk+1);
+ if (filename.size() < 1)
+ throw BBFehlerException(zeile);
+ filename.erase(filename.size()-1);
+ if (filename[0] !='"' || filename[filename.size()-1] != '"')
+ throw BBFehlerException(zeile);
+ // Variablen-Name herausfinden
+ filename.erase(0, 1);
+ filename.erase(filename.size()-1);
+ subz.erase(posk);
+ // Datei laden
+ bt = new BBMatrix();
+//
+// surferDoc sd;
+ CFile file;
+ if (!file.Open(filename.data(), CFile::modeRead))
+ {
+ string out;
+ ostringstream ostr(out);
+ ostr << "Die Datei >" << filename << "< existiert nicht!" << ends;
+ AfxMessageBox(ostr.str().data());
+ delete bt;
+ throw BBFehlerException(zeile);
+ }
+ if (!isSyntaxCheck)
+ {
+ CArchive archive(&file, CArchive::load);
+// sd.readGrid(archive, *(((BBMatrix *) bt)->M));
+ }
+ */
+ }
+ else
+ bt = new BBMatrix;
+ bt->name = subz;
+ bt->type = t;
+ }
+ break;
+ }
+ if (isVar(subz) != NULL) // falls Name bereits vorhanden
+ {
+ delete bt;
+ throw BBFehlerException(zeile);
+ }
+ VarList.push_back(bt);
+
+ // überprüfen auf Komma
+ if (!isNextChar(zeile, pos, ','))
+ break;
+ // wenn Komma, nochmal
+ if (!getNextChar(zeile, pos, c))
+ throw BBFehlerException(zeile);
+ }
+ // überprüfen auf Semikolon;
+ if (!getNextChar(zeile, pos, c) || c != ';')
+ throw BBFehlerException(zeile);
+ zeile_old = zeile;
+ pos_old = pos;
+ }
+}
+
+// überprüft, ob string eine gültige Variable ist
+BBTyp *isVar(const string& s)
+{
+ if (VarList.empty())
+ return NULL;
+// bool exist;
+ T_VarList::iterator it;
+ for (it = VarList.begin(); it != VarList.end(); it++)
+ {
+ string ss = (*it)->name;
+ if ((*it)->name == s)
+ return (*it);
+ }
+ return NULL;
+/* BBTyp bt;
+ bt.name = s;
+ exist = binary_search(VarList.begin(), VarList.end(), &bt, compare_BBType() );
+ if (exist)
+ {
+ it = search(VarList.begin(), VarList.end(), &bt, &bt, compare_BBType2() );
+ if (it != VarList.end())
+ return (*it);
+ else
+ return NULL;
+ }
+ else
+ return NULL;
+*/
+}
+
+
+// ermittelt den Variablen-Typ einer Variablen
+BBTyp::T_type getVarType(BBTyp *s)
+{
+ return s->type;
+}
+
+// liefert die jeweilige Variable zurück
+BBInteger *getVarI(BBTyp *s)
+{
+ return ((BBInteger *) s);
+}
+
+BBFloat *getVarF(BBTyp *s)
+{
+ return ((BBFloat *) s);
+}
+
+BBMatrix *getVarM(BBTyp *s)
+{
+ return ((BBMatrix *) s);
+}
+
+BBPoint *getVarP(BBTyp *s)
+{
+ return ((BBPoint *) s);
+}
+
+void setMatrixVariables(BBMatrix *M)
+{
+ BBInteger *i;
+ BBFloat *f;
+ BBTyp *b;
+
+ // xanz
+ b = isVar(M->name + ".xanz");
+ assert(b != NULL);
+ i = getVarI(b);
+ assert(i->i == NULL);
+ i->i = &(M->M->xanz);
+ // yanz
+ b = isVar(M->name + ".yanz");
+ assert(b != NULL);
+ i = getVarI(b);
+ assert(i->i == NULL);
+ i->i = &(M->M->yanz);
+ // xll
+ b = isVar(M->name + ".xll");
+ assert(b != NULL);
+ f = getVarF(b);
+ assert(f->f == NULL);
+ f->f = &(M->M->xll);
+ // yll
+ b = isVar(M->name + ".yll");
+ assert(b != NULL);
+ f = getVarF(b);
+ assert(f->f == NULL);
+ f->f = &(M->M->yll);
+ // dxy
+ b = isVar(M->name + ".dxy");
+ assert(b != NULL);
+ f = getVarF(b);
+ assert(f->f == NULL);
+ f->f = &(M->M->dxy);
+}
+
+bool GetMemoryGrids(CSG_Parameters *BSLParameters)
+{
+ T_VarList::iterator it;
+
+ for (it = VarList.begin(); it != VarList.end(); it++)
+ {
+ BBTyp::T_type t = getVarType(*it);
+
+ if (t == BBTyp::MType)
+ {
+ BBMatrix *M = getVarM(*it);
+
+ if (!M->isMem) // falls noch erzeugt werden muß
+ {
+ CSG_Grid *pInput = (*BSLParameters)(M->name.c_str())->asGrid();
+ GridWerte *pGrid = new GridWerte();
+
+ pGrid->Create(*pInput);
+
+ pGrid->xanz = pGrid->Get_NX();
+ pGrid->yanz = pGrid->Get_NY();
+ pGrid->dxy = pGrid->Get_Cellsize();
+ pGrid->xll = pGrid->Get_XMin();
+ pGrid->yll = pGrid->Get_YMin();
+
+ pGrid->calcMinMax();
+
+ M->M = pGrid;
+ M->isMem = true;
+
+ setMatrixVariables(M);
+ }
+ }
+ }
+
+ bool ret = (it == VarList.end());
+ VarList.sort(compare_BB_greater());
+ return ret;
+}
+
+bool FindMemoryGrids(void)
+{
+ InputGrids.clear();
+
+ T_VarList::iterator it;
+ for (it = VarList.begin(); it != VarList.end(); it++)
+ {
+ BBTyp::T_type t = getVarType(*it);
+ if (t == BBTyp::MType)
+ {
+ BBMatrix *M = getVarM(*it);
+ if (!M->isMem)
+ {
+ InputGrids.push_back(M->name);
+ }
+ }
+
+ }
+ bool ret = (it == VarList.end());
+ return ret;
+}
+
+void AddMatrixPointVariables(bool pointer2matrix)
+{
+// if (pointer2matrix)
+// {
+ // Alle anderen Matirx/Point-Variablen hinzu
+ T_VarList::iterator it;
+ for (it = VarList.begin(); it != VarList.end(); it++)
+ {
+ if ((*it)->type == BBTyp::MType)
+ {
+ BBMatrix *m = getVarM(*it);
+ BBTyp *bt;
+ bt = new BBInteger((m->isMem ? &(((BBMatrix *)(*it))->M->xanz) : NULL));
+ bt->name = (*it)->name + string(".xanz");
+ VarList.push_back(bt);
+ bt = new BBInteger((m->isMem ? &(((BBMatrix *)(*it))->M->yanz) : NULL));
+ bt->name = (*it)->name + string(".yanz");
+ VarList.push_back(bt);
+ bt = new BBFloat((m->isMem ? &(((BBMatrix *)(*it))->M->dxy) : NULL));
+ bt->name = (*it)->name + string(".dxy");
+ VarList.push_back(bt);
+ bt = new BBFloat((m->isMem ? &(((BBMatrix *)(*it))->M->xll) : NULL));
+ bt->name = (*it)->name + string(".xll");
+ VarList.push_back(bt);
+ bt = new BBFloat((m->isMem ? &(((BBMatrix *)(*it))->M->yll) : NULL));
+ bt->name = (*it)->name + string(".yll");
+ VarList.push_back(bt);
+ }
+ else if ((*it)->type == BBTyp::PType)
+ {
+ BBTyp *bt;
+ bt = new BBInteger(&(((BBPoint *)(*it))->v.x));
+ bt->name = (*it)->name + string(".x");
+ VarList.push_back(bt);
+ bt = new BBInteger(&(((BBPoint *)(*it))->v.y));
+ bt->name = (*it)->name + string(".y");
+ VarList.push_back(bt);
+ }
+ }
+/* }
+ else
+ {
+ // Alle anderen Matirx/Point-Variablen hinzu
+ T_VarList::iterator it;
+ for (it = VarList.begin(); it != VarList.end(); it++)
+ {
+ if ((*it)->type == BBTyp::MType)
+ {
+ BBTyp *bt;
+ bt = new BBInteger();
+ bt->name = (*it)->name + string(".xanz");
+ VarList.push_back(bt);
+ bt = new BBInteger();
+ bt->name = (*it)->name + string(".yanz");
+ VarList.push_back(bt);
+ bt = new BBFloat();
+ bt->name = (*it)->name + string(".dxy");
+ VarList.push_back(bt);
+ bt = new BBFloat();
+ bt->name = (*it)->name + string(".xll");
+ VarList.push_back(bt);
+ bt = new BBFloat();
+ bt->name = (*it)->name + string(".yll");
+ VarList.push_back(bt);
+ }
+ else if ((*it)->type == BBTyp::PType)
+ {
+ BBTyp *bt;
+ bt = new BBInteger();
+ bt->name = (*it)->name + string(".x");
+ VarList.push_back(bt);
+ bt = new BBInteger();
+ bt->name = (*it)->name + string(".y");
+ VarList.push_back(bt);
+ }
+ }
+
+ }
+
+
+*/
+
+ // kommt später
+ //if (!pointer2matrix)
+ VarList.sort(compare_BB_greater());
+}
diff --git a/src/modules/grid/grid_calculus_bsl/basistypen.h b/src/modules/grid/grid_calculus_bsl/basistypen.h
new file mode 100644
index 0000000..1230e7d
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/basistypen.h
@@ -0,0 +1,219 @@
+#ifndef __BASISTYPEN_H
+#define __BASISTYPEN_H
+
+#include <vector>
+#include <list>
+#include <string>
+#include "grid_bsl.h"
+#include "MLB_Interface.h"
+//#include "grid.h"
+//#include "Parameters.h"
+
+
+#pragma warning (disable : 4786 )
+
+extern int FehlerZeile;
+extern std::string FehlerString;
+extern int FehlerPos1;
+extern int FehlerPos2;
+extern bool isSyntaxCheck;
+
+class BBFehlerException
+{
+public:
+ BBFehlerException()
+ {
+ FehlerPos1 = 0;
+ FehlerPos2 = 0;
+ };
+
+ BBFehlerException(int z, int p1 = 0, int p2 = 0)
+ {
+ FehlerPos1 = p1;
+ FehlerPos2 = p2;
+ };
+};
+
+struct T_Point
+{
+ long x;
+ long y;
+};
+
+class BBTyp
+{
+public:
+ std::string name;
+ enum T_type {IType, FType, PType, MType} type;
+
+ BBTyp() {};
+ virtual ~BBTyp() {};
+};
+
+class BBInteger : public BBTyp
+{
+public:
+ BBInteger()
+ {
+ type = IType;
+ isMem = true;
+ i = new long;
+ *i = 0;
+ };
+
+ BBInteger(int ii)
+ {
+ type = IType;
+ isMem = true;
+ i = new long;
+ *i = ii;
+ };
+
+ BBInteger(long *ii)
+ {
+ type = IType;
+ isMem = false;
+ i = ii;
+ };
+ ~BBInteger()
+ {
+ if (isMem)
+ delete i;
+ };
+
+ // z.B. M.xanz auch ein int ist und *i auch darauf zeigen soll
+ bool isMem;
+ long *i;
+};
+
+class BBFloat : public BBTyp
+{
+public:
+ BBFloat()
+ {
+ type = FType;
+ isMem = true;
+ f = new double;
+ *f = 0.0;
+ };
+
+ BBFloat(double ff)
+ {
+ type = FType;
+ isMem = true;
+ f = new double;
+ *f = ff;
+ };
+
+ BBFloat(double *ff)
+ {
+ type = FType;
+ isMem = false;
+ f = ff;
+ };
+
+ ~BBFloat()
+ {
+ if (isMem)
+ delete f;
+ };
+
+ // Datenelement ist nur ein Pointer, da
+ // z.B. M.dxy auch ein double ist und *f auch darauf zeigen soll
+ bool isMem;
+ double *f;
+};
+
+
+class BBPoint : public BBTyp
+{
+public:
+ BBPoint()
+ {
+ type = PType;
+ };
+
+ BBPoint(const T_Point& vv) : v(vv)
+ {
+ type = PType;
+ };
+
+ ~BBPoint() { };
+
+ T_Point v;
+};
+
+
+class BBMatrix : public BBTyp
+{
+public:
+ BBMatrix()
+ {
+ type = MType;
+ isMem = true;
+ M = new GridWerte;
+ };
+
+ BBMatrix(GridWerte *m)
+ {
+ type = MType;
+ isMem = false;
+ M = m;
+
+ };
+
+ ~BBMatrix()
+ {
+ if (isMem)
+ delete M;
+ };
+
+ bool isMem;
+ GridWerte *M;
+};
+
+
+// Liste aller Variablen
+typedef std::list<BBTyp *> T_VarList;
+typedef std::vector<std::string> T_InputText;
+
+extern T_VarList Varlist;
+extern T_InputText InputText;
+extern T_InputText InputGrids;
+void DeleteVarList(void);
+
+
+void WhiteSpace(std::string& s, int& pos, bool vorn = true);
+void trim(std::string& s);
+bool isNextToken(int zeile, int pos, std::string& cmp);
+bool isNextChar(int zeile, int pos, const char c);
+bool getNextToken(int &zeile, int& pos, std::string& erg);
+bool getNextZeile(int &zeile, int& pos, std::string& erg);
+bool getNextChar(int& zeile, int& pos, char& c);
+bool isNotEnd(int& zeile, int& pos, std::string& s);
+
+
+
+
+
+
+// wandelt Strings in Variablen um (aus InputText wird VarList)
+void ParseVars(int& zeile, int& pos);
+
+// überprüft, ob string eine gültige Variable ist
+BBTyp *isVar(const std::string& s);
+
+// ermittelt den Variablen-Typ einer Variablen
+BBTyp::T_type getVarType(BBTyp *s);
+
+// liefert die jeweilige Variable zurück
+BBInteger *getVarI(BBTyp *s);
+BBFloat *getVarF(BBTyp *s);
+BBMatrix *getVarM(BBTyp *s);
+BBPoint *getVarP(BBTyp *s);
+
+bool GetMemoryGrids(CSG_Parameters *BSLParameters);
+bool FindMemoryGrids(void);
+void AddMatrixPointVariables(bool pointer2matrix);
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/bedingung.cpp b/src/modules/grid/grid_calculus_bsl/bedingung.cpp
new file mode 100644
index 0000000..050e916
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/bedingung.cpp
@@ -0,0 +1,511 @@
+
+//#include <..\stdafx.h>
+
+#include "bedingung.h"
+#include "pars_all.h"
+
+
+using namespace std;
+
+
+BBBool::BBBool()
+{
+ type = Nothing;
+ memset(&BoolVar1, 0, sizeof(T_BoolVar));
+ memset(&BoolVar2, 0, sizeof(T_BoolVar));
+}
+
+BBBool::~BBBool()
+{
+ if (type == Nothing)
+ return;
+ switch (type)
+ {
+ case IFVar:
+ if (BoolVar1.IF != NULL)
+ delete BoolVar1.IF;
+ if (BoolVar2.IF != NULL)
+ delete BoolVar2.IF;
+ break;
+ case PVar:
+ case MVar:
+ if (BoolVar1.MP != NULL)
+ delete BoolVar1.MP;
+ if (BoolVar2.MP != NULL)
+ delete BoolVar2.MP;
+ break;
+ }
+ memset(&BoolVar1, 0, sizeof(T_BoolVar));
+ memset(&BoolVar2, 0, sizeof(T_BoolVar));
+}
+
+BBBedingung::BBBedingung()
+{
+ type = Nothing;
+ memset(&BedingungVar, 0, sizeof(T_BedingungVar));
+}
+
+BBBedingung::~BBBedingung()
+{
+ if (type == Nothing)
+ return;
+ switch (type)
+ {
+ case Bool:
+ if (BedingungVar.BoolVar.b != NULL)
+ delete BedingungVar.BoolVar.b;
+ break;
+ case Und:
+ case Oder:
+ case XOder:
+ if (BedingungVar.BoolBiOp.b1 != NULL)
+ delete BedingungVar.BoolBiOp.b1;
+ if (BedingungVar.BoolBiOp.b2 != NULL)
+ delete BedingungVar.BoolBiOp.b2;
+ break;
+ case Not:
+ if (BedingungVar.BoolUniOp.b != NULL)
+ delete BedingungVar.BoolUniOp.b;
+ break;
+ }
+ memset(&BedingungVar, 0, sizeof(T_BedingungVar));
+}
+
+BBIf::BBIf()
+{
+ b = 0;
+ isElse = false;
+}
+
+BBIf::~BBIf()
+{
+ if (b != NULL)
+ delete b;
+ DeleteAnweisungList(z);
+ DeleteAnweisungList(zelse);
+ b = 0;
+}
+
+bool getFirstTokenKlammer(const string& statement, int& posvor, int& posnach, string& token)
+{
+ if (statement.empty())
+ return false;
+
+ int klammer_ebene = 0;
+ for (int i=0; i<statement.size()-1; i++)
+ {
+ if (statement[i] == '(')
+ klammer_ebene++;
+ if (statement[i] == ')')
+ klammer_ebene--;
+ if (klammer_ebene == 0 && i != statement.size() -1 && i != 0)
+ {
+ bool gefunden = false;
+ if (statement[i] == '&' && statement[i+1] == '&')
+ {
+ token = "&&";
+ gefunden = true;
+ }
+ else if (statement[i] == '|' && statement[i+1] == '|')
+ {
+ token = "||";
+ gefunden = true;
+ }
+ else if (statement[i] == '^' && statement[i+1] == '^')
+ {
+ token = "^^";
+ gefunden = true;
+ }
+ if (gefunden)
+ {
+ posvor = i;
+ posnach = i+2;
+
+ return true;
+ }
+
+ /*
+ int p = i+1;
+ if (!getNextToken(statement, p, token))
+ return false;
+
+ posvor = i+1;
+ posnach = p;
+ return true;
+ */
+ }
+ }
+ return false;
+}
+
+void deleteKlammern(string& s)
+{
+ // Klammern ( .. ) entfernen
+ if (s.size() < 2)
+ return;
+ s.erase(s.end()-1);
+ s.erase(s.begin());
+}
+
+bool isBoolBiOperator(const string& s, string& links, string& rechts, BBBedingung::T_BedingungType& t)
+{
+ // in Klammer-Ebene 0 auf Strings suchen
+ int pos = 0, posvor, posnach;
+ string token;
+
+ if (!getFirstTokenKlammer(s, posvor, posnach, token))
+ return false;
+ if (token == "&&")
+ {
+ links = s.substr(0, posvor);
+ rechts = s.substr(posnach);
+ trim(links);
+ trim(rechts);
+// deleteKlammern(links);
+// deleteKlammern(rechts);
+ t = BBBedingung::Und;
+ return true;
+ }
+ else if (token == "||")
+ {
+ links = s.substr(0, posvor);
+ rechts = s.substr(posnach);
+ trim(links);
+ trim(rechts);
+// deleteKlammern(links);
+// deleteKlammern(rechts);
+ t = BBBedingung::Oder;
+ return true;
+
+ }
+ else if (token == "^^")
+ {
+ links = s.substr(0, posvor);
+ rechts = s.substr(posnach);
+ trim(links);
+ trim(rechts);
+// deleteKlammern(links);
+// deleteKlammern(rechts);
+ t = BBBedingung::XOder;
+ return true;
+ }
+ return false;
+}
+
+bool isBoolUniOperator(const string& s, string& rechts)
+{
+ string t;
+ int pos = 0;
+ if (!getNextToken(s, pos, t))
+ return false;
+ if (t != "not")
+ return false;
+ rechts = s.substr(pos);
+ return true;
+}
+
+
+bool isBool(const string& s, BBBool * &b)
+{
+
+ // ausdruck1 == != < > <= >= ausdruck2
+ //
+ string links, rechts;
+ BBBool::T_booloperator t; //{ Gleich, Ungleich, Kleiner, Groesser, KleinerG, GroesserG} BoolOp;
+
+ int pos, pos1, pos2;
+ if ((pos = s.find("==")) > 0)
+ {
+ t = BBBool::Gleich;
+ pos2 = pos+1;
+ }
+ else if ((pos = s.find("!=")) > 0)
+ {
+ t = BBBool::Ungleich;
+ pos2 = pos+1;
+ }
+ else if ((pos = s.find(">=")) > 0)
+ {
+ t = BBBool::GroesserG;
+ pos2 = pos+1;
+ }
+ else if ((pos = s.find("<=")) > 0)
+ {
+ t = BBBool::KleinerG;
+ pos2 = pos+1;
+ }
+ else if ((pos = s.find(">")) > 0)
+ {
+ t = BBBool::Groesser;
+ pos2 = pos;
+ }
+ else if ((pos = s.find("<")) > 0)
+ {
+ t = BBBool::Kleiner;
+ pos2 = pos;
+ }
+ else
+ return false;
+
+
+ pos1 = pos-1;
+ bool found = true; // bei Fehler immer return false
+ // Auf IntegerFloat pruefen
+ BBBaumInteger *k = NULL;
+ try
+ {
+ pars_integer_float(s.substr(0, pos1+1), k, false);
+ }
+ catch (BBFehlerException)
+ {
+ found = false;
+ }
+ if (found)
+ {
+ b = new BBBool;
+ b->type = BBBool::IFVar;
+ b->BoolOp = t;
+ string links, rechts;
+ links = s.substr(0, pos1+1);
+ rechts = s.substr(pos2+1);
+ try
+ {
+ // erste Variable
+ pars_integer_float(links, b->BoolVar1.IF);
+ pars_integer_float(rechts, b->BoolVar2.IF);
+ }
+ catch (BBFehlerException)
+ {
+ delete b;
+ b = 0;
+ return false;
+ }
+ return true;
+ }
+ else
+ {
+ // Matrix oder Point
+
+ found = true;
+ BBBool::T_BoolType BType;
+ // Auf Matrix pruefen
+ BBBaumMatrixPoint *k = NULL;
+ BType = BBBool::MVar;
+ try
+ {
+ pars_matrix_point(s.substr(0, pos1+1), k, true, false);
+ }
+ catch (BBFehlerException)
+ {
+ found = false;
+ }
+ if (!found)
+ {
+ found = true;
+ // Auf Point pruefen
+ BType = BBBool::PVar;
+ try
+ {
+ pars_matrix_point(s.substr(0, pos1+1), k, false, false);
+ }
+ catch (BBFehlerException)
+ {
+ found = false;
+ }
+ }
+ if (!found)
+ return false;
+
+ // Matrix oder Point gefunden
+ b = new BBBool;
+ b->type = BType;
+ b->BoolOp = t;
+ string links, rechts;
+ links = s.substr(0, pos1+1);
+ rechts = s.substr(pos2+1);
+ try
+ {
+ pars_matrix_point(links, b->BoolVar1.MP, BType == BBBool::MVar);
+ pars_matrix_point(rechts, b->BoolVar2.MP, BType == BBBool::MVar);
+ }
+ catch (BBFehlerException)
+ {
+ delete b;
+ b = 0;
+ return false;
+ }
+ return true;
+ }
+}
+
+bool isBedingung(const std::string& statement, BBBedingung * &bed)
+{
+ string s(statement);
+ string rechts;
+ string links;
+ BBBedingung::T_BedingungType t;
+ BBBool *b;
+
+ // zuerst uni-, dann bidirektionale Operatoren prüfen
+ trim(s);
+ if (isKlammer(s))
+ {
+ string ss = s;
+ ss.erase(ss.begin());
+ ss.erase(ss.end()-1);
+ return isBedingung(ss, bed);
+ }
+ else if (isBoolUniOperator(s, rechts))
+ {
+ bed = new BBBedingung;
+ bed->type = BBBedingung::Not;
+ int ret = isBedingung(rechts, bed->BedingungVar.BoolUniOp.b);
+ if (!ret)
+ {
+ delete bed;
+ bed = 0;
+ }
+ return (ret!=0);
+ }
+ else if (isBoolBiOperator(s, links, rechts, t))
+ {
+ bed = new BBBedingung;
+ bed->type = t;
+ bool ret1 = isBedingung(links, bed->BedingungVar.BoolBiOp.b2);
+ if (ret1)
+ {
+ int ret2 = isBedingung(rechts, bed->BedingungVar.BoolBiOp.b1);
+ if (ret2)
+ return true;
+ }
+ delete bed;
+ bed = 0;
+ return false;
+ }
+ else if (isBool(s, b))
+ {
+ bed = new BBBedingung;
+ bed->type = BBBedingung::Bool;
+ bed->BedingungVar.BoolVar.b = b;
+ return true;
+ }
+ else
+ return false;
+}
+
+bool getNextKlammerString(const string& s, int& pos)
+// liefert den String zwischen der ersten Klammer ( und der
+// zugehoerigen Klammer ).
+// z.B. ((hallo(1)) d) liefert (hallo(1)) d
+
+{
+ if (pos >= s.size())
+ return false;
+ if (s[pos] != '(')
+ return false;
+
+ int klammer_ebene = 1;
+ for (int i=pos+1; i<s.size(); i++)
+ {
+ if (s[i] == '(')
+ klammer_ebene++;
+ if (s[i] == ')')
+ klammer_ebene--;
+ if (klammer_ebene == 0)
+ {
+ pos = i;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool isIf(const std::string& statement, int& pos, BBIf *& i, string& anweisungen, string& anweisungen_else)
+{
+ // pos wird auf { gesetzt
+ //
+ //
+ // Syntax: if (bedingung) { anweisungen }
+ // bedingung: bool / (bool && || ^^ ! bool)
+ // bool: 1.) (IF/IF P/P M/M) == != < >
+
+ string s(statement.substr(pos));
+ int pos0;
+ pos0 = s.find_first_not_of(" \t\n");
+ if (pos0 < 0)
+ return false;
+ s.erase(0, pos0);
+ if (s.size() < 2)
+ return false;
+ // if
+ if (s[0] != 'i' || s[1] != 'f')
+ return false;
+ s.erase(s.begin(), s.begin()+2);
+
+ // Bedingung herausfinden
+ // passende Klammern suchen
+ int pos1;
+ pos1 = s.find_first_not_of(" \t\n");
+ if (pos1 < 0)
+ return false;
+ int pos2 = pos1;
+ if (!getNextKlammerString(s, pos2))
+ return false;
+ string bedstring;
+ bedstring = s.substr(pos1, pos2-pos1+1);
+ BBBedingung * bed;
+ if (isBedingung(bedstring, bed))
+ {
+ i = new BBIf;
+ i->b = bed;
+ int p = pos2+1; // Klammer ) wegnehmen
+ // Klammer { finden
+ char c;
+ getNextChar(s, p, c);
+ if (c != '{')
+ {
+ delete i;
+ i = 0;
+ return false;
+ }
+ int p2 = p;
+ if (!getStringBetweenKlammer(s, p2))
+ {
+ delete i;
+ i = 0;
+ return false;
+ }
+ anweisungen = s.substr(p, p2-p);
+ pos += pos0 + p +2; // pos0 sind blanks, p ist ein hinter { und 2 kommt vom if
+ pos += anweisungen.size();
+ // hier den Else-Zweig abfragen
+ i->isElse = false;
+
+ int p3 = p2+1;
+ string selse;
+ if (!getNextToken(s, p3, selse))
+ return true;
+ if (selse != "else")
+ return true;
+
+ getNextChar(s, p3, c);
+ if (c != '{')
+ {
+ delete i;
+ i = 0;
+ return false;
+ }
+ p = p3;
+ if (!getStringBetweenKlammer(s, p))
+ {
+ delete i;
+ i = 0;
+ return false;
+ }
+ anweisungen_else = s.substr(p3, p-p3);
+ pos += p-p2;
+ i->isElse = true;
+ return true;
+ }
+ return false;
+}
diff --git a/src/modules/grid/grid_calculus_bsl/bedingung.h b/src/modules/grid/grid_calculus_bsl/bedingung.h
new file mode 100644
index 0000000..b8105e4
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/bedingung.h
@@ -0,0 +1,71 @@
+#ifndef __BEDINGUNG_H
+#define __BEDINGUNG_H
+
+#include "foreach.h"
+
+// Syntax: if (bedingung) { anweisungen }
+// bedingung: bool / (bool && || ^^ ! bool)
+// bool: 1.) (IF/IF P/P M/M) == != < >
+
+
+class BBBool
+{
+public:
+ enum T_BoolType { IFVar, PVar, MVar, Nothing } type;
+ BBBool();
+ ~BBBool();
+
+ union T_BoolVar
+ {
+ BBBaumInteger *IF;
+ BBBaumMatrixPoint *MP;
+ } BoolVar1, BoolVar2;
+
+ enum T_booloperator { Gleich, Ungleich, Kleiner, Groesser, KleinerG, GroesserG} BoolOp;
+};
+
+class BBBedingung
+{
+public:
+ enum T_BedingungType { Bool, Und, Oder, XOder, Not, Nothing} type;
+
+ BBBedingung();
+ ~BBBedingung();
+
+ union T_BedingungVar
+ {
+ struct BedBool
+ {
+ BBBool *b;
+ } BoolVar;
+
+ struct BedBiOperator
+ {
+ BBBedingung *b1;
+ BBBedingung *b2;
+ } BoolBiOp;
+
+ struct BedUniOperator
+ {
+ BBBedingung *b;
+ } BoolUniOp;
+ } BedingungVar;
+};
+
+
+class BBIf
+{
+public:
+ BBIf();
+ ~BBIf();
+
+ BBBedingung *b;
+ T_AnweisungList z, zelse;
+ bool isElse;
+};
+
+bool getNextKlammerString(const std::string& statement, int& pos);
+bool isBedingung(const std::string& s, BBBedingung * &bed);
+bool isIf(const std::string& statement, int& pos, BBIf *& i, std::string& anweisungen, std::string& anweisungen_else);
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/bsl_interpreter.cpp b/src/modules/grid/grid_calculus_bsl/bsl_interpreter.cpp
new file mode 100644
index 0000000..d274cdb
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/bsl_interpreter.cpp
@@ -0,0 +1,278 @@
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "bsl_interpreter.h"
+#include "basistypen.h"
+#include "pars_all.h"
+#include "auswert_anweisung.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CBSL_Interpreter *g_pInterpreter = NULL;
+
+void g_Add_Grid (CSG_Grid *pGrid)
+{
+ if( g_pInterpreter )
+ {
+ CSG_Grid *p = SG_Create_Grid(*pGrid);
+
+ p->Set_Name(pGrid->Get_Name());
+
+ g_pInterpreter->Get_Parameters()->Get_Parameter("OUTPUT")->asGridList()->Add_Item(p);
+ }
+}
+
+//---------------------------------------------------------
+bool g_bProgress = true;
+
+bool g_Set_Progress (int i, int n)
+{
+ return( g_bProgress ? SG_UI_Process_Set_Progress(i, n) : SG_UI_Process_Get_Okay() );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CBSL_Interpreter::CBSL_Interpreter(bool bFile)
+{
+ m_bFile = bFile;
+
+ //-----------------------------------------------------
+ Set_Name (m_bFile ? _TL("BSL from File") : _TL("BSL"));
+
+ Set_Author (SG_T("SAGA User Group Associaton (c) 2009"));
+
+ Set_Description (_TW(
+ "Boehner's Simple Language (BSL) is a macro script language for grid cell based calculations. "
+ "BSL has been developed by C. Trachinow and J. Boehner originally as part of the grid analysis "
+ "software SADO, 'System fuer die Analyse Diskreter Oberflaechen'. \n"
+ "\n"
+ "References:\n"
+ "Boehner, J., Koethe, R., Trachinow, C. (1997): "
+ "Weiterentwicklung der automatischen Reliefanalyse auf der Basis von digitalen Gelaendemodellen. "
+ "Göttinger Geogr. Abh. 100: 3-21."
+ ));
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid_List(
+ NULL, "OUTPUT" , _TL("Output"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ if( m_bFile )
+ {
+ Parameters.Add_FilePath(
+ NULL, "BSL" , _TL("BSL Script"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s"),
+ _TL("BSL Files (*.bsl)") , SG_T("*.bsl"),
+ _TL("Text Files (*.txt)") , SG_T("*.txt"),
+ _TL("All Files") , SG_T("*.*")
+ )
+ );
+ }
+ else
+ {
+ Parameters.Add_String(
+ NULL, "BSL" , _TL("BSL Script"),
+ _TL(""),
+ _TW(
+ "Matrix R(), NIR(), NDVI, RANGE;\n"
+ "Point p;\n"
+ "\n"
+ "NDVI = R;\n"
+ "RANGE = R;\n"
+ "\n"
+ "foreach p in R do\n"
+ "{\n"
+ " NDVI[p] = (NIR[p] - R[p]) / (NIR[p] + R[p]);\n"
+ " RANGE[p] = max8(p, R) - min8(p, R);\n"
+ "}\n"
+ "\n"
+ "showMatrix(NDVI);\n"
+ "showMatrix(RANGE);\n"
+ ), true
+ );
+ }
+
+ Parameters.Add_Value(
+ NULL, "PROGRESS" , _TL("Show Progress"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, true
+ );
+}
+
+//---------------------------------------------------------
+CBSL_Interpreter::~CBSL_Interpreter(void)
+{
+ g_pInterpreter = NULL;
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CBSL_Interpreter::On_Execute(void)
+{
+ //-----------------------------------------------------
+ Parameters("OUTPUT")->asGridList()->Del_Items();
+
+ g_bProgress = Parameters("PROGRESS")->asBool();
+
+ if( m_bFile )
+ {
+ CSG_File Stream;
+
+ if( !Stream.Open(Parameters("BSL")->asString(), SG_FILE_R, false) )
+ {
+ return( false );
+ }
+
+ Stream.Read(m_BSL, Stream.Length());
+ }
+ else
+ {
+ m_BSL = Parameters("BSL")->asString();
+ }
+
+ //-----------------------------------------------------
+ if( !Parse_Vars(false) )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ CSG_Parameters Input(this, _TL("Input"), _TL(""), SG_T("INPUT"), true);
+
+ FindMemoryGrids();
+
+ for(T_InputText::iterator it=InputGrids.begin(); it!=InputGrids.end(); it++)
+ {
+ CSG_String sName(it->c_str());
+
+ Input.Add_Grid(NULL, sName, sName, _TL(""), PARAMETER_INPUT, true);
+ }
+
+ DeleteVarList();
+ DeleteAnweisungList(AnweisungList);
+
+ if( Dlg_Parameters(&Input, _TL("Input")) == false )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ if( !Parse_Vars(true) )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ g_pInterpreter = this;
+
+ if( GetMemoryGrids(&Input) )
+ {
+ try
+ {
+ ausfuehren_anweisung(AnweisungList);
+ }
+ catch(BBFehlerAusfuehren x)
+ {
+ if( x.Text == "" )
+ Message_Add(_TL("unknown error: execution"));
+ else
+ Message_Add(CSG_String::Format(SG_T("error: %s\n"), CSG_String(x.Text.c_str()).c_str()));
+ }
+ catch(BBFehlerUserbreak x)
+ {
+ if( x.Text == "" )
+ Message_Add(_TL("unknown error: user break"));
+ else
+ Message_Add(CSG_String::Format(SG_T("error: %s\n"), CSG_String(x.Text.c_str()).c_str()));
+ }
+ }
+
+ g_pInterpreter = NULL;
+
+ DeleteVarList();
+ DeleteAnweisungList(AnweisungList);
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CBSL_Interpreter::Parse_Vars(bool bFlag)
+{
+ InputText.clear();
+
+ CSG_String s(m_BSL);
+
+ while( s.Length() > 0 )
+ {
+ InputText.push_back(s.BeforeFirst('\n').b_str());
+
+ s = s.AfterFirst('\n');
+ }
+
+ InputText.push_back("\t\n\n");
+
+ //-----------------------------------------------------
+ try
+ {
+ int zeile = 0;
+ int p = 0;
+ isSyntaxCheck = true;
+
+ ParseVars (zeile, p);
+ AddMatrixPointVariables(bFlag);
+ pars_ausdruck (zeile, p);
+
+ return( true );
+ }
+ catch (BBFehlerException)
+ {
+ Message_Add(CSG_String::Format(SG_T("error in line %d: %s\n"), FehlerZeile, CSG_String(FehlerString.c_str()).c_str()));
+
+ DeleteVarList();
+ DeleteAnweisungList(AnweisungList);
+
+ return( false );
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_calculus_bsl/bsl_interpreter.h b/src/modules/grid/grid_calculus_bsl/bsl_interpreter.h
new file mode 100644
index 0000000..c2cf3ff
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/bsl_interpreter.h
@@ -0,0 +1,59 @@
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__BSL_Interpreter_H
+#define HEADER_INCLUDED__BSL_Interpreter_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CBSL_Interpreter : public CSG_Module_Grid
+{
+public:
+ CBSL_Interpreter(bool bFile);
+ virtual ~CBSL_Interpreter(void);
+
+
+protected:
+
+ virtual bool On_Execute(void);
+
+
+private:
+
+ bool m_bFile;
+
+ CSG_String m_BSL;
+
+
+ bool Parse_Vars (bool bFlag);
+
+
+};
+
+//---------------------------------------------------------
+void g_Add_Grid (CSG_Grid *pGrid);
+bool g_Set_Progress (int i, int n);
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__BSL_Interpreter_H
diff --git a/src/modules/grid/grid_calculus_bsl/diverses.cpp b/src/modules/grid/grid_calculus_bsl/diverses.cpp
new file mode 100644
index 0000000..debc4e5
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/diverses.cpp
@@ -0,0 +1,297 @@
+// diverses.cc
+
+//#include "../stdafx.h"
+#include <iostream>
+#include <sstream>
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+
+#include "grid_bsl.h"
+#include "diverses.h"
+
+#include <vector>
+#include <algorithm>
+
+using namespace std;
+
+#define false 0
+#define true 1
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#endif
+
+using namespace std;
+
+
+/*int Rand(const I_Vec& I, const GridWerte& G, int abstand)
+{
+ IVecWerte W((GridWerte &) G);
+ return Rand(I, W, abstand);
+}
+*/
+/*
+int Rand(const I_Vec& I, const IVecWerte& W, int abstand)
+{
+ return Rand(I.X(), I.Y(), W(), abstand);
+
+}
+*/
+bool Rand(int x, int y, const GridWerte& W, int abstand )
+{
+ return (x == abstand || x == W.xanz-1-abstand
+ || y == abstand || y == W.yanz-1-abstand);
+}
+
+/*
+int innerhalb(const I_Vec& I, const GridWerte& W)
+{
+ int x = I.X();
+ int y = I.Y();
+
+ return (x >= 0 && x < W.xanz && y >= 0 && y < W.yanz);
+}
+
+int innerhalb(const I_Vec& I, const IVecWerte& W)
+{
+ int x = I.X();
+ int y = I.Y();
+
+ return (x >= 0 && x < W().xanz && y >= 0 && y < W().yanz);
+}
+*/
+int innerhalb(int x, int y, const GridWerte& W)
+{
+ return (x >= 0 && x < W.xanz && y >= 0 && y < W.yanz);
+}
+
+
+ostream& operator << (ostream& o, const C_Vec2& V)
+{
+ o << "(" << V.X() << ", " << V.Y() << ")";
+ return o;
+}
+
+void normieren(C_Vec2& G)
+ // Normiert einen Vektor
+{
+ double r = G.Length();
+ G /= r;
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// min3 max3
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+double max3(double x, double y, double z)
+{
+ return( x > y ? (x > z ? x : z) : (y > z ? y : z) );
+}
+
+double min3(double x, double y, double z)
+{
+ return( x < y ? (x < z ? x : z) : (y < z ? y : z) );
+}
+
+
+static int
+NachbarBesetzt(int y0, int y1, int x0, int x1, int y, int x,
+ GridWerte& G)
+{
+ for (int i=y0; i<=y1; i++)
+ for (int j=x0; j<=x1; j++)
+ if (i == -1 || i == 1 || j == -1 || j == 1)
+ {
+ if (innerhalb(x+j, y+i, G))
+ if (G(x+j,y+i) != 0.0)
+ return true;
+ }
+ return false;
+}
+
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// DeleteNotKonvex
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// LinRand
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+void
+LinRand( GridWerte& G, GridWerte& Erg)
+{
+ Erg = G;
+ Erg.xanz += 2;
+ Erg.yanz += 2;
+ Erg.xll -= Erg.dxy;
+ Erg.yll -= Erg.dxy;
+ Erg.getMem();
+
+ int i;
+ int j;
+ long yyy = G.yanz;
+ long xxx = G.xanz;
+
+// for (i=0; i<G.yanz; i++)
+// for (j=0; j<G.xanz; j++)
+ for (i=0; i<yyy; i++)
+ for (j=0; j<xxx; j++)
+ Erg.Set_Value(j+1,i+1, G(j,i));
+
+ // linke Kante
+ j = 0;
+ for (i=1; i<=G.yanz; i++)
+ Erg.Set_Value(j,i, 2.0*G(j,i-1)-G(j+1,i-1));
+
+ // rechte Kante
+ j = G.xanz-1;
+
+ for (i=1; i<=G.yanz; i++)
+ Erg.Set_Value(j+2,i, 2.0*G(j,i-1)-G(j-1,i-1));
+
+ // untere Kante
+ i = 0;
+// for (j=1; j<=G.xanz; j++)
+ for (j=1; j<=xxx; j++)
+ Erg.Set_Value(j,i, 2.0*G(j-1,i)-G(j-1,i+1));
+
+ // obere Kante
+ i = G.yanz-1;
+// for (j=1; j<=G.xanz; j++)
+ for (j=1; j<=xxx; j++)
+ Erg.Set_Value(j,i+2, 2.0*G(j-1,i)-G(j-1,i-1));
+
+ double m1, m2;
+ // Ecke ul
+ m1 = 2*Erg(0,1)-Erg(0,2);
+ m2 = 2*Erg(1,0)-Erg(2,0);
+ Erg.Set_Value(0,0, (m1+m2)/2);
+
+ // Ecke ur
+ m1 = 2*Erg(Erg.xanz-1,1)-Erg(Erg.xanz-1,2);
+ m2 = 2*Erg(Erg.xanz-2,0)-Erg(Erg.xanz-3,0);
+ Erg.Set_Value(Erg.xanz-1,0, (m1+m2)/2);
+
+ // Ecke ol
+ m1 = 2*Erg(0,Erg.yanz-2)-Erg(0,Erg.yanz-3);
+ m2 = 2*Erg(1,Erg.yanz-1)-Erg(2,Erg.yanz-1);
+ Erg.Set_Value(0,Erg.yanz-1, (m1+m2)/2);
+
+ // Ecke or
+ m1 = 2*Erg(Erg.xanz-1,Erg.yanz-2)-Erg(Erg.xanz-1,Erg.yanz-3);
+ m2 = 2*Erg(Erg.xanz-2,Erg.yanz-1)-Erg(Erg.xanz-3,Erg.yanz-1);
+
+ Erg.Set_Value(Erg.xanz-1,Erg.yanz-1, (m1+m2)/2);
+
+ Erg.calcMinMax();
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// RandHinzu
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+void copyGrid(GridWerte &Dest, GridWerte &Source, bool newmem)
+{
+ if (newmem)
+ {
+ Dest = Source;
+ Dest.getMem();
+ }
+
+ for (int i=0; i<Source.yanz; i++)
+ {
+ for (int j=0; j<Source.xanz; j++)
+ {
+ double wert= Source(j,i);
+
+ Dest.Set_Value(j,i, wert);
+ }
+ }
+
+
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Expositions-Abweichung
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+void calcExpoAbweichung(GridWerte& Erg, GridWerte& Expo)
+{
+ int i;
+
+ double w[9];
+ // Standard-Expositionen zur mittleren Rasterzelle
+ w[0] = double( 45.0/180.0*M_PI); // -1 -1
+ w[1] = double( 0.0/180.0*M_PI); // 0 -1
+ w[2] = double(315.0/180.0*M_PI); // 1 -1
+
+ w[3] = double( 90.0/180.0*M_PI); // -1 0
+ w[4] = double( 0.0/180.0*M_PI); // 0 0 egal, wird nicht benutzt
+ w[5] = double(270.0/180.0*M_PI); // 1 0
+
+ w[6] = double(135.0/180.0*M_PI); // -1 +1
+ w[7] = double(180.0/180.0*M_PI); // 0 +1
+ w[8] = double(225.0/180.0*M_PI); // 1 +1
+
+ Erg = Expo;
+ Erg.getMem();
+ for (i=0; i<Erg.yanz; i++)
+ {
+ for (int j=0; j<Erg.xanz; j++)
+ Erg.Set_Value(j,i, 0.0f);
+ }
+
+ int zaehler;
+ double winkel;
+ for (i=0; i<Erg.yanz; i++)
+ {
+ for (int j=0; j<Erg.xanz; j++)
+ {
+ zaehler = 0;
+ for (int ii=-1; ii<=1; ii++)
+ {
+ for (int jj=-1; jj<=1; jj++)
+ {
+ if ((ii != 0 || j != 0) && innerhalb(j+jj,i+ii, Erg))
+ {
+ winkel = fabs(w[(ii+1)*3+jj+1]-Expo(j+jj,i+ii));
+ if (winkel > M_PI)
+ winkel = 2*M_PI-winkel;
+ Erg.Add_Value(j,i, winkel/M_PI);
+ zaehler++;
+ }
+ }
+ }
+ if (zaehler != 0)
+ Erg.Mul_Value(j,i, 1.0 / zaehler);
+ }
+ }
+
+}
+
+static double calcMittelwert( GridWerte& H, int x, int y)
+{
+ if (x != H.xanz-1 && y != H.yanz-1)
+ return (H(x,y) + H(x,y+1) + H(x+1,y) + H(x+1,y+1))/4.0f;
+ else if (x == H.xanz-1)
+ {
+ return (H(x,y) + H(x,y+1))/2.0f;
+ }
+ else
+ {
+ return (H(x,y) + H(x+1,y))/2.0f;
+ }
+}
+
+
+
+
+
diff --git a/src/modules/grid/grid_calculus_bsl/diverses.h b/src/modules/grid/grid_calculus_bsl/diverses.h
new file mode 100644
index 0000000..01653b4
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/diverses.h
@@ -0,0 +1,130 @@
+/* diverses.h */
+
+#ifndef __DIVERSES_H
+#define __DIVERSES_H
+
+#include "grid_bsl.h"
+#include <vector>
+/*
+class I_Vec : public C_Vec2
+{
+ public:
+ I_Vec(double x = 0.0, double y = 0.0);
+ I_Vec(const C_Vec2& V);
+ ~I_Vec();
+
+ int X(void) const;
+ int Y(void) const;
+ double X_binary(void) const;
+ double Y_binary(void) const;
+ void adjust(void);
+ int operator ==(const I_Vec& V);
+ int operator ==(const I_Vec& V) const;
+};
+*/
+
+class I_Vec
+{
+ public:
+// I_Vec(double x = 0.0, double y = 0.0);
+ I_Vec(int xx = 0, int yy = 0) : x(xx), y(yy) {};
+ I_Vec(const C_Vec2& V) { x = (int)V.X(); y = (int)V.Y(); };
+ ~I_Vec() {};
+
+ inline int X(void) const {return x; };
+ inline int Y(void) const {return y; };
+// void adjust(void);
+ int operator ==(const I_Vec& V) {return x == V.X() && y == V.Y(); };
+ int operator ==(const I_Vec& V) const {return x == V.X() && y == V.Y(); };
+ inline I_Vec operator+(const I_Vec& v) const {return I_Vec(x+v.X(), y+v.Y());};
+ inline I_Vec operator-(const I_Vec& v) const {return I_Vec(x-v.X(), y-v.Y());};
+ inline I_Vec& operator = (const I_Vec& v) {x = v.X(); y = v.Y(); return *this;};
+ inline I_Vec& operator += (const I_Vec& v) { x += v.X(); y += v.Y(); return *this;};
+ inline I_Vec& operator -= (const I_Vec& v) { x -= v.X(); y -= v.Y(); return *this;};
+
+ inline double Length(void) { return double(sqrt((double)(x*x+y*y))); };
+ protected:
+ int x, y;
+};
+
+
+/*class IVecWerte
+{
+ public:
+ IVecWerte( GridWerte& G) : Grid(G) {};
+ ~IVecWerte() {};
+
+ inline double& operator [] ( I_Vec& I)
+ {
+ return Grid(int(I.X()),int(I.Y()));
+ }
+
+ const GridWerte& operator () () const
+ {
+ return Grid;
+ }
+ protected:
+ const GridWerte& Grid;
+};
+*/
+/*
+class IVecWerteInt
+{
+ public:
+ IVecWerteInt(GridWerteInt& G) : Grid(G) {};
+ ~IVecWerteInt() {};
+
+ inline int& operator [] (const I_Vec& I) const
+ {
+ return Grid.Z[I.Y()][I.X()];
+ }
+
+ GridWerteInt& operator () () const
+ {
+ return Grid;
+ }
+ protected:
+ GridWerteInt& Grid;
+};
+*/
+
+bool Rand(int x, int y, const GridWerte& W, int abstand = 0);
+//int Rand(const I_Vec& I, const IVecWerte& W, int abstand = 0);
+//int Rand(const I_Vec& I, const GridWerte& W, int abstand = 0);
+//int innerhalb(const I_Vec& I, const GridWerte& W);
+//int innerhalb(const I_Vec& I, const IVecWerte& W);
+int innerhalb(int x, int y, const GridWerte& W);
+//int isRandPunkt(const I_Vec iv, const GridWerte& G);
+
+void normieren(C_Vec2& G);
+//double WinkelDiff(double x, double y);
+
+double max3(double x, double y, double z);
+double min3(double x, double y, double z);
+
+
+
+void
+LinRand( GridWerte& G, GridWerte& Erg);
+/* Speicher: Erg.getMem */
+
+
+
+
+void DGMGlatt(const GridWerte& G, GridWerte& Erg);
+/* Speicher: Erg.getMem */
+
+void copyGrid(GridWerte& Dest, GridWerte& Source, bool newmem = true);
+
+void calcExpoAbweichung4erFeld(GridWerte& Erg, GridWerte& Hoehe);
+/* Speicher: Erg.getMem */
+
+void calcExpoAbweichung(GridWerte& Erg, GridWerte& Expo);
+/* Speicher: Erg.getMem */
+
+
+
+
+#endif
+
+/* End of file */
diff --git a/src/modules/grid/grid_calculus_bsl/foreach.cpp b/src/modules/grid/grid_calculus_bsl/foreach.cpp
new file mode 100644
index 0000000..7ba5542
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/foreach.cpp
@@ -0,0 +1,228 @@
+//#include <..\stdafx.h>
+
+#include "foreach.h"
+#include "bedingung.h"
+
+
+using namespace std;
+
+BBAnweisung::BBAnweisung()
+{
+ typ = Zuweisung;
+ memset(&AnweisungVar, 0, sizeof(T_AnweisungVar));
+}
+
+BBAnweisung::~BBAnweisung()
+{
+ switch(typ)
+ {
+ case ForEach:
+ if (AnweisungVar.For != NULL)
+ delete AnweisungVar.For;
+ break;
+ case IF:
+ if (AnweisungVar.IF != NULL)
+ delete AnweisungVar.IF;
+ break;
+ case Zuweisung:
+ if (AnweisungVar.Zu != NULL)
+ delete AnweisungVar.Zu;
+ break;
+ case Funktion:
+ if (AnweisungVar.Fkt != NULL)
+ delete AnweisungVar.Fkt;
+ break;
+ }
+ memset(&AnweisungVar, 0, sizeof(T_AnweisungVar));
+}
+
+BBForEach::BBForEach()
+{
+ M = 0;
+ P = 0;
+ N = 0;
+ type = Point;
+}
+
+BBForEach::~BBForEach()
+{
+// if (M != NULL)
+// delete M;
+// if (P != NULL)
+// delete P;
+// if (N != NULL)
+// delete N;
+// M = 0;
+// P = 0;
+// N = 0;
+ DeleteAnweisungList(z);
+}
+
+void DeleteAnweisungList(T_AnweisungList& a)
+{
+ T_AnweisungList::iterator it;
+ for (it = a.begin(); it != a.end(); it++)
+ {
+ if (*it != NULL)
+ delete *it;
+ }
+ a.clear();
+}
+
+bool getNextToken(const string& ss, int& pos, string& erg)
+{
+ if (pos >= ss.size())
+ return false;
+
+ string s = ss;
+ erg = ss.substr(pos);
+
+ WhiteSpace(erg, pos);
+ WhiteSpace(erg, pos, false);
+ pos += erg.size();
+ return true;
+}
+
+bool getNextChar(const string& ss, int& pos, char& c)
+{
+ string s = ss.substr(pos);
+ WhiteSpace(s, pos);
+ pos++;
+ c = s[0];
+ return true;
+}
+
+bool getStringBetweenKlammer(const string& s, int& pos)
+{
+
+ if (pos >= s.size())
+ return false;
+
+ int klammer_ebene = 1;
+
+ for (int i=pos; i<s.size(); i++)
+ {
+ if (s[i] == '{')
+ klammer_ebene++;
+ if (s[i] == '}')
+ klammer_ebene--;
+ if (klammer_ebene == 0)
+ {
+ pos = i;
+ return true;
+ }
+ }
+ return false;
+}
+
+bool isForEach(const string& ins, int& pos, BBForEach *& f, string& anweisungen)
+{
+ // pos wird auf { gesetzt
+ //
+ //
+ // Syntax: foreach p in M do { ... }
+ // foreachn n of p in M do { ... }
+ string s;
+ BBPoint *p1, *p2;
+ BBMatrix *m;
+ bool isPoint;
+
+ if (!getNextToken(ins, pos, s))
+ return false;
+ trim(s);
+ // foreach
+ if (s == "foreach")
+ isPoint = true;
+ else if (s == "foreachn")
+ isPoint = false;
+ else
+ return false;
+
+ if (!getNextToken(ins, pos, s))
+ return false;
+ trim(s);
+ BBTyp *bt = isVar(s);
+ if (bt == NULL)
+ return false;
+ // p/n
+ if (isPVar(s, bt))
+ p1 = getVarP(bt);
+ else
+ return false;
+
+ if (!getNextToken(ins, pos, s))
+ return false;
+ trim(s);
+ // of
+ if (s == "of")
+ {
+ if (isPoint)
+ return false;
+ if (!getNextToken(ins, pos, s))
+ return false;
+ trim(s);
+ BBTyp *bt1 = isVar(s);
+ if (bt1 == NULL)
+ return false;
+ // p
+ if (isPVar(s, bt1))
+ p2 = getVarP(bt1);
+ else
+ return false;
+
+ if (!getNextToken(ins, pos, s)) // nächstes "of" holen
+ return false;
+ trim(s);
+ }
+ else if (!isPoint) // "foreachn" ohne "of" ist Fehler
+ return false;
+
+ // in
+ if (s != "in")
+ return false;
+
+ if (!getNextToken(ins, pos, s))
+ return false;
+
+ // M
+ bt = isVar(s);
+ if (bt == NULL)
+ return false;
+ if (isMVar(s, bt))
+ m = getVarM(bt);
+ else
+ return false;
+
+ char c;
+ // do
+ getNextChar(ins, pos, c);
+ if (c != 'd')
+ return false;
+ getNextChar(ins, pos, c);
+ if (c != 'o')
+ return false;
+
+ // Klammer-Paar finden { .. }
+ getNextChar(ins, pos, c);
+ if (c != '{')
+ return false;
+ int p = pos;
+ if (!getStringBetweenKlammer(ins, p))
+ return false;
+
+ // alles OK
+
+ anweisungen = ins.substr(pos, p-pos);
+ f = new BBForEach;
+ f->type = (isPoint ? BBForEach::Point : BBForEach::Nachbar);
+ f->M = m;
+ f->P = p1;
+ if (!isPoint)
+ {
+ f->P = p2;
+ f->N = p1;
+ }
+ return true;
+}
+
+
diff --git a/src/modules/grid/grid_calculus_bsl/foreach.h b/src/modules/grid/grid_calculus_bsl/foreach.h
new file mode 100644
index 0000000..b67d01e
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/foreach.h
@@ -0,0 +1,55 @@
+#ifndef __FOREACH_H
+#define __FOREACH_H
+
+#include "zuweisung.h"
+#include <string>
+
+class BBForEach;
+class BBIf;
+
+class BBAnweisung
+{
+public:
+ BBAnweisung();
+ ~BBAnweisung();
+
+ enum T_AnweisungTyp {ForEach, IF, Zuweisung, Funktion } typ;
+
+ union T_AnweisungVar
+ {
+ BBForEach *For;
+ BBIf *IF;
+ BBZuweisung *Zu;
+ BBFktExe *Fkt;
+ } AnweisungVar;
+};
+
+typedef std::list<BBAnweisung *> T_AnweisungList;
+void DeleteAnweisungList(T_AnweisungList& a);
+
+
+class BBForEach
+{
+public:
+ BBForEach();
+ ~BBForEach();
+
+ enum ForEachType { Point, Nachbar } type;
+
+ BBMatrix *M;
+ BBPoint *P;
+ BBPoint *N;
+ T_AnweisungList z;
+};
+
+bool getNextToken(const std::string& ss, int& pos, std::string& erg);
+bool getNextChar(const std::string& ss, int& pos, char& c);
+bool getStringBetweenKlammer(const std::string& s, int& pos);
+
+
+bool isForEach(const std::string& ins, int& pos, BBForEach *& f, std::string& anweisungen);
+
+
+
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/funktion.cpp b/src/modules/grid/grid_calculus_bsl/funktion.cpp
new file mode 100644
index 0000000..9d15841
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/funktion.cpp
@@ -0,0 +1,805 @@
+
+//#include <..\stdafx.h>
+#include <iostream>
+#include <sstream>
+
+#include "funktion.h"
+#include "auswert_zuweisung.h"
+
+#include "diverses.h"
+#include "interpolation.h"
+
+#include "funktion_numerisch.h"
+#include "funktion_statistisch.h"
+
+#include "bsl_interpreter.h"
+
+using namespace std;
+
+T_FunktionList FunktionList;
+
+BBArgumente::BBArgumente()
+{
+ ArgTyp.IF = NULL;
+ ArgTyp.MP = NULL;
+ typ = NoOp;
+}
+BBArgumente::~BBArgumente()
+{
+ return;
+}
+
+BBFunktion::BBFunktion()
+{
+}
+
+BBFunktion::~BBFunktion()
+{
+}
+
+BBFktExe::BBFktExe()
+{
+ f = 0;
+}
+
+BBFktExe::~BBFktExe()
+{
+ for (int i=0; i<f->args.size(); i++)
+ {
+ switch (f->args[i].typ)
+ {
+ case BBArgumente::ITyp:
+ case BBArgumente::FTyp:
+ if (f->args[i].ArgTyp.IF)
+ delete f->args[i].ArgTyp.IF;
+ f->args[i].ArgTyp.IF = NULL;
+ break;
+ case BBArgumente::MTyp:
+ case BBArgumente::PTyp:
+ if (f->args[i].ArgTyp.MP)
+ delete f->args[i].ArgTyp.MP;
+ f->args[i].ArgTyp.MP = NULL;
+ break;
+ }
+ }
+}
+
+//****************************************************************
+// Definition von Funktionen
+//****************************************************************
+#define __GET_MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define __GET_MAX(a, b) (((a) > (b)) ? (a) : (b))
+
+class BBFunktion_showMatrix : public BBFunktion
+//
+// showMatrix: zeigt einen Grid in einem neuen Fenster
+//
+{
+public:
+ BBFunktion_showMatrix()
+ {
+ name = "showMatrix";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::MTyp;
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::NoOp;
+ };
+ virtual void fkt(void)
+ {
+
+ args[0].ArgTyp.MP->k.M->M->Set_Name(CSG_String((char *)args[0].ArgTyp.MP->k.M->name.c_str()));
+ g_Add_Grid( (args[0].ArgTyp.MP->k.M->M) );
+
+ };
+
+};
+
+
+class BBFunktion_saveMatrix : public BBFunktion
+//
+// saveMatrix: zeigt einen Grid in einem neuen Fenster
+//
+{
+public:
+ BBFunktion_saveMatrix()
+ {
+ name = "saveMatrix";
+ // Argumente: Matrix, Pfad
+ BBArgumente a;
+ a.typ = BBArgumente::MTyp;
+ args.push_back(a);
+ a.typ = BBArgumente::ITyp;
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::NoOp;
+ };
+ virtual void fkt(void)
+ {
+ if (args[0].ArgTyp.MP->typ != BBBaumMatrixPoint::MVar)
+ throw BBFehlerAusfuehren();
+
+ int filename_number = auswert_integer(*(args[1].ArgTyp.IF));
+ char filename[40];
+ sprintf(filename, "OutputGrid%03d.grd", filename_number);
+
+ args[0].ArgTyp.MP->k.M->M->Save(filename,2);
+
+
+ };
+
+};
+
+class BBFunktion_getMemory : public BBFunktion
+//
+// getMemory: ruft GridWerte.getMem auf
+//
+{
+public:
+ BBFunktion_getMemory()
+ {
+ name = "getMemory";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::MTyp; // x
+ args.push_back(a);
+ a.typ = BBArgumente::ITyp; // x
+ args.push_back(a);
+ a.typ = BBArgumente::ITyp; // y
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::NoOp; // kein Return-Wert
+ };
+ virtual void fkt(void)
+ {
+ int x, y;
+ x = auswert_integer(*(args[1].ArgTyp.IF));
+ y = auswert_integer(*(args[2].ArgTyp.IF));
+
+ // MP darf nur aus einer Matrix bestehen
+ if (args[0].ArgTyp.MP->typ != BBBaumMatrixPoint::MVar)
+ throw BBFehlerAusfuehren();
+
+ args[0].ArgTyp.MP->k.M->M->xanz = x;
+ args[0].ArgTyp.MP->k.M->M->yanz = y;
+ args[0].ArgTyp.MP->k.M->M->getMem();
+ };
+ BBBaumInteger baum;
+};
+
+class BBFunktion_max3 : public BBFunktion
+//
+// max3: ruft (Diverses::) max3 auf
+//
+{
+public:
+ BBFunktion_max3()
+ {
+ name = "max3";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+ a.typ = BBArgumente::FTyp; // x2
+ args.push_back(a);
+ a.typ = BBArgumente::FTyp; // x3
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_max3()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x, y, z;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+ y = auswert_float(*(args[1].ArgTyp.IF));
+ z = auswert_float(*(args[2].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = max3(x,y,z);
+ };
+};
+
+
+class BBFunktion_min3 : public BBFunktion
+//
+// min3: ruft (Diverses::) min3 auf
+//
+{
+public:
+ BBFunktion_min3()
+ {
+ name = "min3";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+ a.typ = BBArgumente::FTyp; // x2
+ args.push_back(a);
+ a.typ = BBArgumente::FTyp; // x3
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_min3()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x, y, z;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+ y = auswert_float(*(args[1].ArgTyp.IF));
+ z = auswert_float(*(args[2].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = min3(x,y,z);
+ };
+};
+
+
+class BBFunktion_max8 : public BBFunktion
+//
+// max8: berechnet das Maximum aller Nachbarn
+//
+{
+public:
+ BBFunktion_max8()
+ {
+ name = "max8";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::PTyp; // x1
+ args.push_back(a);
+ a.typ = BBArgumente::MTyp; // x2
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_max8()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ GridWerte *W;
+
+ // MP darf nur aus einer Matrix bestehen
+ if (args[1].ArgTyp.MP->typ != BBBaumMatrixPoint::MVar)
+ throw BBFehlerAusfuehren("Funktion >max8<");
+ W = args[1].ArgTyp.MP->k.M->M;
+
+ // get point p
+ bool ret1;
+ T_Point p;
+ double f;
+ ret1 = auswert_point(*(args[0].ArgTyp.MP), p, f);
+ if (!ret1)
+ throw BBFehlerAusfuehren("Funktion >max8<");
+
+
+ double hoehe = -1e30f;
+ for (int i=-1; i<=1; i++)
+ {
+ for (int j=-1; j<=1; j++)
+ {
+ int x = p.x + i;
+ int y = p.y + j;
+ if (innerhalb(x, y, *W) && (i != 0 || j != 0))
+ {
+ hoehe = __GET_MAX(hoehe, (*W)(x,y) );
+ }
+ }
+ }
+ ret.ArgTyp.IF->k.FZahl = hoehe;
+ };
+};
+
+class BBFunktion_min8 : public BBFunktion
+//
+// max8: berechnet das Maximum aller Nachbarn
+//
+{
+public:
+ BBFunktion_min8()
+ {
+ name = "min8";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::PTyp; // x1
+ args.push_back(a);
+ a.typ = BBArgumente::MTyp; // x2
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_min8()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ GridWerte *W;
+
+ // MP darf nur aus einer Matrix bestehen
+ if (args[1].ArgTyp.MP->typ != BBBaumMatrixPoint::MVar)
+ throw BBFehlerAusfuehren("Funktion >max8<");
+ W = args[1].ArgTyp.MP->k.M->M;
+
+ // get point p
+ bool ret1;
+ T_Point p;
+ double f;
+ ret1 = auswert_point(*(args[0].ArgTyp.MP), p, f);
+ if (!ret1)
+ throw BBFehlerAusfuehren("Funktion >max8<");
+
+
+ double hoehe = 1e30f;
+ for (int i=-1; i<=1; i++)
+ {
+ for (int j=-1; j<=1; j++)
+ {
+ int x = p.x + i;
+ int y = p.y + j;
+ if (innerhalb(x, y, *W) && (i != 0 || j != 0))
+ {
+ hoehe = __GET_MIN(hoehe, (*W)(x,y));
+ }
+ }
+ }
+ ret.ArgTyp.IF->k.FZahl = hoehe;
+ };
+};
+
+class BBFunktion_max9 : public BBFunktion
+//
+// max8: berechnet das Maximum aller Nachbarn
+//
+{
+public:
+ BBFunktion_max9()
+ {
+ name = "max9";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::PTyp; // x1
+ args.push_back(a);
+ a.typ = BBArgumente::MTyp; // x2
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_max9()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ GridWerte *W;
+
+ // MP darf nur aus einer Matrix bestehen
+ if (args[1].ArgTyp.MP->typ != BBBaumMatrixPoint::MVar)
+ throw BBFehlerAusfuehren("Funktion >max8<");
+ W = args[1].ArgTyp.MP->k.M->M;
+
+ // get point p
+ bool ret1;
+ T_Point p;
+ double f;
+ ret1 = auswert_point(*(args[0].ArgTyp.MP), p, f);
+ if (!ret1)
+ throw BBFehlerAusfuehren("Funktion >max8<");
+
+
+ double hoehe = -1e30f;
+ for (int i=-1; i<=1; i++)
+ {
+ for (int j=-1; j<=1; j++)
+ {
+ int x = p.x + i;
+ int y = p.y + j;
+ if (innerhalb(x, y, *W))
+ {
+ hoehe = __GET_MAX(hoehe, (*W)(x,y));
+ }
+ }
+ }
+ ret.ArgTyp.IF->k.FZahl = hoehe;
+ };
+};
+
+class BBFunktion_min9 : public BBFunktion
+//
+// max8: berechnet das Maximum aller Nachbarn
+//
+{
+public:
+ BBFunktion_min9()
+ {
+ name = "min9";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::PTyp; // x1
+ args.push_back(a);
+ a.typ = BBArgumente::MTyp; // x2
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_min9()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ GridWerte *W;
+
+ // MP darf nur aus einer Matrix bestehen
+ if (args[1].ArgTyp.MP->typ != BBBaumMatrixPoint::MVar)
+ throw BBFehlerAusfuehren("Funktion >max8<");
+ W = args[1].ArgTyp.MP->k.M->M;
+
+ // get point p
+ bool ret1;
+ T_Point p;
+ double f;
+ ret1 = auswert_point(*(args[0].ArgTyp.MP), p, f);
+ if (!ret1)
+ throw BBFehlerAusfuehren("Funktion >max8<");
+
+
+ double hoehe = 1e30f;
+ for (int i=-1; i<=1; i++)
+ {
+ for (int j=-1; j<=1; j++)
+ {
+ int x = p.x + i;
+ int y = p.y + j;
+ if (innerhalb(x, y, *W))
+ {
+ hoehe = __GET_MIN(hoehe, (*W)(x,y));
+ }
+ }
+ }
+ ret.ArgTyp.IF->k.FZahl = hoehe;
+ };
+};
+
+class BBFunktion_isRand : public BBFunktion
+//
+// ruft (Diverses::) isRand auf
+//
+{
+public:
+ BBFunktion_isRand()
+ {
+ name = "isRand";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::PTyp; // x1
+ args.push_back(a);
+ a.typ = BBArgumente::MTyp; // x2
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::ITyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::IZahl;
+ ret.ArgTyp.IF->k.IZahl = 0;
+ };
+ ~BBFunktion_isRand()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ int x, y;
+
+ // MP darf nur aus einer Matrix bestehen
+ if (args[1].ArgTyp.MP->typ != BBBaumMatrixPoint::MVar)
+ throw BBFehlerAusfuehren("Funktion >isRand<");
+ bool ret1;
+ T_Point p;
+ double f;
+ ret1 = auswert_point(*(args[0].ArgTyp.MP), p, f);
+ if (!ret1)
+ throw BBFehlerAusfuehren("Funktion >isRand<");
+ x = args[1].ArgTyp.MP->k.M->M->xanz;
+ y = args[1].ArgTyp.MP->k.M->M->yanz;
+ ret.ArgTyp.IF->k.IZahl = ( (p.x <= 0 || p.y <= 0 || p.x >= x-1 || p.y >= y-1) ? 1 : 0);
+ };
+};
+
+
+
+class BBFunktion_setRandN : public BBFunktion
+//
+// setRandN : setzt alle Randpunkte auf den nächsten Nachbarn
+//
+{
+public:
+ BBFunktion_setRandN()
+ {
+ name = "setRandN";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::MTyp; // x2
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::NoOp;
+ };
+ ~BBFunktion_setRandN()
+ {
+ }
+ virtual void fkt(void)
+ {
+ int x, y;
+
+ // MP darf nur aus einer Matrix bestehen
+ if (args[0].ArgTyp.MP->typ != BBBaumMatrixPoint::MVar)
+ throw BBFehlerAusfuehren("Funktion >setRandN<");
+ GridWerte *G = args[0].ArgTyp.MP->k.M->M;
+ x = 0;
+ for (y=1; y<G->yanz-1; y++)
+ G->Set_Value(x,y, G->asDouble(x+1,y));
+ x = G->xanz-1;
+ for (y=1; y<G->yanz-1; y++)
+ G->Set_Value(x,y, G->asDouble(x-1,y));
+ y = 0;
+ for (x=1; x<G->xanz-1; x++)
+ G->Set_Value(x,y, G->asDouble(x,y+1));
+ y = G->yanz-1;
+ for (x=1; x<G->xanz-1; x++)
+ G->Set_Value(x,y, G->asDouble(x,y-1));
+
+ // die vier Randpunkte setzen
+ G->Set_Value( 0, 0, G->asDouble( 1, 1, false));
+ G->Set_Value(G->xanz-1, 0, G->asDouble(G->xanz-2, 1, false));
+ G->Set_Value( 0,G->yanz-1, G->asDouble( 1,G->yanz-2, false));
+ G->Set_Value(G->xanz-1,G->yanz-1, G->asDouble(G->xanz-2,G->yanz-2, false));
+ };
+};
+
+
+class BBFunktion_setRandI : public BBFunktion
+//
+// setRandI : setzt alle Randpunkte durch lineare extrapolation
+//
+{
+public:
+ BBFunktion_setRandI()
+ {
+ name = "setRandI";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::MTyp; // x2
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::NoOp;
+ };
+ ~BBFunktion_setRandI()
+ {
+ }
+ virtual void fkt(void)
+ {
+ // MP darf nur aus einer Matrix bestehen
+ if (args[0].ArgTyp.MP->typ != BBBaumMatrixPoint::MVar)
+ throw BBFehlerAusfuehren("Funktion >setRandN<");
+ GridWerte *G = args[0].ArgTyp.MP->k.M->M;
+ GridWerte H;
+ H = *G;
+ H.xanz -= 2;
+ H.yanz -= 2;
+ H.xll += G->dxy;
+ H.yll += G->dxy;
+ H.getMem();
+ for (int i=1; i<G->yanz-1; i++)
+ for (int j=1; j<G->xanz-1; j++)
+ H.Set_Value(j-1,i-1, G->asDouble(j,j));
+ LinRand(H, *(args[0].ArgTyp.MP->k.M->M));
+ };
+};
+
+
+class BBFunktion_showValue : public BBFunktion
+//
+// setRandI : setzt alle Randpunkte durch lineare extrapolation
+//
+{
+public:
+ BBFunktion_showValue()
+ {
+ name = "showValue";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x2
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::NoOp;
+ };
+ ~BBFunktion_showValue()
+ {
+ }
+ virtual void fkt(void)
+ {
+ string s("");
+ ostringstream os1(s);
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+ os1 << "Value = " << x << ends;
+
+ //Hier in output frnster
+// AfxMessageBox(os1.str().data());
+ };
+};
+/*
+class BBFunktion_spline : public BBFunktion
+//
+// ruft (Diverses::) isRand auf
+//
+{
+public:
+ BBFunktion_spline()
+ {
+ name = "spline";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::MTyp; // x1
+ args.push_back(a);
+ a.typ = BBArgumente::FTyp; // x2: faktor
+ args.push_back(a);
+ a.typ = BBArgumente::MTyp; // x3: neues Grid
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::NoOp;
+ };
+ ~BBFunktion_spline()
+ {
+ }
+ virtual void fkt(void)
+ {
+ int x, y;
+
+ // MP darf nur aus einer Matrix bestehen
+ if (args[0].ArgTyp.MP->typ != BBBaumMatrixPoint::MVar)
+ throw BBFehlerAusfuehren("Funktion >spline<");
+ // MP darf nur aus einer Matrix bestehen
+ if (args[2].ArgTyp.MP->typ != BBBaumMatrixPoint::MVar)
+ throw BBFehlerAusfuehren("Funktion >spline<");
+
+ // Übergabe-Parameter extrahieren
+ GridWerte *sourceGrid = args[0].ArgTyp.MP->k.M->M;
+ GridWerte *destGrid = args[2].ArgTyp.MP->k.M->M;
+ double factor = auswert_float(*(args[1].ArgTyp.IF));
+
+ // Anzahl der Punkte berechnen
+ // z.B. Abstand: 3 (=0, 1, 2, 3), faktor 0.4
+ // --> 0, 0.4, 0.8, 1.2, 1.6, 2.0, 2.4, 2.8
+ // aber: 3 / 0.4 = 30 / 4 = 7.5 = 7 + 1
+ // oder
+ // Abstand: 2 (0, 1, 2), faktor 0.4
+ // --> 0, 0.4, 0.8, 1.2, 1.6, 2.0
+ // aber 2 / 0.4 = 5
+ // Abstand 1 (0, 1), faktor 0.4
+ //--> 0, 0,4, 0.8
+ // aber 1 / 0.4 = 2,5
+ //
+ // ==> Formel: floor((xanz-1)/faktor))+1
+
+ x = floor( (sourceGrid->xanz-1)/factor ) + 1;
+ y = floor( (sourceGrid->yanz-1)/factor ) + 1;
+
+ Interpolation *I;
+ I = new QSpline(*sourceGrid);
+ I->setParams(0, 0, factor, x, y); // von 0,0 in factor-Schritten über x,y Punkte
+ I->interpol(*destGrid);
+ delete I;
+ destGrid->calcMinMax();
+
+ };
+};
+*/
+//****************************************************************
+// Initialisierung der Funktionen
+//****************************************************************
+
+void InitFunktionen(void)
+{
+ FunktionList.push_back(new BBFunktion_showMatrix() );
+ FunktionList.push_back(new BBFunktion_saveMatrix() );
+ FunktionList.push_back(new BBFunktion_getMemory() );
+ FunktionList.push_back(new BBFunktion_max3() );
+ FunktionList.push_back(new BBFunktion_min3() );
+ FunktionList.push_back(new BBFunktion_max8() );
+ FunktionList.push_back(new BBFunktion_min8() );
+ FunktionList.push_back(new BBFunktion_max9() );
+ FunktionList.push_back(new BBFunktion_min9() );
+ FunktionList.push_back(new BBFunktion_isRand() );
+ FunktionList.push_back(new BBFunktion_setRandN() );
+ FunktionList.push_back(new BBFunktion_setRandI() );
+ FunktionList.push_back(new BBFunktion_showValue() );
+// FunktionList.push_back(new BBFunktion_spline() );
+
+
+ // aus funktion_numerisch.h
+ FunktionList.push_back(new BBFunktion_sin() );
+ FunktionList.push_back(new BBFunktion_cos() );
+ FunktionList.push_back(new BBFunktion_tan() );
+ FunktionList.push_back(new BBFunktion_sinargs() );
+ FunktionList.push_back(new BBFunktion_cosargs() );
+ FunktionList.push_back(new BBFunktion_tanargs() );
+ FunktionList.push_back(new BBFunktion_asin() );
+ FunktionList.push_back(new BBFunktion_acos() );
+ FunktionList.push_back(new BBFunktion_atan() );
+ FunktionList.push_back(new BBFunktion_asinargs() );
+ FunktionList.push_back(new BBFunktion_acosargs() );
+ FunktionList.push_back(new BBFunktion_atanargs() );
+ FunktionList.push_back(new BBFunktion_log() );
+ FunktionList.push_back(new BBFunktion_ln() );
+ FunktionList.push_back(new BBFunktion_exp() );
+
+ // aus funktion_statistisch.h
+ FunktionList.push_back(new BBFunktion_setStatistikDaten() );
+ FunktionList.push_back(new BBFunktion_resetStatistikDaten() );
+ FunktionList.push_back(new BBFunktion_calcMittelwert() );
+ FunktionList.push_back(new BBFunktion_calcVarianz() );
+
+}
+
+void DeleteFunktionen(void)
+{
+ T_FunktionList::iterator it;
+ for (it = FunktionList.begin(); it != FunktionList.end(); it++)
+ {
+ delete (*it);
+ }
+}
+
+class InitFunktionenOnce
+{
+public:
+ InitFunktionenOnce()
+ {
+ InitFunktionen();
+ }
+ ~InitFunktionenOnce()
+ {
+ DeleteFunktionen();
+ }
+};
+
+InitFunktionenOnce initfunktionenonce;
diff --git a/src/modules/grid/grid_calculus_bsl/funktion.h b/src/modules/grid/grid_calculus_bsl/funktion.h
new file mode 100644
index 0000000..7b38022
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/funktion.h
@@ -0,0 +1,58 @@
+#ifndef __FUNKTION_BB_H
+#define __FUNKTION_BB_H
+
+
+
+#include "ausdruck.h"
+
+
+class BBArgumente
+{
+public:
+ BBArgumente();
+ ~BBArgumente();
+ enum ArgumentTyp { NoOp, ITyp, FTyp, MTyp, PTyp } typ;
+ union BBArgs
+ {
+ BBBaumMatrixPoint *MP;
+ BBBaumInteger *IF;
+ } ArgTyp;
+};
+
+typedef std::vector<BBArgumente> T_FktArgumente;
+
+class BBFunktion
+{
+public:
+ BBFunktion();
+ virtual ~BBFunktion();
+ virtual void fkt(void) = 0;
+ T_FktArgumente args;
+ BBArgumente ret;
+ const char *name;
+};
+
+// Um einen Funktionsaufruf zu speichern, ist folgendes notwending:
+// BBFunktion *f;
+// vector<Argumente> args;
+//
+struct BBFktExe
+{
+ BBFktExe();
+ ~BBFktExe();
+
+ BBFunktion *f;
+ T_FktArgumente args;
+};
+
+typedef std::list<BBFunktion *> T_FunktionList;
+extern T_FunktionList FunktionList;
+
+void InitFunktionen(void);
+void DeleteFunktionen(void);
+
+bool operator<(const BBArgumente& x, const BBArgumente& y);
+bool operator==(const BBArgumente& x, const BBArgumente& y);
+
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/funktion_numerisch.h b/src/modules/grid/grid_calculus_bsl/funktion_numerisch.h
new file mode 100644
index 0000000..82c23d0
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/funktion_numerisch.h
@@ -0,0 +1,523 @@
+#ifndef __FUNKTION_NUMERISCH_H
+#define __FUNKTION_NUMERISCH_H
+
+#include <math.h>
+
+
+//****************** SINUS **************************
+class BBFunktion_sin : public BBFunktion
+//
+// sin: ruft sinus(...) auf
+//
+{
+public:
+ BBFunktion_sin()
+ {
+ name = "sin";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_sin()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = sin(x);
+ };
+};
+
+//****************** COSINUS **************************
+class BBFunktion_cos : public BBFunktion
+//
+// cos: ruft cosinus(...) auf
+//
+{
+public:
+ BBFunktion_cos()
+ {
+ name = "cos";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_cos()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = cos(x);
+ };
+};
+
+//****************** TANGENS **************************
+class BBFunktion_tan : public BBFunktion
+//
+// tan: ruft tangens(...) auf
+//
+{
+public:
+ BBFunktion_tan()
+ {
+ name = "tan";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_tan()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = tan(x);
+ };
+};
+
+//****************** SINUS **************************
+class BBFunktion_sinargs : public BBFunktion
+//
+// sin: ruft sinus(...) auf
+//
+{
+public:
+ BBFunktion_sinargs()
+ {
+ name = "sinargs";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_sinargs()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = sin(x*M_PI/180.0);
+ };
+};
+
+//****************** COSINUS **************************
+class BBFunktion_cosargs : public BBFunktion
+//
+// cos: ruft cosinus(...) auf
+//
+{
+public:
+ BBFunktion_cosargs()
+ {
+ name = "cosargs";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_cosargs()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = cos(x*M_PI/180.0);
+ };
+};
+
+//****************** TANGENS **************************
+class BBFunktion_tanargs : public BBFunktion
+//
+// tan: ruft tangens(...) auf
+//
+{
+public:
+ BBFunktion_tanargs()
+ {
+ name = "tanargs";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_tanargs()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = tan(x*M_PI/180.0);
+ };
+};
+
+
+//****************** SINUS **************************
+class BBFunktion_asin : public BBFunktion
+//
+// sin: ruft arcussinus(...) auf
+//
+{
+public:
+ BBFunktion_asin()
+ {
+ name = "asin";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_asin()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = asin(x);
+ };
+};
+
+//****************** COSINUS **************************
+class BBFunktion_acos : public BBFunktion
+//
+// acos: ruft arcuscosinus(...) auf
+//
+{
+public:
+ BBFunktion_acos()
+ {
+ name = "acos";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_acos()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = acos(x);
+ };
+};
+
+
+//****************** TANGENS **************************
+class BBFunktion_atan : public BBFunktion
+//
+// tan: ruft tangens(...) auf
+//
+{
+public:
+ BBFunktion_atan()
+ {
+ name = "atan";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_atan()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = atan(x);
+ };
+};
+
+//****************** SINUS **************************
+class BBFunktion_asinargs : public BBFunktion
+//
+// asin: ruft sinus(...) auf
+//
+{
+public:
+ BBFunktion_asinargs()
+ {
+ name = "asinargs";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_asinargs()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = asin(x)*180.0/M_PI;
+ };
+};
+
+//****************** COSINUS **************************
+class BBFunktion_acosargs : public BBFunktion
+//
+// cos: ruft cosinus(...) auf
+//
+{
+public:
+ BBFunktion_acosargs()
+ {
+ name = "acosargs";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_acosargs()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+
+ ret.ArgTyp.IF->k.FZahl = acos(x)/M_PI*180.0;
+ };
+};
+
+
+//****************** TANGENS **************************
+class BBFunktion_atanargs : public BBFunktion
+//
+// tan: ruft tangens(...) auf
+//
+{
+public:
+ BBFunktion_atanargs()
+ {
+ name = "atanargs";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_atanargs()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+ ret.ArgTyp.IF->k.FZahl = atan(x)/M_PI*180.0;
+ };
+};
+
+//****************** LOG **************************
+class BBFunktion_log : public BBFunktion
+//
+// ruft log10(...) auf
+//
+{
+public:
+ BBFunktion_log()
+ {
+ name = "log";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_log()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+ if (x < 0)
+ throw BBFehlerAusfuehren("Argument vom Logarithmus ist negativ!");
+ ret.ArgTyp.IF->k.FZahl = log10(x);
+ };
+};
+
+//****************** LN **************************
+class BBFunktion_ln : public BBFunktion
+//
+// ruft log(...) auf
+//
+{
+public:
+ BBFunktion_ln()
+ {
+ name = "ln";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_ln()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+ if (x < 0)
+ throw BBFehlerAusfuehren("Argument vom Logarithmus ist negativ!");
+ ret.ArgTyp.IF->k.FZahl = log(x);
+ };
+};
+
+
+//****************** LN **************************
+class BBFunktion_exp : public BBFunktion
+//
+// ruft exp(...) auf
+//
+{
+public:
+ BBFunktion_exp()
+ {
+ name = "exp";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ // Return-Typ
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_exp()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+ ret.ArgTyp.IF->k.FZahl = exp(x);
+ };
+};
+
+
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/funktion_statistisch.h b/src/modules/grid/grid_calculus_bsl/funktion_statistisch.h
new file mode 100644
index 0000000..8b7b546
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/funktion_statistisch.h
@@ -0,0 +1,118 @@
+#ifndef __FUNKTION_STATISTISCH_H
+#define __FUNKTION_STATISTISCH_H
+
+
+std::vector<double> StatistikVektor;
+
+
+//****************** setStatistikDaten **************************
+class BBFunktion_setStatistikDaten : public BBFunktion
+//
+// setzt den Vektor, von dem die Statistik berechnet wird
+//
+{
+public:
+ BBFunktion_setStatistikDaten()
+ {
+ name = "setStatistikDaten";
+ // Argumente
+ BBArgumente a;
+ a.typ = BBArgumente::FTyp; // x1
+ args.push_back(a);
+
+ ret.typ = BBArgumente::NoOp;
+ };
+ ~BBFunktion_setStatistikDaten()
+ {
+ }
+ virtual void fkt(void)
+ {
+ double x;
+ x = auswert_float(*(args[0].ArgTyp.IF));
+ StatistikVektor.push_back(x);
+ };
+};
+
+
+class BBFunktion_resetStatistikDaten : public BBFunktion
+//
+// löscht den Vektor, von dem die Statistik berechnet wird
+//
+{
+public:
+ BBFunktion_resetStatistikDaten()
+ {
+ name = "resetStatistikDaten";
+ ret.typ = BBArgumente::NoOp;
+ };
+ ~BBFunktion_resetStatistikDaten()
+ {
+ }
+ virtual void fkt(void)
+ {
+ StatistikVektor.clear();
+ };
+};
+
+
+class BBFunktion_calcMittelwert : public BBFunktion
+//
+//
+{
+public:
+ BBFunktion_calcMittelwert()
+ {
+ name = "calcMittelwert";
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_calcMittelwert()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ double summe = 0.0f;
+ for (int i=0; i<StatistikVektor.size(); i++)
+ summe += StatistikVektor[i];
+ summe /= StatistikVektor.size();
+ ret.ArgTyp.IF->k.FZahl = summe;
+ };
+};
+
+class BBFunktion_calcVarianz : public BBFunktion
+
+{
+public:
+ BBFunktion_calcVarianz()
+ {
+ name = "calcVarianz";
+ ret.typ = BBArgumente::FTyp;
+ ret.ArgTyp.IF = new BBBaumInteger;
+ ret.ArgTyp.IF->typ = BBBaumInteger::FZahl;
+ ret.ArgTyp.IF->k.FZahl = 0;
+ };
+ ~BBFunktion_calcVarianz()
+ {
+ delete ret.ArgTyp.IF;
+ }
+ virtual void fkt(void)
+ {
+ // Mittelwert
+ double sum_x = 0.0f, sum_x2 = 0.0f;
+ int n = StatistikVektor.size();
+ for (int i=0; i<n; i++)
+ {
+ sum_x += StatistikVektor[i];
+ sum_x2 += StatistikVektor[i]*StatistikVektor[i];
+ }
+ sum_x = sum_x*sum_x;
+
+ ret.ArgTyp.IF->k.FZahl = (sum_x2 - sum_x/n)/(n-1);
+ };
+};
+
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/gr_def.h b/src/modules/grid/grid_calculus_bsl/gr_def.h
new file mode 100644
index 0000000..d4ded7c
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/gr_def.h
@@ -0,0 +1,196 @@
+////////////////////////////////////////////////////////////////////////////
+// Programm :
+// Bibliothek :
+// Header-Datei: Gr_def.h
+//
+////////////////////////////////////////////////////////////////////////////
+//
+// Autoren : Joerg Dolle
+// Christian Trachinow
+// Stephan Westphal
+// Telefon-Nr. :
+// Mail-Adresse : jdolle at gwdg.de
+//
+////////////////////////////////////////////////////////////////////////////
+//
+// Compiler : Borland C++ V.: 4.00
+// Ersterstellung : 09.11.95
+// Ueberarbeitung : 22.04.96
+//
+//
+// Programmversion: 2.00
+//
+////////////////////////////////////////////////////////////////////////////
+
+
+/****************** Include-Dateien **************/
+#ifndef __gr_def__
+#define __gr_def__
+
+#include "gr_syst.h"
+#include "vector.h"
+
+#undef HEADER_INCLUDED__DATA
+#define HEADER_INCLUDED__DATA
+
+
+//DO *Typkonstrukte***************************************************
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+
+typedef int G_Color;
+
+typedef struct {
+ unsigned char red, green, blue;
+} G_RgbColor;
+
+typedef struct {
+ char *name;
+ G_Color index;
+} G_NamedColors;
+
+typedef struct {
+ int NumColors;
+ G_RgbColor *RgbColor;
+ int NumNamedColors;
+ G_NamedColors *NamedColor;
+} G_ColorDef;
+
+typedef struct {
+ double x, y;
+} G_Point;
+
+//DO * Papierformate und Ausrichtungen ******
+typedef enum G_PaperFormat { A0P, A0L, A1P, A1L, A2P, A2L,
+ A3P, A3L, A4P, A4L, A5P, A5L};
+typedef enum G_PaperOrient { Portrait, Landscape };
+typedef enum G_FillType { Hollow, Blank, Filled };
+
+
+//DO *RGB-Felder********************
+#define RGBMAX_DOS 16
+#define RGBMAX_REGENBOGEN 256
+#define RGBMAX_ATLAS 256
+#define RGBMAX_ATLAS_SMALL 64
+#define RGBMAX_REGULAR 128
+#define RGBMAX_WINDOWS 16
+
+extern G_RgbColor RGBDos[RGBMAX_DOS];
+extern G_RgbColor RGBRegenbogen[RGBMAX_REGENBOGEN];
+extern G_RgbColor RGBAtlas[RGBMAX_ATLAS];
+extern G_RgbColor RGBAtlasSmall[RGBMAX_ATLAS_SMALL];
+extern G_RgbColor RGBRegular[RGBMAX_REGULAR];
+extern G_RgbColor RGBWindows[RGBMAX_WINDOWS];
+
+#define NAMEDCOLORSMAX 16
+extern G_NamedColors NamedColorsDos[NAMEDCOLORSMAX];
+extern G_NamedColors NamedColorsRegenbogen[NAMEDCOLORSMAX];
+extern G_NamedColors NamedColorsAtlas[NAMEDCOLORSMAX];
+extern G_NamedColors NamedColorsAtlasSmall[NAMEDCOLORSMAX];
+extern G_NamedColors NamedColorsRegular[NAMEDCOLORSMAX];
+extern G_NamedColors NamedColorsWindows[NAMEDCOLORSMAX];
+
+
+extern G_ColorDef ColorDefDos;
+extern G_ColorDef ColorDefRegenbogen;
+extern G_ColorDef ColorDefAtlas;
+extern G_ColorDef ColorDefAtlasSmall;
+extern G_ColorDef ColorDefRegular;
+extern G_ColorDef ColorDefWindows;
+
+
+//DO * Textdefinitionen *****************
+typedef enum G_TextOrientX {Left, HCenter, Right };
+typedef enum G_TextOrientY {Bottom,VCenter, Top};
+typedef enum G_TextFont { TimesRoman,
+ TimesBold,
+ TimesItalic,
+ TimesBoldItalic,
+ Helvetica,
+ HelveticaBold,
+ HelveticaOblique,
+ HelveticaBoldOblique,
+ Greek,
+ Symbol };
+
+//DO *** Clipping Type ******************
+typedef enum G_ClipType {NoClip,Clip};
+
+#define CS_TEXT_COLOR 1
+#define CS_TEXT_FONT 2
+#define CS_TEXT_ORIENT 4
+#define CS_TEXT_ANGLE 8
+#define CS_TEXT_HEIGHT 16
+
+#define CS_POLY_WIDTH 1
+#define CS_POLY_COLOR 2
+#define CS_POLY_FILL 4
+
+#define CS_POLYLINE_WIDTH 1
+#define CS_POLYLINE_COLOR 2
+
+#define CS_RECT_WIDTH 1
+#define CS_RECT_COLOR 2
+#define CS_RECT_FILL 4
+
+#define CS_CIRCLE_WIDTH 1
+#define CS_CIRCLE_RADIUS 2
+#define CS_CIRCLE_COLOR 4
+#define CS_CIRCLE_FILL 8
+
+#define CS_TRIANGLE_WIDTH 1
+#define CS_TRIANGLE_COLOR 2
+#define CS_TRIANGLE_FILL 4
+
+#define CS_LINE_WIDTH 1
+#define CS_LINE_COLOR 2
+
+typedef struct
+{
+ unsigned Text : 5;
+ unsigned TextVector : 5;
+ unsigned Poly : 3;
+ unsigned Polyline : 2;
+ unsigned Rect : 3;
+ unsigned Circle : 4;
+ unsigned Triangle : 3;
+ unsigned Line : 2;
+ unsigned Palette : 1;
+ void setBits(void)
+ {
+ Text = 31;
+ TextVector = 31;
+ Poly = 7;
+ Polyline = 3;
+ Rect = 7;
+ Circle = 15;
+ Triangle = 7;
+ Line = 3;
+ }
+} ContextStatus;
+
+
+//DO * RGB-Farben in einer Klasse gekapselt
+
+class RGBModelle
+{
+public:
+
+ RGBModelle();
+ ~RGBModelle();
+
+private:
+ void init_dos_colors(void);
+ void init_atlas_colors(void);
+ void init_small_atlas_colors(void);
+ void init_regenbogen_colors(void);
+ void init_regular_colors(void);
+ void init_windows_colors(void);
+};
+
+
+#undef HEADER_INCLUDED__DATA
+#define HEADER_INCLUDED__DATA
+
+#endif
+
diff --git a/src/modules/grid/grid_calculus_bsl/gr_syst.h b/src/modules/grid/grid_calculus_bsl/gr_syst.h
new file mode 100644
index 0000000..3d5a6d4
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/gr_syst.h
@@ -0,0 +1,15 @@
+#ifndef __gr_syst_h__
+#define __gr_syst_h__
+
+
+// Elementare Definitionen
+#define __MFC
+#define MODELL
+#define SMODELL
+
+// sonstiges
+//#define M_PI 3.14159265358979323846
+//#define M_PI_2 M_PI/2.0
+
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/grid_bsl.cpp b/src/modules/grid/grid_calculus_bsl/grid_bsl.cpp
new file mode 100644
index 0000000..123dec0
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/grid_bsl.cpp
@@ -0,0 +1,57 @@
+
+#include <string>
+
+#include "grid_bsl.h"
+
+using namespace std;
+
+GridWerte::GridWerte(void)
+{
+ xanz = 0;
+ yanz = 0;
+}
+
+GridWerte::~GridWerte(void)
+{
+ freeMem();
+}
+
+void GridWerte::getMem(void)
+{
+ Create(SG_DATATYPE_Float, xanz, yanz, dxy, xll, yll);
+}
+
+void GridWerte::freeMem(void)
+{
+ Destroy();
+}
+
+GridWerte& GridWerte::operator =(const GridWerte& W)
+{
+ dxy = W.dxy;
+ xll = W.xll;
+ yll = W.yll;
+ xanz = W.xanz;
+ yanz = W.yanz;
+ maxy = W.maxy;
+ miny = W.miny;
+
+ return( *this );
+}
+
+void GridWerte::calcMinMax(void)
+{
+ maxy = (*this)(0,0);
+ miny = (*this)(0,0);
+
+ for (int i=0; i<yanz; i++)
+ {
+ for (int j=0; j<xanz; j++)
+ {
+ maxy = M_GET_MAX((*this) (j,i), maxy);
+ miny = M_GET_MIN((*this) (j,i), miny);
+ }
+ }
+}
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/src/modules/grid/grid_calculus_bsl/grid_bsl.h b/src/modules/grid/grid_calculus_bsl/grid_bsl.h
new file mode 100644
index 0000000..2740eb5
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/grid_bsl.h
@@ -0,0 +1,39 @@
+#ifndef __GRID_H
+#define __GRID_H
+
+
+#include "gr_def.h"
+
+#include "MLB_Interface.h"
+
+class GridWerte :public CSG_Grid
+{
+public:
+
+ GridWerte(void);
+ virtual ~GridWerte(void);
+
+ double dxy, xll, yll;
+ long xanz, yanz;
+
+ void getMem (void);
+ void freeMem (void);
+
+ GridWerte & operator = (const GridWerte& W);
+
+ void calcMinMax (void);
+ double getMax (void) const { return( maxy ); };
+ double getMin (void) const { return( miny ); };
+
+ bool getHoeheRechtsHoch (double x, double y, double& erg) const;
+
+
+private:
+
+ double maxy, miny;
+
+};
+
+
+#endif
+
diff --git a/src/modules/grid/grid_calculus_bsl/interpolation.cpp b/src/modules/grid/grid_calculus_bsl/interpolation.cpp
new file mode 100644
index 0000000..d0bcc28
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/interpolation.cpp
@@ -0,0 +1,700 @@
+// interplation.cc
+//#include "../stdafx.h"
+
+#include <iostream>
+#include <math.h>
+#include <stdlib.h>
+
+#include "diverses.h"
+#include "interpolation.h"
+
+
+#define false 0
+#define true 1
+
+
+double LinPol(double x0, double y0, double x1, double y1, double x)
+{
+ if (x1 == x0)
+ return y0;
+ return (y1-y0)/(x1-x0)*(x-x0) + y0;
+}
+
+
+Interpolation::Interpolation( GridWerte& I) : W(I)
+{
+}
+
+void Interpolation::setParams(double minx, double miny, double dx, int anzx, int anzy)
+{
+ MinX = minx;
+ MinY = miny;
+ DX = dx;
+ AnzahlX = anzx;
+ AnzahlY = anzy;
+}
+
+void Interpolation::setZwischenwerte(void)
+{
+ MinX = 0.5f;
+ MinY = 0.5f;
+ DX = 1.0f;
+ AnzahlX = W.xanz -1;
+ AnzahlY = W.yanz -1;
+}
+
+void Interpolation::setDoppeltewerte(void)
+{
+ MinX = 0.0f;
+ MinY = 0.0f;
+ DX = 0.5f;
+ AnzahlX = 2*W.xanz -1;
+ AnzahlY = 2*W.yanz -1;
+}
+
+bool Interpolation::IsOk(void)
+{
+ return ( (MinX + AnzahlX*DX <= W.xanz)
+ && (MinY + AnzahlY*DX <= W.yanz)
+ && (MinX > 0)
+ && (MinY > 0)
+ && (DX > 0)
+ && (AnzahlX > 0)
+ && (AnzahlY > 0) );
+
+}
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Spline + Splinefloat
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+/*
+void QSpline::spline(double x[],double y[],int n, double yp1,double ypn,double y2[], double tmp_u[])
+{
+ int i,k;
+ double p,qn,sig,un, *u = tmp_u;
+
+
+ if (yp1 > 0.99e30)
+ y2[1]=u[1]=0.0f;
+ else {
+ y2[1] = -0.5f;
+ u[1]=(3.0f/(x[2]-x[1]))*((y[2]-y[1])/(x[2]-x[1])-yp1);
+ }
+ for (i=2;i<=n-1;i++) {
+ sig=(x[i]-x[i-1])/(x[i+1]-x[i-1]);
+ p=sig*y2[i-1]+2.0f;
+ y2[i]=(sig-1.0f)/p;
+ u[i]=(y[i+1]-y[i])/(x[i+1]-x[i]) - (y[i]-y[i-1])/(x[i]-x[i-1]);
+ u[i]=(6.0f*u[i]/(x[i+1]-x[i-1])-sig*u[i-1])/p;
+ }
+ if (ypn > 0.99e30f)
+ qn=un=0.0f;
+ else {
+ qn=0.5f;
+ un=(3.0f/(x[n]-x[n-1]))*(ypn-(y[n]-y[n-1])/(x[n]-x[n-1]));
+ }
+ y2[n]=(un-qn*u[n-1])/(qn*y2[n-1]+1.0f);
+ for (k=n-1;k>=1;k--)
+ y2[k]=y2[k]*y2[k+1]+u[k];
+}
+
+void QSpline::splint(double xa[],double ya[],double y2a[],int n, double x,double *y)
+{
+ int klo,khi,k;
+ double h,b,a;
+
+ klo=1;
+ khi=n;
+ while (khi-klo > 1) {
+ k=(khi+klo) >> 1;
+ if (xa[k] > x) khi=k;
+ else klo=k;
+ }
+ h=xa[khi]-xa[klo];
+ if (h == 0.0)
+ throw InterpolError("Bad XA input to routine SPLINT");
+ a=(xa[khi]-x)/h;
+ b=(x-xa[klo])/h;
+ *y=a*ya[klo]+b*ya[khi]+((a*a*a-a)*y2a[klo]+(b*b*b-b)*y2a[khi])*(h*h)/6.0f;
+}
+
+void QSpline::splie2(double x1a[], double x2a[], double **ya, int m, int n, double **y2a)
+{
+ int j;
+ double *tmp_u = new double [n];
+ for (j=1;j<=m;j++)
+ spline(x2a,ya[j],n,1.0e30f,1.0e30f,y2a[j], tmp_u);
+ delete[] tmp_u;
+}
+
+
+void QSpline::splin2(double x1a[], double x2a[], double **ya, double **y2a,
+ int m, int n, double x1, double x2, double *y,
+ double *ytmp, double *yytmp, double *tmp_u)
+{
+ int j;
+ for (j=1;j<=m;j++)
+ splint(x2a,ya[j],y2a[j],n,x2,&yytmp[j]);
+
+ spline(x1a,yytmp,m,1.0e30f,1.0e30f,ytmp, tmp_u);
+ splint(x1a,yytmp,ytmp,m,x1,y);
+}
+
+void QSpline::mysplin( double x1a[], double x2a[], double **ya, double **y2a,
+ GridWerte& Erg, int mm, int nn,
+ double *ytmp, double *yytmp, double *tmp_u)
+{
+ int j, m, n;
+ double y, x1, x2;
+
+ //m = Erg.yanz+1; // vorher G.yanz
+ //n = Erg.xanz+1; // vorher G.xanz
+
+ m = AnzahlY+1;
+ n = AnzahlX+1;
+
+ for (int n2=1; n2<n; n2++)
+ {
+ //x2 = double(n2)-0.5; // x
+ x2 = double(n2-1)*DX + MinX; // x
+
+ for (j=1;j<=mm;j++)
+ splint(x2a,ya[j],y2a[j],nn,x2,&yytmp[j]);
+
+ spline(x1a,yytmp,mm,1.0e30f,1.0e30f,ytmp, tmp_u);
+ for (int m2=1; m2<m; m2++)
+ {
+ //x1 = double(m2)-0.5; // y
+ x1 = double(m2-1)*DX+MinY; // y
+
+ splint(x1a,yytmp,ytmp,mm,x1,&y);
+ Erg(n2-1,m2-1) = y;
+ }
+ }
+}
+
+
+void QSpline::interpol(GridWerte& Erg)
+{
+
+ double *ya = new double[W.yanz+1];
+ double *xa = new double[W.xanz+1];
+ double **z = new double * [W.yanz+1];
+ double **z2a = new double * [W.yanz+1];
+ z[0] = new double[(W.yanz+1)*(W.xanz+1)];
+ z2a[0] = new double[(W.yanz+1)*(W.xanz+1)];
+
+ for (int i=0; i<W.yanz+1; i++)
+ {
+ z[i] = &(z[0][(W.xanz+1)*i]);
+ z2a[i] = &(z2a[0][(W.xanz+1)*i]);
+ }
+
+ for (i=1; i<W.yanz+1; i++)
+ ya[i] = double(i-1);
+
+ for (int j=1; j<W.xanz+1; j++)
+ xa[j] = double(j-1);
+
+ for (i=1; i<W.yanz+1; i++)
+ for (j=1; j<W.xanz+1; j++)
+ z[i][j] = W.Z[i-1][j-1];
+
+ int m=__max(W.yanz, W.xanz);
+ double *ytmp = new double[m+1];
+ double *yytmp = new double[m+1];
+ double *tmp_u = new double[m];
+
+ splie2(ya, xa, z, W.yanz, W.xanz, z2a);
+
+ Erg.yanz = AnzahlY;
+ Erg.xanz = AnzahlX;
+ Erg.xll = MinX*W.dxy + W.xll;
+ Erg.yll = MinY*W.dxy + W.yll;
+ Erg.dxy = W.dxy*DX;
+ Erg.getMem();
+ mysplin(ya, xa, z, z2a, Erg, W.yanz, W.xanz, ytmp, yytmp, tmp_u);
+
+ delete[] ytmp;
+ delete[] yytmp;
+ delete[] tmp_u;
+ delete[] ya;
+ delete[] xa;
+ delete[] z[0];
+ delete[] z2a[0];
+ delete[] z;
+ delete[] z2a;
+}
+
+*/
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Resample
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+void Resample::setTiefe(int T)
+{
+ Tiefe = T;
+}
+
+double Resample::sinc(double x)
+{
+
+ x *= M_PI;
+ double ret;
+ if (fabs(x) > 1e-12)
+ {
+ ret = sin(x);
+ ret /= x;
+ }
+ else
+ ret = 1.0f;
+
+ return ret;
+
+
+/*
+ // qubic polynom
+ x = fabs(x);
+ if (x <= 1.0f)
+ return (1-2*x*x+x*x*x);
+ if (x <= 2.0f)
+ return (4-8*x+5*x*x-x*x*x);
+ return 0.0f;
+*/
+}
+
+void Resample::interpol(GridWerte& Erg)
+{
+ int i;
+
+ Tiefe = W.xanz;
+ int T = Tiefe/2;
+ double sum;
+
+
+// double MinX, MinY, DX;
+// int AnzahlX, AnzahlY;
+
+ Erg.yanz = AnzahlY;
+ Erg.xanz = AnzahlX;
+ Erg.xll = MinX*W.dxy + W.xll;
+ Erg.yll = MinY*W.dxy + W.yll;
+ Erg.dxy = W.dxy*DX;
+ Erg.getMem();
+
+ double Mittelwert = 0;
+ for (i=0; i<AnzahlY; i++)
+ {
+ double M = 0;
+ for (int j=0; j<AnzahlX; j++)
+ M += (int)W(j,i);
+ Mittelwert += M/AnzahlX;
+ }
+ Mittelwert /= AnzahlY;
+
+ for (i=0; i<AnzahlY; i++)
+ {
+ for (int j=0; j<AnzahlX; j++)
+ {
+
+ double xhilf = MinX + j * DX;
+ double yhilf = MinY + i * DX;
+ int x = int(xhilf);
+ int y = int(yhilf);
+ double dx = xhilf - x;
+ double dy = yhilf - y;
+
+ sum = 0;
+ for (int u=0; u<Tiefe; u++)
+ {
+ double sum2 = 0;
+ for (int v=0; v<Tiefe; v++)
+ sum2 += sinc(xhilf-v)*(W(v,u)-Mittelwert);
+ sum += sum2*sinc(yhilf-u);
+ }
+ Erg.Set_Value(j,i, sum+Mittelwert);
+
+ /*
+ // eigentliche Berechnung
+ sum = 0;
+ for (u=-T+1; u<=T; u++)
+ {
+
+ double sum2 = 0;
+ for (v=-T+1; v<=T; v++)
+ if (innerhalb(I_Vec(x+v, y+u), W))
+ sum2 += sinc(v-dx)*W.Z[y+u][x+v];
+ sum += sum2*sinc(u-dy);
+ }
+ Erg.Z[i][j] = sum;
+ */
+ }
+ }
+}
+
+/*
+ PROGRAM TRESAMPLE
+************************************************************************
+* Autor : Dipl. Geogr. Ruediger Koethe
+* Geographisches Institut der Universitaet Goettingen
+* Goldschmidtstr. 5, 3400 Goettingen
+* verändert von : Corinna Walther
+* Erstellt am : 21-OCT-1993 15:04
+* Letzte Aenderung : 29-JAN-1996 19:13
+************************************************************************
+C
+C Kurzbeschreibung:
+C -----------------
+C
+C Testprogramm für SARA zum Einbinden der Subroutine DGM_RESAMPLE
+C
+C Aufbau von binaeren DGM-Dateien:
+C - unformatierte sequentielle Datei
+C - 3 Header-Records:
+C -- 1.: Titelzeile (C*80)
+C -- 2.: Herkunft des DGM (C*80)
+C -- 3.: Rasterweite (R), X-Welt-Koordinate SW-Ecke (R),
+C Y-Welt-Koordinate SW-Ecke (R), Anzahl der Hoehenwerte in
+C X-Richtung (I), Anzahl der Hoehenwerte in Y-Richtung (I),
+C Format der Hoehenwerte (2 = I*2, 4 = R*4) (I)
+C - Datenteil mit je einer Matrix-Zeile von Hoehenwerten pro Record als
+C I*2- oder R*4-Werte
+C
+C-----------------------------------------------------------------------
+ IMPLICIT NONE
+C-----------------------------------------------------------------------
+C
+C Referenzen:
+C -----------
+ INTEGER LAENGE
+ EXTERNAL LAENGE, SET_XYNB, GL_RANDMVH, GL_MVINTPOL, DGM_RESAMPLE
+C
+C-----------------------------------------------------------------------
+C
+C Common-Bloecke:
+C ---------------
+C----------------------------------------------------------------------
+C Dimensionierung der DGM-Matrix
+ INTEGER OGR
+ PARAMETER (OGR=961)
+C----------------------------------------------------------------------
+C Common-Block /DGMHOH/ Matrix mit Hoehenwerten des DGM
+C HOEHE = R Hoehe ueber NN in Meter
+ REAL HOEHE(OGR,OGR)
+ COMMON /DGMHOH/ HOEHE
+C-----------------------------------------------------------------------
+C Common-Block /HOEHE_3/ Matrix mit Hoehenwerten des DRM
+C HOEHE3 = R(OGR,OGR) Hoehe ueber NN in Meter
+ REAL HOEHE3(OGR,OGR)
+ COMMON /HOEHE_3/ HOEHE3
+C=======================================================================
+
+ INTEGER L1, L2, U1, U2, U3, XOGR, YOGR, X, Y, DATTYP, NMVH,
+ & XMAX3, YMAX3,xmax,ymax
+ INTEGER*2 I2X, I2Y
+ REAL DXY3, GEWRZ, DXY, XMIN, YMIN, MVWERT,STARTX3,STARTY3
+ CHARACTER NAME1*80, NAME2*80, TITEL*80, HKNFT*80, TITEL2*80
+ LOGICAL EXIS
+
+ U1 = 1
+ U2 = 2
+ U3 = 3
+
+ WRITE (*,*) ' '
+ WRITE (*,*) 'Programm DGMGLATT zur Aufbereitung von DGM mit ',
+ & 'gerundeten Höhenwerten'
+ WRITE (*,*) ' '
+
+C Name der DGM-Datei mit gerundeten Hoehenwerten erfragen
+C und Datei oeffnen
+10 WRITE (*,*) 'Name der DGM-Datei mit gerundeten Höhenwerten ',
+ & '(ohne Extension):'
+ READ (*,'(A)') NAME1
+ L1 = LAENGE(NAME1)
+ INQUIRE(FILE=NAME1(1:L1)//'.BIN',EXIST=EXIS)
+ IF (.NOT.EXIS) THEN
+ WRITE (*,*) '-E- Diese Datei existiert nicht'
+ GOTO 10
+ END IF
+ OPEN(UNIT=U1,FILE=NAME1(1:L1)//'.BIN',STATUS='OLD',
+ & FORM='UNFORMATTED',ERR=910,READONLY)
+
+C Name fuer DGM-Datei mit aufbereiteten Hoehenwerten erfragen
+C und Datei oeffnen
+20 WRITE (*,*) 'Name für die aufbereitete DGM-Datei ',
+ & '(ohne Extension):'
+ READ (*,'(A)') NAME2
+ IF (NAME1.EQ.NAME2) THEN
+ WRITE (*,*) '-W- Für aufbereitete DGM-Datei bitte anderen ',
+ & 'Namen verwenden'
+ GOTO 20
+ END IF
+ L2 = LAENGE(NAME2)
+ OPEN(UNIT=U2,FILE=NAME2(1:L2)//'.BIN',STATUS='NEW',ERR=920,
+ & FORM='UNFORMATTED')
+ WRITE (*,*) 'Titelzeile für aufbereitete DGM-Datei:'
+ WRITE (*,*) '(Bei Eingabe von <RETURN> wird alte Titelzeile ',
+ & 'genommen)'
+ READ (*,'(A)') TITEL2
+ IF (LAENGE(TITEL2).EQ.0) TITEL2 = TITEL
+
+30 WRITE (*,*) 'Bitte neue Rasterweite (m) angeben:'
+ READ (*,*,ERR=40) DXY3
+ GOTO 50
+40 WRITE (*,*) '-E- Falsche Eingabe'
+ GOTO 30
+50 CONTINUE
+
+60 WRITE (*,*) 'Abstand des neuen ersten Gitterpunktes (lu)',
+ & 'vom alten (Wert >= 1 (< 2 Empf.)): (x,y)'
+ READ (*,*,ERR=70) STARTX3, STARTY3
+ GOTO 80
+70 WRITE (*,*) '-E- Falsche Eingabe'
+ GOTO 60
+80 CONTINUE
+
+CC Relative Nachbar-Koordinaten einer RZ initialisieren
+C CALL SET_XYNB
+
+C DGM-Datei mit gerundeten Hoehenwerten lesen
+ WRITE (*,*) '-I- Die DGM-Datei mit den gerundeten ',
+ & 'Höhenwerten wird gelesen...'
+ CALL READ_DGMBIN(0,U1,TITEL,HKNFT,DXY,XMIN,YMIN,XOGR,YOGR,DATTYP)
+ WRITE (*,*) HOEHE(1,1)
+ write (*,*) hoehe(2,2)
+
+
+C DGM generalisieren
+C Programm zum Generalisieren wird gerufen
+ WRITE (*,*) '-I- Die DGM-Datei wird generalisiert'
+ WRITE (*,*) DXY3,STARTX3,STARTY3,xogr,yogr
+
+ CALL DGM_RESAMPLE(DXY,DXY3,STARTX3,STARTY3,XOGR,YOGR,XMAX3,YMAX3)
+ WRITE (*,*) XMAX3,YMAX3
+ write (*,*) 'Hoehe3(1,1)=', hoehe3(1,1)
+
+C DGM-Datei mit generalisierten Hoehenwerten erzeugen
+ WRITE (*,*) '-I- Die DGM-Datei mit den generalisierten ',
+ & 'Höhenwerten wird erzeugt...'
+C ...Header schreiben
+ WRITE (U2) TITEL2
+ WRITE (U2) HKNFT
+ WRITE (U2) DXY3, XMIN+(STARTX3*DXY),
+ & YMIN+(STARTY3*DXY), XMAX3, YMAX3, DATTYP
+C ...Hoehenwerte schreiben
+ DO 200 Y=1,YMAX3
+ WRITE (U2) (HOEHE3(X,Y),X=1,XMAX3)
+200 CONTINUE
+
+C Dateien schliessen
+ CLOSE(U1)
+ CLOSE(U2)
+ STOP
+
+C Fehlerbehandlung
+910 WRITE (*,*) '-F- Fehler beim Öffnen der DGM-Datei mit ',
+ & 'gerundeteten Höhenwerten'
+ STOP
+
+920 WRITE (*,*) '-F- Fehler beim Öffnen der DGM-Datei für ',
+ & 'die aufbereiteten Höhenwerte'
+ STOP
+ END
+
+ SUBROUTINE DGM_RESAMPLE(DXY2,DXY3,STARTX3,STARTY3,XMAX2,YMAX2,
+ & XMAX3,YMAX3)
+************************************************************************
+* Autor : Christian Trachinow / Corinna Walther
+* Geographisches Institut der Universitaet Goettingen
+* Goldschmidtstr. 5, 3400 Goettingen
+* Erstellt am : 14-DEC-1995 12:06
+* Letzte Aenderung : 15-JAN-1996 16:50
+************************************************************************
+C
+C Kurzbeschreibung:
+C -----------------
+C Programm zur Generalisierung von DGM aus SARADRM
+C STARTX3 und STARTY3
+C
+C Eingabe:
+C --------
+C ueber Parameterliste:
+C BINUNIT = I, Unit-Nr. unter der die binaere Datei geoeffnet wurde
+C DXY3 = R, gewuenschte neue Rasterweite
+C STARTX3 = R, Abstand des ersten Punktes der gener. Matrix vom
+C ersten Punkt der alten Matrix (in Rasterzellen),
+C muss groesser gleich 1 sein (optimal 1 <= ... <2)
+C STARTY3 = R, siehe STARTX3
+C
+C ueber Common-Block:
+C /HOEHE_2/ (S.U.): XOGR, YOGR
+C /MATRIX2/ (s.u.): XMANF, YMANF
+C
+C Ausgabe:
+C --------
+C ueber Common-Block:
+C /HOEHE_3/ (s.u.): XOGR, YOGR
+C
+C
+C-----------------------------------------------------------------------
+ IMPLICIT NONE
+C-----------------------------------------------------------------------
+C
+C Referenzen:
+C -----------
+ REAL CUBICP
+ EXTERNAL READ_DGMBIN, CUBICP
+ INTRINSIC INT, ABS
+C
+C-----------------------------------------------------------------------
+C
+C COMMON-Bloecke:
+C ---------------
+C-----------------------------------------------------------------------
+C Dimensionierung der DRM-Matrizen
+ INTEGER OGR
+ PARAMETER (OGR=961)
+C-----------------------------------------------------------------------
+C Common-Block /DGMHOH/ Matrix mit Hoehenwerten des DRM
+C HOEHE2 = R(OGR,OGR) Hoehe ueber NN in Meter
+ REAL HOEHE2(OGR,OGR)
+ COMMON /DGMHOH/ HOEHE2
+C-----------------------------------------------------------------------
+C Common-Block /HOEHE_3/ Matrix mit Hoehenwerten des DRM
+C HOEHE3 = R(OGR,OGR) Hoehe ueber NN in Meter
+ REAL HOEHE3(OGR,OGR)
+ COMMON /HOEHE_3/ HOEHE3
+C-----------------------------------------------------------------------
+C es fehlen: die alte Rasterweite DXY2
+C die tatsaechlich im Commonblock vorhandene Anzahl der Werte
+C XMAX2
+C YMAX2
+C die Gauss-Krueger-Koordinaten der linken unteren Ecke der
+C alten Matrix XLL2
+C YLL2
+C Ausgabe:
+C die vorhandene Anzahl der neuen Werte
+C XMAX3
+C YMAX3
+C die Gauss-Krueger-Koordinaten der linken unteren Ecke der
+C alten Matrix XLL3
+C YLL3
+C=======================================================================
+C Eingabe
+ REAL NEWDXY, STARTX3, ABSTANDX2, ABSTANDX3, ABSTANDY2, ABSTANDY3,
+ & N3, STARTY3, XLL2, YLL2, XLL3, YLL3, DM, DN, SUM, MHILF,
+ & NHILF, DXY3, DXY2, SUM2, FELD16(-1:2,-1:2), WERTSUM, WERT
+
+ INTEGER U, V, XMAX2, YMAX2, XMAX3, YMAX3, N, M, NS, MS, Y,
+ & MESS, BINUNIT, DATTYP
+ CHARACTER TITEL*80, HKNFT*80
+
+C Liest Hoehenwerte in Commonblock HOEHE_2...
+C CALL READ_DGMBIN(2,BINUNIT,TITEL,HKNFT,DXY2,XLL2,YLL2,XMAX2,YMAX2,
+C & DATTYP)
+
+C Ermittlung der neuen Anzahl von Rasterpunkten (STARTX3 uebergeben
+C mit einem Wert zwischen 1 und 2)
+C Berechnung der alten Matrixgroesse...
+ ABSTANDX2 = (XMAX2 - 1) * DXY2
+ ABSTANDY2 = (YMAX2 - 1) * DXY2
+C Berechnung der neuen Matrixgroesse...
+ ABSTANDX3 = ABSTANDX2 - STARTX3 * DXY2 - DXY2
+ ABSTANDY3 = ABSTANDY2 - STARTY3 * DXY2 - DXY2
+C auf geraden Werte runden...
+C XMAX3 und YMAX3 = Anzahl der neuen Rasterpunkte...
+ XMAX3 = INT(ABSTANDX3 / DXY3)
+ IF (ABSTANDX3 / DXY3 - REAL(XMAX3) .GT. 0.00001) THEN
+ XMAX3 = XMAX3 + 1
+ END IF
+ YMAX3 = INT(ABSTANDY3 / DXY3)
+ IF (ABSTANDY3 / DXY3 - REAL(YMAX3) .GT. 0.00001) THEN
+ YMAX3 = YMAX3 + 1
+ END IF
+
+C neue Matrixgroesse...
+ ABSTANDX3 = (XMAX3 - 1) * DXY3
+ ABSTANDY3 = (YMAX3 - 1) * DXY3
+ WRITE (*,*) 'xmax3=', xmax3 , 'ymax3=', ymax3
+ WRITE (*,*) 'abstandx3=', abstandx3 , 'abstandy3=', abstandy3
+
+C Bildung der gewichteten Mittel pro neuem Rasterpunkt...
+ DO 10 NS = 1, XMAX3
+ DO 20 MS = 1, YMAX3
+ NHILF = STARTX3 + (NS - 1) * DXY3 / DXY2 + 1
+ MHILF = STARTY3 + (MS - 1) * DXY3 / DXY2 + 1
+C write (*,*) 'nhilf=', nhilf, 'mhilf=', mhilf
+C write (*,*) 'ns=', ns, 'ms=', ms
+ N = INT(NHILF)
+ M = INT(MHILF)
+ DN = NHILF - N
+ DM = MHILF - M
+C write (*,*) 'dn=', dn, 'dm=', dm
+ SUM = 0.0
+C 16 Werte einlesen und auf Missing Values überprüfen....
+ Y = 0
+ WERTSUM = 0.0
+ WERT = 0.0
+ DO 90 U = -1,2
+ Do 99 V = -1,2
+ WERT = HOEHE2(N + V, M + U)
+ IF (WERT .EQ. -999.0) THEN
+ Y = Y + 1
+ ELSE
+ WERTSUM = WERTSUM + WERT
+ END IF
+ FELD16(V,U) = WERT
+99 CONTINUE
+90 CONTINUE
+C wenn mehr als 8 Werte MV sind, ist der neue Höhenwert auch ein
+C MV, wenn weniger vorhanden sind, wird an ihrer Stelle der arithm.
+C Mittelwert der übrigen Höhenwerte eingesetzt...
+ IF (Y .GE. 8) THEN
+ HOEHE3(NS,MS) = -999.0
+ GOTO 20
+ ELSE IF (Y .GT. 0) THEN
+ WERT = WERTSUM / (16 - Y)
+ DO 100 U = -1,2
+ DO 101 V = -1,2
+ IF (FELD16(V, U) .EQ. -999.0) FELD16(V, U) = WERT
+101 CONTINUE
+100 CONTINUE
+ END IF
+ DO 30 U = -1,2
+ SUM2 = 0
+ DO 40 V = -1,2
+ SUM2 = SUM2 + CUBICP(V - DN) * FELD16(V, U)
+C write (*,*) 'cubicp(v-dn)=', cubicp(v - dn)
+C WRITE (*,*) 'Hoehe2=', hoehe2(n + v, m + u)
+C write (*,*) 'sum=', sum
+40 CONTINUE
+ SUM = SUM + SUM2 * CUBICP(U - DM)
+C write (*,*) 'cubicp(u-dm)=', cubicp(u - dm)
+C write (*,*) 'sum=', sum
+30 CONTINUE
+ HOEHE3(NS,MS) = SUM
+C WRITE (*,*) 'Hoehe3=', hoehe3(ns,ms)
+20 CONTINUE
+10 CONTINUE
+
+ XLL3 = STARTX3*DXY2
+ YLL3 = STARTY3*DXY2
+
+ RETURN
+ END
+
+ FUNCTION CUBICP(Z)
+ REAL Z
+ IF (ABS(Z) .GE. 0.0 .AND. ABS(Z) .LE. 1.0) THEN
+ CUBICP = 1 - 2*Z*Z + ABS(Z*Z*Z)
+ ELSE IF (ABS(Z) .GT. 1.0 .AND. ABS(Z) .LE. 2.0) THEN
+ CUBICP = 4 - 8* ABS(Z) + 5*Z*Z - ABS(Z*Z*Z)
+ ELSE
+ CUBICP = 0.0
+ END IF
+ RETURN
+ END
+
+*/
+
diff --git a/src/modules/grid/grid_calculus_bsl/interpolation.h b/src/modules/grid/grid_calculus_bsl/interpolation.h
new file mode 100644
index 0000000..f46e0b5
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/interpolation.h
@@ -0,0 +1,76 @@
+#ifndef __INTERPOL_H
+#define __INTERPOL_H
+
+
+#include "grid_bsl.h"
+
+double LinPol(double x0, double y0, double x1, double y1, double x);
+
+class MathError
+{
+public:
+ MathError(){};
+};
+
+class InterpolError: public MathError
+{
+public:
+ InterpolError(const char *s) : S(s) {};
+
+ const char *S;
+};
+
+class Interpolation
+{
+public:
+ Interpolation( GridWerte& I);
+ virtual ~Interpolation() {};
+
+ void setParams(double minx, double miny, double dx, int anzx, int anzy);
+ virtual void interpol(GridWerte& G) = 0;
+ void setZwischenwerte(void);
+ void setDoppeltewerte(void);
+ bool IsOk(void);
+protected:
+ GridWerte& W;
+ double MinX, MinY, DX;
+ int AnzahlX, AnzahlY;
+};
+
+class QSpline : public Interpolation
+{
+public:
+ QSpline( GridWerte& I) : Interpolation(I) {};
+ ~QSpline() {};
+
+ virtual void interpol(GridWerte& G);
+
+private:
+ void spline(double x[],double y[],int n, double yp1,double ypn,double y2[], double tmp_u[]);
+ void splint(double xa[],double ya[],double y2a[],int n, double x,double *y);
+ void splie2(double x1a[], double x2a[], double **ya, int m, int n, double **y2a);
+ void splin2(double x1a[], double x2a[], double **ya, double **y2a,
+ int m, int n, double x1, double x2, double *y,
+ double *ytmp, double *yytmp, double *tmp_u);
+ void mysplin(double x1a[], double x2a[], double **ya, double **y2a,
+ GridWerte& Erg, int mm, int nn,
+ double *ytmp, double *yytmp, double *tmp_u);
+};
+
+class Resample : public Interpolation
+{
+public:
+ Resample( GridWerte& I) : Interpolation(I), Tiefe(4) {};
+ ~Resample() {};
+
+ void setTiefe(int T);
+ virtual void interpol(GridWerte& G);
+
+private:
+ double sinc(double x);
+
+ int Tiefe;
+};
+
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/pars_all.cpp b/src/modules/grid/grid_calculus_bsl/pars_all.cpp
new file mode 100644
index 0000000..29550cb
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/pars_all.cpp
@@ -0,0 +1,292 @@
+
+//#include "..\stdafx.h"
+#include <string>
+
+#include "pars_all.h"
+#include <deque>
+
+
+using namespace std;
+
+T_AnweisungList AnweisungList;
+
+
+/*
+ Anweisungen sind 1.) foreach
+ 2.) if
+ 3.) Zuweisung
+ 4.) Funktion (ohne Zuweisung aufgerufen)
+
+ */
+
+
+bool getNextZuweisung(const string& s, int& pos, string& erg)
+{
+ // Erstellt string von (zeile, pos) bis zum nächsten Komma
+ string sub = s.substr(pos);
+ erg = "";
+ int p;
+
+ if ((p = sub.find_first_of(';')) >= 0)
+ {
+ sub.erase(p, sub.size());
+ pos += p;
+ erg = sub;
+ return true;
+ }
+ return false;
+}
+
+bool getFunktion(const string& s, int& pos, string& erg)
+{
+ string zeile;
+ if (!getNextZuweisung(s, pos, zeile))
+ return false;
+ BBFktExe *f = NULL;
+ if (isFunktion(zeile, f, false))
+ {
+ erg = zeile;
+ return true;
+ }
+ return false;
+}
+
+bool isKommentar(const string& s, int& p)
+{
+ char f = s[p], n = s[p+1];
+
+ // whitespaces vorne entfernen
+ // !!!
+#define WHITE_SP " \r\t\n"
+ int pos = s.find_first_not_of(WHITE_SP, p);
+ if (pos >= 0 && s[pos] == '/' && s[pos+1] == '/')
+ {
+ // Kommentar bis Ende der Zeile
+ pos = s.find("\n", pos+2);
+ if (pos > 0)
+ p = pos;
+ else // letzte Zeile
+ p = s.length();
+ return true;
+ }
+ return false;
+}
+
+
+void pars_ausdruck_string(const string& s, T_AnweisungList & al)
+{
+ int pos = 0;
+ BBForEach *f;
+ BBIf *If;
+ string anweisungen, anweisungen_else;
+ int p;
+
+ do
+ {
+ FehlerString = s.substr(pos);
+ p = pos;
+ if (isKommentar(s, p))
+ {
+ pos = p;
+ continue;
+ }
+ p = pos;
+ if (isForEach(s, p, f, anweisungen))
+ {
+ int offset = anweisungen.size();
+ trim(anweisungen);
+ offset -= anweisungen.size();
+ // neue AL erzeugen
+ BBAnweisung *a;
+ a = new BBAnweisung;
+ a->typ = BBAnweisung::ForEach;
+ a->AnweisungVar.For = f;
+ FehlerZeile += p + offset + 1 - pos;
+ FehlerString = s.substr(p);
+ try
+ {
+ pars_ausdruck_string(anweisungen, a->AnweisungVar.For->z);
+ }
+ catch (BBFehlerException)
+ {
+ delete a;
+ throw BBFehlerException(pos);
+ }
+ al.push_back(a);
+ pos = p + offset + 1 + anweisungen.size();
+ }
+ else
+ {
+ p = pos;
+ if (isIf(s, p, If, anweisungen, anweisungen_else))
+ {
+ //int offset = anweisungen.size();
+ trim(anweisungen);
+ trim(anweisungen_else);
+ // neue AL erzeugen
+ BBAnweisung *a;
+ a = new BBAnweisung;
+ a->typ = BBAnweisung::IF;
+ a->AnweisungVar.IF = If;
+ //FehlerZeile += p + offset + 1 - pos;
+ FehlerString = anweisungen;
+ FehlerZeile += p + 1 - pos;
+ FehlerZeile -= anweisungen.size();
+ if (If->isElse)
+ FehlerZeile -= anweisungen_else.size();
+ try
+ {
+ pars_ausdruck_string(anweisungen, a->AnweisungVar.IF->z);
+ if (If->isElse)
+ {
+ FehlerZeile += anweisungen.size();
+ FehlerString = anweisungen_else;
+ pars_ausdruck_string(anweisungen_else, a->AnweisungVar.IF->zelse);
+ }
+ }
+ catch (BBFehlerException)
+ {
+ delete a;
+ throw BBFehlerException(pos);
+ }
+ al.push_back(a);
+ // pos = p + offset + 1;
+ pos = p + 1;
+ }
+ else
+ {
+ p = pos;
+ FehlerString = s.substr(p);
+ if (getFunktion(s, p, anweisungen))
+ {
+ BBFktExe *fkt;
+ if (!isFunktion(anweisungen, fkt, true, true)) // alle Funktionen erwünscht
+ throw BBFehlerException(pos);
+ BBAnweisung *a;
+ a = new BBAnweisung;
+ a->typ = BBAnweisung::Funktion;
+ a->AnweisungVar.Fkt = fkt;
+ al.push_back(a);
+ p++; //Komma entfernen
+ FehlerZeile += p - pos;
+ FehlerString = s.substr(p);
+ pos = p;
+ }
+ else
+ {
+ p = pos;
+ if (getNextZuweisung(s, p, anweisungen))
+ {
+ BBZuweisung *Z;
+ trim(anweisungen);
+ if (isZuweisung(anweisungen, Z))
+ {
+ // neue AL erzeugen
+ BBAnweisung *a;
+ a = new BBAnweisung;
+ a->typ = BBAnweisung::Zuweisung;
+ a->AnweisungVar.Zu = Z;
+ al.push_back(a);
+ p++; //Komma entfernen
+ FehlerZeile += p - pos;
+ FehlerString = s.substr(p);
+ pos = p;
+ }
+ else
+ throw BBFehlerException(pos);
+ }
+ else
+ throw BBFehlerException(pos);
+ }
+ }
+ }
+ } while (pos < s.size());
+}
+
+void pars_ausdruck(int& zeile, int& pos)
+{
+ int i;
+ int zeile_save = zeile;
+ int pos_save = pos;
+ long size_inputtext;
+ vector<int> InputZeilenNummer;
+// deque<int> InputZeilenNummer;
+
+ long size_of_crlf = strlen("\n");
+ FehlerZeile = 0;
+ FehlerString = "";
+ size_inputtext = InputText.size();
+ if (zeile >= InputText.size())
+ throw BBFehlerException(zeile);
+// T_AnweisungList a;
+ string s = "";
+ long size = 0;
+ for (int i1=0; i1 < InputText.size(); i1++)
+ size += InputText[i1].size() + size_of_crlf;
+ char *s_buff = new char[size+1];
+ //s.reserve(size);
+
+ InputZeilenNummer.reserve(5000);
+ // wenn (zeile,pos) am Zeilenende -> neue Zeile
+ if (pos >= InputText[zeile].size())
+ {
+ zeile++;
+ pos = 0;
+ if (zeile >= InputText.size())
+ return;
+ }
+
+ // erste Zeile
+ s = InputText[zeile].substr(pos);
+ InputZeilenNummer.push_back(pos); // ????
+
+ // alle weiteren Zeilen
+ long size_s_buff = 0;
+ for (i=zeile/*+1*/; i<size_inputtext; i++)
+ {
+///*!!!*/ s += "\n";
+// s += InputText[i];
+ long l = InputText[i].size();
+ strcpy(s_buff+size_s_buff, "\n");
+ strcpy(s_buff+size_s_buff+size_of_crlf, InputText[i].data());
+ size_s_buff += l+size_of_crlf;
+
+// InputZeilenNummer.push_back((InputZeilenNummer[i-zeile-1] + InputText[i].size()));
+ if( i > zeile )
+ InputZeilenNummer.push_back((InputZeilenNummer[i-zeile-1] + InputText[i].size() + 1 /* CR + LF ist nur 1 char ???*/ ));
+ }
+ s_buff[size_s_buff] = 0;
+ s = s_buff;
+ delete[] s_buff;
+
+ // nur hinten abschneiden
+ int pos1 = s.find_last_not_of(" \t\n");
+ if (pos1 >= 0)
+ {
+ // s.erase(&s[pos1+1], s.end());
+ s.erase(s.begin()+pos1+1, s.end());
+ }
+
+ try
+ {
+ pars_ausdruck_string(s, AnweisungList);
+ }
+ catch (BBFehlerException)
+ {
+ // Übersetzen in Zeilen-Nummer
+ for (i=0; i<InputZeilenNummer.size(); i++)
+ {
+ int znr = InputZeilenNummer[i];
+ if (FehlerZeile < InputZeilenNummer[i])
+ {
+ FehlerZeile = i+zeile_save+1;
+ throw BBFehlerException();
+ }
+ }
+ if (i == InputZeilenNummer.size()) // falls letzte Zeile
+ FehlerZeile = i+zeile_save+1;
+ else
+ FehlerZeile = zeile_save+1;
+ throw BBFehlerException();
+ }
+}
diff --git a/src/modules/grid/grid_calculus_bsl/pars_all.h b/src/modules/grid/grid_calculus_bsl/pars_all.h
new file mode 100644
index 0000000..ab87cdd
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/pars_all.h
@@ -0,0 +1,13 @@
+#ifndef __PARS_ALL_H
+#define __PARS_ALL_H
+
+#include "foreach.h"
+#include "bedingung.h"
+
+extern T_AnweisungList AnweisungList;
+
+void pars_ausdruck_string(const std::string& s, T_AnweisungList & al);
+void pars_ausdruck(int& zeile, int& pos);
+
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/vector.cpp b/src/modules/grid/grid_calculus_bsl/vector.cpp
new file mode 100644
index 0000000..435892c
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/vector.cpp
@@ -0,0 +1,548 @@
+////////////////////////////////////////////////////////////////////////////
+// Programm :
+// Bibliothek : vector.cpp
+// Header-Datei:
+//
+////////////////////////////////////////////////////////////////////////////
+//
+// Autoren : Christian Trachinow
+// Joerg Dolle
+//
+// Telefon-Nr. : 0551/66437
+// Mail-Adresse : jdolle at gwdg.de
+//
+////////////////////////////////////////////////////////////////////////////
+//
+// Compiler : Borland C++ V.: 4.00
+// Ersterstellung : 16.11.95
+// Ueberarbeitung : 22.04.96
+//
+// Programmversion: 1.01
+//
+////////////////////////////////////////////////////////////////////////////
+
+
+/****************** Include-Dateien **************/
+
+#include "MLB_Interface.h"
+//#include ".\..\INCLUDE\MAT_Tools.h" // für M_PI etc...
+
+#include "vector.h"
+
+
+//Do * 2D-Vectorklasse ***********************************************
+C_Vec2::C_Vec2(double x_neu, double y_neu)
+{
+ x = x_neu;
+ y = y_neu;
+}
+
+C_Vec2::C_Vec2(const C_Vec2& V)
+{
+ x = V.x;
+ y = V.y;
+}
+
+C_Vec2::~C_Vec2()
+{
+}
+
+void C_Vec2::setPolar(double l, double a)
+{
+ x = double(l*cos(a));
+ y = double(l*sin(a));
+}
+
+
+C_Vec2& C_Vec2::operator = (const C_Vec2& v)
+{
+ x = v.x;
+ y = v.y;
+ return *this;
+}
+
+C_Vec2& C_Vec2::operator += (const C_Vec2& v)
+{
+ x += v.x;
+ y += v.y;
+ return *this;
+}
+
+C_Vec2& C_Vec2::operator -= (const C_Vec2& v)
+{
+ x -= v.x;
+ y -= v.y;
+ return *this;
+}
+
+C_Vec2 operator + (const C_Vec2& w,const C_Vec2& v)
+{
+
+ return C_Vec2(w.x+v.x, w.y+v.y);
+}
+
+C_Vec2 operator - (const C_Vec2& w,const C_Vec2& v)
+{
+ return C_Vec2(w.x-v.x, w.y-v.y);
+}
+
+C_Vec2 C_Vec2::operator - ()
+{
+ return C_Vec2(-x, -y);
+}
+
+C_Vec2& C_Vec2::operator /= (double v)
+{
+ x = x/v;
+ y = y/v;
+ return *this;
+}
+
+C_Vec2& C_Vec2::operator *= (double v)
+{
+ x = x*v;
+ y = y*v;
+ return *this;
+}
+
+C_Vec2 operator * (const C_Vec2& w, double v)
+{
+ return C_Vec2(double (w.x*v), double (w.y*v));
+}
+
+C_Vec2 operator / (const C_Vec2& w, double v)
+{
+ return C_Vec2(double(w.x/v), double(w.y/v));
+}
+
+C_Vec2 operator * (double v,const C_Vec2& w)
+{
+ return C_Vec2(double(w.x*v), double(w.y*v));
+}
+
+C_Vec2 operator / (double v,const C_Vec2& w)
+{
+ return C_Vec2(double(w.x/v), double(w.y/v));
+}
+
+
+double operator * (const C_Vec2& v, const C_Vec2& w)
+{
+ return ((v.x*w.x) + (v.y*w.y));
+}
+
+
+double operator < (const C_Vec2& v, const C_Vec2& w)
+{
+ return double(acos((v*w) / (v.Length() * w.Length())));
+}
+
+
+// *** Funktionen **************
+double C_Vec2::X(void) const
+{
+ return x;
+}
+
+double C_Vec2::Y(void) const
+{
+ return y;
+}
+
+double C_Vec2::Length(void) const
+{
+ return double(sqrt(x*x+y*y));
+}
+
+double C_Vec2::Angle(void) const
+{
+ // Angabe es Polarwinkels in rad
+ if (x > 0.0f) return double(atan(y/x));
+ if (x < 0.0f) return double(atan(y/x) + M_PI);
+ if (x == 0.0f || y > 0.0f) return double(M_PI_090);
+ if (x == 0.0f || y < 0.0f) return double(-M_PI_090);
+ return 0.0f;
+}
+
+//****************************************************************
+
+
+
+//Do * 3D-Vectorklasse ***********************************************
+C_Vec3::C_Vec3(double x_neu, double y_neu, double z_neu)
+{
+ x = x_neu;
+ y = y_neu;
+ z = z_neu;
+}
+
+
+C_Vec3::C_Vec3(const C_Vec3& V)
+{
+ x = V.x;
+ y = V.y;
+ z = V.z;
+}
+
+C_Vec3::~C_Vec3()
+{
+}
+
+void C_Vec3::setPolar(double l, double a_phi, double a_psi)
+{
+ x = double(l*sin(a_psi)*sin(a_phi));
+ y = double(l*sin(a_psi)*cos(a_phi));
+ z = double(l*cos(a_psi));
+}
+
+
+
+C_Vec3& C_Vec3::operator = (const C_Vec3& v)
+{
+ x = v.x;
+ y = v.y;
+ z = v.z;
+ return *this;
+}
+
+C_Vec3& C_Vec3::operator += (const C_Vec3& v)
+{
+ x += v.x;
+ y += v.y;
+ z += v.z;
+ return *this;
+}
+
+C_Vec3& C_Vec3::operator -= (const C_Vec3& v)
+{
+ x -= v.x;
+ y -= v.y;
+ z -= v.z;
+ return *this;
+}
+
+C_Vec3 operator + (const C_Vec3& w,const C_Vec3& v)
+{
+ return C_Vec3(w.x+v.x, w.y+v.y, w.z+v.z);
+}
+
+C_Vec3 operator - (const C_Vec3& w,const C_Vec3& v)
+{
+ return C_Vec3(w.x-v.x, w.y-v.y, w.z-v.z);
+}
+
+C_Vec3 C_Vec3::operator - (const C_Vec3 &v)
+{
+ return C_Vec3(-v.x, -v.y, -v.z);
+}
+
+C_Vec3& C_Vec3::operator /= (double v)
+{
+ x = x/v;
+ y = y/v;
+ z = z/v;
+ return *this;
+}
+
+C_Vec3& C_Vec3::operator *= (double v)
+{
+ x = x*v;
+ y = y*v;
+ z = z*v;
+ return *this;
+}
+
+C_Vec3 operator * (const C_Vec3& w, double v)
+{
+ return C_Vec3(w.x*v, w.y*v, w.z*v);
+}
+
+C_Vec3 operator / (const C_Vec3& w, double v)
+{
+ return C_Vec3(w.x/v, w.y/v, w.z/v);
+}
+
+C_Vec3 operator * (double v,const C_Vec3& w)
+{
+ return C_Vec3(w.x*v, w.y*v, w.z*v);
+}
+
+C_Vec3 operator / (double v,const C_Vec3& w)
+{
+ return C_Vec3(w.x/v, w.y/v, w.z/v);
+}
+
+
+double operator * (const C_Vec3& v, const C_Vec3& w)
+{
+ return ((v.x*w.x) + (v.y*w.y) + (v.z*w.z));
+}
+
+
+double operator < (const C_Vec3& v, const C_Vec3& w)
+{
+ return double(acos((v*w) / (v.Length() * w.Length())));
+}
+
+
+// *** Funktionen **************
+double C_Vec3::X(void) const
+{
+ return x;
+}
+
+double C_Vec3::Y(void) const
+{
+ return y;
+}
+
+double C_Vec3::Z(void) const
+{
+ return z;
+}
+
+double C_Vec3::Length(void) const
+{
+ return double(sqrt(x*x+y*y+z*z));
+}
+
+double C_Vec3::Angle_Phi(void)const
+{ // Angabe es Polarwinkels in rad
+ if (x > 0.0f) return double(atan(y/x));
+ if (x < 0.0f) return double(atan(y/x) + M_PI);
+ if (x == 0.0f || y > 0.0f) return double(M_PI_090);
+ if (x == 0.0f || y < 0.0f) return double(-M_PI_090);
+ return 0.0f;
+}
+
+double C_Vec3::Angle_Psi(void)const
+{ // Angabe es Höhenwinkels in rad
+ return double(asin(z/(sqrt(x*x+y*y))));
+}
+
+
+C_Vec3 C_Vec3::Kreuzprod(C_Vec3& v){
+ return C_Vec3( ( (y *v.Z()) - (z *v.Y()) ) ,
+ ( (z *v.X()) - (x *v.Z()) ) ,
+ ( (x *v.Y()) - (y *v.X()) ) );
+ }
+
+
+double C_Vec3::Spatprod(C_Vec3& v, C_Vec3& w){
+ return (*this * (v.Kreuzprod(w)));
+ }
+
+
+//DO * Rechteck-Klasse ***********************************************
+C_Rect::C_Rect()
+{
+ double startx, endx, starty, endy;
+
+ startx = 0.0f;
+ starty = 0.0f;
+ endx = 0.0f;
+ endy = 0.0f;
+
+ Start = C_Vec2(startx, starty);
+ End = C_Vec2(endx, endy);
+}
+
+
+C_Rect::C_Rect(const double startX,const double startY,
+ const double endX, const double endY)
+{
+ double startx, endx, starty, endy;
+
+ startx = startX;
+ starty = startY;
+ endx = endX;
+ endy = endY;
+
+ if (startX > endX)
+ {
+ startx = endX;
+ endx = startX;
+ }
+ if (startY > endY)
+ {
+ starty = endY;
+ endy = startY;
+ }
+
+ Start = C_Vec2(startx, starty);
+ End = C_Vec2(endx, endy);
+}
+
+
+C_Rect::C_Rect(const C_Vec2& start, const C_Vec2& end)
+{
+ double startx, endx, starty, endy;
+
+ Start = start;
+ End = end;
+
+ startx = start.X();
+ starty = start.Y();
+ endx = end.X();
+ endy = end.Y();
+
+ if (start.X() > end.X())
+ {
+ startx = end.X();
+ endx = start.X();
+ }
+ if (start.Y() > end.Y())
+ {
+ starty = end.Y();
+ endy = start.Y();
+ }
+
+ Start = C_Vec2(startx, starty);
+ End = C_Vec2(endx, endy);
+}
+
+C_Rect::C_Rect(const C_Rect& r)
+{
+ Start = r.Start;
+ End = r.End;
+}
+
+C_Rect::~C_Rect()
+{
+}
+
+C_Rect& C_Rect::operator = (const C_Rect& r)
+{
+ Start = r.Start;
+ End = r.End;
+ return *this;
+}
+
+C_Rect& C_Rect::operator += (const C_Vec2& v)
+{
+ Start += v;
+ End += v;
+ return *this;
+}
+
+C_Rect& C_Rect::operator -= (const C_Vec2& v)
+{
+ Start -= v;
+ End -= v;
+ return *this;
+}
+
+C_Rect operator + (const C_Rect& r, const C_Vec2& v)
+{
+ return C_Rect(r.Start + v, r.End + v);
+}
+
+C_Rect operator + (const C_Vec2&v, const C_Rect& r)
+{
+ return C_Rect(r.Start + v, r.End + v);
+}
+
+C_Rect operator - (const C_Rect& r, const C_Vec2& v)
+{
+ return C_Rect(r.Start - v, r.End - v);
+}
+
+
+C_Rect operator * (const C_Rect& r, double v)
+{
+ return C_Rect(r.X1()*v, r.Y1()*v, r.X2()*v, r.Y2()*v);
+}
+
+C_Rect operator * (double v, const C_Rect& r)
+{
+ return C_Rect(r.X1()*v, r.Y1()*v, r.X2()*v, r.Y2()*v);
+}
+
+C_Rect operator / (const C_Rect& r, double v)
+{
+ return C_Rect(r.X1()/v, r.Y1()/v, r.X2()/v, r.Y2()/v);
+}
+
+C_Rect C_Rect::intersect(const C_Rect& R)
+{
+/* double tx, ty, tw, th;
+
+ tw = MIN (X2(), R.X2());
+ th = MIN (Y2(), R.Y2());
+ tx = MAX (X1(), R.X1());
+ ty = MAX (Y1(), R.Y1());
+
+ if ((tw > tx) && (th > ty))
+ return C_Rect(tx, ty, tw, th);
+ else
+ return C_Rect(0.0f, 0.0f, 0.0f, 0.0f);*/
+return C_Rect(0.0f, 0.0f, 0.0f, 0.0f);
+}
+
+
+double C_Rect::X(void) const
+{
+ return Start.X();
+}
+
+double C_Rect::Y(void) const
+{
+ return Start.Y();
+}
+
+double C_Rect::X1(void) const
+{
+ return Start.X();
+}
+
+double C_Rect::Y1(void) const
+{
+ return Start.Y();
+}
+
+double C_Rect::W(void) const
+{
+ return End.X() - Start.X();
+}
+
+double C_Rect::H(void) const
+{
+ return End.Y() - Start.Y();
+}
+
+double C_Rect::X2(void) const
+{
+ return End.X();
+}
+
+double C_Rect::Y2(void) const
+{
+ return End.Y();
+}
+
+double C_Rect::diagonale(void) const
+{
+ double x = X2() - X1();
+ double y = Y2() - Y1();
+ return double(sqrt(x*x+y*y));
+}
+
+C_Vec2 C_Rect::showStart(void) const
+{
+ return Start;
+}
+
+C_Vec2 C_Rect::showEnd(void) const
+{
+ return End;
+}
+
+int C_Rect::Inside(C_Vec2 v)
+{
+ if( (v.X()>=Start.X())&&
+ (v.X()<=End.X())&&
+ (v.Y()>=Start.Y())&&
+ (v.Y()<=End.Y()) ) return 1;
+ return 0;
+}
+
diff --git a/src/modules/grid/grid_calculus_bsl/vector.h b/src/modules/grid/grid_calculus_bsl/vector.h
new file mode 100644
index 0000000..5fd9f92
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/vector.h
@@ -0,0 +1,202 @@
+////////////////////////////////////////////////////////////////////////////
+// Programm :
+// Bibliothek :
+// Header-Datei: vector.h
+//
+////////////////////////////////////////////////////////////////////////////
+//
+// Autoren : Joerg Dolle
+// Christian Trachimow
+//
+// Telefon-Nr. : 0561/774807
+// Mail-Adresse : jdolle at gwdg.de
+//
+////////////////////////////////////////////////////////////////////////////
+//
+// Compiler : Borland C++ V.: 4.00
+// Ersterstellung : 16.11.95
+// Ueberarbeitung : 22.04.96
+//
+// Programmversion: 2.00
+//
+////////////////////////////////////////////////////////////////////////////
+
+
+/****************** Include-Dateien **************/
+#ifndef __vector_h__
+#define __vector_h__
+//#include <iostream.h>
+#include <math.h>
+
+//!!#undef HEADER_INCLUDED__DATA
+//!!#define HEADER_INCLUDED__DATA HEADER_INCLUDED__EXT_CLASS
+
+
+//#define M_PI 3.14159265358979323846
+//#define M_PI_2 M_PI/2.0
+
+
+// Umrechnung von Grad in rad und umgekehrt
+#define PI_180 (M_PI/180)
+#define GRAD(arc) (arc/PI_180)
+#define ARC(grad) (grad*PI_180)
+
+
+//Do * 2D-Vectorklasse ***********************************************
+class C_Vec2
+{
+ public:
+ C_Vec2() : x(0.0f), y(0.0f) {};
+ C_Vec2(double x_neu, double y_neu);
+ C_Vec2(const C_Vec2& V);
+ ~C_Vec2();
+
+ void setPolar(double l, double a);
+
+ C_Vec2& operator = (const C_Vec2& v);
+ C_Vec2& operator += (const C_Vec2& v);
+ C_Vec2& operator -= (const C_Vec2& v);
+
+// friend HEADER_INCLUDED__EXT_API const C_Vec2 operator + (const C_Vec2& w, const C_Vec2& v);
+// friend HEADER_INCLUDED__EXT_API const C_Vec2 operator - (const C_Vec2& w, const C_Vec2& v);
+ C_Vec2 operator -();
+// class C_Vec2 operator -();
+
+
+ C_Vec2& operator /= (double v);
+ C_Vec2& operator *= (double v);
+ friend C_Vec2 operator + (const C_Vec2& w, const C_Vec2& v);
+ friend C_Vec2 operator - (const C_Vec2& w, const C_Vec2& v);
+ friend C_Vec2 operator * (const C_Vec2& w, double v);
+ friend C_Vec2 operator / (const C_Vec2& w, double v);
+ friend C_Vec2 operator * (double v, const C_Vec2& w);
+ friend C_Vec2 operator / (double v, const C_Vec2& w);
+
+ friend double operator * (const C_Vec2& v, const C_Vec2& w);
+ friend double operator < (const C_Vec2& v, const C_Vec2& w);
+
+ double X(void) const;
+ double Y(void) const;
+ double Length(void) const;
+ double Angle(void) const;
+
+ protected:
+ double x, y;
+};
+
+ C_Vec2 operator + (const C_Vec2& w,const C_Vec2& v);
+ C_Vec2 operator - (const C_Vec2& w,const C_Vec2& v);
+ C_Vec2 operator * (const C_Vec2& w, double v);
+ C_Vec2 operator / (const C_Vec2& w, double v);
+ C_Vec2 operator * (double v,const C_Vec2& w);
+ C_Vec2 operator / (double v,const C_Vec2& w);
+ double operator * (const C_Vec2& v, const C_Vec2& w);
+ double operator < (const C_Vec2& v, const C_Vec2& w);
+
+
+
+
+//Do * 3D-Vectorklasse ***********************************************
+class C_Vec3
+{
+ public:
+ C_Vec3() : x(0.0f), y(0.0f), z(0.0f) {};
+ C_Vec3(double x_neu, double y_neu, double z_neu);
+ C_Vec3(const C_Vec3& V);
+ ~C_Vec3();
+
+ void setPolar(double l, double a_phi, double a_psi);
+
+ C_Vec3& operator = (const C_Vec3& v);
+ C_Vec3& operator += (const C_Vec3& v);
+ C_Vec3& operator -= (const C_Vec3& v);
+ friend C_Vec3 operator + (const C_Vec3& w, const C_Vec3& v);
+ friend C_Vec3 operator - (const C_Vec3& w, const C_Vec3& v);
+ C_Vec3 operator - (const C_Vec3 &v);
+
+
+ C_Vec3& operator /= (double v);
+ C_Vec3& operator *= (double v);
+ friend C_Vec3 operator * (const C_Vec3& w, double v);
+ friend C_Vec3 operator / (const C_Vec3& w, double v);
+ friend C_Vec3 operator * (double v, const C_Vec3& w);
+ friend C_Vec3 operator / (double v, const C_Vec3& w);
+
+ friend double operator * (const C_Vec3& v, const C_Vec3& w);
+ friend double operator < (const C_Vec3& v, const C_Vec3& w);
+
+ double X(void) const;
+ double Y(void) const;
+ double Z(void) const;
+ double Length(void) const;
+ double Angle_Phi(void) const;
+ double Angle_Psi(void) const;
+ C_Vec3 Kreuzprod(C_Vec3& v);
+ double Spatprod(C_Vec3& v, C_Vec3& w);
+
+ protected:
+ double x, y, z;
+};
+
+ C_Vec3 operator + (const C_Vec3& w,const C_Vec3& v);
+ C_Vec3 operator - (const C_Vec3& w,const C_Vec3& v);
+ C_Vec3 operator * (const C_Vec3& w, double v);
+ C_Vec3 operator / (const C_Vec3& w, double v);
+ C_Vec3 operator * (double v,const C_Vec3& w);
+ C_Vec3 operator / (double v,const C_Vec3& w);
+ double operator * (const C_Vec3& v, const C_Vec3& w);
+ double operator < (const C_Vec3& v, const C_Vec3& w);
+
+
+//DO *einfache Rechteck-Klasse z.B. zum Klipping**********************
+class C_Rect
+{
+ public:
+ C_Rect();
+ C_Rect(const double x1,const double y1,const double x2,const double y2);
+ C_Rect(const C_Vec2& start, const C_Vec2& end);
+ C_Rect(const C_Rect& r);
+ ~C_Rect();
+
+ C_Rect& operator = (const C_Rect& r);
+ C_Rect& operator += (const C_Vec2& v);
+ C_Rect& operator -= (const C_Vec2& v);
+ friend C_Rect operator + (const C_Rect& r, const C_Vec2& v);
+ friend C_Rect operator + (const C_Vec2&v, const C_Rect& r);
+ friend C_Rect operator - (const C_Rect& r, const C_Vec2& v);
+ friend C_Rect operator * (const C_Rect& r, double v);
+ friend C_Rect operator * (double v, const C_Rect& r);
+ friend C_Rect operator / (const C_Rect& r, double v);
+
+
+ double X(void) const;
+ double Y(void) const;
+ double X1(void) const;
+ double Y1(void) const;
+ double W(void) const;
+ double H(void) const;
+ double X2(void) const;
+ double Y2(void) const;
+ double diagonale(void) const;
+ C_Rect intersect(const C_Rect& R);
+ C_Vec2 showStart(void) const;
+ C_Vec2 showEnd(void) const;
+ int Inside(C_Vec2 v);
+ private:
+ C_Vec2 Start, End;
+
+};
+
+ C_Rect operator + (const C_Rect& r, const C_Vec2& v);
+ C_Rect operator + (const C_Vec2&v, const C_Rect& r);
+ C_Rect operator - (const C_Rect& r, const C_Vec2& v);
+ C_Rect operator * (const C_Rect& r, double v);
+ C_Rect operator * (double v, const C_Rect& r);
+ C_Rect operator / (const C_Rect& r, double v);
+
+
+
+//!!#undef HEADER_INCLUDED__DATA
+//!!#define HEADER_INCLUDED__DATA
+
+#endif
diff --git a/src/modules/grid/grid_calculus_bsl/zuweisung.cpp b/src/modules/grid/grid_calculus_bsl/zuweisung.cpp
new file mode 100644
index 0000000..a981309
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/zuweisung.cpp
@@ -0,0 +1,165 @@
+//#include <..\stdafx.h>
+
+#include "zuweisung.h"
+
+
+using namespace std;
+
+BBZuweisung::BBZuweisung()
+{
+ typ = NoTyp;
+ memset(&ZuArt, 0, sizeof(BBZuArt));
+ memset(&ZuVar, 0, sizeof(BBZuVar));
+}
+
+BBZuweisung::~BBZuweisung()
+{
+ if (typ == NoTyp)
+ return;
+
+ switch(typ)
+ {
+ case FTyp:
+ case ITyp:
+ if (ZuArt.IF != NULL)
+ delete ZuArt.IF;
+ break;
+ case PTyp:
+ case MTyp:
+ if (ZuArt.MP != NULL)
+ delete ZuArt.MP;
+ break;
+ case MIndex:
+ if (ZuArt.MP != NULL)
+// delete ZuArt.MP;
+ delete ZuArt.IF;
+ if (ZuVar.MatrixIndex.PVar != NULL)
+ delete ZuVar.MatrixIndex.PVar;
+ break;
+ }
+ typ = NoTyp;
+ memset(&ZuArt, 0, sizeof(BBZuArt));
+ memset(&ZuVar, 0, sizeof(BBZuVar));
+}
+
+
+// Verarbeitung der einzelnen Zeilen
+bool isZuweisung(const string& statement, BBZuweisung *&Z)
+{
+ // Syntax: Variablen-Name = Audruck
+ if (statement.empty())
+ return false;
+ string s(statement);
+ int pos = s.find_first_of('=');
+ if (pos <= 0)
+ return false;
+
+ // erster Substring muß Variablen-Name sein
+ BBZuweisung::BBZuweisungTyp t;
+ BBMatrix *bbm;
+ BBBaumMatrixPoint *bbp;
+ string sub1 = s.substr(0, pos);
+ trim(sub1);
+ BBTyp *b = isVar(sub1);
+ if (b == NULL)
+ {
+ // überprüfen, ob erster Token ein MatrixIndex (M[p]) ist
+ if (!isMatrixIndex(sub1, bbm, bbp))
+ return false;
+ else
+ t = BBZuweisung::MIndex;
+ }
+
+ string sub2 = s.substr(pos+1);
+ trim(sub2);
+ if (sub2.empty())
+ return false;
+
+ if (b != NULL)
+ {
+ // Typ herausfinden
+ switch (b->type)
+ {
+ case BBTyp::IType:
+ t = BBZuweisung::ITyp;
+ break;
+ case BBTyp::FType:
+ t = BBZuweisung::FTyp;
+ break;
+ case BBTyp::MType:
+ t = BBZuweisung::MTyp;
+ break;
+ case BBTyp::PType:
+ t = BBZuweisung::PTyp;
+ break;
+ }
+ }
+ if (t == BBZuweisung::PTyp || t == BBZuweisung::MTyp)
+ {
+ BBBaumMatrixPoint *k = NULL;
+ try
+ {
+ pars_matrix_point(sub2, k, /*false*/ t == BBZuweisung::MTyp);
+ }
+ catch (BBFehlerException)
+ {
+ return false;
+ }
+ Z = new BBZuweisung;
+ Z->typ = t;
+ if (t == BBZuweisung::PTyp)
+ Z->ZuVar.PVar = getVarP(b);
+ else
+ Z->ZuVar.MVar = getVarM(b);
+ try
+ {
+ pars_matrix_point(sub2, Z->ZuArt.MP, /*false*/t == BBZuweisung::MTyp);
+ }
+ catch (BBFehlerException)
+ {
+ return false;
+ }
+ }
+ else if (t == BBZuweisung::ITyp || t == BBZuweisung::FTyp)
+ {
+ BBBaumInteger *k = NULL;
+ try
+ {
+ pars_integer_float(sub2, k, false);
+ }
+ catch (BBFehlerException)
+ {
+ return false;
+ }
+ Z = new BBZuweisung;
+ Z->typ = t;
+ if (t == BBZuweisung::ITyp)
+ Z->ZuVar.IVar = getVarI(b);
+ else
+ Z->ZuVar.FVar = getVarF(b);
+ try
+ {
+ pars_integer_float(sub2, Z->ZuArt.IF);
+ }
+ catch (BBFehlerException)
+ {
+ return false;
+ }
+ }
+ else if (t == BBZuweisung::MIndex)
+ {
+ Z = new BBZuweisung;
+ Z->typ = t;
+ Z->ZuVar.MatrixIndex.PVar = bbp;
+ Z->ZuVar.MatrixIndex.MVar = bbm;
+ try
+ {
+ pars_integer_float(sub2, Z->ZuArt.IF);
+ }
+ catch (BBFehlerException)
+ {
+ return false;
+ }
+ }
+ return true;
+}
diff --git a/src/modules/grid/grid_calculus_bsl/zuweisung.h b/src/modules/grid/grid_calculus_bsl/zuweisung.h
new file mode 100644
index 0000000..75141b1
--- /dev/null
+++ b/src/modules/grid/grid_calculus_bsl/zuweisung.h
@@ -0,0 +1,41 @@
+#ifndef __ZUWEISUNG_H
+#define __ZUWEISUNG_H
+
+#include "funktion.h"
+
+//***************** Zuweisung *****************
+class BBZuweisung
+{
+public:
+ enum BBZuweisungTyp {NoTyp, FTyp, ITyp, PTyp, MTyp, MIndex} typ;
+ BBZuweisung();
+ ~BBZuweisung();
+
+ union BBZuArt
+ {
+ BBBaumMatrixPoint *MP;
+ BBBaumInteger *IF;
+ } ZuArt;
+
+ union BBZuVar
+ {
+ BBInteger *IVar;
+ BBFloat *FVar;
+ BBPoint *PVar;
+ BBMatrix *MVar;
+ struct BBMatrixIndex
+ {
+ BBBaumMatrixPoint *PVar;
+ BBMatrix *MVar;
+ } MatrixIndex;
+ } ZuVar;
+
+};
+
+
+bool isZuweisung(const std::string& statement, BBZuweisung *&Z);
+
+
+
+
+#endif
diff --git a/src/modules/grid/grid_discretisation/Grid_Classify_Supervised.cpp b/src/modules/grid/grid_discretisation/Grid_Classify_Supervised.cpp
index 6c05693..d4cff4b 100644
--- a/src/modules/grid/grid_discretisation/Grid_Classify_Supervised.cpp
+++ b/src/modules/grid/grid_discretisation/Grid_Classify_Supervised.cpp
@@ -58,8 +58,6 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#include <string.h>
-
#include "Grid_Classify_Supervised.h"
@@ -74,11 +72,18 @@ enum
{
CLASS_NR = 0,
CLASS_ID,
- CLASS_N,
- CLASS_M,
- CLASS_S
+ CLASS_TOT_N,
+ CLASS_ROI_N,
+
+ CLASS_ROI_M,
+ CLASS_ROI_S,
+ CLASS_ROI_MIN,
+ CLASS_ROI_MAX
};
+//---------------------------------------------------------
+#define CLASS_NPARMS (CLASS_ROI_MAX - CLASS_ROI_N)
+
///////////////////////////////////////////////////////////
// //
@@ -87,7 +92,136 @@ enum
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define GET_GRID_VALUE(x, y, i) (m_bNormalise ? (m_pGrids->asGrid(i)->asDouble(x, y) - m_pGrids->asGrid(i)->Get_ArithMean()) / sqrt(m_pGrids->asGrid(i)->Get_Variance()) : m_pGrids->asGrid(i)->asDouble(x, y))
+CClass_Info::CClass_Info(void)
+{
+ m_Statistics = NULL;
+ m_nElements = NULL;
+ m_nFeatures = 0;
+}
+
+//---------------------------------------------------------
+CClass_Info::~CClass_Info(void)
+{
+ Destroy();
+}
+
+//---------------------------------------------------------
+void CClass_Info::Create(int nFeatures)
+{
+ Destroy();
+
+ if( nFeatures > 0 )
+ {
+ m_nFeatures = nFeatures;
+ }
+}
+
+//---------------------------------------------------------
+void CClass_Info::Destroy(void)
+{
+ if( Get_Count() > 0 )
+ {
+ for(int i=0; i<Get_Count(); i++)
+ {
+ delete[](m_Statistics[i]);
+ }
+
+ SG_Free(m_Statistics);
+ SG_Free(m_nElements);
+
+ m_Statistics = NULL;
+ m_nElements = NULL;
+
+ m_BE_m .Destroy();
+ m_BE_s .Destroy();
+ m_SAM_l .Destroy();
+ m_ML_s .Destroy();
+ m_ML_a .Destroy();
+ m_ML_b .Destroy();
+
+ m_IDs.Clear();
+ }
+
+ m_nFeatures = 0;
+}
+
+//---------------------------------------------------------
+CSG_Simple_Statistics * CClass_Info::Get_Statistics(const CSG_String &ID)
+{
+ if( m_nFeatures > 0 )
+ {
+ int i;
+
+ for(i=0; i<m_IDs.Get_Count(); i++)
+ {
+ if( !m_IDs[i].Cmp(ID) )
+ {
+ return( m_Statistics[i] );
+ }
+ }
+
+ m_IDs += ID;
+
+ m_nElements = (int *)SG_Realloc(m_nElements, m_IDs.Get_Count() * sizeof(int));
+ m_nElements[i] = 0;
+
+ m_Statistics = (CSG_Simple_Statistics **)SG_Realloc(m_Statistics , m_IDs.Get_Count() * sizeof(CSG_Simple_Statistics *));
+ m_Statistics[i] = new CSG_Simple_Statistics[m_nFeatures];
+
+ return( m_Statistics[i] );
+ }
+
+ return( NULL );
+}
+
+//---------------------------------------------------------
+void CClass_Info::_Update(void)
+{
+ if( m_SAM_l.Get_N() != Get_Count() )
+ {
+ int iClass, iFeature;
+
+ m_BE_s .Create(Get_Feature_Count(), Get_Count());
+ m_BE_m .Create(Get_Count());
+ m_SAM_l .Create(Get_Count());
+ m_ML_s .Create(Get_Count());
+ m_ML_a .Create(Get_Feature_Count(), Get_Count());
+ m_ML_b .Create(Get_Feature_Count(), Get_Count());
+
+ for(iClass=0; iClass<Get_Count(); iClass++)
+ {
+ CSG_Simple_Statistics *Statistic = m_Statistics[iClass];
+
+ double m = 0.0;
+ double l = 0.0;
+ double s = 1.0;
+
+ for(iFeature=0; iFeature<Get_Feature_Count(); iFeature++)
+ {
+ m += Statistic[iFeature].Get_Mean();
+ l += SG_Get_Square(Statistic[iFeature].Get_Mean());
+ s *= Statistic[iFeature].Get_Variance();
+
+ m_ML_a[iClass][iFeature] = 1.0 / sqrt(Statistic[iFeature].Get_Variance() * 2.0 * M_PI);
+ m_ML_b[iClass][iFeature] = -1.0 / (Statistic[iFeature].Get_Variance() * 2.0);
+ }
+
+ m_BE_m [iClass] = m / Get_Feature_Count();
+ m_SAM_l [iClass] = sqrt(l);
+ m_ML_s [iClass] = 1.0 / (pow(2.0 * M_PI, Get_Feature_Count() / 2.0) * sqrt(s));
+ }
+
+ for(iClass=0; iClass<Get_Count(); iClass++)
+ {
+ CSG_Simple_Statistics *Statistic = m_Statistics[iClass];
+
+ for(iFeature=0; iFeature<Get_Feature_Count(); iFeature++)
+ {
+ m_BE_s[iClass][iFeature] = Statistic[iFeature].Get_Mean() < m_BE_m[iClass] ? 0.0 : 1.0;
+ }
+ }
+ }
+}
///////////////////////////////////////////////////////////
@@ -104,7 +238,7 @@ CGrid_Classify_Supervised::CGrid_Classify_Supervised(void)
//-----------------------------------------------------
Set_Name (_TL("Supervised Classification"));
- Set_Author (SG_T("(c) 2005 by O.Conrad"));
+ Set_Author (SG_T("O.Conrad (c) 2005"));
Set_Description (_TW(
"Supervised Classification: Minimum Distance, Maximum Likelihood.\n"
@@ -118,59 +252,81 @@ CGrid_Classify_Supervised::CGrid_Classify_Supervised(void)
);
pNode = Parameters.Add_Shapes(
- NULL , "POLYGONS" , _TL("Training Areas"),
+ NULL , "ROI" , _TL("Training Areas"),
_TL(""),
PARAMETER_INPUT, SHAPE_TYPE_Polygon
);
Parameters.Add_Table_Field(
- pNode , "FIELD" , _TL("Class Identifier"),
+ pNode , "ROI_ID" , _TL("Class Identifier"),
_TL("")
);
Parameters.Add_Table(
- NULL , "CLASSES" , _TL("Class Information"),
+ NULL , "CLASS_INFO" , _TL("Class Information"),
_TL(""),
PARAMETER_OUTPUT
);
Parameters.Add_Grid(
- NULL , "RESULT" , _TL("Classification"),
+ NULL , "CLASSES" , _TL("Classification"),
_TL(""),
- PARAMETER_OUTPUT, true, SG_DATATYPE_Char
+ PARAMETER_OUTPUT, true, SG_DATATYPE_Short
);
Parameters.Add_Grid(
- NULL , "ML_PROB" , _TL("Distance/Probability"),
- _TL("Dependent on chosen method, these are the calculated minimum distances or the maximum probabilities."),
+ NULL , "QUALITY" , _TL("Quality"),
+ _TL("Dependent on chosen method, these are distances or probabilities."),
PARAMETER_OUTPUT_OPTIONAL
);
Parameters.Add_Choice(
NULL , "METHOD" , _TL("Method"),
_TL(""),
- CSG_String::Format(SG_T("%s|%s|"),
- _TL("Minimum Distance"),
- _TL("Maximum Likelihood")
+ CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"),
+ _TL("parallelepiped"),
+ _TL("minimum distance"),
+ _TL("mahalanobis distance"),
+ _TL("maximum likelihood"),
+ _TL("spectral angle mapping"),
+ _TL("binary encoding"),
+ _TL("spectral information divergence")
), 0
);
Parameters.Add_Value(
NULL , "NORMALISE" , _TL("Normalise"),
- _TL("Automatically normalise grids before classifying. Useful for minimum distance classification."),
+ _TL(""),
PARAMETER_TYPE_Bool, false
);
Parameters.Add_Value(
- NULL , "ML_THRESHOLD" , _TL("Probability Threshold (Percent)"),
+ NULL , "THRESHOLD_DIST" , _TL("Distance Threshold"),
+ _TL("Let pixel stay unclassified, if minimum or mahalanobis distance is greater than threshold."),
+ PARAMETER_TYPE_Double, 0.0, 0.0, true
+ );
+
+ pNode = Parameters.Add_Value(
+ NULL , "THRESHOLD_PROB" , _TL("Probability Threshold (Percent)"),
_TL("Let pixel stay unclassified, if maximum likelihood probability is less than threshold."),
PARAMETER_TYPE_Double, 0.0, 0.0, true, 100.0, true
);
-}
-//---------------------------------------------------------
-CGrid_Classify_Supervised::~CGrid_Classify_Supervised(void)
-{}
+ Parameters.Add_Choice(
+ pNode , "RELATIVE_PROB" , _TL("Probability Reference"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("absolute"),
+ _TL("relative")
+ ), 0
+ );
+
+ Parameters.Add_Value(
+ NULL , "THRESHOLD_ANGLE" , _TL("Spectral Angle Threshold (Degree)"),
+ _TL("Let pixel stay unclassified, if spectral angle distance is greater than threshold."),
+ PARAMETER_TYPE_Double, 0.0, 0.0, true, 90.0, true
+ );
+}
///////////////////////////////////////////////////////////
@@ -182,30 +338,66 @@ CGrid_Classify_Supervised::~CGrid_Classify_Supervised(void)
//---------------------------------------------------------
bool CGrid_Classify_Supervised::On_Execute(void)
{
- bool bResult = false;
-
//-------------------------------------------------
- m_pClasses = Parameters("CLASSES") ->asTable();
- m_pGrids = Parameters("GRIDS") ->asGridList();
- m_pResult = Parameters("RESULT") ->asGrid();
- m_bNormalise = Parameters("NORMALISE") ->asBool();
- m_pProbability = Parameters("ML_PROB") ->asGrid();
- m_ML_Threshold = Parameters("ML_THRESHOLD")->asDouble();
+ m_pGrids = Parameters("GRIDS") ->asGridList();
+ m_pClasses = Parameters("CLASSES") ->asGrid();
+ m_bNormalise = Parameters("NORMALISE") ->asBool();
+ m_pQuality = Parameters("QUALITY") ->asGrid();
- //-------------------------------------------------
- if( Initialise() )
+ m_Method = Parameters("METHOD") ->asInt();
+
+ m_Threshold_Dist = Parameters("THRESHOLD_DIST") ->asDouble() * Parameters("THRESHOLD_DIST")->asDouble();
+ m_Threshold_Prob = Parameters("THRESHOLD_PROB") ->asDouble() / 100.0;
+ m_Threshold_Angle = Parameters("THRESHOLD_ANGLE") ->asDouble() * M_DEG_TO_RAD;
+
+ m_bRelative = Parameters("RELATIVE_PROB" ) ->asBool() == 1;
+
+ //-----------------------------------------------------
+ for(int iGrid=m_pGrids->Get_Count()-1; iGrid>=0; iGrid--)
{
- switch( Parameters("METHOD")->asInt() )
+ if( m_pGrids->asGrid(iGrid)->Get_ZRange() <= 0.0 )
{
- case 0: default: bResult = Set_Minimum_Distance(); break;
- case 1: bResult = Set_Maximum_Likelihood(); break;
+ m_pGrids->Del_Item(iGrid);
}
+ }
+
+ if( m_pGrids->Get_Count() <= 0 )
+ {
+ return( false );
+ }
- Finalise();
+ //-------------------------------------------------
+ Process_Set_Text(_TL("analysing training areas"));
+
+ if( !Initialise() )
+ {
+ return( false );
}
//-------------------------------------------------
- return( bResult );
+ Process_Set_Text(_TL("running classification"));
+
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
+ {
+ if( !m_pClasses->is_NoData(x, y) )
+ {
+ switch( m_Method )
+ {
+ case 0: Set_Parallel_Epiped (x, y); break;
+ case 1: Set_Minimum_Distance (x, y); break;
+ case 2: Set_Mahalanobis_Distance (x, y); break;
+ case 3: Set_Maximum_Likelihood (x, y); break;
+ case 4: Set_Spectral_Angle_Mapping(x, y); break;
+ case 5: Set_Binary_Encoding (x, y); break;
+ case 6: Set_Spectral_Divergence (x, y); break;
+ }
+ }
+ }
+ }
+
+ return( Finalise() );
}
@@ -218,171 +410,206 @@ bool CGrid_Classify_Supervised::On_Execute(void)
//---------------------------------------------------------
bool CGrid_Classify_Supervised::Initialise(void)
{
- int x, y, iGrid, iClass, iPolygon, iField;
- double d, n;
- TSG_Point p;
- CSG_Table_Record *pClass;
- CSG_Shapes *pPolygons;
- CSG_Shape_Polygon *pPolygon;
-
- //-----------------------------------------------------
- for(iGrid=m_pGrids->Get_Count()-1; iGrid>=0; iGrid--)
- {
- if( m_pGrids->asGrid(iGrid)->Get_Variance() == 0.0 )
- {
- m_pGrids->Del_Item(iGrid);
- }
- }
-
//-----------------------------------------------------
- if( m_pGrids->Get_Count() > 0 )
- {
- iField = Parameters("FIELD") ->asInt();
- pPolygons = Parameters("POLYGONS") ->asShapes();
+ int x, y, iGrid;
+ TSG_Point p;
- m_pClasses->Destroy();
- m_pClasses->Set_Name(_TL("Class Information"));
+ CSG_Shapes *pROIs = Parameters("ROI") ->asShapes();
+ int iROI_ID = Parameters("ROI_ID") ->asInt();
- m_pClasses->Add_Field(_TL("NR") , SG_DATATYPE_Int);
- m_pClasses->Add_Field(_TL("IDENTIFIER") , SG_DATATYPE_String);
- m_pClasses->Add_Field(_TL("ELEMENTS") , SG_DATATYPE_Int);
+ m_Class_Info.Create(m_pGrids->Get_Count());
- for(iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
+ for(y=0, p.y=Get_YMin(); y<Get_NY() && Set_Progress(y); y++, p.y+=Get_Cellsize())
+ {
+ for(x=0, p.x=Get_XMin(); x<Get_NX(); x++, p.x+=Get_Cellsize())
{
- m_pClasses->Add_Field(CSG_String::Format(_TL("MEAN_%02d") , iGrid + 1), SG_DATATYPE_Double);
- m_pClasses->Add_Field(CSG_String::Format(_TL("STDDEV_%02d"), iGrid + 1), SG_DATATYPE_Double);
- }
+ //---------------------------------------------
+ bool bNoData;
- //-------------------------------------------------
- for(y=0, p.y=Get_YMin(); y<Get_NY() && Set_Progress(y); y++, p.y+=Get_Cellsize())
- {
- for(x=0, p.x=Get_XMin(); x<Get_NX(); x++, p.x+=Get_Cellsize())
+ for(iGrid=0, bNoData=false; iGrid<m_pGrids->Get_Count() && !bNoData; iGrid++)
{
- bool bNoData;
-
- for(iGrid=0, bNoData=false; iGrid<m_pGrids->Get_Count() && !bNoData; iGrid++)
+ if( m_pGrids->asGrid(iGrid)->is_NoData(x, y) )
{
- if( m_pGrids->asGrid(iGrid)->is_NoData(x, y) )
- {
- bNoData = true;
- }
+ bNoData = true;
}
+ }
+
+ if( bNoData )
+ {
+ m_pClasses->Set_NoData(x, y);
- //-----------------------------------------
- if( bNoData )
+ if( m_pQuality )
{
- m_pResult->Set_NoData(x, y);
+ m_pQuality->Set_NoData(x, y);
}
- else
+ }
+
+ //---------------------------------------------
+ else
+ {
+ m_pClasses->Set_Value(x, y, 0.0);
+
+ for(int iROI=0; iROI<pROIs->Get_Count(); iROI++)
{
- m_pResult->Set_Value(x, y, 0.0);
+ CSG_Simple_Statistics *pClass;
+ CSG_Shape_Polygon *pROI = (CSG_Shape_Polygon *)pROIs->Get_Shape(iROI);
- for(iPolygon=0; iPolygon<pPolygons->Get_Count(); iPolygon++)
+ if( pROI->is_Containing(p) && (pClass = m_Class_Info.Get_Statistics(pROI->asString(iROI_ID))) != NULL )
{
- pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon);
-
- if( pPolygon->is_Containing(p) && (pClass = Get_Class(pPolygon->asString(iField))) != NULL )
+ for(iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
{
- pClass->Add_Value(CLASS_N, 1.0);
-
- for(iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
- {
- d = GET_GRID_VALUE(x, y, iGrid);
-
- pClass->Add_Value(CLASS_M + 2 * iGrid, d);
- pClass->Add_Value(CLASS_S + 2 * iGrid, d * d);
- }
+ pClass[iGrid].Add_Value(Get_Value(x, y, iGrid));
}
}
}
}
}
+ }
- //-------------------------------------------------
- for(iClass=0; iClass<m_pClasses->Get_Record_Count(); iClass++)
- {
- pClass = m_pClasses->Get_Record(iClass);
- n = pClass->asDouble(CLASS_N);
+ //-----------------------------------------------------
+ return( m_Class_Info.Get_Count() > 1 );
+}
- for(iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
- {
- d = pClass->asDouble (CLASS_M + 2 * iGrid) / n; // arithmetic mean
- pClass->Set_Value (CLASS_M + 2 * iGrid, d);
- d = pClass->asDouble (CLASS_S + 2 * iGrid) / n - d * d; // variance
- pClass->Set_Value (CLASS_S + 2 * iGrid, sqrt(d)); // standard deviation
- }
- }
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
- //-------------------------------------------------
- if( m_pClasses->Get_Record_Count() > 1 )
- {
- CSG_Parameters Parms;
+//---------------------------------------------------------
+bool CGrid_Classify_Supervised::Finalise(void)
+{
+ int iClass, iGrid, iOffset, nClasses;
+ CSG_String Name_Method, Name_Quality;
+ CSG_Table *pTable;
- if( DataObject_Get_Parameters(m_pResult, Parms) && Parms("COLORS_TYPE") && Parms("LUT") )
- {
- CSG_Table *pLUT = Parms("LUT")->asTable();
+ //-----------------------------------------------------
+ switch( m_Method )
+ {
+ case 0:
+ Name_Method = _TL("Parallelepiped");
+ Name_Quality = _TL("Memberships");
+ break;
+
+ case 1:
+ Name_Method = _TL("Minimum Distance");
+ Name_Quality = _TL("Distance");
+ break;
+
+ case 2:
+ Name_Method = _TL("Mahalanobis Distance");
+ Name_Quality = _TL("Distance");
+ break;
+
+ case 3:
+ Name_Method = _TL("Maximum Likelihood");
+ Name_Quality = _TL("Proximity");
+ break;
+
+ case 4:
+ Name_Method = _TL("Spectral Angle Mapping");
+ Name_Quality = _TL("Angle");
+ break;
+
+ case 5:
+ Name_Method = _TL("Binary Encoding");
+ Name_Quality = _TL("Difference");
+ break;
+
+ case 6:
+ Name_Method = _TL("Spectral Information Divergence");
+ Name_Quality = _TL("Divergence");
+ break;
+ }
- for(iClass=0; iClass<m_pClasses->Get_Record_Count(); iClass++)
- {
- if( (pClass = pLUT->Get_Record(iClass)) == NULL )
- {
- pClass = pLUT->Add_Record();
- pClass->Set_Value(0, SG_GET_RGB(rand() * 255.0 / RAND_MAX, rand() * 255.0 / RAND_MAX, rand() * 255.0 / RAND_MAX));
- }
+ //-----------------------------------------------------
+ pTable = Parameters("CLASS_INFO")->asTable();
- pClass->Set_Value(1, m_pClasses->Get_Record(iClass)->asString(CLASS_ID));
- pClass->Set_Value(2, m_pClasses->Get_Record(iClass)->asString(CLASS_ID));
- pClass->Set_Value(3, iClass + 1);
- pClass->Set_Value(4, iClass + 1);
- }
+ pTable->Destroy();
+ pTable->Set_Name(CSG_String::Format(SG_T("%s [%s]"), _TL("Class Information"), Name_Method.c_str()));
- while( pLUT->Get_Record_Count() > m_pClasses->Get_Record_Count() )
- {
- pLUT->Del_Record(pLUT->Get_Record_Count() - 1);
- }
+ pTable->Add_Field(_TL("NR") , SG_DATATYPE_Int); // CLASS_NR
+ pTable->Add_Field(_TL("ID") , SG_DATATYPE_String); // CLASS_ID
+ pTable->Add_Field(_TL("TOT_N"), SG_DATATYPE_Int); // CLASS_TOT_N
+ pTable->Add_Field(_TL("ROI_N"), SG_DATATYPE_Int); // CLASS_ROI_N
+
+ for(iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
+ {
+ pTable->Add_Field(CSG_String::Format(_TL("%02d_ROI_M") , iGrid + 1), SG_DATATYPE_Double); // CLASS_ROI_M
+ pTable->Add_Field(CSG_String::Format(_TL("%02d_ROI_S") , iGrid + 1), SG_DATATYPE_Double); // CLASS_ROI_S
+ pTable->Add_Field(CSG_String::Format(_TL("%02d_ROI_MIN"), iGrid + 1), SG_DATATYPE_Double); // CLASS_ROI_MIN
+ pTable->Add_Field(CSG_String::Format(_TL("%02d_ROI_MAX"), iGrid + 1), SG_DATATYPE_Double); // CLASS_ROI_MAX
+ }
- Parms("COLORS_TYPE")->Set_Value(1); // Color Classification Type: Lookup Table
+ for(iClass=0; iClass<m_Class_Info.Get_Count(); iClass++)
+ {
+ CSG_Table_Record *pRecord = pTable->Add_Record();
- DataObject_Set_Parameters(m_pResult, Parms);
- }
+ pRecord->Set_Value(CLASS_NR , iClass + 1);
+ pRecord->Set_Value(CLASS_ID , m_Class_Info.Get_ID(iClass).c_str());
+ pRecord->Set_Value(CLASS_ROI_N, m_Class_Info.Get_Statistics(iClass)->Get_Count());
+ pRecord->Set_Value(CLASS_TOT_N, m_Class_Info.Get_Element_Count(iClass));
+
+ for(iGrid=0, iOffset=0; iGrid<m_Class_Info.Get_Feature_Count(); iGrid++, iOffset+=CLASS_NPARMS)
+ {
+ CSG_Simple_Statistics *pStatistics = m_Class_Info.Get_Statistics(iClass) + iGrid;
- return( true );
+ double m = m_bNormalise ? m_pGrids->asGrid(iGrid)->Get_ArithMean() : 0.0;
+ double s = m_bNormalise ? m_pGrids->asGrid(iGrid)->Get_StdDev() : 1.0;
+
+ pRecord->Set_Value(iOffset + CLASS_ROI_M , pStatistics->Get_Mean () * s + m);
+ pRecord->Set_Value(iOffset + CLASS_ROI_S , pStatistics->Get_StdDev () * s);
+ pRecord->Set_Value(iOffset + CLASS_ROI_MIN, pStatistics->Get_Minimum() * s + m);
+ pRecord->Set_Value(iOffset + CLASS_ROI_MAX, pStatistics->Get_Maximum() * s + m);
}
}
- return( false );
-}
+ //-----------------------------------------------------
+ CSG_Parameters P;
-//---------------------------------------------------------
-bool CGrid_Classify_Supervised::Finalise(void)
-{
- if( m_bNormalise )
+ if( DataObject_Get_Parameters(m_pClasses, P) && P("COLORS_TYPE") && P("LUT") )
{
- for(int iClass=0; iClass<m_pClasses->Get_Record_Count(); iClass++)
- {
- CSG_Table_Record *pClass = m_pClasses->Get_Record(iClass);
+ pTable = P("LUT")->asTable();
- for(int iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
+ for(iClass=0, nClasses=0; iClass<m_Class_Info.Get_Count(); iClass++)
+ {
+ if( m_Class_Info.Get_Element_Count(iClass) > 0 )
{
- double d,
- s = sqrt(m_pGrids->asGrid(iGrid)->Get_Variance()),
- m = m_pGrids->asGrid(iGrid)->Get_ArithMean();
+ CSG_Table_Record *pRecord = pTable->Get_Record(nClasses++);
- d = pClass->asDouble (CLASS_M + 2 * iGrid);
- pClass->Set_Value (CLASS_M + 2 * iGrid, s * d + m);
+ if( pRecord == NULL )
+ {
+ pRecord = pTable->Add_Record();
+ pRecord->Set_Value(0, SG_GET_RGB(rand() * 255.0 / RAND_MAX, rand() * 255.0 / RAND_MAX, rand() * 255.0 / RAND_MAX));
+ }
- d = pClass->asDouble (CLASS_S + 2 * iGrid);
- pClass->Set_Value (CLASS_S + 2 * iGrid, s * d);
+ pRecord->Set_Value(1, m_Class_Info.Get_ID(iClass).c_str());
+ pRecord->Set_Value(2, m_Class_Info.Get_ID(iClass).c_str());
+ pRecord->Set_Value(3, iClass + 1);
+ pRecord->Set_Value(4, iClass + 1);
}
}
+
+ while( pTable->Get_Record_Count() > m_Class_Info.Get_Count() )
+ {
+ pTable->Del_Record(pTable->Get_Record_Count() - 1);
+ }
+
+ P("COLORS_TYPE")->Set_Value(1); // Color Classification Type: Lookup Table
+
+ DataObject_Set_Parameters(m_pClasses, P);
}
- if( m_pProbability )
+ //-----------------------------------------------------
+ m_pClasses->Set_Name(CSG_String::Format(SG_T("%s [%s]"), _TL("Classification"), Name_Method.c_str()));
+
+ if( m_pQuality )
{
- DataObject_Set_Colors(m_pProbability, 100, SG_COLORS_WHITE_GREEN);
+ m_pQuality->Set_Name(CSG_String::Format(SG_T("%s [%s]"), _TL("Classification Quality"), Name_Quality.c_str()));
+
+ DataObject_Set_Colors(m_pQuality, 100, SG_COLORS_WHITE_GREEN);
}
+ //-----------------------------------------------------
return( true );
}
@@ -394,193 +621,254 @@ bool CGrid_Classify_Supervised::Finalise(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-CSG_Table_Record * CGrid_Classify_Supervised::Get_Class(const SG_Char *Identifier)
+inline double CGrid_Classify_Supervised::Get_Value(int x, int y, int iGrid)
{
- CSG_Table_Record *pClass = NULL;
+ CSG_Grid *pGrid = m_pGrids->asGrid(iGrid);
- if( m_pClasses && Identifier )
+ return( m_bNormalise
+ ? (pGrid->asDouble(x, y) - pGrid->Get_ArithMean()) / pGrid->Get_StdDev()
+ : pGrid->asDouble(x, y)
+ );
+}
+
+//---------------------------------------------------------
+inline bool CGrid_Classify_Supervised::Set_Class(int x, int y, int iClass, double Quality)
+{
+ if( is_InGrid(x, y) )
{
- int i;
+ if( iClass >= 0 && iClass < m_Class_Info.Get_Count() )
+ {
+ m_pClasses->Set_Value(x, y, 1 + iClass);
- for(i=0; i<m_pClasses->Get_Record_Count(); i++)
+ m_Class_Info.Inc_Element_Count(iClass);
+ }
+
+ if( m_pQuality )
{
- pClass = m_pClasses->Get_Record(i);
+ m_pQuality->Set_Value(x, y, Quality);
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
- if( !SG_STR_CMP(pClass->asString(CLASS_ID), Identifier) )
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CGrid_Classify_Supervised::Set_Parallel_Epiped(int x, int y)
+{
+ int iMember = -1, nMemberships = 0;
+
+ for(int iClass=0; iClass<m_Class_Info.Get_Count(); iClass++)
+ {
+ bool bMember = true;
+
+ for(int iGrid=0; bMember && iGrid<m_pGrids->Get_Count(); iGrid++)
+ {
+ double d = Get_Value(x, y, iGrid);
+
+ if( d < m_Class_Info[iClass][iGrid].Get_Minimum()
+ || d > m_Class_Info[iClass][iGrid].Get_Maximum() )
{
- return( pClass );
+ bMember = false;
}
}
- //-------------------------------------------------
- pClass = m_pClasses->Add_Record();
+ if( bMember )
+ {
+ nMemberships++;
+ iMember = iClass;
+ }
+ }
+
+ Set_Class(x, y, iMember, nMemberships);
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CGrid_Classify_Supervised::Set_Minimum_Distance(int x, int y)
+{
+ int iMember = -1;
+ double dMember = -1.0;
+
+ for(int iClass=0; iClass<m_Class_Info.Get_Count(); iClass++)
+ {
+ double d = 0.0;
- pClass->Set_Value(CLASS_NR , m_pClasses->Get_Record_Count());
- pClass->Set_Value(CLASS_ID , Identifier);
- pClass->Set_Value(CLASS_N , 0.0);
+ for(int iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
+ {
+ d += SG_Get_Square(Get_Value(x, y, iGrid) - m_Class_Info[iClass][iGrid].Get_Mean());
+ }
- for(i=CLASS_M; i<m_pClasses->Get_Field_Count(); i++)
+ if( dMember > d || dMember < 0.0 )
{
- pClass->Set_Value(i, 0.0);
+ dMember = d;
+ iMember = iClass;
}
}
- return( pClass );
+ Set_Class(x, y, m_Threshold_Dist <= 0.0 || dMember <= m_Threshold_Dist ? iMember : -1, sqrt(dMember));
}
///////////////////////////////////////////////////////////
// //
-// //
-// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-bool CGrid_Classify_Supervised::Set_Minimum_Distance(void)
+void CGrid_Classify_Supervised::Set_Mahalanobis_Distance(int x, int y)
{
- int x, y, iClass, iGrid, iMin;
- double dMin, d, e, **m;
+ int iMember = -1;
+ double dMember = -1.0;
- //-----------------------------------------------------
- m = (double **)SG_Malloc(sizeof(double *) * m_pClasses->Get_Record_Count());
- m[0] = (double *)SG_Malloc(sizeof(double ) * m_pClasses->Get_Record_Count() * m_pGrids->Get_Count());
-
- for(iClass=0; iClass<m_pClasses->Get_Record_Count(); iClass++)
+ for(int iClass=0; iClass<m_Class_Info.Get_Count(); iClass++)
{
- m[iClass] = m[0] + iClass * m_pGrids->Get_Count();
+ double d = 0.0;
+
+ for(int iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
+ {
+ d += SG_Get_Square((Get_Value(x, y, iGrid) - m_Class_Info[iClass][iGrid].Get_Mean()) / m_Class_Info[iClass][iGrid].Get_StdDev());
+ }
- for(iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
+ if( dMember > d || dMember < 0.0 )
{
- m[iClass][iGrid] = m_pClasses->Get_Record(iClass)->asDouble(CLASS_M + 2 * iGrid);
+ dMember = d;
+ iMember = iClass;
}
}
- //-----------------------------------------------------
- for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ Set_Class(x, y, m_Threshold_Dist <= 0.0 || dMember <= m_Threshold_Dist ? iMember : -1, sqrt(dMember));
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CGrid_Classify_Supervised::Set_Maximum_Likelihood(int x, int y)
+{
+ int iMember = -1;
+ double dMember = 0.0, dSum = 0.0;
+
+ for(int iClass=0; iClass<m_Class_Info.Get_Count(); iClass++)
{
- for(x=0; x<Get_NX(); x++)
+ double d = 1.0;
+
+ for(int iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
{
- if( !m_pResult->is_NoData(x, y) )
- {
- for(iClass=0, dMin=-1.0; iClass<m_pClasses->Get_Record_Count(); iClass++)
- {
- for(iGrid=0, d=0.0; iGrid<m_pGrids->Get_Count(); iGrid++)
- {
- e = GET_GRID_VALUE(x, y, iGrid) - m[iClass][iGrid];
- d += e*e;
- }
+ d *= m_Class_Info.Get_ML_a(iClass, iGrid) * exp(m_Class_Info.Get_ML_b(iClass, iGrid) * SG_Get_Square(Get_Value(x, y, iGrid) - m_Class_Info[iClass][iGrid].Get_Mean()));
+ }
- if( dMin < 0.0 || dMin > d )
- {
- dMin = d;
- iMin = iClass;
- }
- }
+ dSum += (d = pow(d, 1.0 / m_pGrids->Get_Count()));
- if( dMin >= 0.0 )
- {
- m_pResult->Set_Value(x, y, iMin + 1);
+/**//* double d = 0.0;
- if( m_pProbability )
- {
- m_pProbability->Set_Value(x, y, sqrt(dMin));
- }
- }
- }
+ for(int iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
+ {
+ d += SG_Get_Square((Get_Value(x, y, iGrid) - m_Class_Info[iClass][iGrid].Get_Mean()) / m_Class_Info[iClass][iGrid].Get_StdDev());
}
- }
- //-----------------------------------------------------
- SG_Free(m[0]);
- SG_Free(m);
+ dSum += (d = m_Class_Info.Get_ML_s(iClass) * exp(-0.5 * d)); /**/
- return( true );
+ if( dMember < d )
+ {
+ dMember = d;
+ iMember = iClass;
+ }
+ }
+
+ Set_Class(x, y, m_Threshold_Prob <= 0.0 || dMember >= m_Threshold_Prob ? iMember : -1, 100.0 * (m_bRelative ? dMember / dSum : dMember));
}
///////////////////////////////////////////////////////////
// //
-// //
-// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-bool CGrid_Classify_Supervised::Set_Maximum_Likelihood(void)
+void CGrid_Classify_Supervised::Set_Spectral_Angle_Mapping(int x, int y)
{
- int x, y, iClass, iGrid, iMax;
- double dMax, d, e, **a, **b, **m;
+ int iMember = -1;
+ double dMember = -1.0;
- //-----------------------------------------------------
- a = (double **)SG_Malloc(sizeof(double *) * m_pClasses->Get_Record_Count());
- a[0] = (double *)SG_Malloc(sizeof(double ) * m_pClasses->Get_Record_Count() * m_pGrids->Get_Count());
- b = (double **)SG_Malloc(sizeof(double *) * m_pClasses->Get_Record_Count());
- b[0] = (double *)SG_Malloc(sizeof(double ) * m_pClasses->Get_Record_Count() * m_pGrids->Get_Count());
- m = (double **)SG_Malloc(sizeof(double *) * m_pClasses->Get_Record_Count());
- m[0] = (double *)SG_Malloc(sizeof(double ) * m_pClasses->Get_Record_Count() * m_pGrids->Get_Count());
-
- for(iClass=0; iClass<m_pClasses->Get_Record_Count(); iClass++)
+ for(int iClass=0; iClass<m_Class_Info.Get_Count(); iClass++)
{
- a[iClass] = a[0] + iClass * m_pGrids->Get_Count();
- b[iClass] = b[0] + iClass * m_pGrids->Get_Count();
- m[iClass] = m[0] + iClass * m_pGrids->Get_Count();
+ double d = 0.0;
+ double e = 0.0;
- for(iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
+ for(int iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
{
- d = m_pClasses->Get_Record(iClass)->asDouble(CLASS_S + 2 * iGrid); // standard deviation
- a[iClass][iGrid] = 1.0 / sqrt(d*d * 2.0 * M_PI);
- b[iClass][iGrid] = -1.0 / (d*d * 2.0);
- m[iClass][iGrid] = m_pClasses->Get_Record(iClass)->asDouble(CLASS_M + 2 * iGrid); // arithmetic mean
+ double v = Get_Value(x, y, iGrid);
+
+ d += v * m_Class_Info[iClass][iGrid].Get_Mean();
+ e += v*v;
}
- }
- //-----------------------------------------------------
- for(y=0; y<Get_NY() && Set_Progress(y); y++)
- {
- for(x=0; x<Get_NX(); x++)
+ d = acos(d / (sqrt(e) * m_Class_Info.Get_SAM_l(iClass)));
+
+ if( dMember > d || dMember < 0.0 )
{
- if( !m_pResult->is_NoData(x, y) )
- {
- for(iClass=0, dMax=0.0; iClass<m_pClasses->Get_Record_Count(); iClass++)
- {
- for(iGrid=0, d=1.0; iGrid<m_pGrids->Get_Count(); iGrid++)
- {
- e = GET_GRID_VALUE(x, y, iGrid) - m[iClass][iGrid];
- d *= a[iClass][iGrid] * exp(b[iClass][iGrid] * e*e);
- }
+ dMember = d;
+ iMember = iClass;
+ }
+ }
- if( dMax < d )
- {
- dMax = d;
- iMax = iClass;
- }
- }
+ Set_Class(x, y, m_Threshold_Angle <= 0.0 || dMember <= m_Threshold_Angle ? iMember : -1, M_RAD_TO_DEG * (dMember));
+}
- if( (dMax = 100.0 * pow(dMax, 1.0 / m_pGrids->Get_Count())) < m_ML_Threshold )
- {
- m_pResult->Set_Value(x, y, 0.0);
- }
- else
- {
- m_pResult->Set_Value(x, y, iMax + 1);
- }
- if( m_pProbability )
- {
- m_pProbability->Set_Value(x, y, dMax);
- }
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CGrid_Classify_Supervised::Set_Spectral_Divergence(int x, int y)
+{
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CGrid_Classify_Supervised::Set_Binary_Encoding(int x, int y)
+{
+ int iMember = -1;
+ int dMember = -1;
+
+ for(int iClass=0; iClass<m_Class_Info.Get_Count(); iClass++)
+ {
+ int d = 0;
+
+ for(int iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
+ {
+ if( Get_Value(x, y, iGrid) < m_Class_Info.Get_BE_m(iClass) != m_Class_Info.Get_BE_s(iClass, iGrid) )
+ {
+ d ++;
}
}
- }
- //-----------------------------------------------------
- SG_Free(a[0]);
- SG_Free(a);
- SG_Free(b[0]);
- SG_Free(b);
- SG_Free(m[0]);
- SG_Free(m);
+ if( dMember < d || dMember < 0 )
+ {
+ dMember = d;
+ iMember = iClass;
+ }
+ }
- return( true );
+ Set_Class(x, y, iMember, dMember);
}
diff --git a/src/modules/grid/grid_discretisation/Grid_Classify_Supervised.h b/src/modules/grid/grid_discretisation/Grid_Classify_Supervised.h
index a6b414a..0e0a1c0 100644
--- a/src/modules/grid/grid_discretisation/Grid_Classify_Supervised.h
+++ b/src/modules/grid/grid_discretisation/Grid_Classify_Supervised.h
@@ -79,40 +79,99 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+class CClass_Info
+{
+public:
+ CClass_Info(void);
+ virtual ~CClass_Info(void);
+
+ void Create (int nFeatures);
+ void Destroy (void);
+
+ int Get_Feature_Count (void) { return( m_nFeatures ); }
+
+ int Get_Count (void) { return( m_IDs.Get_Count() ); }
+ const CSG_String & Get_ID (int Index) { return( m_IDs[Index] ); }
+
+ CSG_Simple_Statistics * Get_Statistics (const CSG_String &ID);
+ CSG_Simple_Statistics * Get_Statistics (int Index) { return( m_Statistics[Index] ); }
+ CSG_Simple_Statistics * operator [] (int Index) { return( m_Statistics[Index] ); }
+
+ int Get_Element_Count (int Index) { return( m_nElements[Index] ); }
+ void Inc_Element_Count (int Index) { m_nElements[Index]++; }
+
+ double Get_BE_m (int Index) { _Update(); return( m_BE_m[Index] ); }
+ bool Get_BE_s (int Index, int Feature) { _Update(); return( m_BE_s[Index][Feature] != 0.0 ); }
+ double Get_SAM_l (int Index) { _Update(); return( m_SAM_l[Index] ); }
+ double Get_ML_s (int Index) { _Update(); return( m_ML_s[Index] ); }
+ double Get_ML_a (int Index, int Feature) { _Update(); return( m_ML_a[Index][Feature] ); }
+ double Get_ML_b (int Index, int Feature) { _Update(); return( m_ML_b[Index][Feature] ); }
+
+
+private:
+
+ int m_nFeatures, *m_nElements;
+
+ CSG_Strings m_IDs;
+
+ CSG_Simple_Statistics **m_Statistics;
+
+ CSG_Vector m_ML_s, m_SAM_l, m_BE_m;
+
+ CSG_Matrix m_ML_a, m_ML_b, m_BE_s;
+
+
+ void _Update (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
class CGrid_Classify_Supervised : public CSG_Module_Grid
{
public:
CGrid_Classify_Supervised(void);
- virtual ~CGrid_Classify_Supervised(void);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Classification") ); }
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Classification") ); }
protected:
- virtual bool On_Execute (void);
+ virtual bool On_Execute (void);
private:
- bool m_bNormalise;
+ bool m_bNormalise, m_bRelative;
+
+ int m_Method;
- double m_ML_Threshold;
+ double m_Threshold_Dist, m_Threshold_Prob, m_Threshold_Angle;
- CSG_Table *m_pClasses;
+ CClass_Info m_Class_Info;
- CSG_Grid *m_pResult, *m_pProbability;
+ CSG_Grid *m_pClasses, *m_pQuality;
CSG_Parameter_Grid_List *m_pGrids;
- bool Initialise (void);
- bool Finalise (void);
+ bool Initialise (void);
+ bool Finalise (void);
- CSG_Table_Record * Get_Class (const SG_Char *Identifier);
+ double Get_Value (int x, int y, int iGrid);
+ bool Set_Class (int x, int y, int iClass, double Quality);
- bool Set_Minimum_Distance (void);
- bool Set_Maximum_Likelihood (void);
+ void Set_Parallel_Epiped (int x, int y);
+ void Set_Minimum_Distance (int x, int y);
+ void Set_Mahalanobis_Distance (int x, int y);
+ void Set_Maximum_Likelihood (int x, int y);
+ void Set_Spectral_Angle_Mapping (int x, int y);
+ void Set_Spectral_Divergence (int x, int y);
+ void Set_Binary_Encoding (int x, int y);
};
diff --git a/src/modules/grid/grid_discretisation/Grid_FastSegments.h b/src/modules/grid/grid_discretisation/Grid_FastSegments.h
index 4ad53f4..68c22c9 100644
--- a/src/modules/grid/grid_discretisation/Grid_FastSegments.h
+++ b/src/modules/grid/grid_discretisation/Grid_FastSegments.h
@@ -85,6 +85,8 @@ public:
CGrid_FastSegments(void);
virtual ~CGrid_FastSegments(void);
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Segmentation") ); }
+
protected:
@@ -99,7 +101,7 @@ private:
double *m_Values;
- CSG_Grid *m_pGrid, *m_pSegments, *m_pObjects;
+ CSG_Grid *m_pGrid, *m_pSegments, *m_pObjects;
void Set_Cell (int x, int y);
diff --git a/src/modules/grid/grid_discretisation/Grid_Segmentation.h b/src/modules/grid/grid_discretisation/Grid_Segmentation.h
index d570778..c075fd9 100644
--- a/src/modules/grid/grid_discretisation/Grid_Segmentation.h
+++ b/src/modules/grid/grid_discretisation/Grid_Segmentation.h
@@ -109,6 +109,8 @@ public:
CGrid_Segmentation(void);
virtual ~CGrid_Segmentation(void);
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Segmentation") ); }
+
protected:
diff --git a/src/modules/grid/grid_discretisation/MLB_Interface.cpp b/src/modules/grid/grid_discretisation/MLB_Interface.cpp
index 8622edd..d5a4ef4 100644
--- a/src/modules/grid/grid_discretisation/MLB_Interface.cpp
+++ b/src/modules/grid/grid_discretisation/MLB_Interface.cpp
@@ -71,19 +71,19 @@ const SG_Char * Get_Info(int i)
switch( i )
{
case MLB_INFO_Name: default:
- return( _TL("Grid - Discretisation") );
+ return( _TL("Imagery - Classification") );
case MLB_INFO_Author:
return( _TL("O. Conrad (c) 2002-9") );
case MLB_INFO_Description:
- return( _TL("Tools for the discretisation/classification of metric gridded data.") );
+ return( _TL("Classification and segmentation tools for metric gridded data.") );
case MLB_INFO_Version:
return( SG_T("1.0") );
case MLB_INFO_Menu_Path:
- return( _TL("Grid|Discretisation") );
+ return( _TL("Imagery") );
}
}
@@ -97,6 +97,7 @@ const SG_Char * Get_Info(int i)
#include "Grid_FastSegments.h"
#include "Grid_Skeletonize.h"
#include "rga_basic.h"
+#include "grid_seeds.h"
//---------------------------------------------------------
@@ -106,12 +107,13 @@ CSG_Module * Create_Module(int i)
{
switch( i )
{
- case 0: return( new CGrid_Classify_Supervised );
- case 1: return( new CGrid_Cluster_Analysis );
- case 2: return( new CGrid_Segmentation );
- case 3: return( new CGrid_FastSegments );
- case 4: return( new CGrid_Skeletonize );
- case 5: return( new CRGA_Basic );
+ case 0: return( new CGrid_Classify_Supervised );
+ case 1: return( new CGrid_Cluster_Analysis );
+ case 2: return( new CGrid_Segmentation );
+ case 3: return( new CGrid_FastSegments );
+ case 4: return( new CGrid_Skeletonize );
+ case 5: return( new CRGA_Basic );
+ case 6: return( new CGrid_Seeds );
}
return( NULL );
diff --git a/src/modules/grid/grid_discretisation/Makefile.am b/src/modules/grid/grid_discretisation/Makefile.am
index c210eae..19d12b2 100644
--- a/src/modules/grid/grid_discretisation/Makefile.am
+++ b/src/modules/grid/grid_discretisation/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.7 2009/01/13 16:15:30 oconrad Exp $
+# $Id: Makefile.am,v 1.11 2010/07/13 16:08:11 oconrad Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_discretisation.la
libgrid_discretisation_la_SOURCES =\
Grid_Classify_Supervised.cpp\
@@ -18,6 +18,7 @@ Grid_Cluster_Analysis.cpp\
Grid_FastSegments.cpp\
Grid_Segmentation.cpp\
Grid_Skeletonize.cpp\
+grid_seeds.cpp\
MLB_Interface.cpp\
rga_basic.cpp\
Grid_Classify_Supervised.h\
@@ -25,6 +26,7 @@ Grid_Cluster_Analysis.h\
Grid_FastSegments.h\
Grid_Segmentation.h\
Grid_Skeletonize.h\
+grid_seeds.h\
MLB_Interface.h\
rga_basic.h
diff --git a/src/modules/grid/grid_discretisation/Makefile.in b/src/modules/grid/grid_discretisation/Makefile.in
index abb8e9d..daf3774 100644
--- a/src/modules/grid/grid_discretisation/Makefile.in
+++ b/src/modules/grid/grid_discretisation/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -71,11 +70,11 @@ libgrid_discretisation_la_DEPENDENCIES = \
$(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
am_libgrid_discretisation_la_OBJECTS = Grid_Classify_Supervised.lo \
Grid_Cluster_Analysis.lo Grid_FastSegments.lo \
- Grid_Segmentation.lo Grid_Skeletonize.lo MLB_Interface.lo \
- rga_basic.lo
+ Grid_Segmentation.lo Grid_Skeletonize.lo grid_seeds.lo \
+ MLB_Interface.lo rga_basic.lo
libgrid_discretisation_la_OBJECTS = \
$(am_libgrid_discretisation_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -121,6 +120,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -130,6 +130,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -220,14 +221,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.7 2009/01/13 16:15:30 oconrad Exp $
+# $Id: Makefile.am,v 1.11 2010/07/13 16:08:11 oconrad Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_discretisation.la
libgrid_discretisation_la_SOURCES = \
Grid_Classify_Supervised.cpp\
@@ -235,6 +236,7 @@ Grid_Cluster_Analysis.cpp\
Grid_FastSegments.cpp\
Grid_Segmentation.cpp\
Grid_Skeletonize.cpp\
+grid_seeds.cpp\
MLB_Interface.cpp\
rga_basic.cpp\
Grid_Classify_Supervised.h\
@@ -242,6 +244,7 @@ Grid_Cluster_Analysis.h\
Grid_FastSegments.h\
Grid_Segmentation.h\
Grid_Skeletonize.h\
+grid_seeds.h\
MLB_Interface.h\
rga_basic.h
@@ -326,6 +329,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Segmentation.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Skeletonize.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/grid_seeds.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/rga_basic.Plo at am__quote@
.cpp.o:
diff --git a/src/modules/grid/grid_discretisation/grid_seeds.cpp b/src/modules/grid/grid_discretisation/grid_seeds.cpp
new file mode 100644
index 0000000..a4629a9
--- /dev/null
+++ b/src/modules/grid/grid_discretisation/grid_seeds.cpp
@@ -0,0 +1,432 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// grid_discretisation //
+// //
+//-------------------------------------------------------//
+// //
+// grid_seeds.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "grid_seeds.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGrid_Seeds::CGrid_Seeds(void)
+{
+ //-----------------------------------------------------
+ Set_Name (_TL("Seed Generation"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ ""
+ ));
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid_List(
+ NULL , "GRIDS" , _TL("Features"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "SURFACE" , _TL("Surface"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "SEEDS_GRID" , _TL("Seeds Grid"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Shapes(
+ NULL , "SEEDS" , _TL("Seeds"),
+ _TL(""),
+ PARAMETER_OUTPUT, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Value(
+ NULL , "FACTOR" , _TL("Bandwidth (Cells)"),
+ _TL(""),
+ PARAMETER_TYPE_Double, 2.0, 1.0, true
+ );
+
+ Parameters.Add_Choice(
+ NULL , "TYPE_SURFACE" , _TL("Type of Surface"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("smoothed surface"),
+ _TL("variance (a)"),
+ _TL("variance (b)")
+ ), 1
+ );
+
+ Parameters.Add_Choice(
+ NULL , "TYPE_SEEDS" , _TL("Extraction of..."),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("minima"),
+ _TL("maxima"),
+ _TL("minima and maxima")
+ ), 0
+ );
+
+ Parameters.Add_Choice(
+ NULL , "TYPE_MERGE" , _TL("Feature Aggregation"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("additive"),
+ _TL("multiplicative")
+ ), 0
+ );
+
+ Parameters.Add_Value(
+ NULL , "NORMALIZE" , _TL("Normalized"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, false
+ );
+
+ //-----------------------------------------------------
+ m_Direction.Set_Count(8);
+
+ for(int i=0; i<8; i++)
+ {
+ m_Direction[i].z = (M_PI_360 * i) / 8.0;
+ m_Direction[i].x = sin(m_Direction[i].z);
+ m_Direction[i].y = cos(m_Direction[i].z);
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Seeds::On_Execute(void)
+{
+ bool bNormalize;
+ int Merge;
+ double Cellsize;
+ CSG_Grid *pSurface, Surface, *pSeeds_Grid;
+ CSG_Shapes *pSeeds;
+
+ //-----------------------------------------------------
+ m_pGrids = Parameters("GRIDS") ->asGridList();
+ pSurface = Parameters("SURFACE") ->asGrid();
+ pSeeds_Grid = Parameters("SEEDS_GRID") ->asGrid();
+ pSeeds = Parameters("SEEDS") ->asShapes();
+
+ m_Method = Parameters("TYPE_SURFACE")->asInt();
+ Cellsize = Parameters("FACTOR") ->asDouble() * Get_Cellsize();
+ Merge = Parameters("TYPE_MERGE") ->asInt();
+ bNormalize = Parameters("NORMALIZE") ->asBool();
+
+ //-----------------------------------------------------
+ m_Smooth.Create(SG_DATATYPE_Float,
+ 4 + (int)(Get_System()->Get_XRange() / Cellsize),
+ 4 + (int)(Get_System()->Get_YRange() / Cellsize),
+ Cellsize,
+ Get_XMin() - Cellsize,
+ Get_YMin() - Cellsize
+ );
+
+ if( !m_Smooth.is_Valid() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ if( m_pGrids->Get_Count() > 1 )
+ {
+ Surface.Create(*Get_System(), pSurface->Get_Type());
+ }
+
+ for(int i=0; i<m_pGrids->Get_Count(); i++)
+ {
+ m_Smooth.Assign(m_pGrids->asGrid(i), GRID_INTERPOLATION_Mean_Cells);
+
+ if( i == 0 )
+ {
+ Get_Surface(m_pGrids->asGrid(i), pSurface, bNormalize);
+ }
+ else
+ {
+ Get_Surface(m_pGrids->asGrid(i), &Surface, bNormalize);
+
+ Add_Surface(pSurface, &Surface, Merge);
+ }
+ }
+
+ Get_Seeds(pSurface, pSeeds, pSeeds_Grid, Parameters("TYPE_SEEDS")->asInt());
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Seeds::Get_Surface(CSG_Grid *pFeature, CSG_Grid *pSurface, bool bNormalize)
+{
+ int x, y;
+ double z, Radius;
+ TSG_Point p;
+
+ Radius = m_Method == 2 ? Get_Cellsize() : m_Smooth.Get_Cellsize();
+
+ //-----------------------------------------------------
+ for(y=0, p.y=Get_YMin(); y<Get_NY() && Set_Progress(y); y++, p.y+=Get_Cellsize())
+ {
+ for(x=0, p.x=Get_XMin(); x<Get_NX(); x++, p.x+=Get_Cellsize())
+ {
+ if( pFeature->is_InGrid(x, y) && m_Smooth.Get_Value(p, z) )
+ {
+ switch( m_Method )
+ {
+ case 0:
+ {
+ pSurface->Set_Value(x, y, z);
+ }
+ break;
+
+ case 1: case 2:
+ {
+ CSG_Simple_Statistics s;
+
+ s.Add_Value(z);
+
+ for(int i=0; i<8; i++)
+ {
+ TSG_Point q;
+
+ q.x = p.x + Radius * m_Direction[i].x;
+ q.y = p.y + Radius * m_Direction[i].y;
+
+ if( m_Smooth.Get_Value(q, z) )
+ {
+ s.Add_Value(z);
+ }
+ }
+
+ if( s.Get_Count() > 0 )
+ {
+ pSurface->Set_Value(x, y, s.Get_StdDev());
+ }
+ else
+ {
+ pSurface->Set_NoData(x, y);
+ }
+ }
+ break;
+ }
+ }
+ else
+ {
+ pSurface->Set_NoData(x, y);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ if( bNormalize && pSurface->Get_StdDev() > 0.0 )
+ {
+ pSurface->Multiply(1.0 / pSurface->Get_StdDev());
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Seeds::Add_Surface(CSG_Grid *pSurface, CSG_Grid *pAdd, int Method)
+{
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
+ {
+ if( !pSurface->is_NoData(x, y) )
+ {
+ if( pAdd->is_NoData(x, y) )
+ {
+ pSurface->Set_NoData(x, y);
+ }
+ else switch( Method )
+ {
+ case 0:
+ pSurface->Add_Value(x, y, pAdd->asDouble(x, y));
+ break;
+
+ case 1:
+ pSurface->Mul_Value(x, y, pAdd->asDouble(x, y));
+ break;
+ }
+ }
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Seeds::Get_Seeds(CSG_Grid *pSurface, CSG_Shapes *pSeeds, CSG_Grid *pGrid, int Method)
+{
+ bool bMinimum, bMaximum;
+ int x, y, i, ix, iy, id;
+ double z;
+ TSG_Point p;
+
+ //-----------------------------------------------------
+ pSeeds->Create(SHAPE_TYPE_Point, _TL("Seeds"));
+ pSeeds->Add_Field(SG_T("ID"), SG_DATATYPE_Int);
+ pSeeds->Add_Field(SG_T("X") , SG_DATATYPE_Int);
+ pSeeds->Add_Field(SG_T("Y") , SG_DATATYPE_Int);
+ pSeeds->Add_Field(SG_T("S") , SG_DATATYPE_Double);
+
+ for(i=0; i<m_pGrids->Get_Count(); i++)
+ {
+ pSeeds->Add_Field(m_pGrids->asGrid(i)->Get_Name(), SG_DATATYPE_Double);
+ }
+
+ if( pGrid )
+ {
+ pGrid->Assign_NoData();
+ }
+
+ //-----------------------------------------------------
+ for(id=0, y=0, p.y=Get_YMin(); y<Get_NY() && Set_Progress(y); y++, p.y+=Get_Cellsize())
+ {
+ for(x=0, p.x=Get_XMin(); x<Get_NX(); x++, p.x+=Get_Cellsize())
+ {
+ if( !pSurface->is_NoData(x, y) )
+ {
+ for(i=0, z=pSurface->asDouble(x, y), bMinimum=true, bMaximum=true; (bMinimum || bMaximum) && i<8; i++)
+ {
+ ix = Get_xTo(i, x);
+ iy = Get_yTo(i, y);
+
+ if( !pSurface->is_InGrid(ix, iy) )
+ {
+ bMinimum = bMaximum = false;
+ }
+ else if( z > pSurface->asDouble(ix, iy) )
+ {
+ bMinimum = false;
+ }
+ else if( z < pSurface->asDouble(ix, iy) )
+ {
+ bMaximum = false;
+ }
+ }
+
+ //-----------------------------------------
+ if( (Method == 0 && bMinimum)
+ || (Method == 1 && bMaximum)
+ || (Method == 2 && (bMinimum || bMaximum)) )
+ {
+ CSG_Shape *pSeed = pSeeds->Add_Shape();
+
+ id++;
+
+ pSeed->Add_Point(p);
+ pSeed->Set_Value(0, id);
+ pSeed->Set_Value(1, x);
+ pSeed->Set_Value(2, y);
+ pSeed->Set_Value(3, z);
+
+ for(i=0; i<m_pGrids->Get_Count(); i++)
+ {
+ pSeed->Set_Value(3 + i, m_pGrids->asGrid(i)->asDouble(x, y));
+ }
+
+ if( pGrid )
+ {
+ pGrid->Set_Value(x, y, id);
+ }
+ }
+ }
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_discretisation/grid_seeds.h b/src/modules/grid/grid_discretisation/grid_seeds.h
new file mode 100644
index 0000000..55754be
--- /dev/null
+++ b/src/modules/grid/grid_discretisation/grid_seeds.h
@@ -0,0 +1,111 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// grid_discretisation //
+// //
+//-------------------------------------------------------//
+// //
+// grid_seeds.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__grid_seeds_H
+#define HEADER_INCLUDED__grid_seeds_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGrid_Seeds : public CSG_Module_Grid
+{
+public:
+ CGrid_Seeds(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Segmentation") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ int m_Method;
+
+ CSG_Points_Z m_Direction;
+
+ CSG_Grid m_Smooth;
+
+ CSG_Parameter_Grid_List *m_pGrids;
+
+
+ bool Get_Surface (CSG_Grid *pFeature, CSG_Grid *pSurface, bool bNormalize);
+ bool Add_Surface (CSG_Grid *pSurface, CSG_Grid *pAdd, int Method);
+ bool Get_Seeds (CSG_Grid *pSurface, CSG_Shapes *pShapes, CSG_Grid *pGrid, int Method);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__grid_seeds_H
diff --git a/src/modules/grid/grid_discretisation/rga_basic.cpp b/src/modules/grid/grid_discretisation/rga_basic.cpp
index 387e186..fba8363 100644
--- a/src/modules/grid/grid_discretisation/rga_basic.cpp
+++ b/src/modules/grid/grid_discretisation/rga_basic.cpp
@@ -42,9 +42,7 @@
// //
// contact: Olaf Conrad //
// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
+// University of Hamburg //
// Germany //
// //
///////////////////////////////////////////////////////////
@@ -69,26 +67,27 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define SEEDFIELD_X 2
-#define SEEDFIELD_Y (SEEDFIELD_X + 1)
-#define SEEDFIELD_Z (SEEDFIELD_X + 2)
-
-#define NO_SEGMENT -1
-#define NO_SIMILARITY -1.0
-
+CCandidates::CCandidates(void)
+{
+ m_Candidates = NULL;
+ m_nCandidates = 0;
+ m_pLow = NULL;
+ m_pHigh = NULL;
+ m_nMax = 256;
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
+ Create(m_nMax);
+}
//---------------------------------------------------------
-CCandidates::CCandidates(void)
+CCandidates::CCandidates(int nMax)
{
m_Candidates = NULL;
+ m_nCandidates = 0;
+ m_pLow = NULL;
+ m_pHigh = NULL;
+ m_nMax = nMax;
- Create();
+ Create(m_nMax);
}
//---------------------------------------------------------
@@ -100,46 +99,134 @@ CCandidates::~CCandidates(void)
//---------------------------------------------------------
void CCandidates::Create(void)
{
+ Create(m_nMax);
+}
+
+//---------------------------------------------------------
+void CCandidates::Create(int nMax)
+{
+ if( nMax <= 1 )
+ {
+ Create();
+
+ return;
+ }
+
Destroy();
+
+ m_nMax = nMax;
+
+ m_Candidates = (TCandidate *)SG_Malloc(m_nMax * sizeof(TCandidate));
}
//---------------------------------------------------------
void CCandidates::Destroy(void)
{
+ m_nCandidates = 0;
+
if( m_Candidates )
{
SG_Free(m_Candidates);
+
+ m_Candidates = NULL;
}
- m_nBuffer = 0;
- m_nCandidates = 0;
- m_Candidates = NULL;
+ if( m_pLow )
+ {
+ delete(m_pLow);
+
+ m_pLow = NULL;
+ }
+
+ if( m_pHigh )
+ {
+ delete(m_pHigh);
+
+ m_pHigh = NULL;
+ }
}
-#include <string.h>
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
void CCandidates::Add(int x, int y, int Segment, double Similarity)
{
- int iInsert = _Find(Similarity);
-
- if( m_nCandidates >= m_nBuffer )
+ if( m_Candidates && m_nCandidates < m_nMax )
{
- m_nBuffer += 32;
- m_Candidates = (TCandidate *)SG_Realloc(m_Candidates, m_nBuffer * sizeof(TCandidate));
+ int iInsert = _Find(Similarity);
+
+ memmove(m_Candidates + iInsert + 1, m_Candidates + iInsert, sizeof(TCandidate) * (m_nCandidates - iInsert));
+
+ m_Candidates[iInsert].x = x;
+ m_Candidates[iInsert].y = y;
+ m_Candidates[iInsert].Segment = Segment;
+ m_Candidates[iInsert].Similarity = Similarity;
}
+ else
+ {
+ if( !m_pLow )
+ {
+ int iDivide = m_nMax / 2;
+
+ m_pLow = new CCandidates(m_nMax);
+ m_pHigh = new CCandidates(m_nMax);
+
+ m_pLow ->m_nCandidates = iDivide;
+ m_pHigh->m_nCandidates = m_nMax - iDivide;
+
+ memcpy(m_pLow ->m_Candidates, m_Candidates , m_pLow ->m_nCandidates * sizeof(TCandidate));
+ memcpy(m_pHigh->m_Candidates, m_Candidates + m_pLow->m_nCandidates, m_pHigh->m_nCandidates * sizeof(TCandidate));
- memmove(m_Candidates + iInsert + 1, m_Candidates + iInsert, sizeof(TCandidate) * (m_nCandidates - iInsert));
-// for(int i=m_nCandidates; i>iInsert; i--)
-// {
-// m_Candidates[i] = m_Candidates[i - 1];
-// }
+ SG_Free(m_Candidates);
+ m_Candidates = NULL;
+ }
+
+ if( Similarity > m_pHigh->Get_Minimum() )
+ {
+ m_pHigh->Add(x, y, Segment, Similarity);
+ }
+ else
+ {
+ m_pLow ->Add(x, y, Segment, Similarity);
+ }
+ }
m_nCandidates++;
+}
+
+//---------------------------------------------------------
+double CCandidates::Get_Minimum(void)
+{
+ if( m_nCandidates > 0 )
+ {
+ if( m_pLow )
+ {
+ return( m_pLow->Get_Minimum() );
+ }
+
+ return( m_Candidates[0].Similarity );
+ }
+
+ return( 0.0 );
+}
+
+//---------------------------------------------------------
+double CCandidates::Get_Maximum(void)
+{
+ if( m_nCandidates > 0 )
+ {
+ if( m_pHigh )
+ {
+ return( m_pHigh->Get_Maximum() );
+ }
+
+ return( m_Candidates[m_nCandidates - 1].Similarity );
+ }
- m_Candidates[iInsert].x = x;
- m_Candidates[iInsert].y = y;
- m_Candidates[iInsert].Segment = Segment;
- m_Candidates[iInsert].Similarity = Similarity;
+ return( 0.0 );
}
//---------------------------------------------------------
@@ -190,19 +277,6 @@ int CCandidates::_Find(double Similarity)
return( b );
}
-/*int CCandidates::_Find(double Similarity)
-{
- for(int i=0; i<m_nCandidates; i++)
- {
- if( Similarity < m_Candidates[i].Similarity )
- {
- return( i );
- }
- }
-
- return( m_nCandidates );
-}/**/
-
//---------------------------------------------------------
bool CCandidates::Get(int &x, int &y, int &Segment)
{
@@ -210,9 +284,33 @@ bool CCandidates::Get(int &x, int &y, int &Segment)
{
m_nCandidates--;
- x = m_Candidates[m_nCandidates].x;
- y = m_Candidates[m_nCandidates].y;
- Segment = m_Candidates[m_nCandidates].Segment;
+ if( m_Candidates )
+ {
+ x = m_Candidates[m_nCandidates].x;
+ y = m_Candidates[m_nCandidates].y;
+ Segment = m_Candidates[m_nCandidates].Segment;
+ }
+ else // if( m_pLow )
+ {
+ m_pHigh->Get(x, y, Segment);
+
+ if( m_pHigh->m_nCandidates == 0 )
+ {
+ delete(m_pHigh);
+
+ CCandidates *pLow = m_pLow;
+
+ // m_nCandidates = pLow->m_nCandidates;
+ m_Candidates = pLow->m_Candidates;
+ m_pLow = pLow->m_pLow;
+ m_pHigh = pLow->m_pHigh;
+
+ pLow->m_Candidates = NULL;
+ pLow->m_pLow = NULL;
+ pLow->m_pHigh = NULL;
+ delete(pLow);
+ }
+ }
return( true );
}
@@ -228,6 +326,21 @@ bool CCandidates::Get(int &x, int &y, int &Segment)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+#define SEEDFIELD_X 2
+#define SEEDFIELD_Y (SEEDFIELD_X + 1)
+#define SEEDFIELD_Z (SEEDFIELD_X + 2)
+
+#define NO_SEGMENT -1
+#define NO_SIMILARITY -1.0
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
CRGA_Basic::CRGA_Basic(void)
{
CSG_Parameter *pNode;
@@ -238,7 +351,6 @@ CRGA_Basic::CRGA_Basic(void)
Set_Author (SG_T("B. Bechtel, O. Conrad (c) 2008"));
Set_Description (_TW(
- "!!!UNDER DEVELOPMENT!!!\n"
"\n"
"References\n"
"Bechtel, B., Ringeler, A., Boehner, J. (2008): "
@@ -284,8 +396,8 @@ CRGA_Basic::CRGA_Basic(void)
NULL , "METHOD" , _TL("Method"),
_TL(""),
CSG_String::Format(SG_T("%s|%s|"),
- _TL("colour and position"),
- _TL("colour")
+ _TL("feature space and position"),
+ _TL("feature space")
), 0
);
@@ -299,24 +411,24 @@ CRGA_Basic::CRGA_Basic(void)
);
pNode = Parameters.Add_Node(
- NULL , "NODE_COLSPACE" , _TL("Colour and Space Options"),
+ NULL , "NODE_COLSPACE" , _TL("Feature Space Options"),
_TL("")
);
Parameters.Add_Value(
- pNode , "SIG_1" , _TL("Variance in colour space"),
+ pNode , "SIG_1" , _TL("Variance in Feature Space"),
_TL(""),
PARAMETER_TYPE_Double , 1.0, 0.0, true // 0.36
);
Parameters.Add_Value(
- pNode , "SIG_2" , _TL("Variance in position space"),
+ pNode , "SIG_2" , _TL("Variance in Position Space"),
_TL(""),
PARAMETER_TYPE_Double , 1.0, 0.0, true // 8.2141
);
Parameters.Add_Value(
- pNode , "THRESHOLD" , _TL("Threshold - similarity"),
+ pNode , "THRESHOLD" , _TL("Threshold - Similarity"),
_TL(""),
PARAMETER_TYPE_Double , 0.0, 0.0, true // 0.15
);
@@ -326,6 +438,12 @@ CRGA_Basic::CRGA_Basic(void)
_TL(""),
PARAMETER_TYPE_Bool , false
);
+
+ Parameters.Add_Value(
+ pNode , "LEAFSIZE" , _TL("Leaf Size (for Speed Optimisation)"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 256, 2, true
+ );
}
@@ -381,12 +499,14 @@ bool CRGA_Basic::On_Execute(void)
m_pSeeds->Add_Field(m_pFeatures->asGrid(i)->Get_Name(), SG_DATATYPE_Double);
}
+ m_Candidates.Create(Parameters("LEAFSIZE")->asInt());
+
//-----------------------------------------------------
for(y=0, n=0; y<Get_NY() && Set_Progress(y); y++)
{
for(x=0; x<Get_NX(); x++)
{
- if( pSeeds->asInt(x, y) != 0 )
+ if( !pSeeds->is_NoData(x, y) )
{
CSG_Table_Record *pRec = m_pSeeds->Add_Record();
@@ -499,7 +619,7 @@ double CRGA_Basic::Get_Similarity(int x, int y, int Segment)
switch( m_Method )
{
//-------------------------------------------------
- case 0: // Colour and position
+ case 0: // feature space and position
for(i=0, a=0.0; i<m_nFeatures; i++)
{
a += SG_Get_Square(m_pFeatures->asGrid(i)->asDouble(x, y) - pSeed->asDouble(SEEDFIELD_Z + i));
@@ -513,7 +633,7 @@ double CRGA_Basic::Get_Similarity(int x, int y, int Segment)
break;
//-------------------------------------------------
- case 1: // Colour
+ case 1: // feature space
for(i=0, a=0.0; i<m_nFeatures; i++)
{
a += SG_Get_Square(m_pFeatures->asGrid(i)->asDouble(x, y) - pSeed->asDouble(SEEDFIELD_Z + i));
diff --git a/src/modules/grid/grid_discretisation/rga_basic.h b/src/modules/grid/grid_discretisation/rga_basic.h
index a532fa4..fcee904 100644
--- a/src/modules/grid/grid_discretisation/rga_basic.h
+++ b/src/modules/grid/grid_discretisation/rga_basic.h
@@ -85,9 +85,11 @@ class CCandidates
{
public:
CCandidates(void);
+ CCandidates(int nMax);
~CCandidates(void);
void Create (void);
+ void Create (int nMax);
void Destroy (void);
void Add (int x, int y, int Segment, double Similarity);
@@ -95,13 +97,18 @@ public:
int Get_Count (void) { return( m_nCandidates ); }
+ double Get_Minimum (void);
+ double Get_Maximum (void);
+
private:
- int m_nCandidates, m_nBuffer;
+ int m_nCandidates, m_nMax;
TCandidate *m_Candidates;
+ CCandidates *m_pLow, *m_pHigh;
+
int _Find (double Similarity);
@@ -120,10 +127,12 @@ class CRGA_Basic : public CSG_Module_Grid
public:
CRGA_Basic(void);
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Segmentation") ); }
+
protected:
- virtual bool On_Execute (void);
+ virtual bool On_Execute (void);
private:
diff --git a/src/modules/grid/grid_filter/Filter.cpp b/src/modules/grid/grid_filter/Filter.cpp
index ae21550..62d100b 100644
--- a/src/modules/grid/grid_filter/Filter.cpp
+++ b/src/modules/grid/grid_filter/Filter.cpp
@@ -168,7 +168,11 @@ bool CFilter::On_Execute(void)
{
for(x=0; x<Get_NX(); x++)
{
- if( m_pInput->is_InGrid(x, y) )
+ if( !m_pInput->is_InGrid(x, y) )
+ {
+ pResult->Set_NoData(x, y);
+ }
+ else
{
switch( Mode )
{
diff --git a/src/modules/grid/grid_filter/Filter_Majority.cpp b/src/modules/grid/grid_filter/Filter_Majority.cpp
new file mode 100644
index 0000000..46cd33b
--- /dev/null
+++ b/src/modules/grid/grid_filter/Filter_Majority.cpp
@@ -0,0 +1,325 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Filter //
+// //
+//-------------------------------------------------------//
+// //
+// Filter_Majority.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "Filter_Majority.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CMajority::Create(int nBuffer)
+{
+ m_nValues = 0;
+ m_nBuffer = nBuffer;
+
+ if( m_nBuffer > 0 )
+ {
+ m_Values = (double *)SG_Malloc(m_nBuffer * sizeof(double));
+ m_Count = (int *)SG_Malloc(m_nBuffer * sizeof(int));
+ }
+}
+
+//---------------------------------------------------------
+void CMajority::Destroy(void)
+{
+ if( m_nBuffer > 0 )
+ {
+ SG_Free(m_Values);
+ SG_Free(m_Count);
+ }
+
+ m_nBuffer = 0;
+ m_nValues = 0;
+}
+
+//---------------------------------------------------------
+void CMajority::Add_Value(double Value)
+{
+ for(int i=0; i<m_nValues; i++)
+ {
+ if( m_Values[i] == Value )
+ {
+ m_Count[i]++;
+
+ return;
+ }
+ }
+
+ if( m_nValues < m_nBuffer )
+ {
+ m_Values[m_nValues] = Value;
+ m_Count [m_nValues] = 1;
+ m_nValues++;
+ }
+}
+
+//---------------------------------------------------------
+bool CMajority::Get_Majority(int &Count, double &Value)
+{
+ if( m_nValues > 0 )
+ {
+ Value = m_Values[0];
+ Count = m_Count [0];
+
+ for(int i=1; i<m_nValues; i++)
+ {
+ if( m_Count[i] > Count )
+ {
+ Value = m_Values[i];
+ Count = m_Count [i];
+ }
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CFilter_Majority::CFilter_Majority(void)
+{
+ //-----------------------------------------------------
+ // 1. Info...
+
+ Set_Name (_TL("Majority Filter"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ "Majority filter for grids."
+ ));
+
+
+ //-----------------------------------------------------
+ // 2. Parameters...
+
+ Parameters.Add_Grid(
+ NULL, "INPUT" , _TL("Grid"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL, "RESULT" , _TL("Filtered Grid"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Choice(
+ NULL, "MODE" , _TL("Search Mode"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("Square"),
+ _TL("Circle")
+ ), 1
+ );
+
+ Parameters.Add_Value(
+ NULL, "RADIUS" , _TL("Radius"),
+ _TL(""),
+ PARAMETER_TYPE_Int, 1, 1, true
+ );
+
+ Parameters.Add_Value(
+ NULL, "THRESHOLD" , _TL("Threshold [Percent]"),
+ _TL(""),
+ PARAMETER_TYPE_Double, 0.0, 0.0, true, 100.0, true
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CFilter_Majority::On_Execute(void)
+{
+ int x, y, ix, iy;
+ CSG_Grid *pResult;
+
+ //-----------------------------------------------------
+ m_pInput = Parameters("INPUT") ->asGrid();
+ pResult = Parameters("RESULT") ->asGrid();
+ m_Radius = Parameters("RADIUS") ->asInt();
+
+ //-----------------------------------------------------
+ if( !pResult || pResult == m_pInput )
+ {
+ pResult = SG_Create_Grid(m_pInput);
+
+ Parameters("RESULT")->Set_Value(m_pInput);
+ }
+
+ pResult->Set_NoData_Value(m_pInput->Get_NoData_Value());
+
+ //-----------------------------------------------------
+ m_Kernel.Create(SG_DATATYPE_Byte, 1 + 2 * m_Radius, 1 + 2 * m_Radius);
+ m_Kernel.Set_NoData_Value(0.0);
+ m_Kernel.Assign(1.0);
+ m_Kernel.Set_Value(m_Radius, m_Radius, 0.0);
+
+ if( Parameters("MODE")->asInt() == 1 )
+ {
+ for(y=-m_Radius, iy=0; y<=m_Radius; y++, iy++)
+ {
+ for(x=-m_Radius, ix=0; x<=m_Radius; x++, ix++)
+ {
+ if( x*x + y*y > m_Radius*m_Radius )
+ {
+ m_Kernel.Set_Value(ix, iy, 0.0);
+ }
+ }
+ }
+ }
+
+ m_Majority.Create(m_Kernel.Get_NCells());
+
+ m_Threshold = m_Kernel.Get_NoData_Count();
+
+ m_Threshold = 1 + (int)(0.01 * Parameters("THRESHOLD")->asDouble() * (1 + m_Kernel.Get_NCells() - m_Kernel.Get_NoData_Count()));
+
+ //-----------------------------------------------------
+ for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ if( m_pInput->is_NoData(x, y) )
+ {
+ pResult->Set_NoData(x, y);
+ }
+ else
+ {
+ pResult->Set_Value(x, y, Get_Majority(x, y));
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ if( m_pInput == Parameters("RESULT")->asGrid() )
+ {
+ m_pInput->Assign(pResult);
+
+ delete(pResult);
+ }
+ else
+ {
+ pResult->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pInput->Get_Name(), _TL("Majority Filtered")));
+ }
+
+ m_Kernel .Destroy();
+ m_Majority .Destroy();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+double CFilter_Majority::Get_Majority(int x, int y)
+{
+ m_Majority.Reset();
+
+ m_Majority.Add_Value(m_pInput->asDouble(x, y));
+
+ for(int iy=0, jy=y-m_Radius; iy<m_Kernel.Get_NY(); iy++, jy++)
+ {
+ for(int ix=0, jx=x-m_Radius; ix<m_Kernel.Get_NX(); ix++, jx++)
+ {
+ if( m_Kernel.asByte(ix, iy) && m_pInput->is_InGrid(jx, jy) )
+ {
+ m_Majority.Add_Value(m_pInput->asDouble(jx, jy));
+ }
+ }
+ }
+
+ int Count;
+ double Value;
+
+ m_Majority.Get_Majority(Count, Value);
+
+ return( Count > m_Threshold ? Value : m_pInput->asDouble(x, y) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_filter/Filter_Majority.h b/src/modules/grid/grid_filter/Filter_Majority.h
new file mode 100644
index 0000000..91ce0a5
--- /dev/null
+++ b/src/modules/grid/grid_filter/Filter_Majority.h
@@ -0,0 +1,142 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Filter //
+// //
+//-------------------------------------------------------//
+// //
+// Filter_Majority.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Filter_Majority_H
+#define HEADER_INCLUDED__Filter_Majority_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CMajority
+{
+public:
+ CMajority(void) { m_nBuffer = 0; }
+ ~CMajority(void) { Destroy(); }
+
+ void Create (int nBuffer);
+ void Destroy (void);
+
+ void Reset (void) { m_nValues = 0; }
+
+ void Add_Value (double Value);
+
+ bool Get_Majority (int &Count, double &Value);
+
+
+private:
+
+ int m_nValues, m_nBuffer, *m_Count;
+
+ double *m_Values;
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CFilter_Majority : public CSG_Module_Grid
+{
+public:
+ CFilter_Majority(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ int m_Radius, m_Threshold;
+
+ CSG_Grid m_Kernel, *m_pInput;
+
+ CMajority m_Majority;
+
+
+ double Get_Majority (int x, int y);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Filter_Majority_H
diff --git a/src/modules/grid/grid_filter/Filter_Multi_Dir_Lee.cpp b/src/modules/grid/grid_filter/Filter_Multi_Dir_Lee.cpp
index 9bcfc96..1d352fb 100644
--- a/src/modules/grid/grid_filter/Filter_Multi_Dir_Lee.cpp
+++ b/src/modules/grid/grid_filter/Filter_Multi_Dir_Lee.cpp
@@ -1,553 +1,552 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// Grid_Filter //
-// //
-//-------------------------------------------------------//
-// //
-// Filter_Multi_Dir_Lee.cpp //
-// //
-// Copyright (C) 2003 by //
-// Andre Ringeler //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: aringel at gwdg.de //
-// //
-// contact: Andre Ringeler //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-
-#include "Filter_Multi_Dir_Lee.h"
-
-
-double Filter_Directions[16][9][9] =
-{
- {
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5},
- {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0},
- {0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
- },
-
- {
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {1.0, 1.0, 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0},
- {0.5, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5, 0.5},
- {0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 1.0, 1.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
- },
-
- {
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {1.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.5, 0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.5, 0.5, 1.0, 0.5, 0.5, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 0.5, 0.5},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 1.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
- },
-
- {
- {0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.5, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.5, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 0.5},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5}
- },
-
- {
- {1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0}
- },
-
- {
- {0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.5, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5}
- },
-
- {
- {0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0}
- },
-
- {
- {0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0}
- },
-
- {
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
- {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0}
- }
-};
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CFilter_Multi_Dir_Lee::CFilter_Multi_Dir_Lee(void)
-{
- //-----------------------------------------------------
- Set_Name(_TL("Multi Direction Lee Filter"));
-
- Set_Author(_TL("Copyrights (c) 2003 by Andre Ringeler"));
-
- Set_Description (_TW(
- "This Multi Direction Lee Filter is a enhanced Lee Filter\n"
- "It looks into 16 directions for the direction with the minium variance\n"
- "and applied a Lee Filter on this direction.\n\n"
- "Uses this filter for remove speckle noise in SAR images or DTMs.\n"
- "On DTMs this filter will preserves the slope and narrow valleys. \n\n"
- "For details on the Lee Filter, see the article by Jong-Sen Lee:\n"
- "\"Digital Image Enhancement and Noise Filtering by Use of Local Statistics\",\n"
- "IEEE Transactions on Pattern Analysis and Machine Intelligence,\n"
- "Volume PAMI-2, Number 2, pages 165-168, March 1980.\n\n")
- );
-
-
- //-----------------------------------------------------
- Parameters.Add_Grid(
- NULL, "INPUT" , _TL("Grid"),
- _TL(""),
- PARAMETER_INPUT
- );
-
- Parameters.Add_Grid(
- NULL, "RESULT" , _TL("Filtered Grid"),
- _TL(""),
- PARAMETER_OUTPUT
- );
-
- Parameters.Add_Grid(
- NULL, "STDDEV" , _TL("Minimum Standard Deviation"),
- _TL(""),
- PARAMETER_OUTPUT_OPTIONAL
- );
-
- Parameters.Add_Grid(
- NULL, "DIR" , _TL("Direction of Minimum Standard Deviation"),
- _TL(""),
- PARAMETER_OUTPUT_OPTIONAL
- );
-
- Parameters.Add_Value(
- NULL, "NOISE_ABS" , _TL("Estimated Noise (absolute)"),
- _TL("Estimated noise in units of input data"),
- PARAMETER_TYPE_Double, 1.0
- );
-
- Parameters.Add_Value(
- NULL, "NOISE_REL" , _TL("Estimated Noise (relative)"),
- _TL("Estimated noise relative to mean standard deviation"),
- PARAMETER_TYPE_Double, 1.0
- );
-
- Parameters.Add_Value(
- NULL, "WEIGHTED" , _TL("Weighted"),
- _TL(""),
- PARAMETER_TYPE_Bool, true
- );
-
- Parameters.Add_Choice(
- NULL, "METHOD" , _TL("Method"),
- _TL(""),
- CSG_String::Format(SG_T("%s|%s|%s|"),
- _TL("noise variance given as absolute value"),
- _TL("noise variance given relative to mean standard deviation"),
- _TL("original calculation (Ringeler)")
- ), 1
- );
-
- //-----------------------------------------------------
- for(int i=1; i<8; i++) // Mirror the last 8 filter directions
- {
- for(int y=0; y<9; y++)
- {
- for(int x=0; x<9; x++)
- {
- Filter_Directions[i + 8][y][x] = Filter_Directions[i][y][8 - x];
- }
- }
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CFilter_Multi_Dir_Lee::On_Execute(void)
-{
- bool bResult = false, bWeighted;
-
- m_pInput = Parameters("INPUT") ->asGrid();
- m_pFiltered = Parameters("RESULT") ->asGrid();
- m_pStdDev = Parameters("STDDEV") ->asGrid();
- m_pDirection = Parameters("DIR") ->asGrid();
- bWeighted = Parameters("WEIGHTED") ->asBool();
-
- switch( Parameters("METHOD")->asInt() )
- {
- case 0: bResult = Get_Filter(bWeighted, true); break;
- case 1: bResult = Get_Filter(bWeighted, false); break;
- case 2: bResult = Get_Filter_Ringeler(); break;
- }
-
- m_pFiltered->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pInput->Get_Name(), _TL("Lee Filter")));
-
- if( m_pStdDev )
- {
- m_pStdDev ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pInput->Get_Name(), _TL("Lee Filter - Standard Deviation")));
- }
-
- if( m_pDirection )
- {
- m_pDirection ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pInput->Get_Name(), _TL("Lee Filter - Direction")));
- }
-
- return( bResult );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CFilter_Multi_Dir_Lee::Get_Filter(bool bWeighted, bool bAbsolute)
-{
- int x, y, ix, iy, k, kx, ky, Best_Direction;
- double Count, Mean, StdDev, Variance, Best_Mean, Best_StdDev, Noise, Noise2;
-
- if( bAbsolute )
- {
- Noise = Parameters("NOISE_ABS")->asDouble();
- Noise2 = Noise*Noise;
- }
- else if( m_pStdDev == NULL )
- {
- Parameters("STDDEV")->Set_Value(m_pStdDev = SG_Create_Grid(*Get_System(), SG_DATATYPE_Float));
- }
-
- //-----------------------------------------------------
- for(y=0; y<Get_NY() && Set_Progress(y); y++)
- {
- for(x=0; x<Get_NX(); x++)
- {
- if( m_pInput->is_NoData(x, y) )
- {
- m_pFiltered ->Set_NoData(x, y);
- m_pStdDev ->Set_NoData(x, y);
-
- if( m_pDirection ) m_pDirection ->Set_NoData(x, y);
- }
- else
- {
- //-----------------------------------------
- for(k=0; k<16; k++)
- {
- Variance = Mean = Count = 0;
-
- for(ky=0, iy=y-4; ky<9; iy++, ky++)
- {
- for(kx=0, ix=x-4; kx<9; ix++, kx++)
- {
- if( m_pInput->is_InGrid(ix, iy) && Filter_Directions[k][ky][kx] > 0.0 )
- {
- double w = bWeighted ? Filter_Directions[k][ky][kx] : 1.0;
- double z = m_pInput->asDouble(ix, iy);
- Mean += w * z;
- Variance += w * z*z;
- Count += w;
- }
- }
- }
-
- Mean = Mean / Count;
- Variance = Variance / Count - Mean*Mean;
- StdDev = sqrt(Variance);
-
- if( k == 0 || StdDev < Best_StdDev )
- {
- Best_StdDev = StdDev;
- Best_Mean = Mean;
- Best_Direction = k;
- }
- }
-
- //-----------------------------------------
- if( bAbsolute && Best_StdDev > Noise )
- {
- double b = Best_StdDev*Best_StdDev;
-
- b = (b - Noise2) / b;
-
- m_pFiltered->Set_Value(x, y, m_pInput->asDouble(x, y) * b + (1.0 - b) * Best_Mean);
- }
- else if( Best_StdDev > 0.0 )
- {
- m_pFiltered->Set_Value(x, y, Best_Mean);
- }
- else
- {
- m_pFiltered->Set_Value(x, y, m_pInput->asDouble(x, y));
- }
-
- if( m_pStdDev ) m_pStdDev ->Set_Value(x, y, Best_StdDev);
- if( m_pDirection ) m_pDirection ->Set_Value(x, y, Best_Direction);
- }
- }
- }
-
- //-----------------------------------------------------
- if( !bAbsolute )
- {
- Noise = Parameters("NOISE_REL")->asDouble() * m_pStdDev->Get_ArithMean();
- Noise2 = Noise*Noise;
-
- for(y=0; y<Get_NY() && Set_Progress(y); y++)
- {
- for(x=0; x<Get_NX(); x++)
- {
- if( !m_pInput->is_NoData(x, y) && (Best_StdDev = m_pStdDev->asDouble(x, y)) > Noise )
- {
- double b = Best_StdDev*Best_StdDev;
-
- b = (b - Noise2) / b;
-
- m_pFiltered->Set_Value(x, y, m_pInput->asDouble(x, y) * b + (1.0 - b) * m_pFiltered->asDouble(x, y));
- }
- }
- }
- }
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-const double corr_norm = 109699939.0;
-
-const double corr[16] =
-{
- 97694238.970824,
- 103389994.176977,
- 109699939.129502,
- 103392028.763373,
- 103392435.589500,
- 103392028.763371,
- 109699939.129499,
- 103389994.176979,
- 97694238.970826,
- 103389994.200091,
- 109699939.176253,
- 103392028.826671,
- 103392435.659830,
- 103392028.826669,
- 109699939.176251,
- 103389994.200092
-};
-
-//---------------------------------------------------------
-bool CFilter_Multi_Dir_Lee::Get_Filter_Ringeler(void)
-{
- int x, y, ix, iy, k, kx, ky, Count, Best_Direction;
- double Mean, StdDev, Variance, Best_Mean, Best_StdDev, Noise, Noise2;
-
- Noise = Parameters("NOISE_ABS")->asDouble();
- Noise2 = Noise*Noise;
-
- //-----------------------------------------------------
- for(y=0; y<Get_NY() && Set_Progress(y); y++)
- {
- for(x=0; x<Get_NX(); x++)
- {
- if( m_pInput->is_NoData(x, y) )
- {
- m_pFiltered->Set_NoData(x, y);
-
- if( m_pDirection ) m_pDirection ->Set_NoData(x, y);
- if( m_pStdDev ) m_pStdDev ->Set_NoData(x, y);
- }
- else
- {
- //-----------------------------------------
- for(k=0; k<16; k++)
- {
- Variance = Mean = Count = 0;
-
- for(ky=0, iy=y-4; ky<9; iy++, ky++)
- {
- for(kx=0, ix=x-4; kx<9; ix++, kx++)
- {
- if( m_pInput->is_InGrid(ix, iy) && Filter_Directions[k][ky][kx] > 0.0 )
- {
- Mean += m_pInput->asDouble(ix, iy);
- Count ++;
- }
- }
- }
-
- Mean = Mean / Count;
-
- for(ky=0, iy=y-4; ky<9; iy++, ky++)
- {
- for(kx=0, ix=x-4; kx<9; ix++, kx++)
- {
- if( m_pInput->is_InGrid(ix, iy) && Filter_Directions[k][ky][kx] > 0.0 )
- {
- Variance += M_SQR(Mean - m_pInput->asDouble(ix, iy));
- }
- }
- }
-
- StdDev = corr_norm * sqrt(Variance) / (corr[k] * Count);
-
- if( k == 0 || StdDev < Best_StdDev )
- {
- Best_StdDev = StdDev;
- Best_Mean = Mean;
- Best_Direction = k;
- }
- }
-
- //-----------------------------------------
- if( Best_StdDev > Noise )
- {
- double b = Best_StdDev*Best_StdDev;
-
- b = (b - Noise2) / b;
-
- m_pFiltered->Set_Value(x, y, m_pInput->asDouble(x, y) * b + (1.0 - b) * Best_Mean);
- }
- else if( Best_StdDev > 0.0 )
- {
- m_pFiltered->Set_Value(x, y, Best_Mean);
- }
- else
- {
- m_pFiltered->Set_Value(x, y, m_pInput->asDouble(x, y));
- }
-
- if( m_pDirection ) m_pDirection ->Set_Value(x, y, Best_Direction);
- if( m_pStdDev ) m_pStdDev ->Set_Value(x, y, Best_StdDev);
- }
- }
- }
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Filter //
+// //
+//-------------------------------------------------------//
+// //
+// Filter_Multi_Dir_Lee.cpp //
+// //
+// Copyright (C) 2003 by //
+// Andre Ringeler //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: aringel at gwdg.de //
+// //
+// contact: Andre Ringeler //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+
+#include "Filter_Multi_Dir_Lee.h"
+
+
+double Filter_Directions[16][9][9] =
+{
+ {
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5},
+ {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0},
+ {0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
+ },
+
+ {
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {1.0, 1.0, 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0},
+ {0.5, 0.5, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5, 0.5},
+ {0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 1.0, 1.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
+ },
+
+ {
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {1.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.5, 0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.5, 0.5, 1.0, 0.5, 0.5, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 0.5, 0.5},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 1.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}
+ },
+
+ {
+ {0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.5, 1.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.5, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.5, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 0.5},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5}
+ },
+
+ {
+ {1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0}
+ },
+
+ {
+ {0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.5, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5}
+ },
+
+ {
+ {0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0}
+ },
+
+ {
+ {0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0}
+ },
+
+ {
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0},
+ {0.0, 0.0, 0.0, 0.5, 1.0, 0.5, 0.0, 0.0, 0.0}
+ }
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CFilter_Multi_Dir_Lee::CFilter_Multi_Dir_Lee(void)
+{
+ //-----------------------------------------------------
+ Set_Name(_TL("Multi Direction Lee Filter"));
+
+ Set_Author(_TL("Copyrights (c) 2003 by Andre Ringeler"));
+
+ Set_Description (_TW(
+ "This Multi Direction Lee Filter is a enhanced Lee Filter\n"
+ "It looks into 16 directions for the direction with the minium variance\n"
+ "and applied a Lee Filter on this direction.\n\n"
+ "Uses this filter for remove speckle noise in SAR images or DTMs.\n"
+ "On DTMs this filter will preserves the slope and narrow valleys. \n\n"
+ "For details on the Lee Filter, see the article by Jong-Sen Lee:\n"
+ "\"Digital Image Enhancement and Noise Filtering by Use of Local Statistics\",\n"
+ "IEEE Transactions on Pattern Analysis and Machine Intelligence,\n"
+ "Volume PAMI-2, Number 2, pages 165-168, March 1980.\n\n")
+ );
+
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid(
+ NULL, "INPUT" , _TL("Grid"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL, "RESULT" , _TL("Filtered Grid"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL, "STDDEV" , _TL("Minimum Standard Deviation"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid(
+ NULL, "DIR" , _TL("Direction of Minimum Standard Deviation"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Value(
+ NULL, "NOISE_ABS" , _TL("Estimated Noise (absolute)"),
+ _TL("Estimated noise in units of input data"),
+ PARAMETER_TYPE_Double, 1.0
+ );
+
+ Parameters.Add_Value(
+ NULL, "NOISE_REL" , _TL("Estimated Noise (relative)"),
+ _TL("Estimated noise relative to mean standard deviation"),
+ PARAMETER_TYPE_Double, 1.0
+ );
+
+ Parameters.Add_Value(
+ NULL, "WEIGHTED" , _TL("Weighted"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, true
+ );
+
+ Parameters.Add_Choice(
+ NULL, "METHOD" , _TL("Method"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("noise variance given as absolute value"),
+ _TL("noise variance given relative to mean standard deviation"),
+ _TL("original calculation (Ringeler)")
+ ), 1
+ );
+
+ //-----------------------------------------------------
+ for(int i=1; i<8; i++) // Mirror the last 8 filter directions
+ {
+ for(int y=0; y<9; y++)
+ {
+ for(int x=0; x<9; x++)
+ {
+ Filter_Directions[i + 8][y][x] = Filter_Directions[i][y][8 - x];
+ }
+ }
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CFilter_Multi_Dir_Lee::On_Execute(void)
+{
+ bool bResult = false, bWeighted;
+
+ m_pInput = Parameters("INPUT") ->asGrid();
+ m_pFiltered = Parameters("RESULT") ->asGrid();
+ m_pStdDev = Parameters("STDDEV") ->asGrid();
+ m_pDirection = Parameters("DIR") ->asGrid();
+ bWeighted = Parameters("WEIGHTED") ->asBool();
+
+ switch( Parameters("METHOD")->asInt() )
+ {
+ case 0: bResult = Get_Filter(bWeighted, true); break;
+ case 1: bResult = Get_Filter(bWeighted, false); break;
+ case 2: bResult = Get_Filter_Ringeler(); break;
+ }
+
+ m_pFiltered->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pInput->Get_Name(), _TL("Lee Filter")));
+
+ if( m_pStdDev )
+ {
+ m_pStdDev ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pInput->Get_Name(), _TL("Lee Filter - Standard Deviation")));
+ }
+
+ if( m_pDirection )
+ {
+ m_pDirection ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pInput->Get_Name(), _TL("Lee Filter - Direction")));
+ }
+
+ return( bResult );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CFilter_Multi_Dir_Lee::Get_Filter(bool bWeighted, bool bAbsolute)
+{
+ int x, y, ix, iy, k, kx, ky, Best_Direction;
+ double Count, Mean, StdDev, Variance, Best_Mean, Best_StdDev, Noise, Noise2;
+
+ if( bAbsolute )
+ {
+ Noise = Parameters("NOISE_ABS")->asDouble();
+ Noise2 = Noise*Noise;
+ }
+ else if( m_pStdDev == NULL )
+ {
+ Parameters("STDDEV")->Set_Value(m_pStdDev = SG_Create_Grid(*Get_System(), SG_DATATYPE_Float));
+ }
+
+ //-----------------------------------------------------
+ for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ if( m_pInput->is_NoData(x, y) )
+ {
+ m_pFiltered ->Set_NoData(x, y);
+ if( m_pStdDev ) m_pStdDev ->Set_NoData(x, y);
+ if( m_pDirection ) m_pDirection ->Set_NoData(x, y);
+ }
+ else
+ {
+ //-----------------------------------------
+ for(k=0; k<16; k++)
+ {
+ Variance = Mean = Count = 0;
+
+ for(ky=0, iy=y-4; ky<9; iy++, ky++)
+ {
+ for(kx=0, ix=x-4; kx<9; ix++, kx++)
+ {
+ if( m_pInput->is_InGrid(ix, iy) && Filter_Directions[k][ky][kx] > 0.0 )
+ {
+ double w = bWeighted ? Filter_Directions[k][ky][kx] : 1.0;
+ double z = m_pInput->asDouble(ix, iy);
+ Mean += w * z;
+ Variance += w * z*z;
+ Count += w;
+ }
+ }
+ }
+
+ Mean = Mean / Count;
+ Variance = Variance / Count - Mean*Mean;
+ StdDev = sqrt(Variance);
+
+ if( k == 0 || StdDev < Best_StdDev )
+ {
+ Best_StdDev = StdDev;
+ Best_Mean = Mean;
+ Best_Direction = k;
+ }
+ }
+
+ //-----------------------------------------
+ if( bAbsolute && Best_StdDev > Noise )
+ {
+ double b = Best_StdDev*Best_StdDev;
+
+ b = (b - Noise2) / b;
+
+ m_pFiltered->Set_Value(x, y, m_pInput->asDouble(x, y) * b + (1.0 - b) * Best_Mean);
+ }
+ else if( Best_StdDev > 0.0 )
+ {
+ m_pFiltered->Set_Value(x, y, Best_Mean);
+ }
+ else
+ {
+ m_pFiltered->Set_Value(x, y, m_pInput->asDouble(x, y));
+ }
+
+ if( m_pStdDev ) m_pStdDev ->Set_Value(x, y, Best_StdDev);
+ if( m_pDirection ) m_pDirection ->Set_Value(x, y, Best_Direction);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ if( !bAbsolute )
+ {
+ Noise = Parameters("NOISE_REL")->asDouble() * m_pStdDev->Get_ArithMean();
+ Noise2 = Noise*Noise;
+
+ for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ if( !m_pInput->is_NoData(x, y) && (Best_StdDev = m_pStdDev->asDouble(x, y)) > Noise )
+ {
+ double b = Best_StdDev*Best_StdDev;
+
+ b = (b - Noise2) / b;
+
+ m_pFiltered->Set_Value(x, y, m_pInput->asDouble(x, y) * b + (1.0 - b) * m_pFiltered->asDouble(x, y));
+ }
+ }
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+const double corr_norm = 109699939.0;
+
+const double corr[16] =
+{
+ 97694238.970824,
+ 103389994.176977,
+ 109699939.129502,
+ 103392028.763373,
+ 103392435.589500,
+ 103392028.763371,
+ 109699939.129499,
+ 103389994.176979,
+ 97694238.970826,
+ 103389994.200091,
+ 109699939.176253,
+ 103392028.826671,
+ 103392435.659830,
+ 103392028.826669,
+ 109699939.176251,
+ 103389994.200092
+};
+
+//---------------------------------------------------------
+bool CFilter_Multi_Dir_Lee::Get_Filter_Ringeler(void)
+{
+ int x, y, ix, iy, k, kx, ky, Count, Best_Direction;
+ double Mean, StdDev, Variance, Best_Mean, Best_StdDev, Noise, Noise2;
+
+ Noise = Parameters("NOISE_ABS")->asDouble();
+ Noise2 = Noise*Noise;
+
+ //-----------------------------------------------------
+ for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ if( m_pInput->is_NoData(x, y) )
+ {
+ m_pFiltered->Set_NoData(x, y);
+
+ if( m_pDirection ) m_pDirection ->Set_NoData(x, y);
+ if( m_pStdDev ) m_pStdDev ->Set_NoData(x, y);
+ }
+ else
+ {
+ //-----------------------------------------
+ for(k=0; k<16; k++)
+ {
+ Variance = Mean = Count = 0;
+
+ for(ky=0, iy=y-4; ky<9; iy++, ky++)
+ {
+ for(kx=0, ix=x-4; kx<9; ix++, kx++)
+ {
+ if( m_pInput->is_InGrid(ix, iy) && Filter_Directions[k][ky][kx] > 0.0 )
+ {
+ Mean += m_pInput->asDouble(ix, iy);
+ Count ++;
+ }
+ }
+ }
+
+ Mean = Mean / Count;
+
+ for(ky=0, iy=y-4; ky<9; iy++, ky++)
+ {
+ for(kx=0, ix=x-4; kx<9; ix++, kx++)
+ {
+ if( m_pInput->is_InGrid(ix, iy) && Filter_Directions[k][ky][kx] > 0.0 )
+ {
+ Variance += M_SQR(Mean - m_pInput->asDouble(ix, iy));
+ }
+ }
+ }
+
+ StdDev = corr_norm * sqrt(Variance) / (corr[k] * Count);
+
+ if( k == 0 || StdDev < Best_StdDev )
+ {
+ Best_StdDev = StdDev;
+ Best_Mean = Mean;
+ Best_Direction = k;
+ }
+ }
+
+ //-----------------------------------------
+ if( Best_StdDev > Noise )
+ {
+ double b = Best_StdDev*Best_StdDev;
+
+ b = (b - Noise2) / b;
+
+ m_pFiltered->Set_Value(x, y, m_pInput->asDouble(x, y) * b + (1.0 - b) * Best_Mean);
+ }
+ else if( Best_StdDev > 0.0 )
+ {
+ m_pFiltered->Set_Value(x, y, Best_Mean);
+ }
+ else
+ {
+ m_pFiltered->Set_Value(x, y, m_pInput->asDouble(x, y));
+ }
+
+ if( m_pDirection ) m_pDirection ->Set_Value(x, y, Best_Direction);
+ if( m_pStdDev ) m_pStdDev ->Set_Value(x, y, Best_StdDev);
+ }
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_filter/Filter_Terrain_SlopeBased.cpp b/src/modules/grid/grid_filter/Filter_Terrain_SlopeBased.cpp
new file mode 100644
index 0000000..c709dd8
--- /dev/null
+++ b/src/modules/grid/grid_filter/Filter_Terrain_SlopeBased.cpp
@@ -0,0 +1,305 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Filter //
+// //
+//-------------------------------------------------------//
+// //
+// Filter_Terrain_SlopeBased.cpp //
+// //
+// Copyright (C) 2010 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "Filter_Terrain_SlopeBased.h"
+#include "./../grid_tools/Grid_Gaps.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// Construction/Destruction //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CFilter_Terrain_SlopeBased::CFilter_Terrain_SlopeBased(void)
+{
+
+ //-----------------------------------------------------
+ Set_Name(_TL("DTM Filter (slope-based)"));
+
+ Set_Author(_TL("Volker Wichmann (c) 2010, LASERDATA GmbH"));
+
+ Set_Description (_TW(
+ "The module can be used to filter a digital surface model (DSM), i.e. to classify "
+ "its cells into bare earth and object cells (ground and nonground cells).\n\n"
+ "The module uses concepts described by VOSSELMAN (2000) and is based on the "
+ "assumption that a large height difference between two nearby cells is unlikely "
+ "to be caused by a steep slope in the terrain. The probability that the higher cell "
+ "could be a ground point decreases if the distance between the two cells decreases. "
+ "Therefore the filter defines the acceptable height difference between two cells as "
+ "a function of the distance between the cells. A cell is classified as terrain if "
+ "there is no other cell within the kernel search radius such that the height difference "
+ "between these cells is larger than the allowed maximum height difference at the distance "
+ "between these cells.\n\n"
+ "The approximate terrain slope parameter is used to modify the filter function to match "
+ "the overall slope in the study area. A confidence interval may be used to reject outliers.\n\n"
+ "Reference:\n"
+ "VOSSELMAN, G. (2000): Slope based filtering of laser altimetry data. IAPRS, Vol. XXXIII, "
+ "Part B3, Amsterdam, The Netherlands. pp. 935-942\n\n")
+ );
+
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid(
+ NULL, "INPUT", _TL("Grid to filter"),
+ _TL("The grid to filter."),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Value(
+ NULL, "RADIUS", _TL("Search Radius"),
+ _TL("Search radius of kernel in cells."),
+ PARAMETER_TYPE_Int, 2, 1, true
+ );
+
+ /*Parameters.Add_Value(
+ NULL, "ITERATIONS", _TL("Iterations"),
+ _TL("Number of iterations, starts with search radius and increments with one cell by iteration."),
+ PARAMETER_TYPE_Int, 1, 1, true
+ );*/
+
+ Parameters.Add_Value(
+ NULL, "TERRAINSLOPE", _TL("Approx. Terrain Slope"),
+ _TL("Approximate Terrain Slope [%]"),
+ PARAMETER_TYPE_Double, 30.0, 0.0, true
+ );
+
+ Parameters.Add_Value(
+ NULL, "STDDEV", _TL("Use Confidence Interval"),
+ _TL("Use 5 percent confidence interval"),
+ PARAMETER_TYPE_Bool, false
+ );
+
+ Parameters.Add_Grid(
+ NULL, "GROUND", _TL("Bare Earth"),
+ _TL("Filtered DTM"),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL, "NONGROUND", _TL("Removed Objects"),
+ _TL("Objects removed from input grid"),
+ PARAMETER_OUTPUT
+ );
+
+}
+
+//---------------------------------------------------------
+CFilter_Terrain_SlopeBased::~CFilter_Terrain_SlopeBased(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CFilter_Terrain_SlopeBased::On_Execute(void)
+{
+ CSG_Grid *pInput, *pGround, *pNonGround;
+ CSG_Grid_Radius gridRadius;
+ int sradius;
+ int iterations;
+ double tslope;
+ bool bStdDev;
+
+ CSG_Grid *pFilter;
+ std::vector<double> dzKernel;
+ int gradius;
+ int x, y, ix, iy, iPoint;
+ double dz;
+ int n;
+ double sum, sumsq, stddev, confInter;
+ double min_z, ie;
+
+ //---------------------------------------------------------
+
+ pInput = Parameters("INPUT")->asGrid();
+ pGround = Parameters("GROUND")->asGrid();
+ pNonGround = Parameters("NONGROUND")->asGrid();
+ sradius = Parameters("RADIUS")->asInt() + 1;
+ iterations = 1; //Parameters("ITERATIONS")->asInt();
+ tslope = Parameters("TERRAINSLOPE")->asDouble() / 100.0;
+ bStdDev = Parameters("STDDEV")->asBool();
+
+
+ //---------------------------------------------------------
+ pFilter = SG_Create_Grid(SG_DATATYPE_Double, pInput->Get_NX(), pInput->Get_NY(), pInput->Get_Cellsize(), pInput->Get_XMin(), pInput->Get_YMin());
+
+ pGround ->Assign(pInput);
+ pFilter ->Assign_NoData();
+ pNonGround ->Assign_NoData();
+
+
+
+ for( int iter=0; iter<iterations; iter++ )
+ {
+ //---------------------------------------------------------
+ //Create dzKernel
+
+ gradius = sradius + iter;
+
+ gridRadius.Create(gradius);
+
+ x = gradius + 1;
+ y = gradius + 1;
+
+ for( iPoint=0; iPoint<gridRadius.Get_nPoints(); iPoint++ )
+ {
+ gridRadius.Get_Point(iPoint, x, y, ix, iy);
+ dz = sqrt( pow((x - ix)*pInput->Get_Cellsize(), 2) + pow((y - iy)*pInput->Get_Cellsize(), 2) ) * tslope;
+ dzKernel.push_back(dz);
+ }
+
+ for( y=0; y<pGround->Get_NY() && Set_Progress(y); y++ )
+ {
+ for( x=0; x<pGround->Get_NX(); x++ )
+ {
+ if( !pGround->is_NoData(x, y) )
+ {
+ if( bStdDev )
+ {
+ // calc stddev
+ sum = sumsq = 0.0;
+ n = 0;
+
+ for( iPoint=0; iPoint<gridRadius.Get_nPoints(); iPoint++ )
+ {
+ gridRadius.Get_Point(iPoint, x, y, ix, iy);
+
+ if( pGround->is_InGrid(ix, iy, true) )
+ {
+ if( x != ix && y != iy )
+ {
+ n++;
+ sum += pGround->asDouble(ix, iy);
+ sumsq += pGround->asDouble(ix, iy) * pGround->asDouble(ix, iy);
+ }
+ }
+ }
+
+ stddev = sqrt(sumsq - n * pow(sum/n, 2)) / (n - 1);
+ //stddev = sqrt((sumsq - sum * sum / n) / n);
+
+ confInter = 1.65 * sqrt(2 * stddev);
+ }
+ else
+ confInter = 0.0;
+
+
+ // calc erosion
+ min_z = 999999.0;
+
+ for( iPoint=0; iPoint<gridRadius.Get_nPoints(); iPoint++ )
+ {
+ gridRadius.Get_Point(iPoint, x, y, ix, iy);
+
+ if( pGround->is_InGrid(ix, iy, true) )
+ {
+ if( x != ix && y != iy )
+ {
+ ie = pGround->asDouble(ix, iy) + dzKernel[iPoint] + confInter;
+
+ if( ie < min_z )
+ min_z = ie;
+ }
+ }
+ }
+
+ // classify
+ if( pGround->asDouble(x, y) <= min_z )
+ pFilter->Set_Value(x, y, pGround->asDouble(x, y));
+ else
+ pNonGround->Set_Value(x, y, pGround->asDouble(x, y));
+ }// if not NoData
+ }// for x
+ }// for y
+
+ pGround->Assign(pFilter);
+ pFilter->Assign_NoData();
+
+ gridRadius.Destroy();
+
+ /*CGrid_Gaps CloseGaps;
+
+ if( !CloseGaps.Get_Parameters()->Set_Parameter(SG_T("INPUT") , PARAMETER_TYPE_Grid, pGround)
+ || !CloseGaps.Execute() )
+ {
+ return( false );
+ }*/
+
+ }// for iter
+
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_filter/Filter_Terrain_SlopeBased.h b/src/modules/grid/grid_filter/Filter_Terrain_SlopeBased.h
new file mode 100644
index 0000000..e2f4a38
--- /dev/null
+++ b/src/modules/grid/grid_filter/Filter_Terrain_SlopeBased.h
@@ -0,0 +1,106 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Filter //
+// //
+//-------------------------------------------------------//
+// //
+// Filter_Terrain_SlopeBased.h //
+// //
+// Copyright (C) 2010 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Filter_Terrain_SlopeBased_H
+#define HEADER_INCLUDED__Filter_Terrain_SlopeBased_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include <vector>
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CFilter_Terrain_SlopeBased : public CSG_Module_Grid
+{
+public:
+ CFilter_Terrain_SlopeBased(void);
+ virtual ~CFilter_Terrain_SlopeBased(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Filter_Terrain_SlopeBased_H
diff --git a/src/modules/grid/grid_filter/MLB_Interface.cpp b/src/modules/grid/grid_filter/MLB_Interface.cpp
index 35c995e..3d8a937 100644
--- a/src/modules/grid/grid_filter/MLB_Interface.cpp
+++ b/src/modules/grid/grid_filter/MLB_Interface.cpp
@@ -1,159 +1,135 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// Grid_Filter //
-// //
-//-------------------------------------------------------//
-// //
-// MLB_Interface.cpp //
-// //
-// Copyright (C) 2003 by //
-// SAGA User Group Associaton //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: SAGA User Group Associaton //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// The Module Link Library Interface //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-// 1. Include the appropriate SAGA-API header...
-
-#include "MLB_Interface.h"
-
-
-//---------------------------------------------------------
-// 2. Place general module library informations here...
-
-const SG_Char * Get_Info(int i)
-{
- switch( i )
- {
- case MLB_INFO_Name: default:
- return( _TL("Grid - Filter") );
-
- case MLB_INFO_Author:
- return( _TL("SAGA User Group Associaton (c) 2002") );
-
- case MLB_INFO_Description:
- return( _TL("Tools for the manipulation of gridded data.") );
-
- case MLB_INFO_Version:
- return( SG_T("1.0") );
-
- case MLB_INFO_Menu_Path:
- return( _TL("Grid|Filter") );
- }
-}
-
-
-//---------------------------------------------------------
-// 3. Include the headers of your modules here...
-
-#include "Filter.h"
-#include "Filter_Gauss.h"
-#include "Filter_LoG.h"
-#include "Filter_Multi_Dir_Lee.h"
-#include "Filter_3x3.h"
-#include "FilterClumps.h"
-
-//---------------------------------------------------------
-// 4. Allow your modules to be created here...
-
-CSG_Module * Create_Module(int i)
-{
- // Don't forget to continuously enumerate the case switches
- // when adding new modules! Also bear in mind that the
- // enumeration always has to start with [case 0:] and
- // that [default:] must return NULL!...
-
- CSG_Module *pModule;
-
- switch( i )
- {
- case 0:
- pModule = new CFilter;
- break;
-
- case 1:
- pModule = new CFilter_Gauss;
- break;
-
- case 2:
- pModule = new CFilter_LoG;
- break;
-
- case 3:
- pModule = new CFilter_Multi_Dir_Lee;
- break;
-
- case 4:
- pModule = new CFilter_3x3;
- break;
-
- case 5:
- pModule = new CFilterClumps;
- break;
-
- default:
- pModule = NULL;
- break;
- }
-
- return( pModule );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-//{{AFX_SAGA
-
- MLB_INTERFACE
-
-//}}AFX_SAGA
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Filter //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.cpp //
+// //
+// Copyright (C) 2003 by //
+// SAGA User Group Associaton //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: SAGA User Group Associaton //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// The Module Link Library Interface //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+// 1. Include the appropriate SAGA-API header...
+
+#include "MLB_Interface.h"
+
+
+//---------------------------------------------------------
+// 2. Place general module library informations here...
+
+const SG_Char * Get_Info(int i)
+{
+ switch( i )
+ {
+ case MLB_INFO_Name: default:
+ return( _TL("Grid - Filter") );
+
+ case MLB_INFO_Author:
+ return( _TL("SAGA User Group Associaton (c) 2002-2010") );
+
+ case MLB_INFO_Description:
+ return( _TL("Tools for the manipulation of gridded data.") );
+
+ case MLB_INFO_Version:
+ return( SG_T("1.0") );
+
+ case MLB_INFO_Menu_Path:
+ return( _TL("Grid|Filter") );
+ }
+}
+
+
+//---------------------------------------------------------
+// 3. Include the headers of your modules here...
+
+#include "Filter.h"
+#include "Filter_Gauss.h"
+#include "Filter_LoG.h"
+#include "Filter_Multi_Dir_Lee.h"
+#include "Filter_3x3.h"
+#include "FilterClumps.h"
+#include "Filter_Majority.h"
+#include "Filter_Terrain_SlopeBased.h"
+
+//---------------------------------------------------------
+// 4. Allow your modules to be created here...
+
+CSG_Module * Create_Module(int i)
+{
+ switch( i )
+ {
+ case 0: return( new CFilter );
+ case 1: return( new CFilter_Gauss );
+ case 2: return( new CFilter_LoG );
+ case 3: return( new CFilter_Multi_Dir_Lee );
+ case 4: return( new CFilter_3x3 );
+ case 5: return( new CFilterClumps );
+ case 6: return( new CFilter_Majority );
+ case 7: return( new CFilter_Terrain_SlopeBased );
+ }
+
+ return( NULL );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+//{{AFX_SAGA
+
+ MLB_INTERFACE
+
+//}}AFX_SAGA
diff --git a/src/modules/grid/grid_filter/Makefile.am b/src/modules/grid/grid_filter/Makefile.am
index 6122c73..419017a 100644
--- a/src/modules/grid/grid_filter/Makefile.am
+++ b/src/modules/grid/grid_filter/Makefile.am
@@ -1,32 +1,36 @@
-#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:18 tschorr Exp $
-#
-if DEBUG
-DBGFLAGS = -g -DDEBUG
-endif
-if SAGA_UNICODE
-UC_DEFS = -D_SAGA_UNICODE
-endif
-DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
-CXX_INCS = -I$(top_srcdir)/src/saga_core
-AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
-pkglib_LTLIBRARIES = libgrid_filter.la
-libgrid_filter_la_SOURCES =\
-Filter.cpp\
-Filter_3x3.cpp\
-Filter_Gauss.cpp\
-Filter_LoG.cpp\
-Filter_Multi_Dir_Lee.cpp\
-FilterClumps.cpp\
-MLB_Interface.cpp\
-Filter.h\
-Filter_3x3.h\
-Filter_Gauss.h\
-Filter_LoG.h\
-Filter_Multi_Dir_Lee.h\
-FilterClumps.h\
-MLB_Interface.h
-
-libgrid_filter_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
-
+#
+# $Id: Makefile.am,v 1.8 2010/07/08 14:11:48 johanvdw Exp $
+#
+if DEBUG
+DBGFLAGS = -g -DDEBUG
+endif
+if SAGA_UNICODE
+UC_DEFS = -D_SAGA_UNICODE
+endif
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -avoid-version
+pkglib_LTLIBRARIES = libgrid_filter.la
+libgrid_filter_la_SOURCES =\
+Filter.cpp\
+Filter_3x3.cpp\
+Filter_Gauss.cpp\
+Filter_LoG.cpp\
+Filter_Majority.cpp\
+Filter_Multi_Dir_Lee.cpp\
+Filter_Terrain_SlopeBased.cpp\
+FilterClumps.cpp\
+MLB_Interface.cpp\
+Filter.h\
+Filter_3x3.h\
+Filter_Gauss.h\
+Filter_LoG.h\
+Filter_Majority.h\
+Filter_Multi_Dir_Lee.h\
+Filter_Terrain_SlopeBased.h\
+FilterClumps.h\
+MLB_Interface.h
+
+libgrid_filter_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+
diff --git a/src/modules/grid/grid_filter/Makefile.in b/src/modules/grid/grid_filter/Makefile.in
index 6fc9311..2b6fa2f 100644
--- a/src/modules/grid/grid_filter/Makefile.in
+++ b/src/modules/grid/grid_filter/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -70,10 +69,10 @@ LTLIBRARIES = $(pkglib_LTLIBRARIES)
libgrid_filter_la_DEPENDENCIES = \
$(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
am_libgrid_filter_la_OBJECTS = Filter.lo Filter_3x3.lo Filter_Gauss.lo \
- Filter_LoG.lo Filter_Multi_Dir_Lee.lo FilterClumps.lo \
- MLB_Interface.lo
+ Filter_LoG.lo Filter_Majority.lo Filter_Multi_Dir_Lee.lo \
+ Filter_Terrain_SlopeBased.lo FilterClumps.lo MLB_Interface.lo
libgrid_filter_la_OBJECTS = $(am_libgrid_filter_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +128,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,28 +219,32 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:18 tschorr Exp $
+# $Id: Makefile.am,v 1.8 2010/07/08 14:11:48 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_filter.la
libgrid_filter_la_SOURCES = \
Filter.cpp\
Filter_3x3.cpp\
Filter_Gauss.cpp\
Filter_LoG.cpp\
+Filter_Majority.cpp\
Filter_Multi_Dir_Lee.cpp\
+Filter_Terrain_SlopeBased.cpp\
FilterClumps.cpp\
MLB_Interface.cpp\
Filter.h\
Filter_3x3.h\
Filter_Gauss.h\
Filter_LoG.h\
+Filter_Majority.h\
Filter_Multi_Dir_Lee.h\
+Filter_Terrain_SlopeBased.h\
FilterClumps.h\
MLB_Interface.h
@@ -323,7 +328,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Filter_3x3.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Filter_Gauss.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Filter_LoG.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Filter_Majority.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Filter_Multi_Dir_Lee.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Filter_Terrain_SlopeBased.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
.cpp.o:
diff --git a/src/modules/grid/grid_gridding/Interpolation.cpp b/src/modules/grid/grid_gridding/Interpolation.cpp
index 2b77bae..ffffb08 100644
--- a/src/modules/grid/grid_gridding/Interpolation.cpp
+++ b/src/modules/grid/grid_gridding/Interpolation.cpp
@@ -70,16 +70,7 @@
//---------------------------------------------------------
CInterpolation::CInterpolation(void)
{
- CSG_Parameter *pNode;
- CSG_Parameters *pParameters;
-
- //-----------------------------------------------------
- Parameters.Add_Grid_Output(
- NULL , "GRID" , _TL("Grid"),
- _TL("")
- );
-
- pNode = Parameters.Add_Shapes(
+ CSG_Parameter *pNode = Parameters.Add_Shapes(
NULL , "SHAPES" , _TL("Points"),
_TL(""),
PARAMETER_INPUT
@@ -90,58 +81,31 @@ CInterpolation::CInterpolation(void)
_TL("")
);
+ //-----------------------------------------------------
Parameters.Add_Choice(
NULL , "TARGET" , _TL("Target Grid"),
_TL(""),
-
- CSG_String::Format(SG_T("%s|%s|%s|"),
+ CSG_String::Format(SG_T("%s|%s|"),
_TL("user defined"),
- _TL("grid system"),
_TL("grid")
), 0
);
- //-----------------------------------------------------
- pParameters = Add_Parameters("USER", _TL("User defined grid") , _TL(""));
-
- pParameters->Add_Value(
- NULL , "CELL_SIZE" , _TL("Grid Size"),
- _TL(""),
- PARAMETER_TYPE_Double, 100.0, 0.0, true
- );
-
- pNode = pParameters->Add_Value(
- NULL , "FIT_EXTENT" , _TL("Fit Extent"),
- _TL("Automatically fits the grid to the shapes layers extent."),
- PARAMETER_TYPE_Bool , true
- );
-
- pParameters->Add_Range(
- pNode , "X_EXTENT" , _TL("X-Extent"),
- _TL("")
- );
-
- pParameters->Add_Range(
- pNode , "Y_EXTENT" , _TL("Y-Extent"),
- _TL("")
- );
-
- //-----------------------------------------------------
- pParameters = Add_Parameters("SYSTEM" , _TL("Choose Grid System") , _TL(""));
+ m_Grid_Target.Add_Parameters_User(Add_Parameters("USER", _TL("User Defined Grid") , _TL("")));
+ m_Grid_Target.Add_Parameters_Grid(Add_Parameters("GRID", _TL("Choose Grid") , _TL("")));
+}
- pParameters->Add_Grid_System(
- NULL , "SYSTEM" , _TL("Grid System"),
- _TL("")
- );
- //-----------------------------------------------------
- pParameters = Add_Parameters("GRID" , _TL("Choose Grid") , _TL(""));
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
- pParameters->Add_Grid(
- NULL , "GRID" , _TL("Grid"),
- _TL(""),
- PARAMETER_INPUT , false
- );
+//---------------------------------------------------------
+int CInterpolation::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ return( m_Grid_Target.On_User_Changed(pParameters, pParameter) ? 1 : 0 );
}
@@ -161,8 +125,30 @@ bool CInterpolation::On_Execute(void)
m_zField = Parameters("FIELD") ->asInt();
//-----------------------------------------------------
- if( _Get_Grid() )
+ m_pGrid = NULL;
+
+ switch( Parameters("TARGET")->asInt() )
+ {
+ case 0: // user defined...
+ if( m_Grid_Target.Init_User(m_pShapes->Get_Extent()) && Dlg_Parameters("USER") )
+ {
+ m_pGrid = m_Grid_Target.Get_User();
+ }
+ break;
+
+ case 1: // grid...
+ if( Dlg_Parameters("GRID") )
+ {
+ m_pGrid = m_Grid_Target.Get_Grid();
+ }
+ break;
+ }
+
+ //-----------------------------------------------------
+ if( m_pGrid )
{
+ m_pGrid->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_pShapes->Get_Name(), Get_Name()));
+
bResult = Interpolate();
}
@@ -177,13 +163,20 @@ bool CInterpolation::On_Execute(void)
return( bResult );
}
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
bool CInterpolation::Interpolate(void)
{
if( On_Initialize() )
{
int ix, iy;
- double x, y, z;
+ double x, y, z;
for(iy=0, y=m_pGrid->Get_YMin(); iy<m_pGrid->Get_NY() && Set_Progress(iy, m_pGrid->Get_NY()); iy++, y+=m_pGrid->Get_Cellsize())
{
@@ -216,29 +209,38 @@ bool CInterpolation::Interpolate(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-CSG_Shapes * CInterpolation::Get_Points(void)
+CSG_Shapes * CInterpolation::Get_Points(bool bOnlyNonPoints)
{
m_pShapes = Parameters("SHAPES") ->asShapes();
- if( m_pShapes->Get_Type() != SHAPE_TYPE_Point )
+ if( !bOnlyNonPoints || m_pShapes->Get_Type() != SHAPE_TYPE_Point )
{
- CSG_Shapes *pPoints = SG_Create_Shapes(SHAPE_TYPE_Point, _TL(""), m_pShapes);
+ CSG_Shapes *pPoints = SG_Create_Shapes(SHAPE_TYPE_Point);
+
+ pPoints->Set_NoData_Value_Range(m_pShapes->Get_NoData_Value(), m_pShapes->Get_NoData_hiValue());
+ pPoints->Add_Field(SG_T("Z"), SG_DATATYPE_Double);
for(int iShape=0; iShape<m_pShapes->Get_Count() && Set_Progress(iShape, m_pShapes->Get_Count()); iShape++)
{
CSG_Shape *pShape = m_pShapes->Get_Shape(iShape);
- for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ if( !pShape->is_NoData(m_zField) )
{
- for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
{
- CSG_Shape *pPoint = pPoints->Add_Shape(pShape, SHAPE_COPY_ATTR);
+ for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ CSG_Shape *pPoint = pPoints->Add_Shape();
- pPoint->Add_Point(pShape->Get_Point(iPoint, iPart));
+ pPoint->Add_Point(pShape->Get_Point(iPoint, iPart));
+
+ pPoint->Set_Value(0, pShape->asDouble(m_zField));
+ }
}
}
}
+ m_zField = 0;
m_pShapes = pPoints;
}
@@ -259,75 +261,3 @@ bool CInterpolation::Set_Search_Engine(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-bool CInterpolation::_Get_Grid(void)
-{
- CSG_Shapes *pShapes;
-
- pShapes = Parameters("SHAPES")->asShapes();
- m_pGrid = NULL;
-
- //-------------------------------------------------
- switch( Parameters("TARGET")->asInt() )
- {
- case 0: // user defined...
- if( Dlg_Parameters("USER") )
- {
- m_pGrid = _Get_Grid(pShapes->Get_Extent());
- }
- break;
-
- case 1: // grid system...
- if( Dlg_Parameters("SYSTEM") )
- {
- m_pGrid = SG_Create_Grid(*Get_Parameters("SYSTEM")->Get_Parameter("SYSTEM")->asGrid_System(), SG_DATATYPE_Float);
- }
- break;
-
- case 2: // grid...
- if( Dlg_Parameters("GRID") )
- {
- m_pGrid = Get_Parameters("GRID")->Get_Parameter("GRID")->asGrid();
- }
- break;
- }
-
- //-------------------------------------------------
- if( m_pGrid )
- {
- m_pGrid->Set_Name(CSG_String::Format(SG_T("%s (%s)"), pShapes->Get_Name(), Get_Name()));
- Parameters("GRID")->Set_Value(m_pGrid);
- }
-
- //-----------------------------------------------------
- return( m_pGrid != NULL );
-}
-
-//---------------------------------------------------------
-CSG_Grid * CInterpolation::_Get_Grid(TSG_Rect Extent)
-{
- CSG_Parameters *P = Get_Parameters("USER");
-
- if( !P->Get_Parameter("FIT_EXTENT")->asBool() )
- {
- Extent.xMin = P->Get_Parameter("X_EXTENT")->asRange()->Get_LoVal();
- Extent.yMin = P->Get_Parameter("Y_EXTENT")->asRange()->Get_LoVal();
- Extent.xMax = P->Get_Parameter("X_EXTENT")->asRange()->Get_HiVal();
- Extent.yMax = P->Get_Parameter("Y_EXTENT")->asRange()->Get_HiVal();
- }
-
- double d = P->Get_Parameter("CELL_SIZE")->asDouble();
-
- int nx = 1 + (int)((Extent.xMax - Extent.xMin) / d);
- int ny = 1 + (int)((Extent.yMax - Extent.yMin) / d);
-
- return( nx > 1 && ny > 1 ? SG_Create_Grid(SG_DATATYPE_Float, nx, ny, d, Extent.xMin, Extent.yMin) : NULL );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
diff --git a/src/modules/grid/grid_gridding/Interpolation.h b/src/modules/grid/grid_gridding/Interpolation.h
index 3607cbf..09e5a2d 100644
--- a/src/modules/grid/grid_gridding/Interpolation.h
+++ b/src/modules/grid/grid_gridding/Interpolation.h
@@ -84,38 +84,39 @@ class CInterpolation : public CSG_Module
public:
CInterpolation(void);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Interpolation from Points") ); }
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Interpolation from Points") ); }
protected:
- virtual bool On_Execute (void);
+ virtual bool On_Execute (void);
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
- int m_zField;
- CSG_PRQuadTree m_Search;
+ int m_zField;
- CSG_Grid *m_pGrid;
+ CSG_PRQuadTree m_Search;
- CSG_Shapes *m_pShapes;
+ CSG_Grid *m_pGrid;
+ CSG_Shapes *m_pShapes;
- virtual bool Interpolate (void);
- virtual bool On_Initialize (void) { return( true ); }
- virtual bool On_Finalize (void) { return( true ); }
+ virtual bool Interpolate (void);
- virtual bool Get_Value (double x, double y, double &z) { return( true ); }
+ virtual bool On_Initialize (void) { return( true ); }
+ virtual bool On_Finalize (void) { return( true ); }
- CSG_Shapes * Get_Points (void);
- bool Set_Search_Engine (void);
+ virtual bool Get_Value (double x, double y, double &z) { return( true ); }
+
+ CSG_Shapes * Get_Points (bool bOnlyNonPoints = false);
+ bool Set_Search_Engine (void);
private:
- bool _Get_Grid (void);
- CSG_Grid * _Get_Grid (TSG_Rect Extent);
+ CSG_Parameters_Grid_Target m_Grid_Target;
};
diff --git a/src/modules/grid/grid_gridding/Interpolation_InverseDistance.cpp b/src/modules/grid/grid_gridding/Interpolation_InverseDistance.cpp
index 61c5eab..dd6a414 100644
--- a/src/modules/grid/grid_gridding/Interpolation_InverseDistance.cpp
+++ b/src/modules/grid/grid_gridding/Interpolation_InverseDistance.cpp
@@ -70,40 +70,77 @@
//---------------------------------------------------------
CInterpolation_InverseDistance::CInterpolation_InverseDistance(void)
{
- Set_Name (_TL("Inverse Distance"));
+ CSG_Parameter *pNode;
- Set_Author (SG_T("O. Conrad (c) 2003"));
+ Set_Name (_TL("Inverse Distance Weighted"));
+
+ Set_Author (SG_T("O.Conrad (c) 2003"));
Set_Description (_TW(
- "Inverse distance to a power method for grid interpolation from irregular distributed points."
+ "Inverse distance grid interpolation from irregular distributed points."
));
+ pNode = Parameters.Add_Choice(
+ NULL , "WEIGHTING" , _TL("Distance Weighting"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|%s|"),
+ _TL("inverse distance to a power"),
+ _TL("linearly decreasing within search radius"),
+ _TL("exponential weighting scheme"),
+ _TL("gaussian weighting scheme")
+ ), 0
+ );
+
Parameters.Add_Value(
- NULL , "POWER" , _TL("Inverse Distance: Power"),
+ pNode , "POWER" , _TL("Inverse Distance Power"),
_TL(""),
- PARAMETER_TYPE_Double , 1.0
+ PARAMETER_TYPE_Double , 2.0
);
Parameters.Add_Value(
- NULL , "RADIUS" , _TL("Search Radius"),
+ pNode , "BANDWIDTH" , _TL("Exponential and Gaussian Weighting Bandwidth"),
_TL(""),
- PARAMETER_TYPE_Double , 100.0
+ PARAMETER_TYPE_Double , 1.0, 0.0, true
+ );
+
+ pNode = Parameters.Add_Choice(
+ NULL , "RANGE" , _TL("Search Range"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("search radius (local)"),
+ _TL("no search radius (global)")
+ )
);
Parameters.Add_Value(
- NULL , "NPOINTS" , _TL("Maximum Points"),
+ pNode , "RADIUS" , _TL("Search Radius"),
_TL(""),
- PARAMETER_TYPE_Int , 10.0
+ PARAMETER_TYPE_Double , 100.0
);
Parameters.Add_Choice(
- NULL , "MODE" , _TL("Search Mode"),
+ pNode , "MODE" , _TL("Search Mode"),
_TL(""),
CSG_String::Format(SG_T("%s|%s|"),
_TL("all directions"),
_TL("quadrants")
)
);
+
+ pNode = Parameters.Add_Choice(
+ NULL , "POINTS" , _TL("Number of Points"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("maximum number of points"),
+ _TL("all points")
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode , "NPOINTS" , _TL("Maximum Number of Points"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 10.0
+ );
}
@@ -116,46 +153,89 @@ CInterpolation_InverseDistance::CInterpolation_InverseDistance(void)
//---------------------------------------------------------
bool CInterpolation_InverseDistance::On_Initialize(void)
{
- m_Power = Parameters("POWER") ->asDouble();
- m_Radius = Parameters("RADIUS") ->asDouble();
- m_nPoints_Max = Parameters("NPOINTS") ->asInt();
- m_Mode = Parameters("MODE") ->asInt();
+ m_Weighting = Parameters("WEIGHTING") ->asInt();
+ m_Power = Parameters("POWER") ->asDouble();
+ m_Bandwidth = Parameters("BANDWIDTH") ->asDouble();
+ m_Mode = Parameters("MODE") ->asInt();
+ m_nPoints_Max = Parameters("POINTS") ->asInt() == 0 ? Parameters("NPOINTS")->asInt() : 0;
+ m_Radius = Parameters("RANGE") ->asInt() == 0 ? Parameters("RADIUS") ->asDouble() : 0.0;
- return( Set_Search_Engine() );
+ return( (m_nPoints_Max == 0 && m_Radius == 0.0) || Set_Search_Engine() );
+}
+
+//---------------------------------------------------------
+inline double CInterpolation_InverseDistance::Get_Weight(double Distance)
+{
+ switch( m_Weighting )
+ {
+ default: return( Distance > 0.0 ? pow(Distance, -m_Power) : -1.0 );
+ case 1: return( Distance < m_Radius ? (1.0 - Distance / m_Radius) : 0.0 );
+ case 2: return( exp(-Distance / m_Bandwidth) );
+ case 3: return( exp(-0.5 * SG_Get_Square(Distance / m_Bandwidth)) );
+ }
}
//---------------------------------------------------------
bool CInterpolation_InverseDistance::Get_Value(double x, double y, double &z)
{
- int i, n;
- double ix, iy, iz, d, w;
+ double w, ix, iy, iz;
- switch( m_Mode )
+ z = 0.0;
+ w = 0.0;
+
+ //-----------------------------------------------------
+ if( m_nPoints_Max > 0 || m_Radius > 0.0 ) // using search engine
{
- case 0: n = m_Search.Select_Nearest_Points(x, y, m_nPoints_Max, m_Radius); break;
- case 1: n = m_Search.Select_Nearest_Points(x, y, m_nPoints_Max, m_Radius, 4); break;
+ int nPoints = m_Search.Select_Nearest_Points(x, y, m_nPoints_Max, m_Radius, m_Mode == 0 ? -1 : 4);
+
+ for(int iPoint=0; iPoint<nPoints; iPoint++)
+ {
+ if( m_Search.Get_Selected_Point(iPoint, ix, iy, iz) )
+ {
+ double d = Get_Weight(SG_Get_Distance(x, y, ix, iy));
+
+ if( d <= 0.0 )
+ {
+ z = iz;
+
+ return( true );
+ }
+
+ z += d * iz;
+ w += d;
+ }
+ }
}
- for(i=0, z=0.0, w=0.0; i<n; i++)
+ //-----------------------------------------------------
+ else // without search engine
{
- if( m_Search.Get_Selected_Point(i, ix, iy, iz) )
+ for(int iShape=0; iShape<m_pShapes->Get_Count() && Process_Get_Okay(); iShape++)
{
- d = SG_Get_Distance(x, y, ix, iy);
+ CSG_Shape *pShape = m_pShapes->Get_Shape(iShape);
- if( d <= 0.0 )
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
{
- z = iz;
+ for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ TSG_Point p = pShape->Get_Point(iPoint, iPart);
+ double d = Get_Weight(SG_Get_Distance(x, y, p.x, p.y));
- return( true );
- }
+ if( d < 0.0 )
+ {
+ z = pShape->asDouble(m_zField);
- d = pow(d, -m_Power);
+ return( true );
+ }
- z += d * iz;
- w += d;
+ z += d * pShape->asDouble(m_zField);
+ w += d;
+ }
+ }
}
}
+ //-----------------------------------------------------
if( w > 0.0 )
{
z /= w;
diff --git a/src/modules/grid/grid_gridding/Interpolation_InverseDistance.h b/src/modules/grid/grid_gridding/Interpolation_InverseDistance.h
index fe873f4..2f4c239 100644
--- a/src/modules/grid/grid_gridding/Interpolation_InverseDistance.h
+++ b/src/modules/grid/grid_gridding/Interpolation_InverseDistance.h
@@ -94,9 +94,12 @@ protected:
private:
- int m_nPoints_Max, m_Mode;
+ int m_Weighting, m_nPoints_Max, m_Mode;
- double m_Power, m_Radius;
+ double m_Power, m_Bandwidth, m_Radius;
+
+
+ double Get_Weight (double Distance);
};
diff --git a/src/modules/grid/grid_gridding/Interpolation_NaturalNeighbour.cpp b/src/modules/grid/grid_gridding/Interpolation_NaturalNeighbour.cpp
index fa0ccbc..2c36f57 100644
--- a/src/modules/grid/grid_gridding/Interpolation_NaturalNeighbour.cpp
+++ b/src/modules/grid/grid_gridding/Interpolation_NaturalNeighbour.cpp
@@ -97,7 +97,7 @@ CInterpolation_NaturalNeighbour::CInterpolation_NaturalNeighbour(void)
//---------------------------------------------------------
bool CInterpolation_NaturalNeighbour::Interpolate(void)
{
- int i, x, y;
+ int i, n, x, y;
double zMin, zMax;
TSG_Point p;
@@ -107,24 +107,29 @@ bool CInterpolation_NaturalNeighbour::Interpolate(void)
point *pSrc = (point *)SG_Malloc(m_pShapes->Get_Count() * sizeof(point));
double *zSrc = (double *)SG_Malloc(m_pShapes->Get_Count() * sizeof(double));
- for(i=0; i<m_pShapes->Get_Count() && Set_Progress(i, m_pShapes->Get_Count()); i++)
+ for(i=0, n=0; i<m_pShapes->Get_Count() && Set_Progress(i, m_pShapes->Get_Count()); i++)
{
CSG_Shape *pShape = m_pShapes->Get_Shape(i);
- pSrc[i].x = pShape->Get_Point(0).x;
- pSrc[i].y = pShape->Get_Point(0).y;
- pSrc[i].z = zSrc[i] = pShape->asDouble(m_zField);
-
- if( i == 0 )
- zMin = zMax = pSrc[i].z;
- else if( zMin > pSrc[i].z )
- zMin = pSrc[i].z;
- else if( zMax < pSrc[i].z )
- zMax = pSrc[i].z;
+ if( !pShape->is_NoData(m_zField) )
+ {
+ pSrc[n].x = pShape->Get_Point(0).x;
+ pSrc[n].y = pShape->Get_Point(0).y;
+ pSrc[n].z = zSrc[n] = pShape->asDouble(m_zField);
+
+ if( n == 0 )
+ zMin = zMax = pSrc[n].z;
+ else if( zMin > pSrc[n].z )
+ zMin = pSrc[n].z;
+ else if( zMax < pSrc[n].z )
+ zMax = pSrc[n].z;
+
+ n++;
+ }
}
Process_Set_Text(_TL("triangulating"));
- delaunay *pTIN = delaunay_build(m_pShapes->Get_Count(), pSrc, 0, NULL, 0, NULL);
+ delaunay *pTIN = delaunay_build(n, pSrc, 0, NULL, 0, NULL);
//-----------------------------------------------------
double *xDst = (double *)SG_Malloc(m_pGrid->Get_NCells() * sizeof(double));
diff --git a/src/modules/grid/grid_gridding/Interpolation_Shepard.cpp b/src/modules/grid/grid_gridding/Interpolation_Shepard.cpp
index a8fc9d9..5cb30f6 100644
--- a/src/modules/grid/grid_gridding/Interpolation_Shepard.cpp
+++ b/src/modules/grid/grid_gridding/Interpolation_Shepard.cpp
@@ -115,39 +115,49 @@ CInterpolation_Shepard::~CInterpolation_Shepard(void)
//---------------------------------------------------------
bool CInterpolation_Shepard::On_Initialize(void)
{
- Quadratic_Neighbors = Parameters("QUADRATIC_NEIGHBORS") ->asInt();
- Weighting_Neighbors = Parameters("WEIGHTING_NEIGHBORS") ->asInt();
+ m_Quadratic_Neighbors = Parameters("QUADRATIC_NEIGHBORS") ->asInt();
+ m_Weighting_Neighbors = Parameters("WEIGHTING_NEIGHBORS") ->asInt();
- m_pShapes = Get_Points();
- MaxPoints = m_pShapes->Get_Count();
+ m_pShapes = Get_Points();
+ m_MaxPoints = 0;
- if( MaxPoints > 1 )
+ if( m_pShapes->Get_Count() > 1 )
{
- x_vals = (double *)malloc(MaxPoints*sizeof(double));
- y_vals = (double *)malloc(MaxPoints*sizeof(double));
- f_vals = (double *)malloc(MaxPoints*sizeof(double));
+ x_vals = (double *)malloc(m_pShapes->Get_Count() * sizeof(double));
+ y_vals = (double *)malloc(m_pShapes->Get_Count() * sizeof(double));
+ f_vals = (double *)malloc(m_pShapes->Get_Count() * sizeof(double));
- for(int iPoint=0; iPoint<MaxPoints; iPoint++)
+ for(int iPoint=0; iPoint<m_pShapes->Get_Count(); iPoint++)
{
- x_vals[iPoint] = m_pShapes->Get_Shape(iPoint)->Get_Point(0).x;
- y_vals[iPoint] = m_pShapes->Get_Shape(iPoint)->Get_Point(0).y;
- f_vals[iPoint] = m_pShapes->Get_Shape(iPoint)->asDouble(m_zField);
+ CSG_Shape *pShape = m_pShapes->Get_Shape(iPoint);
+
+ if( !pShape->is_NoData(m_zField) )
+ {
+ x_vals[m_MaxPoints] = pShape->Get_Point(0).x;
+ y_vals[m_MaxPoints] = pShape->Get_Point(0).y;
+ f_vals[m_MaxPoints] = pShape->asDouble(m_zField);
+
+ m_MaxPoints++;
+ }
}
Remove_Duplicate();
- Interpolator.Interpolate(x_vals, y_vals, f_vals, MaxPoints - 1, Quadratic_Neighbors, Weighting_Neighbors);
+ Interpolator.Interpolate(x_vals, y_vals, f_vals, m_MaxPoints - 1, m_Quadratic_Neighbors, m_Weighting_Neighbors);
}
- return( MaxPoints > 1 );
+ return( m_MaxPoints > 1 );
}
//---------------------------------------------------------
bool CInterpolation_Shepard::On_Finalize(void)
{
- free(x_vals);
- free(y_vals);
- free(f_vals);
+ if( m_pShapes->Get_Count() > 1 )
+ {
+ free(x_vals);
+ free(y_vals);
+ free(f_vals);
+ }
return( true );
}
@@ -208,42 +218,44 @@ void CInterpolation_Shepard::Remove_Duplicate()
Data_Point * Data;
int i,j;
- Data = (Data_Point * ) malloc (MaxPoints * sizeof(Data_Point) );
+ Data = (Data_Point * ) malloc (m_MaxPoints * sizeof(Data_Point) );
- for (i = 0; i < MaxPoints; i++)
+ for (i = 0; i < m_MaxPoints; i++)
{
Data[i].x = x_vals[i];
Data[i].y = y_vals[i];
Data[i].val = f_vals[i];
}
- qsort((void *)Data, MaxPoints, sizeof(Data_Point), Comp_Func);
+ qsort((void *)Data, m_MaxPoints, sizeof(Data_Point), Comp_Func);
bool durty = true;
while (durty)
{
durty = false;
- for (i = 0; i < MaxPoints -1; ++i)
+
+ for (i = 0; i < m_MaxPoints -1; ++i)
{
- if (fabs(Data[i].y - Data[i + 1].y) < eps)
- if (fabs(Data[i].x - Data[i + 1].x) < eps)
+ if( fabs(Data[i].y - Data[i + 1].y) < eps
+ && fabs(Data[i].x - Data[i + 1].x) < eps )
+ {
+ for (j = i; j < m_MaxPoints -1; j++)
{
- for (j = i; j < MaxPoints -1; j++)
- {
- Data[j].x = Data[j + 1].x;
- Data[j].y = Data[j + 1].y;
- Data[j].val = Data[j + 1].val;
- }
-
- MaxPoints--;
- durty = true;
+ Data[j].x = Data[j + 1].x;
+ Data[j].y = Data[j + 1].y;
+ Data[j].val = Data[j + 1].val;
}
- }
- qsort((void *)Data, MaxPoints, sizeof(Data_Point), Comp_Func);
+
+ m_MaxPoints--;
+ durty = true;
+ }
+ }
+
+ qsort((void *)Data, m_MaxPoints, sizeof(Data_Point), Comp_Func);
}
- for (i = 0; i < MaxPoints; i++)
+ for (i = 0; i < m_MaxPoints; i++)
{
x_vals[i] = Data[i].x;
y_vals[i] = Data[i].y;
diff --git a/src/modules/grid/grid_gridding/Interpolation_Shepard.h b/src/modules/grid/grid_gridding/Interpolation_Shepard.h
index 06913cb..5016d98 100644
--- a/src/modules/grid/grid_gridding/Interpolation_Shepard.h
+++ b/src/modules/grid/grid_gridding/Interpolation_Shepard.h
@@ -113,7 +113,7 @@ protected:
private:
- int MaxPoints, Quadratic_Neighbors, Weighting_Neighbors;
+ int m_MaxPoints, m_Quadratic_Neighbors, m_Weighting_Neighbors;
double *x_vals, *y_vals, *f_vals;
diff --git a/src/modules/grid/grid_gridding/Interpolation_Triangulation.cpp b/src/modules/grid/grid_gridding/Interpolation_Triangulation.cpp
index 80680ef..a527840 100644
--- a/src/modules/grid/grid_gridding/Interpolation_Triangulation.cpp
+++ b/src/modules/grid/grid_gridding/Interpolation_Triangulation.cpp
@@ -72,17 +72,13 @@ CInterpolation_Triangulation::CInterpolation_Triangulation(void)
{
Set_Name (_TL("Triangulation"));
- Set_Author (SG_T("(c) 2004 by O.Conrad"));
+ Set_Author (SG_T("O.Conrad (c) 2004"));
Set_Description (_TW(
"Gridding of a shapes layer using Delaunay Triangulation."
));
}
-//---------------------------------------------------------
-CInterpolation_Triangulation::~CInterpolation_Triangulation(void)
-{}
-
///////////////////////////////////////////////////////////
// //
@@ -93,26 +89,25 @@ CInterpolation_Triangulation::~CInterpolation_Triangulation(void)
//---------------------------------------------------------
bool CInterpolation_Triangulation::Interpolate(void)
{
- int iTriangle, iPoint;
- TPoint p[3];
- CSG_TIN_Triangle *pTriangle;
- CSG_TIN TIN;
+ CSG_TIN TIN;
- if( TIN.Create(m_pShapes) )
+ if( TIN.Create(Get_Points()) )
{
m_pGrid->Assign_NoData();
- for(iTriangle=0; iTriangle<TIN.Get_Triangle_Count() && Set_Progress(iTriangle, TIN.Get_Triangle_Count()); iTriangle++)
+ for(int iTriangle=0; iTriangle<TIN.Get_Triangle_Count() && Set_Progress(iTriangle, TIN.Get_Triangle_Count()); iTriangle++)
{
- pTriangle = TIN.Get_Triangle(iTriangle);
+ CSG_TIN_Triangle *pTriangle = TIN.Get_Triangle(iTriangle);
if( m_pGrid->Get_Extent().Intersects(pTriangle->Get_Extent()) != INTERSECTION_None )
{
- for(iPoint=0; iPoint<3; iPoint++)
+ TSG_Point_Z p[3];
+
+ for(int iPoint=0; iPoint<3; iPoint++)
{
- p[iPoint].x = m_pGrid->Get_System().Get_xWorld_to_Grid(pTriangle->Get_Node(iPoint)->Get_X());
- p[iPoint].y = m_pGrid->Get_System().Get_yWorld_to_Grid(pTriangle->Get_Node(iPoint)->Get_Y());
- p[iPoint].z = pTriangle->Get_Node(iPoint)->asDouble(m_zField);
+ p[iPoint].x = (pTriangle->Get_Node(iPoint)->Get_X() - m_pGrid->Get_XMin()) / m_pGrid->Get_Cellsize();
+ p[iPoint].y = (pTriangle->Get_Node(iPoint)->Get_Y() - m_pGrid->Get_YMin()) / m_pGrid->Get_Cellsize();
+ p[iPoint].z = pTriangle->Get_Node(iPoint)->asDouble(m_zField);
}
Set_Triangle(p);
@@ -133,128 +128,107 @@ bool CInterpolation_Triangulation::Interpolate(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define SORT_POINTS_Y(a, b) if( p[a].y < p[b].y ) { pp = p[a]; p[a] = p[b]; p[b] = pp; }
-#define SORT_POINTS_X(a, b) if( p[a].x < p[b].x ) { pp = p[a]; p[a] = p[b]; p[b] = pp; }
-
-//---------------------------------------------------------
-void CInterpolation_Triangulation::Set_Triangle(TPoint p[3])
+void CInterpolation_Triangulation::Set_Triangle(TSG_Point_Z p[3])
{
- int i, j, y, y_j;
- double x, x_a, dx, dx_a, dy, z, z_a, dz, dz_a;
- TPoint pp;
-
//-----------------------------------------------------
- SORT_POINTS_Y(1, 0);
- SORT_POINTS_Y(2, 0);
- SORT_POINTS_Y(2, 1);
+ if( p[1].y < p[0].y ) { TSG_Point_Z pp = p[1]; p[1] = p[0]; p[0] = pp; }
+ if( p[2].y < p[0].y ) { TSG_Point_Z pp = p[2]; p[2] = p[0]; p[0] = pp; }
+ if( p[2].y < p[1].y ) { TSG_Point_Z pp = p[2]; p[2] = p[1]; p[1] = pp; }
//-----------------------------------------------------
- if( p[2].y == p[0].y )
- {
- if( p[0].y >= 0 && p[0].y < m_pGrid->Get_NY() )
- {
- SORT_POINTS_X(1, 0);
- SORT_POINTS_X(2, 0);
- SORT_POINTS_X(2, 1);
+ TSG_Rect r;
- //---------------------------------------------
- if( p[2].x == p[0].x )
- {
- if( p[0].x >= 0 && p[0].x < m_pGrid->Get_NX() )
- {
- m_pGrid->Set_Value(p[0].x, p[0].y, p[0].z > p[1].z
- ? (p[0].z > p[2].z ? p[0].z : p[2].z)
- : (p[1].z > p[2].z ? p[1].z : p[2].z)
- );
- }
- }
+ r.yMin = p[0].y;
+ r.yMax = p[2].y;
+ r.xMin = p[0].x < p[1].x ? (p[0].x < p[2].x ? p[0].x : p[2].x) : (p[1].x < p[2].x ? p[1].x : p[2].x);
+ r.xMax = p[0].x > p[1].x ? (p[0].x > p[2].x ? p[0].x : p[2].x) : (p[1].x > p[2].x ? p[1].x : p[2].x);
- //---------------------------------------------
- else
- {
- Set_Triangle_Line(p[0].x, p[1].x, p[0].y, p[0].z, p[1].z);
- Set_Triangle_Line(p[1].x, p[2].x, p[0].y, p[1].z, p[2].z);
- }
- }
+ if( r.yMin >= r.yMax || r.xMin >= r.xMax )
+ {
+ return; // no area
+ }
+
+ if( (r.yMin < 0.0 && r.yMax < 0.0) || (r.yMin >= m_pGrid->Get_NY() && r.yMax >= m_pGrid->Get_NY())
+ || (r.xMin < 0.0 && r.xMax < 0.0) || (r.xMin >= m_pGrid->Get_NX() && r.xMax >= m_pGrid->Get_NX()) )
+ {
+ return; // completely outside grid
}
//-----------------------------------------------------
- else if( !((p[0].y < 0 && p[2].y < 0) || (p[0].y >= m_pGrid->Get_NY() && p[2].y >= m_pGrid->Get_NY())) )
+ TSG_Point_Z d[3];
+
+ if( (d[0].y = p[2].y - p[0].y) != 0.0 )
{
- dy = p[2].y - p[0].y;
- dx_a = (p[2].x - p[0].x) / dy;
- dz_a = (p[2].z - p[0].z) / dy;
- x_a = p[0].x;
- z_a = p[0].z;
+ d[0].x = (p[2].x - p[0].x) / d[0].y;
+ d[0].z = (p[2].z - p[0].z) / d[0].y;
+ }
- for(i=0, j=1; i<2; i++, j++)
- {
- if( (dy = p[j].y - p[i].y) > 0.0 )
- {
- dx = (p[j].x - p[i].x) / dy;
- dz = (p[j].z - p[i].z) / dy;
- x = p[i].x;
- z = p[i].z;
+ if( (d[1].y = p[1].y - p[0].y) != 0.0 )
+ {
+ d[1].x = (p[1].x - p[0].x) / d[1].y;
+ d[1].z = (p[1].z - p[0].z) / d[1].y;
+ }
- if( (y = p[i].y) < 0 )
- {
- x -= y * dx;
- z -= y * dz;
- y = 0;
- x_a = p[0].x - p[0].y * dx_a;
- z_a = p[0].z - p[0].y * dz_a;
- }
+ if( (d[2].y = p[2].y - p[1].y) != 0.0 )
+ {
+ d[2].x = (p[2].x - p[1].x) / d[2].y;
+ d[2].z = (p[2].z - p[1].z) / d[2].y;
+ }
- if( (y_j = p[j].y) > m_pGrid->Get_NY() )
- {
- y_j = m_pGrid->Get_NY();
- }
+ //-----------------------------------------------------
+ int ay = (int)r.yMin; if( ay < 0 ) ay = 0; if( ay < r.yMin ) ay++;
+ int by = (int)r.yMax; if( by >= m_pGrid->Get_NY() ) by = m_pGrid->Get_NY() - 1;
- for( ; y<y_j; y++, x+=dx, z+=dz, x_a+=dx_a, z_a+=dz_a)
- {
- if( x < x_a )
- {
- Set_Triangle_Line((int)x, (int)x_a, y, z, z_a);
- }
- else
- {
- Set_Triangle_Line((int)x_a, (int)x, y, z_a, z);
- }
- }
- }
+ for(int y=ay; y<=by; y++)
+ {
+ if( y <= p[1].y && d[1].y > 0.0 )
+ {
+ Set_Triangle_Line(y,
+ p[0].x + (y - p[0].y) * d[0].x,
+ p[0].z + (y - p[0].y) * d[0].z,
+ p[0].x + (y - p[0].y) * d[1].x,
+ p[0].z + (y - p[0].y) * d[1].z
+ );
+ }
+ else if( d[2].y > 0.0 )
+ {
+ Set_Triangle_Line(y,
+ p[0].x + (y - p[0].y) * d[0].x,
+ p[0].z + (y - p[0].y) * d[0].z,
+ p[1].x + (y - p[1].y) * d[2].x,
+ p[1].z + (y - p[1].y) * d[2].z
+ );
}
}
}
//---------------------------------------------------------
-inline void CInterpolation_Triangulation::Set_Triangle_Line(int xa, int xb, int y, double za, double zb)
+inline void CInterpolation_Triangulation::Set_Triangle_Line(int y, double xa, double za, double xb, double zb)
{
- double dz;
-
- if( (dz = xb - xa) > 0.0 )
+ if( xb < xa )
{
- dz = (zb - za) / dz;
+ double d;
- if( xa < 0 )
- {
- za -= dz * xa;
- xa = 0;
- }
+ d = xa; xa = xb; xb = d;
+ d = za; za = zb; zb = d;
+ }
- if( xb >= m_pGrid->Get_NX() )
- {
- xb = m_pGrid->Get_NX() - 1;
- }
+ if( xb > xa )
+ {
+ double dz = (zb - za) / (xb - xa);
+ int ax = (int)xa; if( ax < 0 ) ax = 0; if( ax < xa ) ax++;
+ int bx = (int)xb; if( bx >= m_pGrid->Get_NX() ) bx = m_pGrid->Get_NX() - 1;
- for(int x=xa; x<=xb; x++, za+=dz)
+ for(int x=ax; x<=bx; x++)
{
- m_pGrid->Set_Value(x, y, za);
+ double z = za + dz * (x - xa);
+
+ if( m_pGrid->is_NoData(x, y) || m_pGrid->asDouble(x, y) < z )
+ {
+ m_pGrid->Set_Value(x, y, z);
+ }
}
}
- else if( xa >= 0 && xa < m_pGrid->Get_NX() )
- {
- m_pGrid->Set_Value(xa, y, za);
- }
}
diff --git a/src/modules/grid/grid_gridding/Interpolation_Triangulation.h b/src/modules/grid/grid_gridding/Interpolation_Triangulation.h
index b6d2355..da4e1c1 100644
--- a/src/modules/grid/grid_gridding/Interpolation_Triangulation.h
+++ b/src/modules/grid/grid_gridding/Interpolation_Triangulation.h
@@ -76,7 +76,6 @@ class CInterpolation_Triangulation : public CInterpolation
{
public:
CInterpolation_Triangulation(void);
- virtual ~CInterpolation_Triangulation(void);
protected:
@@ -86,17 +85,8 @@ protected:
private:
- typedef struct
- {
- int x, y;
-
- double z;
- }
- TPoint;
-
-
- void Set_Triangle (TPoint p[3]);
- void Set_Triangle_Line (int xa, int xb, int y, double za, double zb);
+ void Set_Triangle (TSG_Point_Z p[3]);
+ void Set_Triangle_Line (int y, double xa, double za, double xb, double zb);
};
diff --git a/src/modules/grid/grid_gridding/Makefile.am b/src/modules/grid/grid_gridding/Makefile.am
index b2358b3..6a69dfa 100644
--- a/src/modules/grid/grid_gridding/Makefile.am
+++ b/src/modules/grid/grid_gridding/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.6 2008/09/26 08:53:19 oconrad Exp $
+# $Id: Makefile.am,v 1.7 2010/07/08 14:11:48 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -13,7 +13,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEP_DEFS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_gridding.la
libgrid_gridding_la_SOURCES =\
Interpolation.cpp\
diff --git a/src/modules/grid/grid_gridding/Makefile.in b/src/modules/grid/grid_gridding/Makefile.in
index 6d798e3..036283f 100644
--- a/src/modules/grid/grid_gridding/Makefile.in
+++ b/src/modules/grid/grid_gridding/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -77,7 +76,7 @@ am_libgrid_gridding_la_OBJECTS = Interpolation.lo \
Shepard.lo delaunay.lo hash.lo istack.lo lpi.lo nnai.lo \
nncommon.lo nnpi.lo triangle.lo
libgrid_gridding_la_OBJECTS = $(am_libgrid_gridding_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -123,6 +122,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -132,6 +132,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -222,7 +223,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.6 2008/09/26 08:53:19 oconrad Exp $
+# $Id: Makefile.am,v 1.7 2010/07/08 14:11:48 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at DEP_DEFS = -D_SAGA_UNICODE
@@ -230,7 +231,7 @@ top_srcdir = @top_srcdir@
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEP_DEFS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_gridding.la
libgrid_gridding_la_SOURCES = \
Interpolation.cpp\
diff --git a/src/modules/grid/grid_gridding/Shapes2Grid.cpp b/src/modules/grid/grid_gridding/Shapes2Grid.cpp
index c9a1bdf..db6b111 100644
--- a/src/modules/grid/grid_gridding/Shapes2Grid.cpp
+++ b/src/modules/grid/grid_gridding/Shapes2Grid.cpp
@@ -58,7 +58,6 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#include <string.h>
#include "Shapes2Grid.h"
@@ -83,12 +82,11 @@
CShapes2Grid::CShapes2Grid(void)
{
CSG_Parameter *pNode_0, *pNode_1;
- CSG_Parameters *pParameters;
//-----------------------------------------------------
Set_Name (_TL("Shapes to Grid"));
- Set_Author (SG_T("(c) 2003 by O.Conrad"));
+ Set_Author (SG_T("O.Conrad (c) 2003"));
Set_Description (_TW(
"Gridding of a shapes layer. If some shapes are selected, only these will be gridded."
@@ -96,11 +94,6 @@ CShapes2Grid::CShapes2Grid(void)
//-----------------------------------------------------
- Parameters.Add_Grid_Output(
- NULL , "GRID" , _TL("Grid"),
- _TL("")
- );
-
pNode_0 = Parameters.Add_Shapes(
NULL , "INPUT" , _TL("Shapes"),
_TL(""),
@@ -113,17 +106,6 @@ CShapes2Grid::CShapes2Grid(void)
);
pNode_0 = Parameters.Add_Choice(
- NULL , "TARGET_TYPE" , _TL("Target Dimensions"),
- _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|%s|"),
- _TL("User defined"),
- _TL("Grid Project"),
- _TL("Grid")
- ), 0
- );
-
- pNode_0 = Parameters.Add_Choice(
NULL , "LINE_TYPE" , _TL("Method for Lines"),
_TL(""),
@@ -133,52 +115,8 @@ CShapes2Grid::CShapes2Grid(void)
), 1
);
- //-----------------------------------------------------
- pParameters = Add_Parameters("USER", _TL("User defined grid"), _TL(""));
-
- pNode_0 = pParameters->Add_Value(
- NULL , "CELL_SIZE" , _TL("Grid Size"),
- _TL(""),
- PARAMETER_TYPE_Double, 100.0, 0.0, true
- );
-
- pNode_0 = pParameters->Add_Value(
- NULL , "FIT_EXTENT" , _TL("Fit Extent"),
- _TL("Automatically fits the grid to the shapes layers extent."),
- PARAMETER_TYPE_Bool , true
- );
-
- pNode_1 = pParameters->Add_Range(
- pNode_0 , "X_EXTENT" , _TL("X-Extent"),
- _TL("")
- );
-
- pNode_1 = pParameters->Add_Range(
- pNode_0 , "Y_EXTENT" , _TL("Y-Extent"),
- _TL("")
- );
-
- pNode_0 = pParameters->Add_Choice(
- NULL , "GRID_TYPE" , _TL("Target Grid Type"),
- _TL(""),
- CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"),
- _TL("Integer (1 byte)"),
- _TL("Integer (2 byte)"),
- _TL("Integer (4 byte)"),
- _TL("Floating Point (4 byte)"),
- _TL("Floating Point (8 byte)")
- ), 3
- );
-
- //-----------------------------------------------------
- pParameters = Add_Parameters("GET_SYSTEM" , _TL("Choose Grid Project"), _TL(""));
-
- pNode_0 = pParameters->Add_Grid_System(
- NULL, "SYSTEM" , _TL("System") , _TL("")
- );
-
- pNode_0 = pParameters->Add_Choice(
- NULL , "GRID_TYPE" , _TL("Target Grid Type"),
+ pNode_0 = Parameters.Add_Choice(
+ NULL , "GRID_TYPE" , _TL("Preferred Target Grid Type"),
_TL(""),
CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"),
_TL("Integer (1 byte)"),
@@ -188,20 +126,33 @@ CShapes2Grid::CShapes2Grid(void)
_TL("Floating Point (8 byte)")
), 3
);
-
- //-----------------------------------------------------
- pParameters = Add_Parameters("GRID" , _TL("Choose Grid") , _TL(""));
-
- pNode_0 = pParameters->Add_Grid(
- NULL , "GRID" , _TL("Grid"),
- _TL(""),
- PARAMETER_INPUT , false
- );
+
+ //-----------------------------------------------------
+ Parameters.Add_Choice(
+ NULL , "TARGET" , _TL("Target Grid"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("user defined"),
+ _TL("grid")
+ ), 0
+ );
+
+ m_Grid_Target.Add_Parameters_User(Add_Parameters("USER", _TL("User Defined Grid") , _TL("")));
+ m_Grid_Target.Add_Parameters_Grid(Add_Parameters("GRID", _TL("Choose Grid") , _TL("")));
}
-
-//---------------------------------------------------------
-CShapes2Grid::~CShapes2Grid(void)
-{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int CShapes2Grid::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ return( m_Grid_Target.On_User_Changed(pParameters, pParameter) ? 1 : 0 );
+}
///////////////////////////////////////////////////////////
@@ -215,42 +166,14 @@ TSG_Data_Type CShapes2Grid::Get_Grid_Type(int iType)
{
switch( iType )
{
- case 0: return( SG_DATATYPE_Byte );
- case 1: return( SG_DATATYPE_Short );
- case 2: return( SG_DATATYPE_Int );
- default:
- case 3: return( SG_DATATYPE_Float );
- case 4: return( SG_DATATYPE_Double );
- }
-}
-
-//---------------------------------------------------------
-CSG_Grid * CShapes2Grid::Get_Target_Grid(CSG_Parameters *pParameters, CSG_Shapes *m_pShapes)
-{
- int nx, ny;
- double Cell_Size, xMin, yMin, xMax, yMax;
-
- if( pParameters->Get_Parameter("FIT_EXTENT")->asBool() )
- {
- xMin = m_pShapes->Get_Extent().m_rect.xMin;
- yMin = m_pShapes->Get_Extent().m_rect.yMin;
- xMax = m_pShapes->Get_Extent().m_rect.xMax;
- yMax = m_pShapes->Get_Extent().m_rect.yMax;
- }
- else
- {
- xMin = pParameters->Get_Parameter("X_EXTENT")->asRange()->Get_LoVal();
- yMin = pParameters->Get_Parameter("Y_EXTENT")->asRange()->Get_LoVal();
- xMax = pParameters->Get_Parameter("X_EXTENT")->asRange()->Get_HiVal();
- yMax = pParameters->Get_Parameter("Y_EXTENT")->asRange()->Get_HiVal();
+ case 0: return( SG_DATATYPE_Byte );
+ case 1: return( SG_DATATYPE_Short );
+ case 2: return( SG_DATATYPE_Int );
+ case 3: return( SG_DATATYPE_Float );
+ case 4: return( SG_DATATYPE_Double );
}
- Cell_Size = pParameters->Get_Parameter("CELL_SIZE")->asDouble();
-
- nx = 1 + (int)((xMax - xMin) / Cell_Size);
- ny = 1 + (int)((yMax - yMin) / Cell_Size);
-
- return( SG_Create_Grid(Get_Grid_Type(pParameters->Get_Parameter("GRID_TYPE")->asInt()), nx, ny, Cell_Size, xMin, yMin) );
+ return( SG_DATATYPE_Float );
}
@@ -263,78 +186,62 @@ CSG_Grid * CShapes2Grid::Get_Target_Grid(CSG_Parameters *pParameters, CSG_Shapes
//---------------------------------------------------------
bool CShapes2Grid::On_Execute(void)
{
- m_pGrid = NULL;
- m_pShapes = Parameters("INPUT")->asShapes();
+ int iField, iShape, iType;
//-----------------------------------------------------
- if( m_pShapes->Get_Field_Count() > 0 )
- {
- switch( Parameters("TARGET_TYPE")->asInt() )
- {
- case 0: // User defined...
- if( Dlg_Parameters("USER") )
- {
- m_pGrid = Get_Target_Grid(Get_Parameters("USER"), m_pShapes);
- }
- break;
-
- case 1: // Grid Project...
- if( Dlg_Parameters("GET_SYSTEM") )
- {
- m_pGrid = SG_Create_Grid(
- *Get_Parameters("GET_SYSTEM")->Get_Parameter("SYSTEM")->asGrid_System(),
- Get_Grid_Type(Get_Parameters("GET_SYSTEM")->Get_Parameter("GRID_TYPE")->asInt())
- );
- }
- break;
+ m_pShapes = Parameters("INPUT") ->asShapes();
+ m_Method_Lines = Parameters("LINE_TYPE") ->asInt();
+ iField = Parameters("FIELD") ->asInt();
+ iType = Parameters("GRID_TYPE") ->asInt();
- case 2: // Grid...
- if( Dlg_Parameters("GRID") )
- {
- m_pGrid = Get_Parameters("GRID")->Get_Parameter("GRID")->asGrid();
- }
- break;
- }
+ if( iField < 0 || iField >= m_pShapes->Get_Field_Count() || m_pShapes->Get_Field_Type(iField) == SG_DATATYPE_String )
+ {
+ iField = -1;
- //-------------------------------------------------
- if( m_pGrid )
- {
- int i, iField;
- CSG_Shape *pShape;
+ Message_Add(_TL("WARNING: selected attribute is not numeric; generating unique identifiers instead."));
+ }
- //---------------------------------------------
- m_Method_Lines = Parameters("LINE_TYPE") ->asInt();
- iField = Parameters("FIELD") ->asInt();
+ //-----------------------------------------------------
+ m_pGrid = NULL;
+
+ switch( Parameters("TARGET")->asInt() )
+ {
+ case 0: // user defined...
+ if( m_Grid_Target.Init_User(m_pShapes->Get_Extent()) && Dlg_Parameters("USER") )
+ {
+ m_pGrid = m_Grid_Target.Get_User(Get_Grid_Type(iType));
+ }
+ break;
+
+ case 1: // grid...
+ if( Dlg_Parameters("GRID") )
+ {
+ m_pGrid = m_Grid_Target.Get_Grid(Get_Grid_Type(iType));
+ }
+ break;
+ }
+
+ if( m_pGrid == NULL )
+ {
+ return( false );
+ }
- if( iField >= 0 && iField < m_pShapes->Get_Field_Count()
- && m_pShapes->Get_Field_Type(iField) != SG_DATATYPE_String )
- {
- m_pGrid->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pShapes->Get_Name(), m_pShapes->Get_Field_Name(iField)));
- }
- else
- {
- m_pGrid->Set_Name(m_pShapes->Get_Name());
- iField = -1;
- Message_Add( _TL("WARNING: The selected attribute is of field type string, generating unique identifiers instead.\n"));
- }
+ //-------------------------------------------------
+ m_pGrid->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pShapes->Get_Name(), iField < 0 ? _TL("ID") : m_pShapes->Get_Field_Name(iField)));
+ m_pGrid->Assign_NoData();
- //---------------------------------------------
- m_pGrid->Assign_NoData();
- Parameters("GRID")->Set_Value(m_pGrid);
+ m_pLock = m_pShapes->Get_Type() == SHAPE_TYPE_Point ? NULL : SG_Create_Grid(m_pGrid, SG_DATATYPE_Byte);
- m_pLock = m_pShapes->Get_Type() == SHAPE_TYPE_Point ? NULL
- : SG_Create_Grid(m_pGrid, SG_DATATYPE_Byte);
+ //-----------------------------------------------------
+ for(iShape=0, m_Lock_ID=1; iShape<m_pShapes->Get_Count() && Set_Progress(iShape, m_pShapes->Get_Count()); iShape++, m_Lock_ID++)
+ {
+ CSG_Shape *pShape = m_pShapes->Get_Shape(iShape);
- //---------------------------------------------
- for(i=0, m_Lock_ID=1; i<m_pShapes->Get_Count() && Set_Progress(i, m_pShapes->Get_Count()); i++, m_Lock_ID++)
+ if( m_pShapes->Get_Selection_Count() <= 0 || pShape->is_Selected() )
+ {
+ if( iField < 0 || !pShape->is_NoData(iField) )
{
- pShape = m_pShapes->Get_Shape(i);
- if (m_pShapes->Get_Selection_Count() > 0)
- {
- if (!pShape->is_Selected())
- continue;
- }
- m_Value = iField < 0 ? i + 1 : pShape->asDouble(iField);
+ m_Value = iField < 0 ? iShape + 1 : pShape->asDouble(iField);
if( pShape->Intersects(m_pGrid->Get_Extent().m_rect) )
{
@@ -347,18 +254,16 @@ bool CShapes2Grid::On_Execute(void)
}
}
}
-
- //---------------------------------------------
- if( m_pLock )
- {
- delete(m_pLock);
- }
}
+ }
- return( true );
+ //-----------------------------------------------------
+ if( m_pLock )
+ {
+ delete(m_pLock);
}
- return( false );
+ return( true );
}
diff --git a/src/modules/grid/grid_gridding/Shapes2Grid.h b/src/modules/grid/grid_gridding/Shapes2Grid.h
index a5634c6..af5a847 100644
--- a/src/modules/grid/grid_gridding/Shapes2Grid.h
+++ b/src/modules/grid/grid_gridding/Shapes2Grid.h
@@ -83,37 +83,39 @@ class CShapes2Grid : public CSG_Module
{
public:
CShapes2Grid(void);
- virtual ~CShapes2Grid(void);
protected:
- virtual bool On_Execute (void);
+ virtual bool On_Execute (void);
+
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
private:
- int m_Lock_ID, m_Method_Lines;
+ int m_Lock_ID, m_Method_Lines;
+
+ double m_Value;
- double m_Value;
+ CSG_Parameters_Grid_Target m_Grid_Target;
- CSG_Grid *m_pGrid, *m_pLock;
+ CSG_Grid *m_pGrid, *m_pLock;
- CSG_Shapes *m_pShapes;
+ CSG_Shapes *m_pShapes;
- TSG_Data_Type Get_Grid_Type (int iType);
- CSG_Grid * Get_Target_Grid (CSG_Parameters *pParameters, CSG_Shapes *pShapes);
+ TSG_Data_Type Get_Grid_Type (int iType);
- void Set_Value (int x, int y);
+ void Set_Value (int x, int y);
- void Set_Points (CSG_Shape *pShape);
+ void Set_Points (CSG_Shape *pShape);
- void Set_Line (CSG_Shape *pShape);
- void Set_Line_A (TSG_Point a, TSG_Point b);
- void Set_Line_B (TSG_Point a, TSG_Point b);
+ void Set_Line (CSG_Shape *pShape);
+ void Set_Line_A (TSG_Point a, TSG_Point b);
+ void Set_Line_B (TSG_Point a, TSG_Point b);
- void Set_Polygon (CSG_Shape *pShape);
+ void Set_Polygon (CSG_Shape *pShape);
};
diff --git a/src/modules/grid/grid_spline/Gridding_Spline_BA.h b/src/modules/grid/grid_spline/Gridding_Spline_BA.h
index bd4d19f..e5bcaf3 100644
--- a/src/modules/grid/grid_spline/Gridding_Spline_BA.h
+++ b/src/modules/grid/grid_spline/Gridding_Spline_BA.h
@@ -93,7 +93,7 @@ protected:
private:
- CSG_Points_3D m_Points;
+ CSG_Points_Z m_Points;
void BA_Set_Grid (CSG_Grid &Phi, bool bAdd = false);
diff --git a/src/modules/grid/grid_spline/Gridding_Spline_Base.cpp b/src/modules/grid/grid_spline/Gridding_Spline_Base.cpp
index 3a5653e..93378e2 100644
--- a/src/modules/grid/grid_spline/Gridding_Spline_Base.cpp
+++ b/src/modules/grid/grid_spline/Gridding_Spline_Base.cpp
@@ -70,17 +70,9 @@
//---------------------------------------------------------
CGridding_Spline_Base::CGridding_Spline_Base(bool bGridPoints)
{
- CSG_Parameter *pNode;
- CSG_Parameters *pParameters;
-
m_bGridPoints = bGridPoints;
//-----------------------------------------------------
- Parameters.Add_Grid_Output(
- NULL , "GRID" , _TL("Grid"),
- _TL("")
- );
-
if( m_bGridPoints )
{
Parameters.Add_Grid(
@@ -91,7 +83,7 @@ CGridding_Spline_Base::CGridding_Spline_Base(bool bGridPoints)
}
else
{
- pNode = Parameters.Add_Shapes(
+ CSG_Parameter *pNode = Parameters.Add_Shapes(
NULL , "SHAPES" , _TL("Points"),
_TL(""),
PARAMETER_INPUT
@@ -103,64 +95,20 @@ CGridding_Spline_Base::CGridding_Spline_Base(bool bGridPoints)
);
}
+ //-----------------------------------------------------
Parameters.Add_Choice(
NULL , "TARGET" , _TL("Target Grid"),
_TL(""),
-
- CSG_String::Format(SG_T("%s|%s|%s|"),
+ CSG_String::Format(SG_T("%s|%s|"),
_TL("user defined"),
- _TL("grid system"),
_TL("grid")
), 0
);
- //-----------------------------------------------------
- pParameters = Add_Parameters("USER", _TL("User defined grid") , _TL(""));
-
- pParameters->Add_Value(
- NULL , "CELL_SIZE" , _TL("Grid Size"),
- _TL(""),
- PARAMETER_TYPE_Double, 100.0, 0.0, true
- );
-
- pNode = pParameters->Add_Value(
- NULL , "FIT_EXTENT" , _TL("Fit Extent"),
- _TL("Automatically fits the grid to the shapes layers extent."),
- PARAMETER_TYPE_Bool , true
- );
-
- pParameters->Add_Range(
- pNode , "X_EXTENT" , _TL("X-Extent"),
- _TL("")
- );
-
- pParameters->Add_Range(
- pNode , "Y_EXTENT" , _TL("Y-Extent"),
- _TL("")
- );
-
- //-----------------------------------------------------
- pParameters = Add_Parameters("SYSTEM" , _TL("Choose Grid System") , _TL(""));
-
- pParameters->Add_Grid_System(
- NULL , "SYSTEM" , _TL("Grid System"),
- _TL("")
- );
-
- //-----------------------------------------------------
- pParameters = Add_Parameters("GRID" , _TL("Choose Grid") , _TL(""));
-
- pParameters->Add_Grid(
- NULL , "GRID" , _TL("Grid"),
- _TL(""),
- PARAMETER_INPUT , false
- );
+ m_Grid_Target.Add_Parameters_User(Add_Parameters("USER", _TL("User Defined Grid") , _TL("")));
+ m_Grid_Target.Add_Parameters_Grid(Add_Parameters("GRID", _TL("Choose Grid") , _TL("")));
}
-//---------------------------------------------------------
-CGridding_Spline_Base::~CGridding_Spline_Base(void)
-{}
-
///////////////////////////////////////////////////////////
// //
@@ -169,53 +117,28 @@ CGridding_Spline_Base::~CGridding_Spline_Base(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-bool CGridding_Spline_Base::_Get_Points(CSG_Points_3D &Points, bool bInGridOnly)
+int CGridding_Spline_Base::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
{
- Points.Clear();
-
- if( m_bGridPoints )
- {
- int x, y;
- TSG_Point p;
- CSG_Grid *pGrid = Parameters("GRIDPOINTS") ->asGrid();
-
- for(y=0, p.y=pGrid->Get_YMin(); y<pGrid->Get_NY() && Set_Progress(y, pGrid->Get_NY()); y++, p.y+=pGrid->Get_Cellsize())
- {
- for(x=0, p.x=pGrid->Get_XMin(); x<pGrid->Get_NX(); x++, p.x+=pGrid->Get_Cellsize())
- {
- if( !pGrid->is_NoData(x, y) && (!bInGridOnly || m_pGrid->is_InGrid_byPos(p)) )
- {
- Points.Add(p.x, p.y, pGrid->asDouble(x, y));
- }
- }
- }
- }
- else
- {
- CSG_Shapes *pShapes = Parameters("SHAPES") ->asShapes();
- int zField = Parameters("FIELD") ->asInt();
+ return( m_Grid_Target.On_User_Changed(pParameters, pParameter) ? 1 : 0 );
+}
- for(int iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
- {
- CSG_Shape *pShape = pShapes->Get_Shape(iShape);
- double zValue = pShape->asDouble(zField);
- for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
- {
- for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
- {
- TSG_Point p = pShape->Get_Point(iPoint, iPart);
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
- if( !bInGridOnly || m_pGrid->is_InGrid_byPos(p) )
- {
- Points.Add(p.x, p.y, zValue);
- }
- }
- }
- }
- }
+//---------------------------------------------------------
+bool CGridding_Spline_Base::Initialise(void)
+{
+ return( On_Initialise() && _Get_Grid() );
+}
- return( Points.Get_Count() >= 3 );
+//---------------------------------------------------------
+bool CGridding_Spline_Base::Initialise(CSG_Points_Z &Points, bool bInGridOnly)
+{
+ return( Initialise() && _Get_Points(Points, bInGridOnly) );
}
@@ -228,41 +151,25 @@ bool CGridding_Spline_Base::_Get_Points(CSG_Points_3D &Points, bool bInGridOnly)
//---------------------------------------------------------
bool CGridding_Spline_Base::_Get_Grid(void)
{
- CSG_Grid *pGrid;
- CSG_Shapes *pShapes;
-
- if( m_bGridPoints )
- {
- pGrid = Parameters("GRIDPOINTS") ->asGrid();
- }
- else
- {
- pShapes = Parameters("SHAPES") ->asShapes();
- }
+ CSG_Grid *pGrid = m_bGridPoints ? Parameters("GRIDPOINTS")->asGrid () : NULL;
+ CSG_Shapes *pShapes = !m_bGridPoints ? Parameters("SHAPES") ->asShapes() : NULL;
- m_pGrid = NULL;
+ //-----------------------------------------------------
+ m_pGrid = NULL;
- //-------------------------------------------------
switch( Parameters("TARGET")->asInt() )
{
case 0: // user defined...
- if( Dlg_Parameters("USER") )
+ if( m_Grid_Target.Init_User(m_bGridPoints ? pGrid->Get_Extent() : pShapes->Get_Extent()) && Dlg_Parameters("USER") )
{
- m_pGrid = _Get_Grid(m_bGridPoints ? pGrid->Get_Extent() : pShapes->Get_Extent());
+ m_pGrid = m_Grid_Target.Get_User();
}
break;
- case 1: // grid system...
- if( Dlg_Parameters("SYSTEM") )
- {
- m_pGrid = SG_Create_Grid(*Get_Parameters("SYSTEM")->Get_Parameter("SYSTEM")->asGrid_System(), SG_DATATYPE_Float);
- }
- break;
-
- case 2: // grid...
+ case 1: // grid...
if( Dlg_Parameters("GRID") )
{
- m_pGrid = Get_Parameters("GRID")->Get_Parameter("GRID")->asGrid();
+ m_pGrid = m_Grid_Target.Get_Grid();
}
break;
}
@@ -272,34 +179,12 @@ bool CGridding_Spline_Base::_Get_Grid(void)
{
m_pGrid->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_bGridPoints ? pGrid->Get_Name() : pShapes->Get_Name(), Get_Name()));
m_pGrid->Assign_NoData();
- Parameters("GRID")->Set_Value(m_pGrid);
}
//-----------------------------------------------------
return( m_pGrid != NULL );
}
-//---------------------------------------------------------
-CSG_Grid * CGridding_Spline_Base::_Get_Grid(TSG_Rect Extent)
-{
- CSG_Parameters *P = Get_Parameters("USER");
-
- if( !P->Get_Parameter("FIT_EXTENT")->asBool() )
- {
- Extent.xMin = P->Get_Parameter("X_EXTENT")->asRange()->Get_LoVal();
- Extent.yMin = P->Get_Parameter("Y_EXTENT")->asRange()->Get_LoVal();
- Extent.xMax = P->Get_Parameter("X_EXTENT")->asRange()->Get_HiVal();
- Extent.yMax = P->Get_Parameter("Y_EXTENT")->asRange()->Get_HiVal();
- }
-
- double d = P->Get_Parameter("CELL_SIZE")->asDouble();
-
- int nx = 1 + (int)((Extent.xMax - Extent.xMin) / d);
- int ny = 1 + (int)((Extent.yMax - Extent.yMin) / d);
-
- return( nx > 1 && ny > 1 ? SG_Create_Grid(SG_DATATYPE_Float, nx, ny, d, Extent.xMin, Extent.yMin) : NULL );
-}
-
///////////////////////////////////////////////////////////
// //
@@ -308,15 +193,57 @@ CSG_Grid * CGridding_Spline_Base::_Get_Grid(TSG_Rect Extent)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-bool CGridding_Spline_Base::Initialise(void)
+bool CGridding_Spline_Base::_Get_Points(CSG_Points_Z &Points, bool bInGridOnly)
{
- return( On_Initialise() && _Get_Grid() );
-}
+ Points.Clear();
-//---------------------------------------------------------
-bool CGridding_Spline_Base::Initialise(CSG_Points_3D &Points, bool bInGridOnly)
-{
- return( Initialise() && _Get_Points(Points, bInGridOnly) );
+ if( m_bGridPoints )
+ {
+ int x, y;
+ TSG_Point p;
+ CSG_Grid *pGrid = Parameters("GRIDPOINTS") ->asGrid();
+
+ for(y=0, p.y=pGrid->Get_YMin(); y<pGrid->Get_NY() && Set_Progress(y, pGrid->Get_NY()); y++, p.y+=pGrid->Get_Cellsize())
+ {
+ for(x=0, p.x=pGrid->Get_XMin(); x<pGrid->Get_NX(); x++, p.x+=pGrid->Get_Cellsize())
+ {
+ if( !pGrid->is_NoData(x, y) && (!bInGridOnly || m_pGrid->is_InGrid_byPos(p)) )
+ {
+ Points.Add(p.x, p.y, pGrid->asDouble(x, y));
+ }
+ }
+ }
+ }
+ else
+ {
+ CSG_Shapes *pShapes = Parameters("SHAPES") ->asShapes();
+ int zField = Parameters("FIELD") ->asInt();
+
+ for(int iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
+ {
+ CSG_Shape *pShape = pShapes->Get_Shape(iShape);
+
+ if( !pShape->is_NoData(zField) )
+ {
+ double zValue = pShape->asDouble(zField);
+
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ TSG_Point p = pShape->Get_Point(iPoint, iPart);
+
+ if( !bInGridOnly || m_pGrid->is_InGrid_byPos(p) )
+ {
+ Points.Add(p.x, p.y, zValue);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return( Points.Get_Count() >= 3 );
}
diff --git a/src/modules/grid/grid_spline/Gridding_Spline_Base.h b/src/modules/grid/grid_spline/Gridding_Spline_Base.h
index 581cc9d..ea59fd8 100644
--- a/src/modules/grid/grid_spline/Gridding_Spline_Base.h
+++ b/src/modules/grid/grid_spline/Gridding_Spline_Base.h
@@ -83,30 +83,32 @@ class grid_spline_EXPORT CGridding_Spline_Base : public CSG_Module
{
public:
CGridding_Spline_Base(bool bGridPoints = false);
- virtual ~CGridding_Spline_Base(void);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Spline Interpolation") ); }
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Spline Interpolation") ); }
protected:
- CSG_Grid *m_pGrid;
+ CSG_Grid *m_pGrid;
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
- bool Initialise (void);
- bool Initialise (CSG_Points_3D &Points, bool bInGridOnly = false);
- virtual bool On_Initialise (void) { return( true ); }
+ bool Initialise (void);
+ bool Initialise (CSG_Points_Z &Points, bool bInGridOnly = false);
+
+ virtual bool On_Initialise (void) { return( true ); }
private:
- bool m_bGridPoints;
+ bool m_bGridPoints;
+
+ CSG_Parameters_Grid_Target m_Grid_Target;
- bool _Get_Points (CSG_Points_3D &Points, bool bInGridOnly);
- bool _Get_Grid (void);
- CSG_Grid * _Get_Grid (TSG_Rect Extent);
+ bool _Get_Grid (void);
+ bool _Get_Points (CSG_Points_Z &Points, bool bInGridOnly);
};
diff --git a/src/modules/grid/grid_spline/Gridding_Spline_CSA.h b/src/modules/grid/grid_spline/Gridding_Spline_CSA.h
index bd5fdb1..ed48682 100644
--- a/src/modules/grid/grid_spline/Gridding_Spline_CSA.h
+++ b/src/modules/grid/grid_spline/Gridding_Spline_CSA.h
@@ -87,7 +87,7 @@ protected:
private:
- CSG_Points_3D m_Points;
+ CSG_Points_Z m_Points;
};
diff --git a/src/modules/grid/grid_spline/Gridding_Spline_MBA.h b/src/modules/grid/grid_spline/Gridding_Spline_MBA.h
index 9b5d0fb..9513f6a 100644
--- a/src/modules/grid/grid_spline/Gridding_Spline_MBA.h
+++ b/src/modules/grid/grid_spline/Gridding_Spline_MBA.h
@@ -99,7 +99,7 @@ private:
double m_Epsilon, m_Resolution;
- CSG_Points_3D m_Points;
+ CSG_Points_Z m_Points;
bool _Set_MBA (double dCell);
diff --git a/src/modules/grid/grid_spline/Gridding_Spline_MBA_Grid.cpp b/src/modules/grid/grid_spline/Gridding_Spline_MBA_Grid.cpp
index a958b2f..4378630 100644
--- a/src/modules/grid/grid_spline/Gridding_Spline_MBA_Grid.cpp
+++ b/src/modules/grid/grid_spline/Gridding_Spline_MBA_Grid.cpp
@@ -310,7 +310,7 @@ bool CGridding_Spline_MBA_Grid::_Get_Difference(CSG_Grid &Phi)
{
int xPoint, yPoint, nErrors;
double x, y, z, zMax, zMean;
- TSG_Point_3D p;
+ TSG_Point_Z p;
CSG_String s;
//-----------------------------------------------------
diff --git a/src/modules/grid/grid_spline/Gridding_Spline_TPS_Global.h b/src/modules/grid/grid_spline/Gridding_Spline_TPS_Global.h
index 35948c0..bfb59e2 100644
--- a/src/modules/grid/grid_spline/Gridding_Spline_TPS_Global.h
+++ b/src/modules/grid/grid_spline/Gridding_Spline_TPS_Global.h
@@ -70,7 +70,6 @@
//---------------------------------------------------------
#include "Gridding_Spline_Base.h"
-#include "Thin_Plate_Spline.h"
///////////////////////////////////////////////////////////
@@ -100,7 +99,7 @@ protected:
CSG_Shapes *m_pShapes;
- CThin_Plate_Spline m_Spline;
+ CSG_Thin_Plate_Spline m_Spline;
private:
diff --git a/src/modules/grid/grid_spline/Makefile.am b/src/modules/grid/grid_spline/Makefile.am
index cb869c3..5e5b54b 100644
--- a/src/modules/grid/grid_spline/Makefile.am
+++ b/src/modules/grid/grid_spline/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.8 2008/09/26 08:53:19 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:11:48 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_spline.la
libgrid_spline_la_SOURCES =\
csa.c\
@@ -23,7 +23,6 @@ Gridding_Spline_TPS_Global.cpp\
Gridding_Spline_TPS_Local.cpp\
Gridding_Spline_TPS_TIN.cpp\
MLB_Interface.cpp\
-Thin_Plate_Spline.cpp\
csa.h\
Gridding_Spline_BA.h\
Gridding_Spline_Base.h\
@@ -33,8 +32,7 @@ Gridding_Spline_MBA_Grid.h\
Gridding_Spline_TPS_Global.h\
Gridding_Spline_TPS_Local.h\
Gridding_Spline_TPS_TIN.h\
-MLB_Interface.h\
-Thin_Plate_Spline.h
+MLB_Interface.h
libgrid_spline_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS)
diff --git a/src/modules/grid/grid_spline/Makefile.in b/src/modules/grid/grid_spline/Makefile.in
index 56461b1..e570639 100644
--- a/src/modules/grid/grid_spline/Makefile.in
+++ b/src/modules/grid/grid_spline/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,10 +72,9 @@ am_libgrid_spline_la_OBJECTS = csa.lo Gridding_Spline_BA.lo \
Gridding_Spline_Base.lo Gridding_Spline_CSA.lo \
Gridding_Spline_MBA.lo Gridding_Spline_MBA_Grid.lo \
Gridding_Spline_TPS_Global.lo Gridding_Spline_TPS_Local.lo \
- Gridding_Spline_TPS_TIN.lo MLB_Interface.lo \
- Thin_Plate_Spline.lo
+ Gridding_Spline_TPS_TIN.lo MLB_Interface.lo
libgrid_spline_la_OBJECTS = $(am_libgrid_spline_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -122,6 +120,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -131,6 +130,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -221,14 +221,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.8 2008/09/26 08:53:19 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:11:48 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_spline.la
libgrid_spline_la_SOURCES = \
csa.c\
@@ -241,7 +241,6 @@ Gridding_Spline_TPS_Global.cpp\
Gridding_Spline_TPS_Local.cpp\
Gridding_Spline_TPS_TIN.cpp\
MLB_Interface.cpp\
-Thin_Plate_Spline.cpp\
csa.h\
Gridding_Spline_BA.h\
Gridding_Spline_Base.h\
@@ -251,8 +250,7 @@ Gridding_Spline_MBA_Grid.h\
Gridding_Spline_TPS_Global.h\
Gridding_Spline_TPS_Local.h\
Gridding_Spline_TPS_TIN.h\
-MLB_Interface.h\
-Thin_Plate_Spline.h
+MLB_Interface.h
libgrid_spline_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS)
all: all-am
@@ -338,7 +336,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Gridding_Spline_TPS_Local.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Gridding_Spline_TPS_TIN.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Thin_Plate_Spline.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/csa.Plo at am__quote@
.c.o:
diff --git a/src/modules/grid/grid_tools/Grid_Aggregate.cpp b/src/modules/grid/grid_tools/Grid_Aggregate.cpp
index 29bb0e0..9f8ff45 100644
--- a/src/modules/grid/grid_tools/Grid_Aggregate.cpp
+++ b/src/modules/grid/grid_tools/Grid_Aggregate.cpp
@@ -77,7 +77,10 @@ CGrid_Aggregate::CGrid_Aggregate(void)
Set_Author(_TL("Copyrights (c) 2005 by Victor Olaya"));
- Set_Description (_TW("Aggregate")
+ Set_Description (_TW("Resamples a raster layer to a lower resolution, aggregating"
+ "the values of a group of cells. This should be used in any case in which and a normal"
+ "resampling will result in wrong values in the resulting layer, such as, for instance,"
+ "the number of elements of a given class in each cell.")
);
//-----------------------------------------------------
diff --git a/src/modules/grid/grid_tools/Grid_Gaps_Spline_Fill.cpp b/src/modules/grid/grid_tools/Grid_Gaps_Spline_Fill.cpp
new file mode 100644
index 0000000..24b8bbc
--- /dev/null
+++ b/src/modules/grid/grid_tools/Grid_Gaps_Spline_Fill.cpp
@@ -0,0 +1,444 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Tools //
+// //
+//-------------------------------------------------------//
+// //
+// Grid_Gaps_Spline_Fill.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "Grid_Gaps_Spline_Fill.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGrid_Gaps_Spline_Fill::CGrid_Gaps_Spline_Fill(void)
+{
+ Set_Name (_TL("Close Gaps with Spline"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ ""
+ ));
+
+ Parameters.Add_Grid(
+ NULL, "GRID" , _TL("Grid"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL, "MASK" , _TL("Mask"),
+ _TL(""),
+ PARAMETER_INPUT_OPTIONAL
+ );
+
+ Parameters.Add_Value(
+ NULL, "MAXGAPCELLS" , _TL("Only Process Gaps with Less Cells"),
+ _TL("is ignored if set to zero"),
+ PARAMETER_TYPE_Int , 0, 0, true
+ );
+
+ Parameters.Add_Grid(
+ NULL, "CLOSED" , _TL("Closed Gaps Grid"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Value(
+ NULL, "MAXPOINTS" , _TL("Maximum Points"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 1000, 2, true
+ );
+
+ Parameters.Add_Value(
+ NULL, "LOCALPOINTS" , _TL("Number of Points for Local Interpolation"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 20, 2, true
+ );
+
+ Parameters.Add_Value(
+ NULL, "EXTENDED" , _TL("Extended Neighourhood"),
+ _TL(""),
+ PARAMETER_TYPE_Bool , false
+ );
+
+ Parameters.Add_Choice(
+ NULL, "NEIGHBOURS" , _TL("Neighbourhood"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("Neumann"),
+ _TL("Moore")
+ ), 0
+ );
+
+ Parameters.Add_Value(
+ NULL, "RADIUS" , _TL("Radius (Cells)"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 0.0, 0.0, true
+ );
+
+ Parameters.Add_Value(
+ NULL, "RELAXATION" , _TL("Relaxation"),
+ _TL(""),
+ PARAMETER_TYPE_Double, 0.0, 0.0, true
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Gaps_Spline_Fill::On_Execute(void)
+{
+ //-----------------------------------------------------
+ m_pGrid = Parameters("CLOSED") ->asGrid();
+ m_pMask = Parameters("MASK") ->asGrid();
+ m_nGapCells_Max = Parameters("MAXGAPCELLS") ->asInt();
+ m_nPoints_Max = Parameters("MAXPOINTS") ->asInt();
+ m_nPoints_Local = Parameters("LOCALPOINTS") ->asInt();
+ m_bExtended = Parameters("EXTENDED") ->asBool();
+ m_Neighbours = Parameters("NEIGHBOURS") ->asInt() == 0 ? 2 : 1;
+ m_Radius = Parameters("RADIUS") ->asDouble();
+ m_Relaxation = Parameters("RELAXATION") ->asDouble();
+
+ if( m_pGrid == NULL )
+ {
+ m_pGrid = Parameters("GRID")->asGrid();
+
+ Parameters("CLOSED")->Set_Value(m_pGrid);
+ }
+ else if( m_pGrid != Parameters("GRID")->asGrid() )
+ {
+ m_pGrid->Assign(Parameters("GRID")->asGrid());
+
+ m_pGrid->Set_Name(CSG_String::Format(SG_T("%s [%s]"), Parameters("GRID")->asGrid()->Get_Name(), _TL("no gaps")));
+ }
+
+ if( m_nGapCells_Max == 0 )
+ {
+ m_nGapCells_Max = Get_NCells();
+ }
+
+ if( m_nPoints_Local > m_nPoints_Max )
+ {
+ m_nPoints_Local = m_nPoints_Max;
+ }
+
+ //-----------------------------------------------------
+ m_Gaps.Create(*Get_System(), SG_DATATYPE_Int);
+ m_Gaps.Assign(0.0);
+ m_nGaps = 0;
+
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
+ {
+ if( is_Gap(x, y) && m_Gaps.asInt(x, y) == 0 )
+ {
+ Close_Gap(x, y);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ m_Stack .Clear();
+ m_GapCells .Clear();
+ m_Gaps .Destroy();
+ m_Spline .Destroy();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+inline bool CGrid_Gaps_Spline_Fill::is_Gap(int x, int y)
+{
+ return( (!m_pMask || !m_pMask->is_NoData(x, y)) && m_pGrid->is_NoData(x, y) );
+}
+
+//---------------------------------------------------------
+inline void CGrid_Gaps_Spline_Fill::Push(int x, int y)
+{
+ if( m_iStack >= m_Stack.Get_Count() )
+ {
+ m_Stack.Set_Count(m_Stack.Get_Count() + 1024);
+ }
+
+ m_Stack[m_iStack].x = x;
+ m_Stack[m_iStack].y = y;
+
+ m_iStack++;
+}
+
+//---------------------------------------------------------
+inline void CGrid_Gaps_Spline_Fill::Pop(int &x, int &y)
+{
+ if( m_iStack > 0 )
+ {
+ m_iStack--;
+
+ x = m_Stack[m_iStack].x;
+ y = m_Stack[m_iStack].y;
+ }
+}
+
+//---------------------------------------------------------
+void CGrid_Gaps_Spline_Fill::Set_Gap_Cell(int x, int y)
+{
+ if( is_InGrid(x, y) && (!m_pMask || !m_pMask->is_NoData(x, y)) && m_Gaps.asInt(x, y) != m_nGaps )
+ {
+ m_Gaps.Set_Value(x, y, m_nGaps);
+
+ if( !is_Gap(x, y) )
+ {
+ m_Spline.Add_Point(x, y, m_pGrid->asDouble(x, y));
+
+ for(int i=0; m_bExtended && i<8; i+=m_Neighbours)
+ {
+ int ix = Get_xTo(i, x), iy = Get_yTo(i, y);
+
+ if( m_pGrid->is_InGrid(ix, iy) && m_Gaps.asInt(ix, iy) != m_nGaps )
+ {
+ m_Gaps.Set_Value(ix, iy, m_nGaps);
+
+ m_Spline.Add_Point(ix, iy, m_pGrid->asDouble(ix, iy));
+ }
+ }
+ }
+ else
+ {
+ if( m_nGapCells >= m_GapCells.Get_Count() )
+ {
+ m_GapCells.Set_Count(m_GapCells.Get_Count() + 1024);
+ }
+
+ m_GapCells[m_nGapCells].x = x;
+ m_GapCells[m_nGapCells].y = y;
+
+ m_nGapCells++;
+
+ Push(x, y);
+ }
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CGrid_Gaps_Spline_Fill::Close_Gap(int x, int y)
+{
+ //-----------------------------------------------------
+ m_nGaps ++;
+ m_nGapCells = 0;
+ m_iStack = 0;
+
+ m_Spline.Destroy();
+
+ Set_Gap_Cell(x, y);
+
+ while( m_iStack > 0 && m_nGapCells <= m_nGapCells_Max && Process_Get_Okay() )
+ {
+ Pop(x, y);
+
+ for(int i=0; i<8; i+=m_Neighbours)
+ {
+ Set_Gap_Cell(Get_xTo(i, x), Get_yTo(i, y));
+ }
+ }
+
+ //-----------------------------------------------------
+ if( m_nGapCells <= m_nGapCells_Max )
+ {
+ if( m_nPoints_Max == 0 || m_Spline.Get_Point_Count() <= m_nPoints_Max )
+ {
+ if( m_Spline.Create(m_Relaxation, true) )
+ {
+ for(int i=0; i<m_nGapCells; i++)
+ {
+ TSG_Point_Int p = m_GapCells[i];
+
+ m_pGrid->Set_Value(p.x, p.y, m_Spline.Get_Value(p.x, p.y));
+ }
+ }
+ }
+ else
+ {
+ Close_Gap();
+ }
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CGrid_Gaps_Spline_Fill::Close_Gap(void)
+{
+ int i, j;
+ CSG_PRQuadTree Search(CSG_Rect(0, 0, Get_NX(), Get_NY()));
+
+ for(i=0; i<m_Spline.Get_Point_Count(); i++)
+ {
+ TSG_Point_Z p = m_Spline.Get_Points().Get_Point(i);
+
+ Search.Add_Point(p.x, p.y, p.z);
+ }
+
+ for(i=0; i<m_nGapCells && Process_Get_Okay(); i++)
+ {
+ TSG_Point_Int p = m_GapCells[i];
+
+ m_Spline.Destroy();
+
+ for(j=0; j<4; j++)
+ {
+ Search.Select_Nearest_Points(p.x, p.y, m_nPoints_Local, m_Radius, j);
+
+ for(int k=0; k<Search.Get_Selected_Count(); k++)
+ {
+ double x, y, z;
+
+ Search.Get_Selected_Point(k, x, y, z);
+
+ m_Spline.Add_Point(x, y, z);
+ }
+ }
+
+ if( m_Spline.Create(m_Relaxation, true) )
+ {
+ m_pGrid->Set_Value(p.x, p.y, m_Spline.Get_Value(p.x, p.y));
+ }
+ }
+
+/* for(i=0; i<m_nGapCells && Process_Get_Okay(); i++)
+ {
+ TSG_Point_Int p = m_GapCells[i];
+
+ if( Search.Select_Nearest_Points(p.x, p.y, m_nPoints_Local, m_Radius, m_Radius > 0 ? -1 : 4) > 2 )
+ {
+ m_Spline.Set_Point_Count(Search.Get_Selected_Count());
+
+ for(j=0; j<m_Spline.Get_Point_Count(); j++)
+ {
+ double x, y, z;
+
+ Search.Get_Selected_Point(j, x, y, z);
+
+ m_Spline.Set_Point(j, x, y, z);
+ }
+
+ if( m_Spline.Create(m_Relaxation, true) )
+ {
+ m_pGrid->Set_Value(p.x, p.y, m_Spline.Get_Value(p.x, p.y));
+ }
+ }
+ }/**/
+
+/* m_Spline.Set_Point_Count(m_nPoints_Local);
+
+ for(i=0; i<m_nGapCells && Process_Get_Okay(); i++)
+ {
+ TSG_Point_Int p = m_GapCells[i];
+
+ if( Search.Select_Nearest_Points(p.x, p.y, m_Spline.Get_Point_Count()) == m_Spline.Get_Point_Count() )
+ {
+ for(j=0; j<m_Spline.Get_Point_Count(); j++)
+ {
+ double x, y, z;
+
+ Search.Get_Selected_Point(j, x, y, z);
+
+ m_Spline.Set_Point(j, x, y, z);
+ }
+
+ if( m_Spline.Create(m_Relaxation, true) )
+ {
+ m_pGrid->Set_Value(p.x, p.y, m_Spline.Get_Value(p.x, p.y));
+ }
+ }
+ }/**/
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_tools/Grid_Gaps_Spline_Fill.h b/src/modules/grid/grid_tools/Grid_Gaps_Spline_Fill.h
new file mode 100644
index 0000000..a30333a
--- /dev/null
+++ b/src/modules/grid/grid_tools/Grid_Gaps_Spline_Fill.h
@@ -0,0 +1,128 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Tools //
+// //
+//-------------------------------------------------------//
+// //
+// Grid_Gaps_Spline_Fill.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Grid_Gaps_Spline_Fill_H
+#define HEADER_INCLUDED__Grid_Gaps_Spline_Fill_H
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGrid_Gaps_Spline_Fill : public CSG_Module_Grid
+{
+public:
+ CGrid_Gaps_Spline_Fill(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("A:Grid|Construction") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ bool m_bExtended;
+
+ int m_nGaps, m_nGapCells, m_iStack, m_nPoints_Max, m_nPoints_Local, m_nGapCells_Max, m_Neighbours;
+
+ double m_Relaxation, m_Radius;
+
+ CSG_Points_Int m_GapCells, m_Stack;
+
+ CSG_Thin_Plate_Spline m_Spline;
+
+ CSG_Grid *m_pGrid, *m_pMask, m_Gaps;
+
+
+ bool is_Gap (int x, int y);
+
+ void Push (int x, int y);
+ void Pop (int &x, int &y);
+
+ void Set_Gap_Cell (int x, int y);
+
+ void Close_Gap (int x, int y);
+
+ void Close_Gap (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Grid_Gaps_Spline_Fill_H
diff --git a/src/modules/grid/grid_tools/Grid_Mask.cpp b/src/modules/grid/grid_tools/Grid_Mask.cpp
new file mode 100644
index 0000000..6121343
--- /dev/null
+++ b/src/modules/grid/grid_tools/Grid_Mask.cpp
@@ -0,0 +1,165 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Tools //
+// //
+//-------------------------------------------------------//
+// //
+// Grid_Mask.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "Grid_Mask.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGrid_Mask::CGrid_Mask(void)
+{
+ //-----------------------------------------------------
+ // 1. Info...
+
+ Set_Name (_TL("Grid Masking"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ ""
+ ));
+
+
+ //-----------------------------------------------------
+ // 2. Standard in- and output...
+
+ Parameters.Add_Grid(
+ NULL , "GRID" , _TL("Grid"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "MASK" , _TL("Mask"),
+ _TL(""),
+ PARAMETER_INPUT, false
+ );
+
+ Parameters.Add_Grid(
+ NULL , "MASKED" , _TL("Masked Grid"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Mask::On_Execute(void)
+{
+ int x, y;
+ double z;
+ TSG_Point p;
+ CSG_Grid *pGrid, *pMask, *pMasked;
+
+ pGrid = Parameters("GRID") ->asGrid();
+ pMask = Parameters("MASK") ->asGrid();
+ pMasked = Parameters("MASKED") ->asGrid();
+
+ if( !pGrid->is_Intersecting(pMask->Get_Extent()) )
+ {
+ Message_Add(_TL("no intersection with mask grid."));
+
+ return( false );
+ }
+
+ if( pMasked == NULL )
+ {
+ pMasked = pGrid;
+
+ Parameters("MASKED")->Set_Value(pMasked);
+ }
+ else if( pMasked != pGrid )
+ {
+ pMasked->Assign(pGrid);
+ }
+
+ Process_Set_Text(_TL("masking..."));
+
+ for(y=0, p.y=Get_YMin(); y<Get_NY() && Set_Progress(y); y++, p.y+=Get_Cellsize())
+ {
+ for(x=0, p.x=Get_XMin(); x<Get_NX(); x++, p.x+=Get_Cellsize())
+ {
+ if( !pMasked->is_NoData(x, y) && !pMask->Get_Value(p, z, GRID_INTERPOLATION_NearestNeighbour) )
+ {
+ pMasked->Set_NoData(x, y);
+ }
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_tools/Grid_Mask.h b/src/modules/grid/grid_tools/Grid_Mask.h
new file mode 100644
index 0000000..21ebf92
--- /dev/null
+++ b/src/modules/grid/grid_tools/Grid_Mask.h
@@ -0,0 +1,95 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Tools //
+// //
+//-------------------------------------------------------//
+// //
+// Grid_Mask.h //
+// //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Grid_Mask_H
+#define HEADER_INCLUDED__Grid_Mask_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGrid_Mask : public CSG_Module_Grid
+{
+public:
+ CGrid_Mask(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Values") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Grid_Mask_H
diff --git a/src/modules/grid/grid_tools/Grid_Merge.cpp b/src/modules/grid/grid_tools/Grid_Merge.cpp
index fb90ee7..ac7c524 100644
--- a/src/modules/grid/grid_tools/Grid_Merge.cpp
+++ b/src/modules/grid/grid_tools/Grid_Merge.cpp
@@ -385,6 +385,7 @@ bool CGrid_Merge::On_Execute(void)
pMerged->Set_Value(x, y, pMerged->asDouble(x, y) / pCount->asInt(x, y));
}
}
+ delete (pCount);
}
return( true );
diff --git a/src/modules/grid/grid_tools/Grid_Proximity.cpp b/src/modules/grid/grid_tools/Grid_Proximity.cpp
new file mode 100644
index 0000000..8387005
--- /dev/null
+++ b/src/modules/grid/grid_tools/Grid_Proximity.cpp
@@ -0,0 +1,231 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Tools //
+// //
+//-------------------------------------------------------//
+// //
+// Grid_Proximity.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "Grid_Proximity.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGrid_Proximity::CGrid_Proximity(void)
+{
+ //-----------------------------------------------------
+ // 1. Info...
+
+ Set_Name (_TL("Proximity Grid"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ "Calculates a grid with euclidean distance to feature cells (not no-data cells)."
+ ));
+
+
+ //-----------------------------------------------------
+ // 2. Standard in- and output...
+
+ Parameters.Add_Grid(
+ NULL , "FEATURES" , _TL("Features"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "DISTANCE" , _TL("Distance"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "DIRECTION" , _TL("Direction"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid(
+ NULL , "ALLOCATION" , _TL("Allocation"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Proximity::On_Execute(void)
+{
+ int x, y;
+ double z, d;
+ TSG_Point p;
+ CSG_Grid *pFeatures, *pDistance, *pDirection, *pAllocation;
+ CSG_PRQuadTree Search;
+
+ //-----------------------------------------------------
+ pFeatures = Parameters("FEATURES") ->asGrid();
+ pDistance = Parameters("DISTANCE") ->asGrid();
+ pDirection = Parameters("DIRECTION") ->asGrid();
+ pAllocation = Parameters("ALLOCATION") ->asGrid();
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("preparing distance calculation..."));
+
+ Search.Create(CSG_Rect(-1, -1, Get_NX(), Get_NY()));
+
+ for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ if( pFeatures->is_NoData(x, y) )
+ {
+ pDistance->Set_Value(x, y, -1.0);
+ }
+ else
+ {
+ pDistance->Set_Value(x, y, 0.0);
+
+ if( pDirection )
+ {
+ pDirection->Set_NoData(x, y);
+ }
+
+ if( pAllocation )
+ {
+ pAllocation->Set_Value(x, y, pFeatures->asDouble(x, y));
+ }
+
+ //-----------------------------------------
+ bool bBorder = false;
+
+ for(int i=0; i<8 && !bBorder; i++)
+ {
+ int ix = Get_xTo(i, x);
+ int iy = Get_yTo(i, y);
+
+ if( is_InGrid(ix, iy) && pFeatures->is_NoData(ix, iy) )
+ {
+ bBorder = true;
+ }
+ }
+
+ if( bBorder )
+ {
+ Search.Add_Point(x, y, pFeatures->asDouble(x, y));
+ }
+ }
+ }
+ }
+
+ if( !Search.is_Okay() || Search.Get_Point_Count() <= 0 || Search.Get_Point_Count() >= Get_NCells() )
+ {
+ Message_Add(_TL("no features to buffer."));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("performing distance calculation..."));
+
+ for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ if( pDistance->asDouble(x, y) < 0.0 && Search.Get_Nearest_Point(x, y, p, z, d) )
+ {
+ pDistance->Set_Value(x, y, d * Get_Cellsize());
+
+ if( pDirection )
+ {
+ if( d > 0.0 )
+ {
+ pDirection->Set_Value(x, y, SG_Get_Angle_Of_Direction(x, y, p.x, p.y) * M_RAD_TO_DEG);
+ }
+ else
+ {
+ pDirection->Set_NoData(x, y);
+ }
+ }
+
+ if( pAllocation )
+ {
+ pAllocation->Set_Value(x, y, z);
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_tools/Grid_Proximity.h b/src/modules/grid/grid_tools/Grid_Proximity.h
new file mode 100644
index 0000000..6e054c4
--- /dev/null
+++ b/src/modules/grid/grid_tools/Grid_Proximity.h
@@ -0,0 +1,95 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Tools //
+// //
+//-------------------------------------------------------//
+// //
+// Grid_Proximity.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Grid_Proximity_H
+#define HEADER_INCLUDED__Grid_Proximity_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGrid_Proximity : public CSG_Module_Grid
+{
+public:
+ CGrid_Proximity(void);
+
+// virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Values") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Grid_Proximity_H
diff --git a/src/modules/grid/grid_tools/Grid_Resample.cpp b/src/modules/grid/grid_tools/Grid_Resample.cpp
index e775d90..59c03bc 100644
--- a/src/modules/grid/grid_tools/Grid_Resample.cpp
+++ b/src/modules/grid/grid_tools/Grid_Resample.cpp
@@ -58,8 +58,6 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#include <string.h>
-
#include "Grid_Resample.h"
@@ -78,11 +76,11 @@ CGrid_Resample::CGrid_Resample(void)
//-----------------------------------------------------
Set_Name (_TL("Resampling"));
- Set_Author (SG_T("(c) 2003 by O.Conrad"));
+ Set_Author (SG_T("O.Conrad (c) 2003"));
Set_Description (_TW(
- "Resampling of grids.")
- );
+ "Resampling of grids."
+ ));
//-----------------------------------------------------
Parameters.Add_Grid(
@@ -91,18 +89,6 @@ CGrid_Resample::CGrid_Resample(void)
PARAMETER_INPUT
);
- Parameters.Add_Grid_Output(
- NULL , "GRID" , _TL("Resampled Grid"),
- _TL("")
- );
-
- Parameters.Add_Choice(
- NULL , "METHOD" , _TL("Target Grid"),
- _TL(""),
-
- _TL("Specify dimensions|Create new grid in existing project|Overwrite existing grid|")
- );
-
Parameters.Add_Value(
NULL , "KEEP_TYPE" , _TL("Preserve Data Type"),
_TL(""),
@@ -110,44 +96,6 @@ CGrid_Resample::CGrid_Resample(void)
);
//-----------------------------------------------------
- pParameters = Add_Parameters("DIMENSIONS" , _TL("Target Grid Dimensions") , _TL(""));
-
- pParameters->Add_Value(
- NULL , "CELLSIZE" , _TL("Cell Size"),
- _TL(""),
- PARAMETER_TYPE_Double , 1.0, 0.0, true
- );
-
- pParameters->Add_Value(
- NULL , "CELLS_NX" , _TL("Cell Count: Columns"),
- _TL(""),
- PARAMETER_TYPE_Int , 2, 2, true
- );
-
- pParameters->Add_Value(
- NULL , "CELLS_NY" , _TL("Cell Count: Rows"),
- _TL(""),
- PARAMETER_TYPE_Int , 2, 2, true
- );
-
- //-----------------------------------------------------
- pParameters = Add_Parameters("SYSTEM" , _TL("Choose Grid System") , _TL(""));
-
- pParameters->Add_Grid_System(
- NULL , "SYSTEM" , _TL("Grid System"),
- _TL("")
- );
-
- //-----------------------------------------------------
- pParameters = Add_Parameters("GRID" , _TL("Target Grid") , _TL(""));
-
- pNode = pParameters->Add_Grid(
- NULL , "GRID" , _TL("Target Grid"),
- _TL(""),
- PARAMETER_INPUT , false
- );
-
- //-----------------------------------------------------
pParameters = Add_Parameters("SCALE_UP" , _TL("Up-Scaling") , _TL(""));
pNode = pParameters->Add_Choice(
@@ -180,11 +128,20 @@ CGrid_Resample::CGrid_Resample(void)
_TL("B-Spline Interpolation")
), 4
);
-}
-//---------------------------------------------------------
-CGrid_Resample::~CGrid_Resample(void)
-{}
+ //-----------------------------------------------------
+ Parameters.Add_Choice(
+ NULL , "TARGET" , _TL("Target Grid"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("user defined"),
+ _TL("grid")
+ ), 0
+ );
+
+ m_Grid_Target.Add_Parameters_User(Add_Parameters("USER", _TL("User Defined Grid") , _TL("")));
+ m_Grid_Target.Add_Parameters_Grid(Add_Parameters("GRID", _TL("Choose Grid") , _TL("")));
+}
///////////////////////////////////////////////////////////
@@ -196,44 +153,7 @@ CGrid_Resample::~CGrid_Resample(void)
//---------------------------------------------------------
int CGrid_Resample::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
{
- int nx, ny;
- double cellsize;
- CSG_Grid *pGrid;
-
- if( !SG_STR_CMP(pParameters->Get_Identifier(), SG_T("DIMENSIONS")) )
- {
- pGrid = Parameters ("INPUT") ->asGrid();
- cellsize = pParameters->Get_Parameter("CELLSIZE")->asDouble();
- nx = pParameters->Get_Parameter("CELLS_NX")->asInt();
- ny = pParameters->Get_Parameter("CELLS_NY")->asInt();
-
- if( pGrid && cellsize > 0.0 )
- {
- if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CELLSIZE")) )
- {
- nx = 1 + (int)(pGrid->Get_XRange() / cellsize);
- ny = 1 + (int)(pGrid->Get_YRange() / cellsize);
- }
- else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CELLS_NX")) )
- {
- cellsize = pGrid->Get_XRange() / (nx - 1);
- ny = 1 + (int)(pGrid->Get_YRange() / cellsize);
- }
- else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CELLS_NY")) )
- {
- cellsize = pGrid->Get_YRange() / (ny - 1);
- nx = 1 + (int)(pGrid->Get_XRange() / cellsize);
- }
-
- pParameters->Get_Parameter("CELLSIZE")->Set_Value(cellsize);
- pParameters->Get_Parameter("CELLS_NX")->Set_Value(nx);
- pParameters->Get_Parameter("CELLS_NY")->Set_Value(ny);
-
- return( true );
- }
- }
-
- return( false );
+ return( m_Grid_Target.On_User_Changed(pParameters, pParameter) ? 1 : 0 );
}
@@ -247,117 +167,95 @@ int CGrid_Resample::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parame
bool CGrid_Resample::On_Execute(void)
{
bool bResult;
- double Cellsize;
TSG_Grid_Interpolation Interpolation;
CSG_Grid *pInput, *pOutput;
- CSG_Grid_System System;
CSG_Parameters *pParameters;
//-----------------------------------------------------
bResult = false;
pInput = Parameters("INPUT")->asGrid();
- pOutput = NULL;
//-----------------------------------------------------
- switch( Parameters("METHOD")->asInt() )
- {
- case 0: // Target Dimensions...
- Get_Parameters("DIMENSIONS")->Get_Parameter("CELLSIZE")->Set_Value(pInput->Get_Cellsize());
- Get_Parameters("DIMENSIONS")->Get_Parameter("CELLS_NX")->Set_Value(pInput->Get_NX());
- Get_Parameters("DIMENSIONS")->Get_Parameter("CELLS_NY")->Set_Value(pInput->Get_NY());
-
- if( Dlg_Parameters("DIMENSIONS") && (Cellsize = Get_Parameters("DIMENSIONS")->Get_Parameter("CELLSIZE")->asDouble()) > 0.0 )
- {
- System.Assign(Cellsize, pInput->Get_XMin(), pInput->Get_YMin(),
- 1 + (int)(pInput->Get_XRange() / Cellsize),
- 1 + (int)(pInput->Get_YRange() / Cellsize)
- );
- }
- break;
+ pOutput = NULL;
- case 1: // Target Project...
- if( Dlg_Parameters("SYSTEM") )
+ switch( Parameters("TARGET")->asInt() )
+ {
+ case 0: // user defined...
+ if( m_Grid_Target.Init_User(pInput->Get_Extent()) && Dlg_Parameters("USER") )
{
- System.Assign(*Get_Parameters("SYSTEM")->Get_Parameter("SYSTEM")->asGrid_System());
+ pOutput = m_Grid_Target.Get_User(Parameters("KEEP_TYPE")->asBool() ? pInput->Get_Type() : SG_DATATYPE_Undefined);
}
break;
- case 2: // Target Grid...
+ case 1: // grid...
if( Dlg_Parameters("GRID") )
{
- System.Assign(Get_Parameters("GRID")->Get_Parameter("GRID")->asGrid()->Get_System());
-
- pOutput = Get_Parameters("GRID")->Get_Parameter("GRID")->asGrid();
+ pOutput = m_Grid_Target.Get_Grid(Parameters("KEEP_TYPE")->asBool() ? pInput->Get_Type() : SG_DATATYPE_Undefined);
}
break;
}
//-----------------------------------------------------
- if( System.is_Valid() && pInput->is_Intersecting(System.Get_Extent()) )
+ if( !pOutput || !pInput->is_Intersecting(pOutput->Get_Extent()) )
{
- pParameters = NULL;
-
- //-------------------------------------------------
- // Up-Scaling...
+ return( false );
+ }
- if( pInput->Get_Cellsize() < System.Get_Cellsize() )
- {
- if( Dlg_Parameters("SCALE_UP") )
- {
- switch( Get_Parameters("SCALE_UP")->Get_Parameter("METHOD")->asInt() )
- {
- case 0: Interpolation = GRID_INTERPOLATION_NearestNeighbour; break;
- case 1: Interpolation = GRID_INTERPOLATION_Bilinear; break;
- case 2: Interpolation = GRID_INTERPOLATION_InverseDistance; break;
- case 3: Interpolation = GRID_INTERPOLATION_BicubicSpline; break;
- case 4: Interpolation = GRID_INTERPOLATION_BSpline; break;
- case 5: Interpolation = GRID_INTERPOLATION_Mean_Nodes; break;
- case 6: Interpolation = GRID_INTERPOLATION_Mean_Cells; break;
- case 7: Interpolation = GRID_INTERPOLATION_Minimum; break;
- case 8: Interpolation = GRID_INTERPOLATION_Maximum; break;
- }
-
- pParameters = Get_Parameters("SCALE_UP");
- }
- }
+ pParameters = NULL;
- //-------------------------------------------------
- // Down-Scaling...
+ //-------------------------------------------------
+ // Up-Scaling...
- else
+ if( pInput->Get_Cellsize() < pOutput->Get_Cellsize() )
+ {
+ if( Dlg_Parameters("SCALE_UP") )
{
- if( Dlg_Parameters("SCALE_DOWN") )
+ switch( Get_Parameters("SCALE_UP")->Get_Parameter("METHOD")->asInt() )
{
- switch( Get_Parameters("SCALE_DOWN")->Get_Parameter("METHOD")->asInt() )
- {
- case 0: Interpolation = GRID_INTERPOLATION_NearestNeighbour; break;
- case 1: Interpolation = GRID_INTERPOLATION_Bilinear; break;
- case 2: Interpolation = GRID_INTERPOLATION_InverseDistance; break;
- case 3: Interpolation = GRID_INTERPOLATION_BicubicSpline; break;
- case 4: Interpolation = GRID_INTERPOLATION_BSpline; break;
- }
-
- pParameters = Get_Parameters("SCALE_DOWN");
+ case 0: Interpolation = GRID_INTERPOLATION_NearestNeighbour; break;
+ case 1: Interpolation = GRID_INTERPOLATION_Bilinear; break;
+ case 2: Interpolation = GRID_INTERPOLATION_InverseDistance; break;
+ case 3: Interpolation = GRID_INTERPOLATION_BicubicSpline; break;
+ case 4: Interpolation = GRID_INTERPOLATION_BSpline; break;
+ case 5: Interpolation = GRID_INTERPOLATION_Mean_Nodes; break;
+ case 6: Interpolation = GRID_INTERPOLATION_Mean_Cells; break;
+ case 7: Interpolation = GRID_INTERPOLATION_Minimum; break;
+ case 8: Interpolation = GRID_INTERPOLATION_Maximum; break;
}
+
+ pParameters = Get_Parameters("SCALE_UP");
}
+ }
- //-------------------------------------------------
- if( pParameters )
+ //-------------------------------------------------
+ // Down-Scaling...
+
+ else
+ {
+ if( Dlg_Parameters("SCALE_DOWN") )
{
- if( !pOutput )
+ switch( Get_Parameters("SCALE_DOWN")->Get_Parameter("METHOD")->asInt() )
{
- pOutput = SG_Create_Grid(System, Parameters("KEEP_TYPE")->asBool() || (Interpolation == GRID_INTERPOLATION_NearestNeighbour) ? pInput->Get_Type() : SG_DATATYPE_Undefined);
+ case 0: Interpolation = GRID_INTERPOLATION_NearestNeighbour; break;
+ case 1: Interpolation = GRID_INTERPOLATION_Bilinear; break;
+ case 2: Interpolation = GRID_INTERPOLATION_InverseDistance; break;
+ case 3: Interpolation = GRID_INTERPOLATION_BicubicSpline; break;
+ case 4: Interpolation = GRID_INTERPOLATION_BSpline; break;
}
- pOutput->Set_Name(pInput->Get_Name());
+ pParameters = Get_Parameters("SCALE_DOWN");
+ }
+ }
- pOutput->Assign(pInput, Interpolation);
+ //-------------------------------------------------
+ if( pParameters )
+ {
+ pOutput->Set_Name(pInput->Get_Name());
- Parameters("GRID")->Set_Value(pOutput);
+ pOutput->Assign(pInput, Interpolation);
- return( true );
- }
+ return( true );
}
return( false );
diff --git a/src/modules/grid/grid_tools/Grid_Resample.h b/src/modules/grid/grid_tools/Grid_Resample.h
index 9f6b947..964f54c 100644
--- a/src/modules/grid/grid_tools/Grid_Resample.h
+++ b/src/modules/grid/grid_tools/Grid_Resample.h
@@ -62,28 +62,50 @@
#define HEADER_INCLUDED__Grid_Resample_H
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
#include "MLB_Interface.h"
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
class CGrid_Resample : public CSG_Module_Grid
{
public:
CGrid_Resample(void);
- virtual ~CGrid_Resample(void);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("A:Grid|Construction") ); }
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("A:Grid|Construction") ); }
protected:
- virtual bool On_Execute (void);
+ virtual bool On_Execute (void);
- virtual int On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter);
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
private:
+ CSG_Parameters_Grid_Target m_Grid_Target;
+
};
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
#endif // #ifndef HEADER_INCLUDED__Grid_Resample_H
diff --git a/src/modules/grid/grid_tools/Grid_SortRaster.cpp b/src/modules/grid/grid_tools/Grid_SortRaster.cpp
index 0802436..30e684b 100644
--- a/src/modules/grid/grid_tools/Grid_SortRaster.cpp
+++ b/src/modules/grid/grid_tools/Grid_SortRaster.cpp
@@ -1,88 +1,87 @@
-/*******************************************************************************
- SortRaster.cpp
- Copyright (C) Victor Olaya
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*******************************************************************************/
-
-#include "Grid_SortRaster.h"
-
-CSortRaster::CSortRaster(void){
-
- Parameters.Set_Name(_TL("Sort Grid"));
- Parameters.Set_Description(_TW(
- "(c) 2004 by Victor Olaya. Sort Grid"));
-
- Parameters.Add_Grid(NULL,
- "GRID",
- _TL("Input Grid"),
- _TL(""),
- PARAMETER_INPUT);
-
- Parameters.Add_Grid(NULL,
- "OUTPUT",
- _TL("Sorted Grid"),
- _TL(""),
- PARAMETER_OUTPUT);
-
- Parameters.Add_Value(NULL,
- "DOWN",
- _TL("Down sort"),
- _TL(""),
- PARAMETER_TYPE_Bool,
- false);
-
-}//constructor
-
-
-CSortRaster::~CSortRaster(void)
-{}
-
-bool CSortRaster::On_Execute(void){
-
- CSG_Grid* pGrid = Parameters("GRID")->asGrid();
- CSG_Grid* pSortedGrid = Parameters("OUTPUT")->asGrid();
- bool bDown = Parameters("DOWN")->asBool();
- bool bCopy = false;
- long i;
- int iX, iY;
- int iCell=0;
-
- if (pGrid == pSortedGrid){
- pSortedGrid = SG_Create_Grid(pGrid);
- bCopy = true;
- }//if
-
- pSortedGrid->Set_NoData_Value(0.0);
-
- for(i=0; i<Get_NCells() && Set_Progress(i, Get_NCells()); i++){
- pGrid->Get_Sorted(i, iX, iY, bDown);
- if (pGrid->is_NoData(iX,iY)){
- pSortedGrid->Set_NoData(iX,iY);
- }//if
- else{
- // pSortedGrid->Set_Value(iX, iY, i);
- pSortedGrid->Set_Value(iX, iY, ++iCell);
- }//else
- }//for
-
- if (bCopy){
- pGrid->Assign(pSortedGrid);
- delete pSortedGrid;
- }//if
-
- return true;
-
-}//method
+/*******************************************************************************
+ SortRaster.cpp
+ Copyright (C) Victor Olaya
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*******************************************************************************/
+
+#include "Grid_SortRaster.h"
+
+CSortRaster::CSortRaster(void){
+
+ Parameters.Set_Name(_TL("Sort Grid"));
+ Parameters.Set_Description(_TW(
+ "(c) 2004 by Victor Olaya. Sort Grid"));
+
+ Parameters.Add_Grid(NULL,
+ "GRID",
+ _TL("Input Grid"),
+ _TL(""),
+ PARAMETER_INPUT);
+
+ Parameters.Add_Grid(NULL,
+ "OUTPUT",
+ _TL("Sorted Grid"),
+ _TL(""),
+ PARAMETER_OUTPUT);
+
+ Parameters.Add_Value(NULL,
+ "DOWN",
+ _TL("Down sort"),
+ _TL(""),
+ PARAMETER_TYPE_Bool,
+ false);
+
+}//constructor
+
+
+CSortRaster::~CSortRaster(void)
+{}
+
+bool CSortRaster::On_Execute(void){
+
+ CSG_Grid* pGrid = Parameters("GRID")->asGrid();
+ CSG_Grid* pSortedGrid = Parameters("OUTPUT")->asGrid();
+ bool bDown = Parameters("DOWN")->asBool();
+ bool bCopy = false;
+ long i;
+ int iX, iY;
+ int iCell=0;
+
+ if (pGrid == pSortedGrid){
+ pSortedGrid = SG_Create_Grid(pGrid);
+ bCopy = true;
+ }//if
+
+ pSortedGrid->Set_NoData_Value(0.0);
+
+ for(i=0; i<Get_NCells() && Set_Progress(i, Get_NCells()); i++){
+ pGrid->Get_Sorted(i, iX, iY, bDown, false);
+ if (pGrid->is_NoData(iX,iY)){
+ pSortedGrid->Set_NoData(iX,iY);
+ }//if
+ else{
+ // pSortedGrid->Set_Value(iX, iY, i);
+ pSortedGrid->Set_Value(iX, iY, ++iCell);
+ }//else
+ }//for
+
+ if (bCopy){
+ pGrid->Assign(pSortedGrid);
+ }//if
+
+ return true;
+
+}//method
diff --git a/src/modules/grid/grid_tools/Grid_Value_Replace_Interactive.cpp b/src/modules/grid/grid_tools/Grid_Value_Replace_Interactive.cpp
index 1a63c37..44f4735 100644
--- a/src/modules/grid/grid_tools/Grid_Value_Replace_Interactive.cpp
+++ b/src/modules/grid/grid_tools/Grid_Value_Replace_Interactive.cpp
@@ -75,7 +75,7 @@ bool CGrid_Value_Replace_Interactive::On_Execute_Position(CSG_Point ptWorld, TSG
m_pGrid->Set_Value(iX,iY,m_dNewValue);
- DataObject_Update(m_pGrid, true);
+ DataObject_Update(m_pGrid, SG_UI_DATAOBJECT_UPDATE_ONLY);
return (true);
diff --git a/src/modules/grid/grid_tools/Grid_Value_Request.cpp b/src/modules/grid/grid_tools/Grid_Value_Request.cpp
index 8d9c65c..4049e29 100644
--- a/src/modules/grid/grid_tools/Grid_Value_Request.cpp
+++ b/src/modules/grid/grid_tools/Grid_Value_Request.cpp
@@ -210,7 +210,7 @@ bool CGrid_Value_Request::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Inte
for(iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
{
- if( m_pGrids->asGrid(iGrid)->Get_Value(ptWorld.m_point, Value, m_Interpolation, true) )
+ if( m_pGrids->asGrid(iGrid)->Get_Value(ptWorld, Value, m_Interpolation, true) )
{
m_pTable->Get_Record(iGrid + 2)->Set_Value(FIELD_VALUE, Value);
}
@@ -237,7 +237,7 @@ bool CGrid_Value_Request::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Inte
for(iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
{
- if( m_pGrids->asGrid(iGrid)->Get_Value(ptWorld.m_point, Value, m_Interpolation, true) )
+ if( m_pGrids->asGrid(iGrid)->Get_Value(ptWorld, Value, m_Interpolation, true) )
{
pRecord->Set_Value(FIELD_GRIDS + iGrid, Value);
}
diff --git a/src/modules/grid/grid_tools/Grid_Value_Type.cpp b/src/modules/grid/grid_tools/Grid_Value_Type.cpp
index d2ff599..14ae9b2 100644
--- a/src/modules/grid/grid_tools/Grid_Value_Type.cpp
+++ b/src/modules/grid/grid_tools/Grid_Value_Type.cpp
@@ -70,12 +70,10 @@
//---------------------------------------------------------
CGrid_Value_Type::CGrid_Value_Type(void)
{
- CSG_Parameter *pNode;
-
//-----------------------------------------------------
Set_Name(_TL("Convert Data Storage Type"));
- Set_Author (SG_T("(c) 2003 by O.Conrad"));
+ Set_Author (SG_T("O.Conrad (c) 2003"));
Set_Description (_TW(
"Changes the storage data type of a grid "
@@ -84,39 +82,35 @@ CGrid_Value_Type::CGrid_Value_Type(void)
);
//-----------------------------------------------------
- pNode = Parameters.Add_Grid(
+ Parameters.Add_Grid(
NULL , "INPUT" , _TL("Grid"),
_TL(""),
PARAMETER_INPUT
);
- pNode = Parameters.Add_Grid(
+ Parameters.Add_Grid(
NULL , "OUTPUT" , _TL("Converted Grid"),
_TL(""),
PARAMETER_OUTPUT_OPTIONAL
);
- pNode = Parameters.Add_Choice(
+ Parameters.Add_Choice(
NULL , "TYPE" , _TL("Data storage type"),
_TL(""),
CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|"),
- _TL("1 bit"),
- _TL("1 byte unsigned"),
- _TL("1 byte signed"),
- _TL("2 byte unsigned"),
- _TL("2 byte signed"),
- _TL("4 byte unsigned"),
- _TL("4 byte signed"),
- _TL("4 byte floating point"),
- _TL("8 byte floating point")
+ SG_Data_Type_Get_Name(SG_DATATYPE_Bit),
+ SG_Data_Type_Get_Name(SG_DATATYPE_Byte),
+ SG_Data_Type_Get_Name(SG_DATATYPE_Char),
+ SG_Data_Type_Get_Name(SG_DATATYPE_Word),
+ SG_Data_Type_Get_Name(SG_DATATYPE_Short),
+ SG_Data_Type_Get_Name(SG_DATATYPE_DWord),
+ SG_Data_Type_Get_Name(SG_DATATYPE_Int),
+ SG_Data_Type_Get_Name(SG_DATATYPE_Float),
+ SG_Data_Type_Get_Name(SG_DATATYPE_Double)
)
);
}
-//---------------------------------------------------------
-CGrid_Value_Type::~CGrid_Value_Type(void)
-{}
-
///////////////////////////////////////////////////////////
// //
@@ -127,53 +121,36 @@ CGrid_Value_Type::~CGrid_Value_Type(void)
//---------------------------------------------------------
bool CGrid_Value_Type::On_Execute(void)
{
- bool bCopy;
- TSG_Data_Type Type;
- CSG_Grid *pInput, *pOutput;
-
//-----------------------------------------------------
- pOutput = Parameters("OUTPUT")->asGrid();
+ CSG_Grid *pOutput = Parameters("OUTPUT") ->asGrid();
+ CSG_Grid *pInput = Parameters("INPUT") ->asGrid();
- if( pOutput == NULL || pOutput == Parameters("INPUT")->asGrid() )
+ if( pOutput == NULL || pOutput == pInput )
{
- bCopy = true;
-
- pInput = new CSG_Grid(Parameters("INPUT")->asGrid());
- pInput->Assign(Parameters("INPUT")->asGrid());
-
- if( pOutput == NULL )
- {
- pOutput = Parameters("INPUT")->asGrid();
- }
- }
- else
- {
- bCopy = false;
-
- pInput = Parameters("INPUT")->asGrid();
+ pOutput = pInput;
+ pInput = new CSG_Grid(*pOutput);
}
//-----------------------------------------------------
switch( Parameters("TYPE")->asInt() )
{
default:
- case 0: Type = SG_DATATYPE_Bit; break;
- case 1: Type = SG_DATATYPE_Byte; break;
- case 2: Type = SG_DATATYPE_Char; break;
- case 3: Type = SG_DATATYPE_Word; break;
- case 4: Type = SG_DATATYPE_Short; break;
- case 5: Type = SG_DATATYPE_DWord; break;
- case 6: Type = SG_DATATYPE_Int; break;
- case 7: Type = SG_DATATYPE_Float; break;
- case 8: Type = SG_DATATYPE_Double; break;
+ case 0: pOutput->Create(*Get_System(), SG_DATATYPE_Bit ); break;
+ case 1: pOutput->Create(*Get_System(), SG_DATATYPE_Byte ); break;
+ case 2: pOutput->Create(*Get_System(), SG_DATATYPE_Char ); break;
+ case 3: pOutput->Create(*Get_System(), SG_DATATYPE_Word ); break;
+ case 4: pOutput->Create(*Get_System(), SG_DATATYPE_Short ); break;
+ case 5: pOutput->Create(*Get_System(), SG_DATATYPE_DWord ); break;
+ case 6: pOutput->Create(*Get_System(), SG_DATATYPE_Int ); break;
+ case 7: pOutput->Create(*Get_System(), SG_DATATYPE_Float ); break;
+ case 8: pOutput->Create(*Get_System(), SG_DATATYPE_Double); break;
}
//-----------------------------------------------------
- pOutput->Create(pInput, Type);
pOutput->Assign(pInput);
//-----------------------------------------------------
- if( bCopy )
+ if( pInput != Parameters("INPUT")->asGrid() )
{
delete(pInput);
}
diff --git a/src/modules/grid/grid_tools/Grid_Value_Type.h b/src/modules/grid/grid_tools/Grid_Value_Type.h
index d3377b0..f070d38 100644
--- a/src/modules/grid/grid_tools/Grid_Value_Type.h
+++ b/src/modules/grid/grid_tools/Grid_Value_Type.h
@@ -62,27 +62,43 @@
#define HEADER_INCLUDED__Grid_Value_Type_H
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
//---------------------------------------------------------
#include "MLB_Interface.h"
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
class CGrid_Value_Type : public CSG_Module_Grid
{
public:
CGrid_Value_Type(void);
- virtual ~CGrid_Value_Type(void);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Values") ); }
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Values") ); }
protected:
- virtual bool On_Execute(void);
+ virtual bool On_Execute (void);
+};
-private:
-};
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+//---------------------------------------------------------
#endif // #ifndef HEADER_INCLUDED__Grid_Value_Type_H
diff --git a/src/modules/grid/grid_tools/GridsFromTableAndGrid.cpp b/src/modules/grid/grid_tools/GridsFromTableAndGrid.cpp
index 045580a..109b080 100644
--- a/src/modules/grid/grid_tools/GridsFromTableAndGrid.cpp
+++ b/src/modules/grid/grid_tools/GridsFromTableAndGrid.cpp
@@ -17,117 +17,173 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
#include "GridsFromTableAndGrid.h"
-#include <string.h>
-
-CGridsFromTableAndGrid::CGridsFromTableAndGrid(){
-
- CSG_Parameter *pNode_0, *pNode_1;
-
- Parameters.Set_Name(_TL("Grids from classified grid and table"));
-
- Parameters.Set_Description(_TW("Creates several grids using a classified grid and a table with data values for each class."));
-
- pNode_0 = Parameters.Add_Table( NULL,
- "TABLE",
- _TL("Table"),
- _TL(""),
- PARAMETER_INPUT);
-
- pNode_1 = Parameters.Add_Table_Field(pNode_0,
- "TABLE_ID",
- _TL("Field"),
- _TL(""));
-
- Parameters.Add_Grid(NULL,
- "CLASSES",
- _TL("Classified Grid"),
- _TL(""),
- PARAMETER_INPUT);
-
-}//constructor
-
-CGridsFromTableAndGrid::~CGridsFromTableAndGrid(void){}
-
-bool CGridsFromTableAndGrid::On_Execute(void){
-
- int i,j;
- int x,y;
- CSG_Grid* pClassifiedGrid = Parameters("CLASSES")->asGrid();
- CSG_Table* pTable = Parameters("TABLE")->asTable();
- int iField = Parameters("TABLE_ID")->asInt();
- CSG_Table_Record* pRecord;
- int iMax;
- int iValue;
- float **pValues;
- int *pValidFields;
- int iValidFields = 0;
- CSG_Grid **pGrid;
-
- if (pTable->Get_Record_Count()){
- pRecord = pTable->Get_Record(0);
- iMax = pRecord->asInt(iField);
- for (i = 0; i < pTable->Get_Record_Count(); i++){
- pRecord = pTable->Get_Record(i);
- iValue = pRecord->asInt(iField);
- if (iValue > iMax){
- iMax = iValue;
- }//if
- }//for
- pValues = new float*[iMax+1];
- for (i = 0; i < pTable->Get_Field_Count(); i++){
- if (pTable->Get_Field_Type(i) == SG_DATATYPE_String || i == iField){
- }//if
- else{
- iValidFields++;
- }//else
- }//for
- pValidFields = new int[iValidFields];
- iValidFields = 0;
- for (i = 0; i < pTable->Get_Field_Count(); i++){
- if (pTable->Get_Field_Type(i) == SG_DATATYPE_String || i == iField){
- }//if
- else{
- pValidFields[iValidFields] = i;
- iValidFields++;
- }//else
- }//for
- for (i = 0; i < iMax+1; i++){
- pValues[i] = new float[iValidFields];
- }//for
- for (i = 0; i < pTable->Get_Record_Count(); i++){
- pRecord = pTable->Get_Record(i);
- iValue = pRecord->asInt(iField);
- for (j = 0; j < iValidFields; j++){
- pValues[iValue][j] = pRecord->asFloat(pValidFields[j]);
- }//for
- }//for
-
- pGrid = new CSG_Grid*[iValidFields];
- for (i = 0; i < iValidFields; i++){
- pGrid[i] = new CSG_Grid(pClassifiedGrid);
- }//if
-
- for(y=0; y<Get_NY() && Set_Progress(y); y++){
- for(x=0; x<Get_NX(); x++){
- iValue = pClassifiedGrid->asInt(x,y);
- if (iValue > 0 && iValue < iMax + 1){
- for (i = 0; i < iValidFields; i++){
- pGrid[i]->Set_Value(x, y, pValues[iValue][i]);
- }//for
- }//if
- }//for
- }//for
-
- for (i = 0; i < iValidFields; i++){
- DataObject_Add(pGrid[i], true);
- }//for
- }//if
- else{
- Message_Add(_TL("Selected table contains no valid records"));
- }//else
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGridsFromTableAndGrid::CGridsFromTableAndGrid(void)
+{
+ CSG_Parameter *pNode;
+
+ Set_Name (_TL("Grids from classified grid and table"));
+
+ Set_Description (_TW(
+ "Creates several grids using a classified grid and a table with data values for each class."
+ ));
+
+ pNode = Parameters.Add_Table(
+ NULL , "TABLE" , _TL("Table"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "ID_FIELD" , _TL("Attribute"),
+ _TL("")
+ );
+
+ Parameters.Add_Grid(
+ NULL , "CLASSES" , _TL("Classes"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid_List(
+ NULL , "GRIDS" , _TL("Grids"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGridsFromTableAndGrid::On_Execute(void)
+{
+ int iField, iRecord, iAttribute, nAttributes, *Attribute;
+ long iCell, jCell;
+ CSG_Parameter_Grid_List *pGrids;
+ CSG_Grid *pClasses;
+ CSG_Table *pTable;
+
+ //-----------------------------------------------------
+ pClasses = Parameters("CLASSES") ->asGrid();
+ pGrids = Parameters("GRIDS") ->asGridList();
+ pTable = Parameters("TABLE") ->asTable();
+ iField = Parameters("ID_FIELD") ->asInt();
+
+ pGrids->Del_Items();
+
+ //-----------------------------------------------------
+ if( pTable->Get_Field_Count() == 0 || pTable->Get_Count() == 0 )
+ {
+ Message_Add(_TL("selected table contains no valid records"));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ if( !pTable->Set_Index(iField, TABLE_INDEX_Ascending) )
+ {
+ Message_Add(_TL("failed to create index for table"));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ if( !pClasses->Get_Sorted(0, iCell, false, true) )
+ {
+ Message_Add(_TL("failed to create index for grid"));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Attribute = new int[pTable->Get_Field_Count()];
+
+ for(iAttribute=0, nAttributes=0; iAttribute<pTable->Get_Field_Count(); iAttribute++)
+ {
+ if( iAttribute != iField && pTable->Get_Field_Type(iAttribute) != SG_DATATYPE_String )
+ {
+ Attribute[nAttributes++] = iAttribute;
+
+ CSG_Grid *pGrid = SG_Create_Grid(*Get_System());
+
+ pGrid->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pClasses->Get_Name(), pTable->Get_Field_Name(iAttribute)));
+
+ pGrids->Add_Item(pGrid);
+ }
+ }
+
+ if( nAttributes == 0 )
+ {
+ delete[](Attribute);
+
+ Message_Add(_TL("selected table does not have numeric attributes"));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ CSG_Table_Record *pRecord = pTable->Get_Record_byIndex(0);
+
+ for(iCell=0, iRecord=0; iCell<Get_NCells() && pRecord && Set_Progress_NCells(iCell); iCell++)
+ {
+ if( pClasses->Get_Sorted(iCell, jCell, false, true) )
+ {
+ double valClass = pClasses->asDouble(jCell);
+
+ while( pRecord && pRecord->asDouble(iField) < valClass )
+ {
+ pRecord = pTable->Get_Record_byIndex(++iRecord);
+ }
+
+ if( !pRecord || pRecord->asDouble(iField) > valClass )
+ {
+ for(iAttribute=0; iAttribute<nAttributes; iAttribute++)
+ {
+ pGrids->asGrid(iAttribute)->Set_NoData(jCell);
+ }
+ }
+ else
+ {
+ for(iAttribute=0; iAttribute<nAttributes; iAttribute++)
+ {
+ pGrids->asGrid(iAttribute)->Set_Value(jCell, pRecord->asDouble(Attribute[iAttribute]));
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ delete[](Attribute);
return true;
+}
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
-}//method
\ No newline at end of file
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_tools/GridsFromTableAndGrid.h b/src/modules/grid/grid_tools/GridsFromTableAndGrid.h
index 2ac5097..50e874a 100644
--- a/src/modules/grid/grid_tools/GridsFromTableAndGrid.h
+++ b/src/modules/grid/grid_tools/GridsFromTableAndGrid.h
@@ -17,20 +17,42 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
#include "MLB_Interface.h"
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
class CGridsFromTableAndGrid : public CSG_Module_Grid
{
public:
CGridsFromTableAndGrid(void);
- virtual ~CGridsFromTableAndGrid(void);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("A:Grid|Construction") ); }
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("A:Grid|Construction") ); }
+
protected:
- virtual bool On_Execute(void);
+ virtual bool On_Execute (void);
+
+};
-private:
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
-};
\ No newline at end of file
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_tools/MLB_Interface.cpp b/src/modules/grid/grid_tools/MLB_Interface.cpp
index 4266a16..ae9e31e 100644
--- a/src/modules/grid/grid_tools/MLB_Interface.cpp
+++ b/src/modules/grid/grid_tools/MLB_Interface.cpp
@@ -74,7 +74,7 @@ const SG_Char * Get_Info(int i)
return( _TL("Grid - Tools") );
case MLB_INFO_Author:
- return( _TL("Olaf Conrad, Victor Olaya, Volker Wichmann (c) 2002-5") );
+ return( _TL("Olaf Conrad, Victor Olaya, Volker Wichmann (c) 2002-10") );
case MLB_INFO_Description:
return( _TL("Tools for the manipulation of gridded data.") );
@@ -122,6 +122,10 @@ const SG_Char * Get_Info(int i)
#include "CreateGridSystem.h"
+#include "Grid_Mask.h"
+#include "Grid_Gaps_Spline_Fill.h"
+#include "Grid_Proximity.h"
+
//---------------------------------------------------------
// 4. Allow your modules to be created here...
@@ -154,6 +158,9 @@ CSG_Module * Create_Module(int i)
case 21: return( new CSortRaster );
case 22: return( new CGridsFromTableAndGrid );
case 23: return( new CCreateGridSystem );
+ case 24: return( new CGrid_Mask );
+ case 25: return( new CGrid_Gaps_Spline_Fill );
+ case 26: return( new CGrid_Proximity );
}
return( NULL );
diff --git a/src/modules/grid/grid_tools/Makefile.am b/src/modules/grid/grid_tools/Makefile.am
index 6ab2356..39c8212 100644
--- a/src/modules/grid/grid_tools/Makefile.am
+++ b/src/modules/grid/grid_tools/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.7 2007/07/30 07:29:24 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_tools.la
libgrid_tools_la_SOURCES =\
CreateGridSystem.cpp\
@@ -25,9 +25,12 @@ Grid_Cut.cpp\
Grid_Fill.cpp\
Grid_Gaps.cpp\
Grid_Gaps_OneCell.cpp\
+Grid_Gaps_Spline_Fill.cpp\
Grid_InvertNoData.cpp\
+Grid_Mask.cpp\
Grid_Merge.cpp\
Grid_Orientation.cpp\
+Grid_Proximity.cpp\
Grid_Resample.cpp\
Grid_SortRaster.cpp\
Grid_ThresholdBuffer.cpp\
@@ -50,9 +53,12 @@ Grid_Cut.h\
Grid_Fill.h\
Grid_Gaps.h\
Grid_Gaps_OneCell.h\
+Grid_Gaps_Spline_Fill.h\
Grid_InvertNoData.h\
+Grid_Mask.h\
Grid_Merge.h\
Grid_Orientation.h\
+Grid_Proximity.h\
Grid_Resample.h\
Grid_SortRaster.h\
Grid_ThresholdBuffer.h\
diff --git a/src/modules/grid/grid_tools/Makefile.in b/src/modules/grid/grid_tools/Makefile.in
index 834527f..f987fed 100644
--- a/src/modules/grid/grid_tools/Makefile.in
+++ b/src/modules/grid/grid_tools/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,13 +72,14 @@ am_libgrid_tools_la_OBJECTS = CreateGridSystem.lo Grid_Aggregate.lo \
Grid_Buffer.lo Grid_Buffer_Proximity.lo Grid_CombineGrids.lo \
Grid_Completion.lo Grid_ConstantGrid.lo Grid_CropToData.lo \
Grid_Cut.lo Grid_Fill.lo Grid_Gaps.lo Grid_Gaps_OneCell.lo \
- Grid_InvertNoData.lo Grid_Merge.lo Grid_Orientation.lo \
+ Grid_Gaps_Spline_Fill.lo Grid_InvertNoData.lo Grid_Mask.lo \
+ Grid_Merge.lo Grid_Orientation.lo Grid_Proximity.lo \
Grid_Resample.lo Grid_SortRaster.lo Grid_ThresholdBuffer.lo \
Grid_Value_Reclassify.lo Grid_Value_Replace.lo \
Grid_Value_Replace_Interactive.lo Grid_Value_Request.lo \
Grid_Value_Type.lo GridsFromTableAndGrid.lo MLB_Interface.lo
libgrid_tools_la_OBJECTS = $(am_libgrid_tools_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -125,6 +125,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -134,6 +135,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -224,14 +226,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.7 2007/07/30 07:29:24 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_tools.la
libgrid_tools_la_SOURCES = \
CreateGridSystem.cpp\
@@ -246,9 +248,12 @@ Grid_Cut.cpp\
Grid_Fill.cpp\
Grid_Gaps.cpp\
Grid_Gaps_OneCell.cpp\
+Grid_Gaps_Spline_Fill.cpp\
Grid_InvertNoData.cpp\
+Grid_Mask.cpp\
Grid_Merge.cpp\
Grid_Orientation.cpp\
+Grid_Proximity.cpp\
Grid_Resample.cpp\
Grid_SortRaster.cpp\
Grid_ThresholdBuffer.cpp\
@@ -271,9 +276,12 @@ Grid_Cut.h\
Grid_Fill.h\
Grid_Gaps.h\
Grid_Gaps_OneCell.h\
+Grid_Gaps_Spline_Fill.h\
Grid_InvertNoData.h\
+Grid_Mask.h\
Grid_Merge.h\
Grid_Orientation.h\
+Grid_Proximity.h\
Grid_Resample.h\
Grid_SortRaster.h\
Grid_ThresholdBuffer.h\
@@ -372,9 +380,12 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Fill.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Gaps.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Gaps_OneCell.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Gaps_Spline_Fill.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_InvertNoData.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Mask.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Merge.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Orientation.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Proximity.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Resample.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_SortRaster.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_ThresholdBuffer.Plo at am__quote@
diff --git a/src/modules/grid/grid_visualisation/Grid_Color_Blend.cpp b/src/modules/grid/grid_visualisation/Grid_Color_Blend.cpp
index 8f63075..a220e46 100644
--- a/src/modules/grid/grid_visualisation/Grid_Color_Blend.cpp
+++ b/src/modules/grid/grid_visualisation/Grid_Color_Blend.cpp
@@ -95,6 +95,17 @@ CGrid_Color_Blend::CGrid_Color_Blend(void)
_TL(""),
PARAMETER_TYPE_Int , 0.0, 0.0, true
);
+
+ Parameters.Add_Choice(
+ NULL , "RANGE" , _TL("Color Stretch"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|%s|"),
+ _TL("fit to each grid"),
+ _TL("fit to overall range"),
+ _TL("fit to overall 1.5 standard deviation"),
+ _TL("fit to overall 2.0 standard deviation")
+ ), 3
+ );
}
//---------------------------------------------------------
@@ -111,13 +122,14 @@ CGrid_Color_Blend::~CGrid_Color_Blend(void)
//---------------------------------------------------------
bool CGrid_Color_Blend::On_Execute(void)
{
- int iGrid, x, y, iStep, nSteps;
- double d, dStep, Value_A, Value_B;
- CSG_Grid *pGrid, *pGrid_A, *pGrid_B;
+ int iGrid, x, y, iStep, nSteps, Range;
+ double d, dStep, Value_A, Value_B, Range_Min, Range_Max;
+ CSG_Grid *pGrid, *pGrid_A, *pGrid_B;
CSG_Parameter_Grid_List *pGrids;
pGrid = Parameters("GRID") ->asGrid();
pGrids = Parameters("GRIDS") ->asGridList();
+ Range = Parameters("RANGE") ->asInt();
if( pGrids->Get_Count() > 1 )
{
@@ -126,18 +138,57 @@ bool CGrid_Color_Blend::On_Execute(void)
nSteps = (1 + nSteps) * (pGrids->Get_Count() - 1);
pGrid_B = pGrids->asGrid(0);
+ pGrid->Assign(pGrid_B);
- if( pGrid->Get_ZRange() > 0.0 )
- {
- pGrid->Assign(pGrid_B);
- DataObject_Update(pGrid, true);
- }
- else
+ switch( Range )
{
- pGrid->Assign(pGrid_B);
- DataObject_Update(pGrid, pGrid_B->Get_ZMin(), pGrid_B->Get_ZMax(), true);
+ case 0:
+ Range_Min = pGrid->Get_ZMin();
+ Range_Max = pGrid->Get_ZMax();
+ break;
+
+ case 1:
+ Range_Min = pGrid->Get_ZMin();
+ Range_Max = pGrid->Get_ZMax();
+
+ for(iGrid=1; iGrid<pGrids->Get_Count(); iGrid++)
+ {
+ if( Range_Min > pGrids->asGrid(iGrid)->Get_ZMin() ) Range_Min = pGrids->asGrid(iGrid)->Get_ZMin();
+ if( Range_Max < pGrids->asGrid(iGrid)->Get_ZMax() ) Range_Max = pGrids->asGrid(iGrid)->Get_ZMax();
+ }
+ break;
+
+ case 2:
+ Range_Min = pGrid->Get_ArithMean() - 1.5 * pGrid->Get_StdDev();
+ Range_Max = pGrid->Get_ArithMean() + 1.5 * pGrid->Get_StdDev();
+
+ for(iGrid=1; iGrid<pGrids->Get_Count(); iGrid++)
+ {
+ double Min = pGrids->asGrid(iGrid)->Get_ArithMean() - 1.5 * pGrids->asGrid(iGrid)->Get_StdDev();
+ double Max = pGrids->asGrid(iGrid)->Get_ArithMean() + 1.5 * pGrids->asGrid(iGrid)->Get_StdDev();
+
+ if( Range_Min > Min ) Range_Min = Min;
+ if( Range_Max < Max ) Range_Max = Max;
+ }
+ break;
+
+ case 3:
+ Range_Min = pGrid->Get_ArithMean() - 2.0 * pGrid->Get_StdDev();
+ Range_Max = pGrid->Get_ArithMean() + 2.0 * pGrid->Get_StdDev();
+
+ for(iGrid=1; iGrid<pGrids->Get_Count(); iGrid++)
+ {
+ double Min = pGrids->asGrid(iGrid)->Get_ArithMean() - 2.0 * pGrids->asGrid(iGrid)->Get_StdDev();
+ double Max = pGrids->asGrid(iGrid)->Get_ArithMean() + 2.0 * pGrids->asGrid(iGrid)->Get_StdDev();
+
+ if( Range_Min > Min ) Range_Min = Min;
+ if( Range_Max < Max ) Range_Max = Max;
+ }
+ break;
}
+ DataObject_Update(pGrid, Range_Min, Range_Max, SG_UI_DATAOBJECT_SHOW);
+
for(iGrid=1, iStep=1; iGrid<pGrids->Get_Count() && Set_Progress(iStep, nSteps); iGrid++, iStep++)
{
pGrid_A = pGrid_B;
@@ -156,11 +207,26 @@ bool CGrid_Color_Blend::On_Execute(void)
}
}
- DataObject_Update(pGrid, true);
+ if( Range == 0 )
+ {
+ DataObject_Update(pGrid);
+ }
+ else
+ {
+ DataObject_Update(pGrid, Range_Min, Range_Max);
+ }
}
pGrid->Assign(pGrid_B);
- DataObject_Update(pGrid, true);
+
+ if( Range == 0 )
+ {
+ DataObject_Update(pGrid);
+ }
+ else
+ {
+ DataObject_Update(pGrid, Range_Min, Range_Max);
+ }
}
return( true );
@@ -168,3 +234,12 @@ bool CGrid_Color_Blend::On_Execute(void)
return( false );
}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_visualisation/Grid_Histogram_Surface.cpp b/src/modules/grid/grid_visualisation/Grid_Histogram_Surface.cpp
new file mode 100644
index 0000000..7445d4d
--- /dev/null
+++ b/src/modules/grid/grid_visualisation/Grid_Histogram_Surface.cpp
@@ -0,0 +1,240 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Visualisation //
+// //
+//-------------------------------------------------------//
+// //
+// Grid_Histogram_Surface.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "Grid_Histogram_Surface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGrid_Histogram_Surface::CGrid_Histogram_Surface(void)
+{
+ Set_Name (_TL("Histogram Surface"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ ""
+ ));
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid(
+ NULL , "GRID" , _TL("Grid"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid_Output(
+ NULL , "HIST" , _TL("Histogram"),
+ _TL("")
+ );
+
+ Parameters.Add_Choice(
+ NULL , "METHOD" , _TL("Method"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("rows"),
+ _TL("columns"),
+ _TL("circle")
+ ), 0
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Histogram_Surface::On_Execute(void)
+{
+ m_pGrid = Parameters("GRID")->asGrid();
+
+ switch( Parameters("METHOD")->asInt() )
+ {
+ case 0: return( Get_Lines( true) );
+ case 1: return( Get_Lines(false) );
+ case 2: return( Get_Circle() );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Histogram_Surface::Get_Lines(bool bRows)
+{
+ int i, j, n_i, n_j;
+ CSG_Table Values;
+ CSG_Grid *pHist;
+
+ //-----------------------------------------------------
+ Parameters("HIST")->Set_Value(pHist = SG_Create_Grid(m_pGrid));
+
+ pHist->Set_NoData_Value_Range(
+ m_pGrid->Get_NoData_Value(),
+ m_pGrid->Get_NoData_hiValue()
+ );
+
+ n_i = bRows ? Get_NX() : Get_NY();
+ n_j = bRows ? Get_NY() : Get_NX();
+
+ Values.Add_Field(SG_T("Z"), SG_DATATYPE_Double);
+
+ for(i=0; i<n_i; i++)
+ {
+ Values.Add_Record();
+ }
+
+ //-----------------------------------------------------
+ for(j=0; j<n_j && Set_Progress(j, n_j); j++)
+ {
+ for(i=0; i<n_i; i++)
+ {
+ Values.Get_Record(i)->Set_Value(0, bRows ? m_pGrid->asDouble(i, j) : m_pGrid->asDouble(j, i));
+ }
+
+ Values.Set_Index(0, TABLE_INDEX_Ascending);
+
+ for(i=0; i<n_i; i++)
+ {
+ int k = i % 2 ? i / 2 : n_i - 1 - i / 2;
+
+ if( bRows )
+ {
+ pHist->Set_Value(k, j, Values.Get_Record_byIndex(i)->asDouble(0));
+ }
+ else
+ {
+ pHist->Set_Value(j, k, Values.Get_Record_byIndex(i)->asDouble(0));
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Histogram_Surface::Get_Circle(void)
+{
+ long i;
+ int n;
+ double r;
+ CSG_Grid *pHist;
+
+ r = sqrt(m_pGrid->Get_NCells() / M_PI);
+ n = 1 + (int)(2.0 * r);
+
+ //-----------------------------------------------------
+ Parameters("HIST")->Set_Value(pHist = SG_Create_Grid(m_pGrid->Get_Type(), n, n, m_pGrid->Get_Cellsize(), -r * m_pGrid->Get_Cellsize(), -r * m_pGrid->Get_Cellsize()));
+
+ pHist->Set_NoData_Value_Range(
+ m_pGrid->Get_NoData_Value(),
+ m_pGrid->Get_NoData_hiValue()
+ );
+
+ //-----------------------------------------------------
+ for(int y=0; y<n && Set_Progress(y, n); y++)
+ {
+ for(int x=0; x<n; x++)
+ {
+ double d = SG_Get_Distance(x, y, r, r);
+
+ if( d < r && m_pGrid->Get_Sorted((long)(d*d*M_PI), i) )
+ {
+ pHist->Set_Value(x, y, m_pGrid->asDouble(i));
+ }
+ else
+ {
+ pHist->Set_NoData(x, y);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/grid/grid_visualisation/Grid_Histogram_Surface.h b/src/modules/grid/grid_visualisation/Grid_Histogram_Surface.h
new file mode 100644
index 0000000..a819b36
--- /dev/null
+++ b/src/modules/grid/grid_visualisation/Grid_Histogram_Surface.h
@@ -0,0 +1,109 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Visualisation //
+// //
+//-------------------------------------------------------//
+// //
+// Grid_Histogram_Surface.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Grid_Histogram_Surface_H
+#define HEADER_INCLUDED__Grid_Histogram_Surface_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGrid_Histogram_Surface : public CSG_Module_Grid
+{
+public:
+ CGrid_Histogram_Surface(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ CSG_Grid *m_pGrid;
+
+
+ bool Get_Lines (bool bRows);
+ bool Get_Circle (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Grid_Histogram_Surface_H
diff --git a/src/modules/grid/grid_visualisation/MLB_Interface.cpp b/src/modules/grid/grid_visualisation/MLB_Interface.cpp
index f782d2d..2598b9c 100644
--- a/src/modules/grid/grid_visualisation/MLB_Interface.cpp
+++ b/src/modules/grid/grid_visualisation/MLB_Interface.cpp
@@ -97,6 +97,7 @@ const SG_Char * Get_Info(int i)
#include "Grid_RGB_Composite.h"
#include "Grid_3D_Image.h"
#include "Grid_Color_Triangle.h"
+#include "Grid_Histogram_Surface.h"
//---------------------------------------------------------
@@ -112,6 +113,7 @@ CSG_Module * Create_Module(int i)
case 3: return( new CGrid_RGB_Composite );
case 4: return( new CGrid_3D_Image );
case 5: return( new CGrid_Color_Triangle );
+ case 6: return( new CGrid_Histogram_Surface );
}
return( NULL );
diff --git a/src/modules/grid/grid_visualisation/Makefile.am b/src/modules/grid/grid_visualisation/Makefile.am
index 3be365c..c37a97a 100644
--- a/src/modules/grid/grid_visualisation/Makefile.am
+++ b/src/modules/grid/grid_visualisation/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.6 2008/02/15 14:30:50 oconrad Exp $
+# $Id: Makefile.am,v 1.8 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_visualisation.la
libgrid_visualisation_la_SOURCES =\
Grid_3D_Image.cpp\
@@ -18,6 +18,7 @@ Grid_Color_Blend.cpp\
Grid_Color_Triangle.cpp\
Grid_Color_Rotate.cpp\
Grid_Colors_Fit.cpp\
+Grid_Histogram_Surface.cpp\
Grid_RGB_Composite.cpp\
MLB_Interface.cpp\
Grid_3D_Image.h\
@@ -25,6 +26,7 @@ Grid_Color_Blend.h\
Grid_Color_Rotate.h\
Grid_Color_Triangle.h\
Grid_Colors_Fit.h\
+Grid_Histogram_Surface.h\
Grid_RGB_Composite.h\
MLB_Interface.h
diff --git a/src/modules/grid/grid_visualisation/Makefile.in b/src/modules/grid/grid_visualisation/Makefile.in
index c299057..17e5c97 100644
--- a/src/modules/grid/grid_visualisation/Makefile.in
+++ b/src/modules/grid/grid_visualisation/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -71,11 +70,12 @@ libgrid_visualisation_la_DEPENDENCIES = \
$(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
am_libgrid_visualisation_la_OBJECTS = Grid_3D_Image.lo \
Grid_Color_Blend.lo Grid_Color_Triangle.lo \
- Grid_Color_Rotate.lo Grid_Colors_Fit.lo Grid_RGB_Composite.lo \
+ Grid_Color_Rotate.lo Grid_Colors_Fit.lo \
+ Grid_Histogram_Surface.lo Grid_RGB_Composite.lo \
MLB_Interface.lo
libgrid_visualisation_la_OBJECTS = \
$(am_libgrid_visualisation_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -121,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -130,6 +131,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -220,14 +222,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.6 2008/02/15 14:30:50 oconrad Exp $
+# $Id: Makefile.am,v 1.8 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgrid_visualisation.la
libgrid_visualisation_la_SOURCES = \
Grid_3D_Image.cpp\
@@ -235,6 +237,7 @@ Grid_Color_Blend.cpp\
Grid_Color_Triangle.cpp\
Grid_Color_Rotate.cpp\
Grid_Colors_Fit.cpp\
+Grid_Histogram_Surface.cpp\
Grid_RGB_Composite.cpp\
MLB_Interface.cpp\
Grid_3D_Image.h\
@@ -242,6 +245,7 @@ Grid_Color_Blend.h\
Grid_Color_Rotate.h\
Grid_Color_Triangle.h\
Grid_Colors_Fit.h\
+Grid_Histogram_Surface.h\
Grid_RGB_Composite.h\
MLB_Interface.h
@@ -325,6 +329,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Color_Rotate.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Color_Triangle.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Colors_Fit.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_Histogram_Surface.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Grid_RGB_Composite.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
diff --git a/src/modules/pointcloud/Makefile.in b/src/modules/pointcloud/Makefile.in
index b91bae0..3d69d0c 100644
--- a/src/modules/pointcloud/Makefile.in
+++ b/src/modules/pointcloud/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules/pointcloud/pointcloud_tools/MLB_Interface.cpp b/src/modules/pointcloud/pointcloud_tools/MLB_Interface.cpp
index 67f633c..e45eaa5 100644
--- a/src/modules/pointcloud/pointcloud_tools/MLB_Interface.cpp
+++ b/src/modules/pointcloud/pointcloud_tools/MLB_Interface.cpp
@@ -1,121 +1,133 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// pointcloud_tools //
-// //
-//-------------------------------------------------------//
-// //
-// MLB_Interface.cpp //
-// //
-// Copyright (C) 2009 by //
-// Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Hamburg //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// The Module Link Library Interface //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "MLB_Interface.h"
-
-
-//---------------------------------------------------------
-const SG_Char * Get_Info(int i)
-{
- switch( i )
- {
- case MLB_INFO_Name: default:
- return( _TL("Point Cloud - Tools") );
-
- case MLB_INFO_Author:
- return( _TL("O.Conrad (c) 2009") );
-
- case MLB_INFO_Description:
- return( _TL("Tools for point clouds.") );
-
- case MLB_INFO_Version:
- return( SG_T("1.0") );
-
- case MLB_INFO_Menu_Path:
- return( _TL("Point Cloud") );
- }
-}
-
-
-//---------------------------------------------------------
-#include "pc_cut.h"
-#include "pc_from_grid.h"
-#include "pc_from_shapes.h"
-#include "pc_to_grid.h"
-#include "pc_to_shapes.h"
-
-
-//---------------------------------------------------------
-CSG_Module * Create_Module(int i)
-{
- switch( i )
- {
- case 0: return( new CPC_Cut );
- case 1: return( new CPC_Cut_Interactive );
- case 2: return( new CPC_From_Grid );
- case 3: return( new CPC_From_Shapes );
- case 4: return( new CPC_To_Grid );
- case 5: return( new CPC_To_Shapes );
- }
-
- return( NULL );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-//{{AFX_SAGA
-
- MLB_INTERFACE
-
-//}}AFX_SAGA
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.cpp //
+// //
+// Copyright (C) 2009 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// The Module Link Library Interface //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+//---------------------------------------------------------
+const SG_Char * Get_Info(int i)
+{
+ switch( i )
+ {
+ case MLB_INFO_Name: default:
+ return( _TL("Shapes - Point Clouds") );
+
+ case MLB_INFO_Author:
+ return( _TL("O.Conrad, Volker Wichmann (c) 2009-10") );
+
+ case MLB_INFO_Description:
+ return( _TL("Tools for point clouds.") );
+
+ case MLB_INFO_Version:
+ return( SG_T("1.0") );
+
+ case MLB_INFO_Menu_Path:
+ return( _TL("Shapes|Point Clouds") );
+ }
+}
+
+
+//---------------------------------------------------------
+#include "pc_attribute_calculator.h"
+#include "pc_cluster_analysis.h"
+#include "pc_cut.h"
+#include "pc_drop_attribute.h"
+#include "pc_from_grid.h"
+#include "pc_from_shapes.h"
+#include "pc_reclass_extract.h"
+#include "pc_thinning_simple.h"
+#include "pc_to_grid.h"
+#include "pc_to_shapes.h"
+#include "pc_transform.h"
+
+
+//---------------------------------------------------------
+CSG_Module * Create_Module(int i)
+{
+ switch( i )
+ {
+ case 0: return( new CPC_Cut );
+ case 1: return( new CPC_Cut_Interactive );
+ case 2: return( new CPC_From_Grid );
+ case 3: return( new CPC_From_Shapes );
+ case 4: return( new CPC_To_Grid );
+ case 5: return( new CPC_To_Shapes );
+ case 6: return( new CPC_Reclass_Extract );
+ case 7: return( new CPC_Drop_Attribute );
+ case 8: return( new CPC_Transform );
+ case 9: return( new CPC_Thinning_Simple );
+ case 10: return( new CPC_Attribute_Calculator );
+ case 11: return( new CPC_Cluster_Analysis );
+ }
+
+ return( NULL );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+//{{AFX_SAGA
+
+ MLB_INTERFACE
+
+//}}AFX_SAGA
diff --git a/src/modules/pointcloud/pointcloud_tools/Makefile.am b/src/modules/pointcloud/pointcloud_tools/Makefile.am
index 3952e5d..7df590d 100644
--- a/src/modules/pointcloud/pointcloud_tools/Makefile.am
+++ b/src/modules/pointcloud/pointcloud_tools/Makefile.am
@@ -1,27 +1,44 @@
-if DEBUG
-DBGFLAGS = -g -DDEBUG
-endif
-if SAGA_UNICODE
-UC_DEFS = -D_SAGA_UNICODE
-endif
-DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
-CXX_INCS = -I$(top_srcdir)/src/saga_core
-AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
-pkglib_LTLIBRARIES = libpointcloud_tools.la
-libpointcloud_tools_la_SOURCES =\
-MLB_Interface.cpp\
-pc_cut.cpp\
-pc_from_grid.cpp\
-pc_from_shapes.cpp\
-pc_to_grid.cpp\
-pc_to_shapes.cpp\
-MLB_Interface.h\
-pc_cut.h\
-pc_from_grid.h\
-pc_from_shapes.h\
-pc_to_grid.h\
-pc_to_shapes.h
-
-libpointcloud_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
-
+if DEBUG
+DBGFLAGS = -g -DDEBUG
+endif
+if SAGA_UNICODE
+DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` -D_SAGA_UNICODE $(DBGFLAGS)
+DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs`
+UC_DEFS = -D_SAGA_UNICODE
+else
+DEP_DEFS = -fPIC `wx-config --unicode=no --static=no --cxxflags` $(DBGFLAGS)
+DEP_LFLG = -fPIC -shared `wx-config --unicode=no --static=no --libs`
+endif
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(UC_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LFLG)
+pkglib_LTLIBRARIES = libpointcloud_tools.la
+libpointcloud_tools_la_SOURCES =\
+MLB_Interface.cpp\
+pc_attribute_calculator.cpp\
+pc_cluster_analysis.cpp\
+pc_cut.cpp\
+pc_drop_attribute.cpp\
+pc_from_grid.cpp\
+pc_from_shapes.cpp\
+pc_reclass_extract.cpp\
+pc_thinning_simple.cpp\
+pc_to_grid.cpp\
+pc_to_shapes.cpp\
+pc_transform.cpp\
+MLB_Interface.h\
+pc_attribute_calculator.h\
+pc_cluster_analysis.h\
+pc_cut.h\
+pc_drop_attribute.h\
+pc_from_grid.h\
+pc_from_shapes.h\
+pc_reclass_extract.h\
+pc_thinning_simple.h\
+pc_to_grid.h\
+pc_to_shapes.h\
+pc_transform.h
+
+libpointcloud_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+
diff --git a/src/modules/pointcloud/pointcloud_tools/Makefile.in b/src/modules/pointcloud/pointcloud_tools/Makefile.in
index 39d38a0..b4c7dac 100644
--- a/src/modules/pointcloud/pointcloud_tools/Makefile.in
+++ b/src/modules/pointcloud/pointcloud_tools/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -69,11 +68,13 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)"
LTLIBRARIES = $(pkglib_LTLIBRARIES)
libpointcloud_tools_la_DEPENDENCIES = \
$(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
-am_libpointcloud_tools_la_OBJECTS = MLB_Interface.lo pc_cut.lo \
- pc_from_grid.lo pc_from_shapes.lo pc_to_grid.lo \
- pc_to_shapes.lo
+am_libpointcloud_tools_la_OBJECTS = MLB_Interface.lo \
+ pc_attribute_calculator.lo pc_cluster_analysis.lo pc_cut.lo \
+ pc_drop_attribute.lo pc_from_grid.lo pc_from_shapes.lo \
+ pc_reclass_extract.lo pc_thinning_simple.lo pc_to_grid.lo \
+ pc_to_shapes.lo pc_transform.lo
libpointcloud_tools_la_OBJECTS = $(am_libpointcloud_tools_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +120,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +130,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -217,25 +220,41 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
+ at SAGA_UNICODE_FALSE@DEP_DEFS = -fPIC `wx-config --unicode=no --static=no --cxxflags` $(DBGFLAGS)
+ at SAGA_UNICODE_TRUE@DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` -D_SAGA_UNICODE $(DBGFLAGS)
+ at SAGA_UNICODE_FALSE@DEP_LFLG = -fPIC -shared `wx-config --unicode=no --static=no --libs`
+ at SAGA_UNICODE_TRUE@DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs`
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
-AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(UC_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LFLG)
pkglib_LTLIBRARIES = libpointcloud_tools.la
libpointcloud_tools_la_SOURCES = \
MLB_Interface.cpp\
+pc_attribute_calculator.cpp\
+pc_cluster_analysis.cpp\
pc_cut.cpp\
+pc_drop_attribute.cpp\
pc_from_grid.cpp\
pc_from_shapes.cpp\
+pc_reclass_extract.cpp\
+pc_thinning_simple.cpp\
pc_to_grid.cpp\
pc_to_shapes.cpp\
+pc_transform.cpp\
MLB_Interface.h\
+pc_attribute_calculator.h\
+pc_cluster_analysis.h\
pc_cut.h\
+pc_drop_attribute.h\
pc_from_grid.h\
pc_from_shapes.h\
+pc_reclass_extract.h\
+pc_thinning_simple.h\
pc_to_grid.h\
-pc_to_shapes.h
+pc_to_shapes.h\
+pc_transform.h
libpointcloud_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
all: all-am
@@ -313,11 +332,17 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pc_attribute_calculator.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pc_cluster_analysis.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pc_cut.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pc_drop_attribute.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pc_from_grid.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pc_from_shapes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pc_reclass_extract.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pc_thinning_simple.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pc_to_grid.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pc_to_shapes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pc_transform.Plo at am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_attribute_calculator.cpp b/src/modules/pointcloud/pointcloud_tools/pc_attribute_calculator.cpp
new file mode 100644
index 0000000..70fab7f
--- /dev/null
+++ b/src/modules/pointcloud/pointcloud_tools/pc_attribute_calculator.cpp
@@ -0,0 +1,205 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_attribute_calculator.cpp //
+// //
+// Copyright (C) 2010 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "pc_attribute_calculator.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// Construction/Destruction //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+CPC_Attribute_Calculator::CPC_Attribute_Calculator(void)
+{
+
+ Set_Name(_TL("Point Cloud Attribute Calculator"));
+
+ Set_Author(_TL("Volker Wichmann (c) 2010, LASERDATA GmbH"));
+
+ CSG_String s(_TW(
+ "The Point Cloud Attribute Calculator calculates a new attribute "
+ "based on existing attributes and a mathematical formula. "
+ "The attribute fields are referenced by characters 'a' to 'z' "
+ "with 'a' referencing the first field, 'b' the second field and so "
+ "on. Please note that the first three fields contain the x,y,z coordinates.\n"
+ "This (meaningless) example calculates the sine of the x coordinate and "
+ "multiplies it with the z coordinate: sin(a) * c\n\n"
+ "The following operators are available for the formula definition:\n"
+ ));
+
+ s += CSG_Formula::Get_Help_Operators();
+
+ Set_Description(s);
+
+
+ //-----------------------------------------------------
+ Parameters.Add_PointCloud(
+ NULL , "PC_IN" ,_TL("Point Cloud"),
+ _TL("Input"),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_PointCloud(
+ NULL , "PC_OUT" ,_TL("Result"),
+ _TL("Output"),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_String(
+ NULL , "FORMULA" , _TL("Formula"),
+ _TL(""),
+ SG_T("a+b")
+ );
+
+ Parameters.Add_String(
+ NULL , "NAME" , _TL("Output Field Name"),
+ _TL(""),
+ SG_T("a+b")
+ );
+
+}
+
+
+//---------------------------------------------------------
+CPC_Attribute_Calculator::~CPC_Attribute_Calculator(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPC_Attribute_Calculator::On_Execute(void)
+{
+ CSG_PointCloud *pInput, *pResult;
+ int iFields;
+ int err_pos;
+ double dValue;
+ double *pFieldValues;
+ const SG_Char *pFormula;
+ CSG_Formula Formula;
+ CSG_String Msg;
+
+
+ //---------------------------------------------------------
+ pInput = Parameters("PC_IN")->asPointCloud();
+ pResult = Parameters("PC_OUT")->asPointCloud();
+
+ pResult->Create(pInput);
+ pResult->Set_Name(CSG_String::Format(SG_T("%s_%s"), pInput->Get_Name(), Parameters("NAME")->asString()));
+
+ pResult->Add_Field(Parameters("NAME")->asString(), SG_DATATYPE_Double);
+
+ pFormula = Parameters("FORMULA")->asString();
+ iFields = pInput->Get_Field_Count();
+
+ Formula.Set_Formula(pFormula);
+
+ if( Formula.Get_Error(&err_pos, &Msg) )
+ {
+ SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Syntax error in formula at position #%d\n%s"), err_pos, pFormula));
+ SG_UI_Msg_Add_Error(CSG_String::Format(_TL("%s"), Msg.c_str()));
+ return (false);
+ }
+
+
+ //---------------------------------------------------------
+ pFieldValues = new double[iFields];
+
+ for( int i=0; i<pInput->Get_Record_Count(); i++ )
+ {
+ pResult->Add_Point(pInput->Get_X(i), pInput->Get_Y(i), pInput->Get_Z(i));
+
+ for( int j=0; j<iFields; j++ )
+ {
+ pFieldValues[j] = pInput->Get_Value(i, j);
+
+ if( j > 2 )
+ pResult->Set_Value(j, pInput->Get_Value(i, j));
+ }
+
+ dValue = Formula.Get_Value(pFieldValues, iFields);
+
+ pResult->Set_Value(iFields, dValue);
+
+ }
+
+ delete[] pFieldValues;
+
+ return (true);
+
+}
+
+
+//---------------------------------------------------------
+int CPC_Attribute_Calculator::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+
+ if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FORMULA")) )
+ pParameters->Get_Parameter(SG_T("NAME"))->Set_Value(pParameter->asString());
+
+ return (true);
+
+}
\ No newline at end of file
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_attribute_calculator.h b/src/modules/pointcloud/pointcloud_tools/pc_attribute_calculator.h
new file mode 100644
index 0000000..949cbfa
--- /dev/null
+++ b/src/modules/pointcloud/pointcloud_tools/pc_attribute_calculator.h
@@ -0,0 +1,109 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_attribute_calculator.h //
+// //
+// Copyright (C) 2010 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__PC_Attribute_Calculator_H
+#define HEADER_INCLUDED__PC_Attribute_Calculator_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPC_Attribute_Calculator : public CSG_Module
+{
+public:
+ CPC_Attribute_Calculator(void);
+ virtual ~CPC_Attribute_Calculator(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Tools") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+ virtual int On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter);
+
+
+private:
+
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__PC_Attribute_Calculator_H
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_cluster_analysis.cpp b/src/modules/pointcloud/pointcloud_tools/pc_cluster_analysis.cpp
new file mode 100644
index 0000000..eb31cb2
--- /dev/null
+++ b/src/modules/pointcloud/pointcloud_tools/pc_cluster_analysis.cpp
@@ -0,0 +1,898 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_cluster_analysis.h //
+// //
+// Copyright (C) 2010 by //
+// Volker Wichmann //
+// //
+// This module is a port of the Grid_Cluster_Analysis //
+// module from the Grid_Discretisation module library, //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "pc_cluster_analysis.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPC_Cluster_Analysis::CPC_Cluster_Analysis(void)
+{
+ //-----------------------------------------------------
+ // 1. Info...
+
+ Set_Name (_TL("Cluster Analysis for Point Clouds"));
+
+ Set_Author (SG_T("Volker Wichmann (c) 2010, LASERDATA GmbH"));
+
+ Set_Description (_TW(
+ "Cluster Analysis for Point Clouds.\n\n"
+ "Module usage is different between SAGA GUI and SAGA CMD: With "
+ "SAGA GUI you will get prompted to choose the attributes to use "
+ "once you execute the module. With SAGA CMD you have to provide "
+ "a string with the -ATTR_FIELDS parameter containing the field "
+ "numbers of the attributes to use (separated by semicolon). Field "
+ "numbers start with 1, e.g. -ATTR_FIELDS=\"4;5;7\".\n\n"
+
+ "References:\n\n"
+
+ "This module is a port of the 'Cluster Analysis for Grids' "
+ "module from the 'Imagery - Classification' module library, "
+ "Copyright (C) 2003 by Olaf Conrad.\n\n"
+
+ "Iterative Minimum Distance:\n"
+ "- Forgy, E. (1965):\n"
+ " 'Cluster Analysis of multivariate data: efficiency vs. interpretability of classifications',\n"
+ " Biometrics 21:768\n\n"
+
+ "Hill-Climbing:"
+ "- Rubin, J. (1967):\n"
+ " 'Optimal Classification into Groups: An Approach for Solving the Taxonomy Problem',\n"
+ " J. Theoretical Biology, 15:103-144\n\n"
+ ));
+
+
+ //-----------------------------------------------------
+ // 2. Datasets...
+
+ Parameters.Add_PointCloud(
+ NULL , "PC_IN" ,_TL("Point Cloud"),
+ _TL("Input"),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_PointCloud(
+ NULL , "PC_OUT" ,_TL("Result"),
+ _TL("Output"),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Table(
+ NULL , "STATISTICS" , _TL("Statistics"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+
+ //-----------------------------------------------------
+ // 3. General Parameters...
+
+ Parameters.Add_Choice(
+ NULL , "METHOD" , _TL("Method"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("Iterative Minimum Distance (Forgy 1965)"),
+ _TL("Hill-Climbing (Rubin 1967)"),
+ _TL("Combined Minimum Distance / Hillclimbing")
+ ),1
+ );
+
+ Parameters.Add_Value(
+ NULL , "NCLUSTER" , _TL("Clusters"),
+ _TL("Number of clusters"),
+ PARAMETER_TYPE_Int, 10, 2, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "NORMALISE" , _TL("Normalise"),
+ _TL("Automatically normalise attributes by standard deviation before clustering."),
+ PARAMETER_TYPE_Bool, true
+ );
+
+ if (!SG_UI_Get_Window_Main())
+ {
+ Parameters.Add_String(
+ NULL , "ATTR_FIELDS" , _TL("Attribute Fields"),
+ _TL("The numbers (starting from 1) of the fields to use for clustering, separated by semicolon, e.g. \"4;5;7\""),
+ SG_T("")
+ );
+ }
+ else
+ {
+ Parameters.Add_Value(
+ NULL , "UPDATEVIEW" , _TL("Update View"),
+ _TL("Update cluster view while clustering."),
+ PARAMETER_TYPE_Bool, true
+ );
+ }
+}
+
+//---------------------------------------------------------
+CPC_Cluster_Analysis::~CPC_Cluster_Analysis(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPC_Cluster_Analysis::On_Execute(void)
+{
+ int i, j, nCluster, cnt;
+ long nElements;
+ double SP;
+ CSG_Parameters Parms;
+
+ //-----------------------------------------------------
+ nCluster = Parameters("NCLUSTER")->asInt();
+ pInput = Parameters("PC_IN") ->asPointCloud();
+ pResult = Parameters("PC_OUT") ->asPointCloud();
+ pResult ->Create(pInput);
+ pResult ->Set_Name(CSG_String::Format(SG_T("%s_cluster"), pInput->Get_Name()));
+ pResult ->Add_Field(SG_T("CLUSTER"), SG_DATATYPE_Int);
+ DataObject_Update(pResult);
+ pResult ->Set_NoData_Value(- 1.0);
+ clustField = pResult->Get_Field_Count()-1;
+
+ vFields.resize(pInput->Get_Field_Count());
+
+ //-----------------------------------------------------
+ if( SG_UI_Get_Window_Main() ) // GUI
+ {
+ CSG_Parameters Parms;
+ CSG_String fName, fID;
+
+ Parms.Set_Name(_TL("Choose the attributes to use for clustering:"));
+
+ for( int iField=0; iField<pInput->Get_Field_Count(); iField++ )
+ {
+ fName.Printf(SG_T("%s"), pInput->Get_Field_Name(iField));
+ fID.Printf(SG_T("FIELD_%03d"), iField);
+ Parms.Add_Value(NULL, fID, fName, _TL(""), PARAMETER_TYPE_Bool, false);
+ }
+
+ if( Dlg_Parameters(&Parms, _TL("")) )
+ {
+ for( int iField=0; iField<pInput->Get_Field_Count(); iField++ )
+ {
+ fID.Printf(SG_T("FIELD_%03d"), iField);
+
+ if( Parms.Get_Parameter(fID)->asBool() )
+ vFields.at(iField) = true;
+ }
+ }
+ else
+ return( false );
+ }
+ else // CMD LINE
+ {
+ CSG_String attrFields;
+ CSG_String token;
+ int field;
+
+ Parameters.Add_Value(
+ NULL , "UPDATEVIEW" , _TL("Update View"),
+ _TL("Update cluster view while clustering."),
+ PARAMETER_TYPE_Bool, false
+ );
+
+ attrFields = Parameters("ATTR_FIELDS")->asString();
+
+ wxStringTokenizer tkz_fields(attrFields.c_str(), wxT(";"), wxTOKEN_STRTOK);
+
+ while( tkz_fields.HasMoreTokens() )
+ {
+ token = tkz_fields.GetNextToken();
+
+ if( token.Length() == 0 )
+ break;
+
+ if( !token.asInt(field) )
+ {
+ SG_UI_Msg_Add_Error(_TL("Error parsing attribute fields: can't convert to number"));
+ return( false );
+ }
+
+ field -= 1;
+
+ if( field < 0 || field > vFields.size() - 1 )
+ {
+ SG_UI_Msg_Add_Error(_TL("Error parsing attribute fields: field index out of range"));
+ return( false );
+ }
+ else
+ vFields.at(field) = true;
+ }
+ }
+
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("Initializing ..."));
+
+ nFields = 0;
+
+ for( i=0; i<vFields.size(); i++ )
+ {
+ if( vFields.at(i) )
+ nFields++;
+ }
+
+ if( nFields > 0 )
+ {
+ for( i=0; i<nFields; i++ )
+ vValues.push_back( std::vector<double>() );
+
+ for( i=0; i<pInput->Get_Record_Count() && SG_UI_Process_Set_Progress(i, pInput->Get_Record_Count()); i++ )
+ {
+ pResult->Add_Point(pInput->Get_X(i), pInput->Get_Y(i), pInput->Get_Z(i));
+
+ cnt = 0;
+
+ for( j=0; j<pInput->Get_Field_Count(); j++ )
+ {
+ if( vFields.at(j) )
+ {
+ if( Parameters("NORMALISE")->asBool() )
+ vValues.at(cnt).push_back( (pInput->Get_Value(i, j) - pInput->Get_Mean(j)) / pInput->Get_StdDev(j) );
+ else
+ vValues.at(cnt).push_back(pInput->Get_Value(i, j));
+
+ cnt++;
+ }
+
+ if( j > 2 )
+ pResult->Set_Value(j, pInput->Get_Value(i, j));
+ }
+ }
+
+ pResult->Set_NoData(clustField);
+
+ if( Parameters("UPDATEVIEW")->asBool() )
+ {
+ if( DataObject_Get_Parameters(pResult, Parms) && Parms("COLORS_TYPE") && Parms("COLORS_ATTRIB") && Parms("METRIC_COLORS") && Parms("METRIC_ZRANGE") )
+ {
+ Parms("COLORS_TYPE") ->Set_Value(2); // graduated color
+ Parms("METRIC_COLORS")->asColors() ->Set_Count(nCluster);
+ Parms("COLORS_ATTRIB") ->Set_Value(clustField);
+ Parms("METRIC_ZRANGE")->asRange() ->Set_Range(0, nCluster);
+ }
+ DataObject_Set_Parameters(pResult, Parms);
+ DataObject_Update(pResult, SG_UI_DATAOBJECT_SHOW_LAST_MAP);
+ }
+
+
+ nMembers = (int *)SG_Malloc(nCluster * sizeof(int));
+ Variances = (double *)SG_Malloc(nCluster * sizeof(double));
+ Centroids = (double **)SG_Malloc(nCluster * sizeof(double *));
+
+ for( i=0; i<nCluster; i++ )
+ {
+ Centroids[i] = (double *)SG_Malloc(nFields * sizeof(double));
+ }
+
+ //-------------------------------------------------
+ nElements = pInput->Get_Point_Count();
+
+ switch( Parameters("METHOD")->asInt() )
+ {
+ case 0:
+ SP = MinimumDistance (nElements, nCluster);
+ break;
+
+ case 1:
+ SP = HillClimbing (nElements, nCluster);
+ break;
+
+ case 2:
+ SP = MinimumDistance (nElements, nCluster);
+
+ nElements = pInput->Get_Point_Count(); // may have been diminished because of no data values...
+
+ SP = HillClimbing (nElements, nCluster);
+ break;
+ }
+
+ //-------------------------------------------------
+ if( Parameters("NORMALISE")->asBool() )
+ {
+ int iv = 0;
+
+ for( i=0; i<vFields.size(); i++ )
+ {
+ if( vFields.at(i) )
+ {
+ for( j=0; j<nCluster; j++ )
+ {
+ Centroids[j][iv] = sqrt(pInput->Get_Variance(i)) * Centroids[j][iv] + pInput->Get_Mean(i);
+ }
+
+ iv++;
+ }
+ }
+ }
+
+ Write_Result(Parameters("STATISTICS")->asTable(), nElements, nCluster, SP);
+
+ //-------------------------------------------------
+ if( DataObject_Get_Parameters(pResult, Parms) && Parms("COLORS_TYPE") && Parms("LUT") && Parms("COLORS_ATTRIB") )
+ {
+ CSG_Table_Record *pClass;
+ CSG_Table *pLUT = Parms("LUT")->asTable();
+
+ for( i=0; i<nCluster; i++ )
+ {
+ if( (pClass = pLUT->Get_Record(i)) == NULL )
+ {
+ pClass = pLUT->Add_Record();
+ pClass->Set_Value(0, SG_GET_RGB(rand() * 255.0 / RAND_MAX, rand() * 255.0 / RAND_MAX, rand() * 255.0 / RAND_MAX));
+ }
+
+ pClass->Set_Value(1, CSG_String::Format(SG_T("%s %d"), _TL("Class"), i));
+ pClass->Set_Value(2, CSG_String::Format(SG_T("%s %d"), _TL("Class"), i));
+ pClass->Set_Value(3, i);
+ pClass->Set_Value(4, i);
+ }
+
+ while( pLUT->Get_Record_Count() > nCluster )
+ {
+ pLUT->Del_Record(pLUT->Get_Record_Count() - 1);
+ }
+
+ Parms("COLORS_TYPE") ->Set_Value(1); // Color Classification Type: Lookup Table
+ Parms("COLORS_ATTRIB") ->Set_Value(clustField);
+
+ DataObject_Set_Parameters(pResult, Parms);
+ }
+
+ //-------------------------------------------------
+ for( i=0; i<nCluster; i++ )
+ {
+ SG_Free(Centroids[i]);
+ }
+
+ SG_Free(Centroids);
+ SG_Free(Variances);
+ SG_Free(nMembers);
+
+ vFields.clear();
+ vValues.clear();
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CPC_Cluster_Analysis::Write_Result(CSG_Table *pTable, long nElements, int nCluster, double SP)
+{
+ int i, j, cntField;
+ CSG_String s;
+ CSG_Table_Record *pRecord;
+
+ pTable->Destroy();
+ s = CSG_String::Format(_TL("Cluster Analysis PC"));
+ s += CSG_String::Format(SG_T("_%s"), pInput->Get_Name());
+ pTable->Set_Name(s);
+
+ pTable->Add_Field(_TL("ClusterID") , SG_DATATYPE_Int);
+ pTable->Add_Field(_TL("Elements") , SG_DATATYPE_Int);
+ pTable->Add_Field(_TL("Variance") , SG_DATATYPE_Double);
+
+ s.Printf(SG_T("\n%s:\t%ld \n%s:\t%d \n%s:\t%d \n%s:\t%f"),
+ _TL("Number of Elements") , nElements,
+ _TL("\nNumber of Variables") , nFields,
+ _TL("\nNumber of Clusters") , nCluster,
+ _TL("\nValue of Target Function") , SP
+ );
+
+ s.Append(CSG_String::Format(SG_T("%s\t%s\t%s"), _TL("Cluster"), _TL("Elements"), _TL("Variance")));
+
+ cntField = 1;
+
+ for( j=0; j<vFields.size(); j++ )
+ {
+ if( vFields.at(j) )
+ {
+ s.Append(CSG_String::Format(SG_T("\t%02d_%s"), cntField, pInput->Get_Field_Name(j)));
+ pTable->Add_Field(pInput->Get_Field_Name(j), SG_DATATYPE_Double);
+ cntField++;
+ }
+ }
+
+ Message_Add(s);
+
+ for( i=0; i<nCluster; i++ )
+ {
+ s.Printf(SG_T("%d\t%d\t%f"), i, nMembers[i], Variances[i]);
+
+ pRecord = pTable->Add_Record();
+ pRecord->Set_Value(0, i);
+ pRecord->Set_Value(1, nMembers[i]);
+ pRecord->Set_Value(2, Variances[i]);
+
+ for( j=0; j<nFields; j++ )
+ {
+ s.Append(CSG_String::Format(SG_T("\t%f"), Centroids[i][j]));
+
+ pRecord->Set_Value(j + 3, Centroids[i][j]);
+ }
+
+ Message_Add(s);
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Minimum Distance //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+// (nElements)-Array -> Bei Eingabe Startgruppierung oder 0.
+// Bei Ausgabe Gruppierung: >Das ite Element ist im Cluster Cluster(i).
+
+double CPC_Cluster_Analysis::MinimumDistance(long &nElements, int nCluster)
+{
+ //-----------------------------------------------------
+ // Variablen...
+
+ bool bContinue;
+ int iElement, iField, iCluster, nClusterElements, nShifts, minCluster, nPasses;
+ double d, Variance, minVariance, SP, SP_Last = -1;
+
+
+ //-----------------------------------------------------
+ // Anfangspartition (Standard falls nicht vorgegeben
+
+ for( iElement=0, nClusterElements=0; iElement<nElements; iElement++ )
+ {
+ /*for( iField=0, bContinue=true; iField<nFields && bContinue; iField++)
+ {
+ if( Grids[iGrid]->is_NoData(iElement) )
+ {
+ bContinue = false;
+ }
+ }*/
+ bContinue = true;
+
+ if( bContinue )
+ {
+ if( pResult->Get_Value(iElement, clustField) < 0 || pResult->Get_Value(iElement, clustField) >= nCluster )
+ {
+ pResult->Set_Value(iElement, clustField, iElement % nCluster);
+ }
+
+ nClusterElements++;
+ }
+ else
+ {
+ pResult->Set_Value(iElement, clustField, -1);
+ }
+ }
+
+ if( Parameters("UPDATEVIEW")->asBool() )
+ {
+ DataObject_Update(pResult);
+ }
+
+
+ //-----------------------------------------------------
+ // Hauptschleife der Iteration
+
+ for( nPasses=1, bContinue=true; bContinue && Process_Get_Okay(false); nPasses++ )
+ {
+ //-------------------------------------------------
+ for( iCluster=0; iCluster<nCluster; iCluster++ )
+ {
+ Variances[iCluster] = 0;
+ nMembers [iCluster] = 0;
+
+ for( iField=0; iField<nFields; iField++ )
+ {
+ Centroids[iCluster][iField] = 0;
+ }
+ }
+
+ //-------------------------------------------------
+ for( iElement=0; iElement<nElements; iElement++ )
+ {
+ if( pResult->Get_Value(iElement, clustField) >= 0 )
+ {
+ iCluster = (int)pResult->Get_Value(iElement, clustField);
+ nMembers[iCluster]++;
+
+ for( iField=0; iField<nFields; iField++ )
+ {
+ Centroids[iCluster][iField] += vValues.at(iField).at(iElement);
+ }
+ }
+ }
+
+ //-------------------------------------------------
+ for( iCluster=0; iCluster<nCluster; iCluster++ )
+ {
+ d = nMembers[iCluster] > 0 ? 1.0 / (double)nMembers[iCluster] : 0;
+
+ for( iField=0; iField<nFields; iField++ )
+ {
+ Centroids[iCluster][iField] *= d;
+ }
+ }
+
+
+ //-------------------------------------------------
+ // Sift and Shift..
+
+ SP = 0;
+ nShifts = 0;
+
+ for( iElement=0; iElement<nElements && bContinue; iElement++ )
+ {
+ if( !(iElement % (nElements / 100)) && !Set_Progress(iElement, nElements) )
+ {
+ bContinue = false;
+ }
+
+ if( pResult->Get_Value(iElement, clustField) >= 0 )
+ {
+ minVariance = -1;
+
+ for( iCluster=0; iCluster<nCluster; iCluster++ )
+ {
+ Variance = 0;
+
+ for( iField=0; iField<nFields; iField++ )
+ {
+ d = Centroids[iCluster][iField] - vValues.at(iField).at(iElement);
+ Variance += d * d;
+ }
+
+ if( minVariance<0 || Variance<minVariance )
+ {
+ minVariance = Variance;
+ minCluster = iCluster;
+ }
+ }
+
+ if( pResult->Get_Value(iElement, clustField) != minCluster )
+ {
+ pResult->Set_Value(iElement, clustField, minCluster);
+ nShifts++;
+ }
+
+ SP += minVariance;
+ Variances[minCluster] += minVariance;
+ }
+ }
+
+
+ //-------------------------------------------------
+
+ if( nShifts == 0 || (SP_Last >= 0 && SP >= SP_Last) )
+ {
+ bContinue = false;
+ }
+
+ Process_Set_Text(CSG_String::Format(SG_T("%s: %d >> %s %f"),
+ _TL("pass") , nPasses,
+ _TL("change") , SP_Last < 0.0 ? SP : SP_Last - SP
+ ));
+
+ SP_Last = SP;
+
+ if( Parameters("UPDATEVIEW")->asBool() )
+ {
+ DataObject_Update(pResult);
+ }
+ }
+
+ nElements = nClusterElements;
+
+ return( SP );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Hill-Climbing //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+double CPC_Cluster_Analysis::HillClimbing(long &nElements, int nCluster)
+{
+ //-----------------------------------------------------
+ // Variablen...
+
+ bool bContinue;
+ int iElement, iField, iCluster, jCluster, kCluster, nClusterElements, noShift, nPasses;
+ double d, e, n_iK, n_jK, V, VMin, V1, V2, SP, SP_Last = -1;
+
+
+ //-----------------------------------------------------
+
+ for( iCluster=0; iCluster<nCluster; iCluster++ )
+ {
+ Variances[iCluster] = 0;
+ nMembers [iCluster] = 0;
+
+ for( iField=0; iField<nFields; iField++)
+ {
+ Centroids[iCluster][iField] = 0;
+ }
+ }
+
+
+ //-----------------------------------------------------
+ // Anfangspartition (Standard falls nicht vorgegeben)
+
+ for( iElement=0, nClusterElements=0; iElement<nElements; iElement++ )
+ {
+ /*for( iField=0, bContinue=true; iField<nFields && bContinue; iField++)
+ {
+ if( Grids[iGrid]->is_NoData(iElement) )
+ {
+ bContinue = false;
+ }
+ }*/
+ bContinue = true;
+
+ if( bContinue )
+ {
+ if( pResult->Get_Value(iElement, clustField) < 0 || pResult->Get_Value(iElement, clustField) >= nCluster )
+ {
+ pResult->Set_Value(iElement, clustField, iElement % nCluster);
+ }
+
+ nClusterElements++;
+
+ iCluster = (int)pResult->Get_Value(iElement, clustField);
+
+ nMembers[iCluster]++;
+
+ V = 0.0;
+
+ for( iField=0; iField<nFields; iField++)
+ {
+ d = vValues.at(iField).at(iElement);
+ Centroids[iCluster][iField] += d;
+ V += d * d;
+ }
+
+ Variances[iCluster] += V;
+ }
+ else
+ {
+ pResult->Set_Value(iElement, clustField, -1);
+ }
+ }
+
+
+ //-----------------------------------------------------
+
+ SP = 0.0;
+
+ for( iCluster=0; iCluster<nCluster; iCluster++ )
+ {
+ d = nMembers[iCluster] != 0 ? 1.0 / (double)nMembers[iCluster] : 0;
+ V = 0.0;
+
+ for( iField=0; iField<nFields; iField++)
+ {
+ Centroids[iCluster][iField] *= d;
+ e = Centroids[iCluster][iField];
+ V += e * e;
+ }
+
+ Variances[iCluster] -= nMembers [iCluster] * V;
+ SP += Variances[iCluster];
+ }
+
+ if( Parameters("UPDATEVIEW")->asBool() )
+ {
+ DataObject_Update(pResult);
+ }
+
+
+ //-----------------------------------------------------
+ // Hauptschleife der Iteration
+
+ noShift = 0;
+
+ for( nPasses=1, bContinue=true; bContinue && Process_Get_Okay(false); nPasses++ )
+ {
+ //-------------------------------------------------
+ for( iElement=0; iElement<nElements && bContinue; iElement++ )
+ {
+ if( !(iElement % (nElements / 100)) && !Set_Progress(iElement, nElements) )
+ {
+ bContinue = false;
+ }
+
+ if( pResult->Get_Value(iElement, clustField) >= 0 )
+ {
+ if( noShift++ >= nElements )
+ {
+ bContinue = false;
+ }
+ else
+ {
+
+ //---------------------------------------------
+ iCluster = (int)pResult->Get_Value(iElement, clustField);
+
+ if( nMembers[iCluster] > 1 )
+ {
+ V = 0.0;
+
+ for( iField=0; iField<nFields; iField++)
+ {
+ d = Centroids[iCluster][iField] - vValues.at(iField).at(iElement);
+ V += d * d;
+ }
+
+ n_iK = nMembers[iCluster];
+ V1 = V * n_iK / (n_iK - 1.0);
+ VMin = -1.0;
+
+ //-----------------------------------------
+ // Bestimme Gruppe iCluster mit evtl. groesster Verbesserung...
+
+ for( jCluster=0; jCluster<nCluster; jCluster++ )
+ {
+ if( jCluster != iCluster )
+ {
+ V = 0.0;
+
+ for( iField=0; iField<nFields; iField++)
+ {
+ d = Centroids[jCluster][iField] - vValues.at(iField).at(iElement);
+ V += d * d;
+ }
+
+ n_jK = nMembers[jCluster];
+ V2 = V * n_jK / (n_jK + 1.0);
+
+ if( VMin < 0 || V2 < VMin )
+ {
+ VMin = V2;
+ kCluster = jCluster;
+ }
+ }
+ }
+
+
+ //-----------------------------------------
+ // Gruppenwechsel und Neuberechnung der Gruppencentroide...
+
+ if( VMin >= 0 && VMin < V1 )
+ {
+ noShift = 0;
+ Variances[iCluster] -= V1;
+ Variances[kCluster] += VMin;
+ SP = SP - V1 + VMin;
+ V1 = 1.0 / (n_iK - 1.0);
+ n_jK = nMembers[kCluster];
+ V2 = 1.0 / (n_jK + 1.0);
+
+ for( iField=0; iField<nFields; iField++)
+ {
+ d = vValues.at(iField).at(iElement);
+ Centroids[iCluster][iField] = (n_iK * Centroids[iCluster][iField] - d) * V1;
+ Centroids[kCluster][iField] = (n_jK * Centroids[kCluster][iField] + d) * V2;
+ }
+
+ pResult->Set_Value(iElement, clustField, kCluster);
+
+ nMembers[iCluster]--;
+ nMembers[kCluster]++;
+ }
+ }
+ }
+ }
+ }
+
+ Process_Set_Text(CSG_String::Format(SG_T("%s: %d >> %s %f"),
+ _TL("pass") , nPasses,
+ _TL("change") , SP_Last < 0.0 ? SP : SP_Last - SP
+ ));
+
+ SP_Last = SP;
+
+ if( Parameters("UPDATEVIEW")->asBool() )
+ {
+ DataObject_Update(pResult);
+ }
+ }
+
+ nElements = nClusterElements;
+
+ return( SP );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_cluster_analysis.h b/src/modules/pointcloud/pointcloud_tools/pc_cluster_analysis.h
new file mode 100644
index 0000000..782f939
--- /dev/null
+++ b/src/modules/pointcloud/pointcloud_tools/pc_cluster_analysis.h
@@ -0,0 +1,114 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_cluster_analysis.h //
+// //
+// Copyright (C) 2010 by //
+// Volker Wichmann //
+// //
+// This module is a port of the Grid_Cluster_Analysis //
+// module from the Grid_Discretisation module library, //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__PC_Cluster_Analysis_H
+#define HEADER_INCLUDED__PC_Cluster_Analysis_H
+
+//---------------------------------------------------------
+#include <vector>
+#include <wx/tokenzr.h>
+
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPC_Cluster_Analysis : public CSG_Module
+{
+public:
+ CPC_Cluster_Analysis(void);
+ virtual ~CPC_Cluster_Analysis(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Classification") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ int nFields, clustField, *nMembers;
+
+ double **Centroids, *Variances;
+
+ CSG_PointCloud *pInput, *pResult;
+
+ std::vector<bool> vFields;
+ std::vector< std::vector<double> > vValues;
+
+ void Write_Result (CSG_Table *pTable, long nElements, int nCluster, double SP);
+
+ double MinimumDistance (long &nElements, int nCluster);
+ double HillClimbing (long &nElements, int nCluster);
+
+};
+
+#endif // #ifndef HEADER_INCLUDED__PC_Cluster_Analysis_H
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_cut.cpp b/src/modules/pointcloud/pointcloud_tools/pc_cut.cpp
index f94282c..fab11ae 100644
--- a/src/modules/pointcloud/pointcloud_tools/pc_cut.cpp
+++ b/src/modules/pointcloud/pointcloud_tools/pc_cut.cpp
@@ -1,371 +1,479 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// pointcloud_tools //
-// //
-//-------------------------------------------------------//
-// //
-// pc_cut.cpp //
-// //
-// Copyright (C) 2009 by //
-// Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Hamburg //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "pc_cut.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CPC_Cut::CPC_Cut(void)
-{
- //-----------------------------------------------------
- Set_Name (_TL("Point Cloud Cutter"));
-
- Set_Author (SG_T("O.Conrad (c) 2009"));
-
- Set_Description (_TW(
- ""
- ));
-
-
- //-----------------------------------------------------
- Parameters.Add_PointCloud(
- NULL , "POINTS" , _TL("Points"),
- _TL(""),
- PARAMETER_INPUT
- );
-
- Parameters.Add_PointCloud(
- NULL , "CUT" , _TL("Cut"),
- _TL(""),
- PARAMETER_OUTPUT
- );
-
- Parameters.Add_Choice(
- NULL , "AREA" , _TL("Choose Cut from ..."),
- _TL(""),
- CSG_String::Format(SG_T("%s|%s|%s|%s|"),
- _TL("User Defined Extent"),
- _TL("Grid System Extent"),
- _TL("Shapes Extent"),
- _TL("Polygons")
- ), 0
- );
-
-
- //-----------------------------------------------------
- CSG_Parameters *pParameters;
-
- pParameters = Add_Parameters ( "USER" , _TL("User Defined Extent"), _TL(""));
- pParameters->Add_Value (NULL, "XMIN" , _TL("Left") , _TL(""), PARAMETER_TYPE_Double);
- pParameters->Add_Value (NULL, "XMAX" , _TL("Right") , _TL(""), PARAMETER_TYPE_Double);
- pParameters->Add_Value (NULL, "YMIN" , _TL("Bottom") , _TL(""), PARAMETER_TYPE_Double);
- pParameters->Add_Value (NULL, "YMAX" , _TL("Top") , _TL(""), PARAMETER_TYPE_Double);
-
- pParameters = Add_Parameters ( "GRID" , _TL("Grid System Extent") , _TL(""));
- pParameters->Add_Grid_System (NULL, "GRID" , _TL("Grid System") , _TL(""));
-
- pParameters = Add_Parameters ( "SHAPES" , _TL("Shapes Extent") , _TL(""));
- pParameters->Add_Shapes (NULL, "SHAPES" , _TL("Left") , _TL(""), PARAMETER_INPUT);
-
- pParameters = Add_Parameters ( "POLYGONS" , _TL("Polygons") , _TL(""));
- pParameters->Add_Shapes (NULL, "POLYGONS" , _TL("Polygons") , _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon);
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CPC_Cut::On_Execute(void)
-{
- CSG_PointCloud *pPoints = Parameters("POINTS") ->asPointCloud();
- CSG_PointCloud *pCut = Parameters("CUT") ->asPointCloud();
-
- //-----------------------------------------------------
- switch( Parameters("AREA")->asInt() )
- {
- case 0: // User Defined Extent
- if( Dlg_Parameters("USER") )
- {
- CSG_Rect r(
- Get_Parameters("USER")->Get_Parameter("XMIN")->asDouble(),
- Get_Parameters("USER")->Get_Parameter("YMIN")->asDouble(),
- Get_Parameters("USER")->Get_Parameter("XMAX")->asDouble(),
- Get_Parameters("USER")->Get_Parameter("YMAX")->asDouble()
- );
-
- return( Get_Cut(pPoints, pCut, r) );
- }
- break;
-
- case 1: // Grid System Extent
- if( Dlg_Parameters("GRID") )
- {
- return( Get_Cut(pPoints, pCut, Get_Parameters("GRID")->Get_Parameter("GRID")->asGrid_System()->Get_Extent()) );
- }
- break;
-
- case 2: // Shapes Extent
- if( Dlg_Parameters("SHAPES") )
- {
- return( Get_Cut(pPoints, pCut, Get_Parameters("SHAPES")->Get_Parameter("SHAPES")->asShapes()->Get_Extent()) );
- }
- break;
-
- case 3: // Polygons
- if( Dlg_Parameters("POLYGONS") )
- {
- return( Get_Cut(pPoints, pCut, Get_Parameters("POLYGONS")->Get_Parameter("POLYGONS")->asShapes()) );
- }
- break;
- }
-
- //-----------------------------------------------------
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CPC_Cut::Get_Cut(CSG_PointCloud *pPoints, CSG_PointCloud *pCut, const CSG_Rect &Extent)
-{
- if( pPoints && pPoints->is_Valid() && pCut )
- {
- pCut->Create(pPoints);
- pCut->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), _TL("Cut")));
-
- if( Extent.Intersects(pPoints->Get_Extent()) )
- {
- for(int i=0; i<pPoints->Get_Point_Count() && SG_UI_Process_Set_Progress(i, pPoints->Get_Point_Count()); i++)
- {
- pPoints->Set_Cursor(i);
-
- if( Extent.Contains(pPoints->Get_X(), pPoints->Get_Y()) )
- {
- pCut->Add_Point(pPoints->Get_X(), pPoints->Get_Y(), pPoints->Get_Z());
-
- for(int j=0; j<pPoints->Get_Field_Count() - 3; j++)
- {
- pCut->Set_Attribute(j, pPoints->Get_Attribute(j));
- }
- }
- }
- }
-
- return( pCut->Get_Count() > 0 );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CPC_Cut::Get_Cut(CSG_PointCloud *pPoints, CSG_PointCloud *pCut, CSG_Shapes *pPolygons)
-{
- if( pPoints && pPoints->is_Valid() && pCut )
- {
- pCut->Create(pPoints);
- pCut->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), pPolygons->Get_Name()));
-
- if( pPolygons && pPolygons->Get_Type() == SHAPE_TYPE_Polygon && pPolygons->Get_Extent().Intersects(pPoints->Get_Extent()) )
- {
- for(int i=0; i<pPoints->Get_Point_Count() && SG_UI_Process_Set_Progress(i, pPoints->Get_Point_Count()); i++)
- {
- pPoints->Set_Cursor(i);
-
- if( Contains(pPolygons, pPoints->Get_X(), pPoints->Get_Y()) )
- {
- pCut->Add_Point(pPoints->Get_X(), pPoints->Get_Y(), pPoints->Get_Z());
-
- for(int j=0; j<pPoints->Get_Field_Count() - 3; j++)
- {
- pCut->Set_Attribute(j, pPoints->Get_Attribute(j));
- }
- }
- }
- }
-
- return( pCut->Get_Count() > 0 );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CPC_Cut::Contains(CSG_Shapes *pPolygons, double x, double y)
-{
- if( pPolygons->Get_Extent().Contains(x, y) )
- {
- for(int iPolygon=0; iPolygon<pPolygons->Get_Count(); iPolygon++)
- {
- CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon);
-
- if( pPolygon->is_Containing(x, y) )
- {
- return( true );
- }
- }
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CPC_Cut_Interactive::CPC_Cut_Interactive(void)
-{
- //-----------------------------------------------------
- Set_Name (_TL("Point Cloud Cutter"));
-
- Set_Author (SG_T("O.Conrad (c) 2009"));
-
- Set_Description (_TW(
- ""
- ));
-
-
- //-----------------------------------------------------
- Parameters.Add_PointCloud(
- NULL , "POINTS" , _TL("Points"),
- _TL(""),
- PARAMETER_INPUT
- );
-
- Parameters.Add_PointCloud(
- NULL , "CUT" , _TL("Cut"),
- _TL(""),
- PARAMETER_OUTPUT
- );
-
- //-----------------------------------------------------
- CSG_Parameters *pParameters = Add_Parameters("CUT", _TL("Cut"), _TL(""));
-
- pParameters->Add_Value(NULL, "XMIN", _TL("Left") , _TL(""), PARAMETER_TYPE_Double);
- pParameters->Add_Value(NULL, "XMAX", _TL("Right") , _TL(""), PARAMETER_TYPE_Double);
- pParameters->Add_Value(NULL, "YMIN", _TL("Bottom") , _TL(""), PARAMETER_TYPE_Double);
- pParameters->Add_Value(NULL, "YMAX", _TL("Top") , _TL(""), PARAMETER_TYPE_Double);
-}
-
-//---------------------------------------------------------
-bool CPC_Cut_Interactive::On_Execute(void)
-{
- m_pPoints = Parameters("POINTS") ->asPointCloud();
- m_pCut = Parameters("CUT") ->asPointCloud();
-
- //-----------------------------------------------------
- return( true );
-}
-
-//---------------------------------------------------------
-bool CPC_Cut_Interactive::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode)
-{
- switch( Mode )
- {
- //-----------------------------------------------------
- case MODULE_INTERACTIVE_LDOWN:
-
- m_ptDown = ptWorld;
-
- return( true );
-
- //-----------------------------------------------------
- case MODULE_INTERACTIVE_LUP:
-
- CSG_Rect r(m_ptDown.Get_X(), m_ptDown.Get_Y(), ptWorld.Get_X(), ptWorld.Get_Y());
-
- CSG_Parameters *pParameters = Get_Parameters("CUT");
-
- pParameters->Get_Parameter("XMIN")->Set_Value(r.Get_XMin());
- pParameters->Get_Parameter("XMAX")->Set_Value(r.Get_XMax());
- pParameters->Get_Parameter("YMIN")->Set_Value(r.Get_YMin());
- pParameters->Get_Parameter("YMAX")->Set_Value(r.Get_YMax());
-
- if( Dlg_Parameters("CUT") )
- {
- r.Assign(
- pParameters->Get_Parameter("XMIN")->asDouble(),
- pParameters->Get_Parameter("YMIN")->asDouble(),
- pParameters->Get_Parameter("XMAX")->asDouble(),
- pParameters->Get_Parameter("YMAX")->asDouble()
- );
-
- if( CPC_Cut::Get_Cut(m_pPoints, m_pCut, r) )
- {
- DataObject_Update(m_pCut);
- }
- }
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_cut.cpp //
+// //
+// Copyright (C) 2009-10 by //
+// Olaf Conrad //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "pc_cut.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPC_Cut::CPC_Cut(void)
+{
+ //-----------------------------------------------------
+ Set_Name (_TL("Point Cloud Cutter"));
+
+ Set_Author (SG_T("O.C onrad, V. Wichmann (c) 2009-10"));
+
+ Set_Description (_TW(
+ "This modules allows to extract subsets from a Point Cloud. The area-of-interest "
+ "is defined either by bounding box coordinates, the extent of a grid system or "
+ "a shapes layer, or by polygons of a shapes layer. Note that the latter "
+ "does not support the inverse selection.\n\n"
+ ));
+
+
+ //-----------------------------------------------------
+ Parameters.Add_PointCloud(
+ NULL , "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_PointCloud(
+ NULL , "CUT" , _TL("Cut"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Choice(
+ NULL , "AREA" , _TL("Choose Cut from ..."),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|%s|"),
+ _TL("User Defined Extent"),
+ _TL("Grid System Extent"),
+ _TL("Shapes Extent"),
+ _TL("Polygons")
+ ), 0
+ );
+
+ Parameters.Add_Value(
+ NULL , "INVERSE" , _TL("Inverse"),
+ _TL("Invert selection."),
+ PARAMETER_TYPE_Bool, false
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPC_Cut::On_Execute(void)
+{
+ CSG_Parameters *pParameters;
+
+ CSG_PointCloud *pPoints = Parameters("POINTS") ->asPointCloud();
+ CSG_PointCloud *pCut = Parameters("CUT") ->asPointCloud();
+
+ //-----------------------------------------------------
+ switch( Parameters("AREA")->asInt() )
+ {
+ case 0: // User Defined Extent
+ pParameters = Add_Parameters ( "USER" , _TL("User Defined Extent"), _TL(""));
+ pParameters->Add_Value (NULL, "XMIN" , _TL("Left") , _TL(""), PARAMETER_TYPE_Double);
+ pParameters->Add_Value (NULL, "XMAX" , _TL("Right") , _TL(""), PARAMETER_TYPE_Double);
+ pParameters->Add_Value (NULL, "YMIN" , _TL("Bottom") , _TL(""), PARAMETER_TYPE_Double);
+ pParameters->Add_Value (NULL, "YMAX" , _TL("Top") , _TL(""), PARAMETER_TYPE_Double);
+
+ if( Dlg_Parameters("USER") )
+ {
+ CSG_Rect r(
+ Get_Parameters("USER")->Get_Parameter("XMIN")->asDouble(),
+ Get_Parameters("USER")->Get_Parameter("YMIN")->asDouble(),
+ Get_Parameters("USER")->Get_Parameter("XMAX")->asDouble(),
+ Get_Parameters("USER")->Get_Parameter("YMAX")->asDouble()
+ );
+
+ return( Get_Cut(pPoints, pCut, r, Parameters("INVERSE")->asBool()) );
+ }
+ break;
+
+ case 1: // Grid System Extent
+ pParameters = Add_Parameters ( "GRID" , _TL("Grid System Extent") , _TL(""));
+ pParameters->Add_Grid_System (NULL, "GRID" , _TL("Grid System") , _TL(""));
+
+ if( Dlg_Parameters("GRID") )
+ {
+ return( Get_Cut(pPoints, pCut, Get_Parameters("GRID")->Get_Parameter("GRID")->asGrid_System()->Get_Extent(), Parameters("INVERSE")->asBool()) );
+ }
+ break;
+
+ case 2: // Shapes Extent
+ pParameters = Add_Parameters ( "SHAPES" , _TL("Shapes Extent") , _TL(""));
+ pParameters->Add_Shapes (NULL, "SHAPES" , _TL("Left") , _TL(""), PARAMETER_INPUT);
+
+ if( Dlg_Parameters("SHAPES") )
+ {
+ return( Get_Cut(pPoints, pCut, Get_Parameters("SHAPES")->Get_Parameter("SHAPES")->asShapes()->Get_Extent(), Parameters("INVERSE")->asBool()) );
+ }
+ break;
+
+ case 3: // Polygons
+ pParameters = Add_Parameters ( "POLYGONS" , _TL("Polygons") , _TL(""));
+ pParameters->Add_Shapes (NULL, "POLYGONS" , _TL("Polygons") , _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon);
+
+ if( Dlg_Parameters("POLYGONS") )
+ {
+ if( Parameters("INVERSE")->asBool() && Get_Parameters("POLYGONS")->Get_Parameter("POLYGONS")->asShapes()->Get_Count() > 1 )
+ {
+ SG_UI_Msg_Add_Error(_TL("The inverse selection is not implemented for input shapefiles with more than one polygon!"));
+ return (false);
+ }
+ return( Get_Cut(pPoints, pCut, Get_Parameters("POLYGONS")->Get_Parameter("POLYGONS")->asShapes(), Parameters("INVERSE")->asBool()) );
+ }
+ break;
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPC_Cut::Get_Cut(CSG_PointCloud *pPoints, CSG_PointCloud *pCut, const CSG_Rect &Extent, bool bInverse)
+{
+ if( pPoints && pPoints->is_Valid() && pCut )
+ {
+ pCut->Create(pPoints);
+ pCut->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), _TL("Cut")));
+
+ if( Extent.Intersects(pPoints->Get_Extent()) )
+ {
+ for(int i=0; i<pPoints->Get_Point_Count() && SG_UI_Process_Set_Progress(i, pPoints->Get_Point_Count()); i++)
+ {
+ pPoints->Set_Cursor(i);
+
+ if( (Extent.Contains(pPoints->Get_X(), pPoints->Get_Y()) && !bInverse) || (!Extent.Contains(pPoints->Get_X(), pPoints->Get_Y()) && bInverse) )
+ {
+ pCut->Add_Point(pPoints->Get_X(), pPoints->Get_Y(), pPoints->Get_Z());
+
+ for(int j=0; j<pPoints->Get_Field_Count() - 3; j++)
+ {
+ pCut->Set_Attribute(j, pPoints->Get_Attribute(j));
+ }
+ }
+ }
+ }
+
+ return( pCut->Get_Count() > 0 );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CPC_Cut::Get_Cut(CSG_PointCloud *pPoints, CSG_PointCloud *pCut, CSG_Shapes *pPolygons, bool bInverse)
+{
+ if( pPoints && pPoints->is_Valid() && pCut )
+ {
+ pCut->Create(pPoints);
+ pCut->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), pPolygons->Get_Name()));
+
+ if( pPolygons && pPolygons->Get_Type() == SHAPE_TYPE_Polygon && pPolygons->Get_Extent().Intersects(pPoints->Get_Extent()) )
+ {
+ for(int i=0; i<pPoints->Get_Point_Count() && SG_UI_Process_Set_Progress(i, pPoints->Get_Point_Count()); i++)
+ {
+ pPoints->Set_Cursor(i);
+
+ if( (Contains(pPolygons, pPoints->Get_X(), pPoints->Get_Y()) && !bInverse) || (!Contains(pPolygons, pPoints->Get_X(), pPoints->Get_Y()) && bInverse) )
+ {
+ pCut->Add_Point(pPoints->Get_X(), pPoints->Get_Y(), pPoints->Get_Z());
+
+ for(int j=0; j<pPoints->Get_Field_Count() - 3; j++)
+ {
+ pCut->Set_Attribute(j, pPoints->Get_Attribute(j));
+ }
+ }
+ }
+ }
+
+ return( pCut->Get_Count() > 0 );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CPC_Cut::Contains(CSG_Shapes *pPolygons, double x, double y)
+{
+ if( pPolygons->Get_Extent().Contains(x, y) )
+ {
+ for(int iPolygon=0; iPolygon<pPolygons->Get_Count(); iPolygon++)
+ {
+ CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon);
+
+ if( pPolygon->is_Containing(x, y) )
+ {
+ return( true );
+ }
+ }
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPC_Cut_Interactive::CPC_Cut_Interactive(void)
+{
+ //-----------------------------------------------------
+ Set_Name (_TL("Point Cloud Cutter"));
+
+ Set_Author (SG_T("O. Conrad, V. Wichmann (c) 2009-10"));
+
+ Set_Description (_TW(
+ "This modules allows to extract subsets from a Point Cloud. The area-of-interest "
+ "is interactively defined either by dragging a box or by digitizing a polygon.\n"
+ "Best practice is to display the Point Cloud in a new Map View first and then "
+ "execute the module. Use the Action tool to define the AOI.\n\n"
+ ));
+
+
+ //-----------------------------------------------------
+ Parameters.Add_PointCloud(
+ NULL , "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_PointCloud(
+ NULL , "CUT" , _TL("Cut"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Choice(
+ NULL , "AOI" , _TL("Define AOI by ..."),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("dragging a box"),
+ _TL("digitzing a polygon")
+ ), 0
+ );
+
+ Parameters.Add_Shapes(
+ Parameters("AOI"), "AOISHAPE" , _TL("AOI Shape"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon
+ );
+
+ Parameters.Add_Value(
+ NULL , "INVERSE" , _TL("Inverse"),
+ _TL("Invert selection."),
+ PARAMETER_TYPE_Bool, false
+ );
+
+
+ //-----------------------------------------------------
+ CSG_Parameters *pParameters = Add_Parameters("CUT", _TL("Cut"), _TL(""));
+
+ pParameters->Add_Value(NULL, "XMIN", _TL("Left") , _TL(""), PARAMETER_TYPE_Double);
+ pParameters->Add_Value(NULL, "XMAX", _TL("Right") , _TL(""), PARAMETER_TYPE_Double);
+ pParameters->Add_Value(NULL, "YMIN", _TL("Bottom") , _TL(""), PARAMETER_TYPE_Double);
+ pParameters->Add_Value(NULL, "YMAX", _TL("Top") , _TL(""), PARAMETER_TYPE_Double);
+}
+
+//---------------------------------------------------------
+bool CPC_Cut_Interactive::On_Execute(void)
+{
+ m_pPoints = Parameters("POINTS") ->asPointCloud();
+ m_pCut = Parameters("CUT") ->asPointCloud();
+ m_bAOIBox = Parameters("AOI") ->asInt() == 0 ? true : false;
+ m_pAOI = Parameters("AOISHAPE")->asShapes();
+ m_bInverse = Parameters("INVERSE") ->asBool();
+
+
+ if( !m_bAOIBox )
+ {
+ m_bAdd = false;
+ Set_Drag_Mode(MODULE_INTERACTIVE_DRAG_LINE);
+
+ if( m_pAOI == NULL )
+ {
+ m_pAOI = SG_Create_Shapes(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("AOI_%s"), m_pPoints->Get_Name()));
+ m_pAOI->Add_Field("ID", SG_DATATYPE_Int);
+ Parameters("AOISHAPE")->Set_Value(m_pAOI);
+ DataObject_Add(m_pAOI, true);
+ }
+ else if( m_pAOI->Get_Field_Count() < 1)
+ m_pAOI->Add_Field("ID", SG_DATATYPE_Int);
+
+
+ CSG_Parameters sParms;
+ if( DataObject_Get_Parameters(m_pAOI, sParms) && sParms("DISPLAY_BRUSH") && sParms("DISPLAY_OUTLINE_COLOR"))
+ {
+ sParms("DISPLAY_OUTLINE_COLOR") ->Set_Value((int)SG_GET_RGB(180, 0, 0)); // outline color
+ sParms("DISPLAY_BRUSH") ->Set_Value(1); // fillstyle transparent
+ DataObject_Set_Parameters(m_pAOI, sParms);
+ DataObject_Update(m_pAOI, SG_UI_DATAOBJECT_SHOW_LAST_MAP);
+ }
+ }
+ else
+ Set_Drag_Mode(MODULE_INTERACTIVE_DRAG_BOX);
+
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CPC_Cut_Interactive::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode)
+{
+ switch( Mode )
+ {
+ //-----------------------------------------------------
+ case MODULE_INTERACTIVE_LDOWN:
+
+ if( m_bAOIBox )
+ m_ptDown = ptWorld;
+ else
+ {
+ if( !m_bAdd )
+ {
+ m_bAdd = true;
+ m_pAOI ->Del_Records();
+ m_pAOI ->Add_Shape();
+
+ m_pAOI->Get_Shape(0)->Add_Point(ptWorld); // workaround to have first line immediately displayed,
+ } // i.e. we add the first point clicked two times
+
+ m_pAOI->Get_Shape(0)->Add_Point(ptWorld);
+ DataObject_Update(m_pAOI, SG_UI_DATAOBJECT_SHOW_LAST_MAP);
+ }
+
+ return( true );
+
+ //-----------------------------------------------------
+ case MODULE_INTERACTIVE_LUP:
+
+ if( m_bAOIBox )
+ {
+ CSG_Rect r(m_ptDown.Get_X(), m_ptDown.Get_Y(), ptWorld.Get_X(), ptWorld.Get_Y());
+
+ CSG_Parameters *pParameters = Get_Parameters("CUT");
+
+ pParameters->Get_Parameter("XMIN")->Set_Value(r.Get_XMin());
+ pParameters->Get_Parameter("XMAX")->Set_Value(r.Get_XMax());
+ pParameters->Get_Parameter("YMIN")->Set_Value(r.Get_YMin());
+ pParameters->Get_Parameter("YMAX")->Set_Value(r.Get_YMax());
+
+ if( Dlg_Parameters("CUT") )
+ {
+ r.Assign(
+ pParameters->Get_Parameter("XMIN")->asDouble(),
+ pParameters->Get_Parameter("YMIN")->asDouble(),
+ pParameters->Get_Parameter("XMAX")->asDouble(),
+ pParameters->Get_Parameter("YMAX")->asDouble()
+ );
+
+ if( CPC_Cut::Get_Cut(m_pPoints, m_pCut, r, m_bInverse) )
+ {
+ DataObject_Update(m_pCut);
+ }
+ }
+
+ return( true );
+ }
+
+ return( false );
+
+ //-----------------------------------------------------
+ case MODULE_INTERACTIVE_RDOWN:
+
+ if( !m_bAOIBox )
+ {
+ m_bAdd = false;
+
+ if( CPC_Cut::Get_Cut(m_pPoints, m_pCut, m_pAOI, m_bInverse) )
+ {
+ DataObject_Update(m_pCut);
+ }
+
+ return( true );
+ }
+
+ return( false );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_cut.h b/src/modules/pointcloud/pointcloud_tools/pc_cut.h
index b5a2f87..9ee596d 100644
--- a/src/modules/pointcloud/pointcloud_tools/pc_cut.h
+++ b/src/modules/pointcloud/pointcloud_tools/pc_cut.h
@@ -1,133 +1,137 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// pointcloud_tools //
-// //
-//-------------------------------------------------------//
-// //
-// pc_cut.h //
-// //
-// Copyright (C) 2009 by //
-// Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Hamburg //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#ifndef HEADER_INCLUDED__PC_Cut_H
-#define HEADER_INCLUDED__PC_Cut_H
-
-//---------------------------------------------------------
-#include "MLB_Interface.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-class CPC_Cut : public CSG_Module
-{
-public:
- CPC_Cut(void);
-
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Tools") ); }
-
- static bool Get_Cut (CSG_PointCloud *pPoints, CSG_PointCloud *pCut, const CSG_Rect &Extent);
- static bool Get_Cut (CSG_PointCloud *pPoints, CSG_PointCloud *pCut, CSG_Shapes *pPolygons);
-
-
-protected:
-
- virtual bool On_Execute (void);
-
-
-private:
-
- static bool Contains (CSG_Shapes *pPolygons, double x, double y);
-
-};
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-class CPC_Cut_Interactive : public CSG_Module_Interactive
-{
-public:
- CPC_Cut_Interactive(void);
-
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Tools") ); }
-
-
-protected:
-
- virtual bool On_Execute (void);
- virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode);
-
-
-private:
-
- CSG_Point m_ptDown;
-
- CSG_PointCloud *m_pPoints, *m_pCut;
-
-};
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#endif // #ifndef HEADER_INCLUDED__PC_Cut_H
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_cut.h //
+// //
+// Copyright (C) 2009 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__PC_Cut_H
+#define HEADER_INCLUDED__PC_Cut_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPC_Cut : public CSG_Module
+{
+public:
+ CPC_Cut(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Tools") ); }
+
+ static bool Get_Cut (CSG_PointCloud *pPoints, CSG_PointCloud *pCut, const CSG_Rect &Extent, bool bInverse);
+ static bool Get_Cut (CSG_PointCloud *pPoints, CSG_PointCloud *pCut, CSG_Shapes *pPolygons, bool bInverse);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ static bool Contains (CSG_Shapes *pPolygons, double x, double y);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPC_Cut_Interactive : public CSG_Module_Interactive
+{
+public:
+ CPC_Cut_Interactive(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Tools") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+ virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode);
+
+
+private:
+
+ CSG_Point m_ptDown;
+
+ CSG_PointCloud *m_pPoints, *m_pCut;
+
+ CSG_Shapes *m_pAOI;
+
+ bool m_bAOIBox, m_bAdd, m_bInverse;
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__PC_Cut_H
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_drop_attribute.cpp b/src/modules/pointcloud/pointcloud_tools/pc_drop_attribute.cpp
new file mode 100644
index 0000000..db34d71
--- /dev/null
+++ b/src/modules/pointcloud/pointcloud_tools/pc_drop_attribute.cpp
@@ -0,0 +1,165 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_drop_attribute.cpp //
+// //
+// Copyright (C) 2010 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "pc_drop_attribute.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// Construction/Destruction //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPC_Drop_Attribute::CPC_Drop_Attribute(void)
+{
+
+ Set_Name(_TL("Drop Point Cloud Attribute"));
+
+ Set_Author(_TL("Volker Wichmann (c) 2010, LASERDATA GmbH"));
+
+ Set_Description (_TW(
+ "The module can be used to drop an attribute from a point cloud.\n\n")
+ );
+
+
+ //-----------------------------------------------------
+ Parameters.Add_PointCloud(
+ NULL , "INPUT" ,_TL("Input"),
+ _TL("Point Cloud to drop attribute from."),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Table_Field(
+ Parameters("INPUT"), "ATTRIB", _TL("Attribute to drop"),
+ _TL("Attribute to drop."),
+ false
+ );
+
+ Parameters.Add_PointCloud(
+ NULL , "RESULT" , _TL("Result"),
+ _TL("Resulting Point Cloud."),
+ PARAMETER_OUTPUT
+ );
+}
+
+//---------------------------------------------------------
+CPC_Drop_Attribute::~CPC_Drop_Attribute(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPC_Drop_Attribute::On_Execute(void)
+{
+ CSG_PointCloud *pInput, *pResult;
+ int AttrField;
+
+ pInput = Parameters("INPUT")->asPointCloud();
+ pResult = Parameters("RESULT")->asPointCloud();
+ AttrField = Parameters("ATTRIB")->asInt() - 3;
+
+ if (AttrField < 0)
+ {
+ SG_UI_Msg_Add_Error(CSG_String::Format(_TL("We must keep the coordinates, please choose another field than x,y,z!")));
+ return (false);
+ }
+
+ pResult->Create(pInput);
+ pResult->Set_Name(CSG_String::Format(SG_T("%s_drop_%s"), pInput->Get_Name(), pInput->Get_Attribute_Name(AttrField)));
+
+ pResult->Del_Field(AttrField + 3);
+
+ for (int i=0; i<pInput->Get_Point_Count() && SG_UI_Process_Set_Progress(i, pInput->Get_Count()); i++)
+ {
+ pResult->Add_Point(pInput->Get_X(i), pInput->Get_Y(i), pInput->Get_Z(i));
+
+ int offset = 0;
+ for (int j=0; j<pInput->Get_Attribute_Count(); j++)
+ {
+ if (j == AttrField)
+ {
+ offset = -1;
+ continue;
+ }
+
+ pResult->Set_Attribute(j + offset, pInput->Get_Attribute(i, j));
+ }
+ }
+
+ //pResult->Del_Field(AttrField + 3);
+
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_drop_attribute.h b/src/modules/pointcloud/pointcloud_tools/pc_drop_attribute.h
new file mode 100644
index 0000000..f1888c9
--- /dev/null
+++ b/src/modules/pointcloud/pointcloud_tools/pc_drop_attribute.h
@@ -0,0 +1,107 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_drop_attribute.h //
+// //
+// Copyright (C) 2010 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__PC_Drop_Attribute_H
+#define HEADER_INCLUDED__PC_Drop_Attribute_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPC_Drop_Attribute : public CSG_Module
+{
+public:
+ CPC_Drop_Attribute(void);
+ virtual ~CPC_Drop_Attribute(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Tools") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__PC_Drop_Attribute_H
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_reclass_extract.cpp b/src/modules/pointcloud/pointcloud_tools/pc_reclass_extract.cpp
new file mode 100644
index 0000000..2a83f3d
--- /dev/null
+++ b/src/modules/pointcloud/pointcloud_tools/pc_reclass_extract.cpp
@@ -0,0 +1,667 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_reclass_extract.cpp //
+// //
+// Copyright (C) 2009 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "pc_reclass_extract.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// Construction/Destruction //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPC_Reclass_Extract::CPC_Reclass_Extract(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name(_TL("Point Cloud Reclassifier / Subset Extractor"));
+
+ Set_Author(_TL("Volker Wichmann (c) 2009, LASERDATA GmbH"));
+
+ Set_Description (_TW(
+ "The module can be used to either reclassify a Point Cloud attribute or to extract "
+ "a subset of a Point Cloud based on the values of an attribute.\n\n"
+ "The module provides three different options:\n"
+ "(a) reclassification of (or extraction based on) single values,\n"
+ "(b) reclassification of (or extraction based on) a range of values and\n"
+ "(c) reclassification of (or extraction based on) value ranges specified in a lookup table.\n\n"
+ "Each of these three options provides it's own parameters. The 'new value' parameters are "
+ "irrelevant in case a subset is extracted.\n\n"
+ "In addition to these settings, two special cases ('NoData values' and 'other values' not "
+ "included in the parameter setup) are supported:\n"
+ "In mode (a) and (b) the 'NoData option' is evaluated before the method settings, in mode "
+ "(c) the option is evaluated only if the NoData value ins't included in the lookup table.\n"
+ "The 'other values' option is always evaluated after checking the method settings.\n\n")
+ );
+
+
+ //-----------------------------------------------------
+ Parameters.Add_PointCloud(
+ NULL , "INPUT" ,_TL("Point Cloud"),
+ _TL("Point Cloud to reclassify/extract"),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Table_Field(
+ Parameters("INPUT"), "ATTRIB", _TL("Attribute"),
+ _TL("Attribute to process."),
+ false
+ );
+
+ Parameters.Add_PointCloud(
+ NULL , "RESULT" , _TL("Result"),
+ _TL("Reclassifed or extracted Point Cloud."),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Choice(
+ NULL , "MODE" , _TL("Mode of operation"),
+ _TL("Choose whether to reclassify a Point Cloud or to extract a subset from a Point Cloud."),
+ _TL("Reclassify|Extract Subset|"), 0
+ );
+
+ Parameters.Add_Choice(
+ NULL , "METHOD" , _TL("Method"),
+ _TL("Select the desired method: 1. a single value or a range defined by a single value is reclassified, 2. a range of values is reclassified, 3. the lookup table is used to reclassify the grid."),
+ _TL("single|range|simple table|user supplied table|"), 0
+ );
+
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Node(
+ NULL , "SINGLE", _TL("Method single"),
+ _TL("Parameter settings for method single.")
+ );
+
+ Parameters.Add_Value(
+ pNode , "OLD" , _TL("old value"),
+ _TL("Value to reclassify."),
+ PARAMETER_TYPE_Double, 0
+ );
+
+ Parameters.Add_Value(
+ pNode , "NEW" , _TL("new value"),
+ _TL("New value."),
+ PARAMETER_TYPE_Double, 1
+ );
+
+ Parameters.Add_Choice(
+ pNode , "SOPERATOR" , _TL("operator"),
+ _TL("Select the desired operator (<;.;=; >;.); it is possible to define a range above or below the old value."),
+
+ CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"),
+ _TL("="),
+ _TL("<"),
+ _TL("<="),
+ _TL(">="),
+ _TL(">")
+ ), 0
+ );
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Node(
+ NULL , "RANGE" , _TL("Method range"),
+ _TL("Parameter settings for method range.")
+ );
+
+ Parameters.Add_Value(
+ pNode , "MIN" , _TL("minimum value"),
+ _TL("Minimum value of the range to be reclassified."),
+ PARAMETER_TYPE_Double, 0
+ );
+
+ Parameters.Add_Value(
+ pNode , "MAX" , _TL("maximum value"),
+ _TL("Maximum value of the range to be reclassified."),
+ PARAMETER_TYPE_Double, 10
+ );
+
+ Parameters.Add_Value(
+ pNode , "RNEW" , _TL("new value"),
+ _TL("new value"),
+ PARAMETER_TYPE_Double, 5
+ );
+
+ Parameters.Add_Choice(
+ pNode , "ROPERATOR" , _TL("operator"),
+ _TL("Select operator: eg. min < value < max."),
+
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("<="),
+ _TL("<")
+ ), 0
+ );
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Node(
+ NULL , "TABLE" , _TL("Method simple table"),
+ _TL("Parameter settings for method simple table.")
+ );
+
+ Parameters.Add_FixedTable(
+ pNode , "RETAB" , _TL("Lookup Table"),
+ _TL("Lookup table used in method \"table\"")
+ );
+
+ Parameters.Add_Choice(
+ pNode , "TOPERATOR" , _TL("operator"),
+ _TL("Select the desired operator (min < value < max; min . value < max; min .value . max; min < value . max)."),
+
+ CSG_String::Format(SG_T("%s|%s|%s|%s|"),
+ _TL("min <= value < max"),
+ _TL("min <= value <= max"),
+ _TL("min < value <= max"),
+ _TL("min < value < max")
+ ), 0
+ );
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Node(
+ NULL , "TABLE_2" , _TL("Method user supplied table"),
+ _TL("Parameter settings for method user supplied table.")
+ );
+
+ pNode = Parameters.Add_Table(
+ pNode , "RETAB_2" , _TL("Lookup Table"),
+ _TL("Lookup table used in method \"user supplied table\""),
+ PARAMETER_INPUT_OPTIONAL
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "F_MIN" , _TL("minimum value"),
+ _TL("")
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "F_MAX" , _TL("maximum value"),
+ _TL("")
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "F_CODE" , _TL("new value"),
+ _TL("")
+ );
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Node(
+ NULL, "OPTIONS" , _TL("Special cases"),
+ _TL("Parameter settings for No-Data and all other values.")
+ );
+
+ Parameters.Add_Value(
+ pNode , "NODATAOPT" , _TL("no data values"),
+ _TL("Use this option to reclassify No-Data values independently of the method settings."),
+ PARAMETER_TYPE_Bool, false
+ );
+
+ Parameters.Add_Value(
+ pNode , "NODATA" , _TL("no data values >> value"),
+ _TL("new value"),
+ PARAMETER_TYPE_Double, 0
+ );
+
+ Parameters.Add_Value(
+ pNode , "OTHEROPT" , _TL("other values"),
+ _TL("Use this option to reclassify all other values that are not specified in the options above."),
+ PARAMETER_TYPE_Bool, false
+ );
+
+ Parameters.Add_Value(
+ pNode , "OTHERS" , _TL("other values >> value"),
+ _TL("new value"),
+ PARAMETER_TYPE_Double, 0
+ );
+
+ //-----------------------------------------------------
+ CSG_Table *pLookup;
+ CSG_Table_Record *pRecord;
+
+ pLookup = Parameters("RETAB")->asTable();
+
+ pLookup->Add_Field(_TL("minimum") , SG_DATATYPE_Double);
+ pLookup->Add_Field(_TL("maximum") , SG_DATATYPE_Double);
+ pLookup->Add_Field(_TL("new") , SG_DATATYPE_Double);
+
+ pRecord = pLookup->Add_Record(); pRecord->Set_Value(0, 0.0); pRecord->Set_Value(1, 10.0); pRecord->Set_Value(2, 1.0);
+ pRecord = pLookup->Add_Record(); pRecord->Set_Value(0, 10.0); pRecord->Set_Value(1, 20.0); pRecord->Set_Value(2, 2.0);
+}
+
+//---------------------------------------------------------
+CPC_Reclass_Extract::~CPC_Reclass_Extract(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPC_Reclass_Extract::On_Execute(void)
+{
+ int method;
+
+ m_pInput = Parameters("INPUT")->asPointCloud();
+ m_pResult = Parameters("RESULT")->asPointCloud();
+ method = Parameters("METHOD")->asInt();
+ m_AttrField = Parameters("ATTRIB")->asInt();
+ m_bExtract = Parameters("MODE")->asInt() == 0 ? false : true;
+
+ m_pResult->Create(m_pInput);
+
+ if (m_bExtract)
+ m_pResult->Set_Name(CSG_String::Format(SG_T("%s_subset_%s"), m_pInput->Get_Name(), m_pInput->Get_Field_Name(m_AttrField)));
+ else
+ m_pResult->Set_Name(CSG_String::Format(SG_T("%s_reclass_%s"), m_pInput->Get_Name(), m_pInput->Get_Field_Name(m_AttrField)));
+
+
+ //-----------------------------------------------------
+ switch( method )
+ {
+ case 0: return( Reclass_Single() );
+ case 1: return( Reclass_Range() );
+ case 2: return( Reclass_Table(false) );
+ case 3: return( Reclass_Table(true) );
+ }
+
+ //-----------------------------------------------------
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPC_Reclass_Extract::Reclass_Range(void)
+{
+ bool otherOpt, noDataOpt, floating;
+ int opera;
+ double minValue, maxValue, value, others, noData, noDataValue, newValue;
+
+
+ minValue = Parameters("MIN")->asDouble();
+ maxValue = Parameters("MAX")->asDouble();
+ newValue = Parameters("RNEW")->asDouble();
+ others = Parameters("OTHERS")->asDouble();
+ noData = Parameters("NODATA")->asDouble();
+ otherOpt = Parameters("OTHEROPT")->asBool();
+ noDataOpt = Parameters("NODATAOPT")->asBool();
+ opera = Parameters("ROPERATOR")->asInt();
+
+ noDataValue = m_pInput->Get_NoData_Value();
+
+ if( (m_pInput->Get_Field_Type(m_AttrField) == SG_DATATYPE_Double) || (m_pInput->Get_Field_Type(m_AttrField) == SG_DATATYPE_Float) )
+ floating = true;
+ else
+ floating = false;
+
+ for (int i=0; i<m_pInput->Get_Point_Count(); i++)
+ {
+ if( floating == true )
+ value = m_pInput->Get_Value(i, m_AttrField);
+ else
+ value = (int)m_pInput->Get_Value(i, m_AttrField);
+
+ if( opera == 0 ) // operator <=
+ {
+ if( noDataOpt == true && value == noDataValue ) // noData option
+ Set_Value(i, noData);
+ else if( minValue <= value && value <= maxValue ) // reclass old range
+ Set_Value(i, newValue);
+ else if( otherOpt == true && value != noDataValue ) // other values option
+ Set_Value(i, others);
+ else
+ {
+ if (!m_bExtract)
+ Set_Value(i, value); // or original value
+ }
+ }
+
+ if( opera == 1 ) // operator <
+ {
+ if( noDataOpt == true && value == noDataValue ) // noData option
+ Set_Value(i, noData);
+ else if( minValue < value && value < maxValue ) // reclass old range
+ Set_Value(i, newValue);
+ else if( otherOpt == true && value != noDataValue ) // other values option
+ Set_Value(i, others);
+ else
+ {
+ if (!m_bExtract)
+ Set_Value(i, value); // or original value
+ }
+ }
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CPC_Reclass_Extract::Reclass_Single(void)
+{
+ bool otherOpt, noDataOpt, floating;
+ int opera;
+ double oldValue, newValue, value, others, noData, noDataValue;
+
+
+ oldValue = Parameters("OLD")->asDouble();
+ newValue = Parameters("NEW")->asDouble();
+ others = Parameters("OTHERS")->asDouble();
+ noData = Parameters("NODATA")->asDouble();
+ otherOpt = Parameters("OTHEROPT")->asBool();
+ noDataOpt = Parameters("NODATAOPT")->asBool();
+ opera = Parameters("SOPERATOR")->asInt();
+
+ noDataValue = m_pInput->Get_NoData_Value();
+
+ if( (m_pInput->Get_Field_Type(m_AttrField) == SG_DATATYPE_Double) || (m_pInput->Get_Attribute_Type(m_AttrField) == SG_DATATYPE_Float) )
+ floating = true;
+ else
+ floating = false;
+
+
+ for (int i=0; i<m_pInput->Get_Point_Count(); i++)
+ {
+ if( floating == true )
+ value = m_pInput->Get_Value(i, m_AttrField);
+ else
+ value = (int)m_pInput->Get_Value(i, m_AttrField);
+
+
+ if( opera == 0 ) // operator =
+ {
+ if( noDataOpt == true && value == noDataValue ) // noData option
+ Set_Value(i, noData);
+ else if( value == oldValue ) // reclass old value
+ Set_Value(i, newValue);
+ else if( otherOpt == true && value != noDataValue ) // other values option
+ Set_Value(i, others);
+ else
+ {
+ if (!m_bExtract)
+ Set_Value(i, value); // or original value
+ }
+ }
+
+ if( opera == 1 ) // operator <
+ {
+ if( noDataOpt == true && value == noDataValue ) // noData option
+ Set_Value(i, noData);
+ else if( value < oldValue ) // reclass old value
+ Set_Value(i, newValue);
+ else if( otherOpt == true && value != noDataValue ) // other values option
+ Set_Value(i, others);
+ else
+ {
+ if (!m_bExtract)
+ Set_Value(i, value); // or original value
+ }
+ }
+
+ if( opera == 2 ) // operator <=
+ {
+ if( noDataOpt == true && value == noDataValue ) // noData option
+ Set_Value(i, noData);
+ else if( value <= oldValue ) // reclass old value
+ Set_Value(i, newValue);
+ else if( otherOpt == true && value != noDataValue ) // other values option
+ Set_Value(i, others);
+ else
+ {
+ if (!m_bExtract)
+ Set_Value(i, value); // or original value
+ }
+ }
+
+ if( opera == 3 ) // operator >=
+ {
+ if( noDataOpt == true && value == noDataValue ) // noData option
+ Set_Value(i, noData);
+ else if( value >= oldValue ) // reclass old value
+ Set_Value(i, newValue);
+ else if( otherOpt == true && value != noDataValue ) // other values option
+ Set_Value(i, others);
+ else
+ {
+ if (!m_bExtract)
+ Set_Value(i, value); // or original value
+ }
+ }
+
+ if( opera == 4 ) // operator >
+ {
+ if( noDataOpt == true && value == noDataValue ) // noData option
+ Set_Value(i, noData);
+ else if( value > oldValue ) // reclass old value
+ Set_Value(i, newValue);
+ else if( otherOpt == true && value != noDataValue ) // other values option
+ Set_Value(i, others);
+ else
+ {
+ if (!m_bExtract)
+ Set_Value(i, value); // or original value
+ }
+ }
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+#define MAX_CAT 128
+
+//---------------------------------------------------------
+bool CPC_Reclass_Extract::Reclass_Table(bool bUser)
+{
+ bool set, otherOpt, noDataOpt;
+ int n, opera, recCount, count[MAX_CAT], field_Min, field_Max, field_Code;
+ double min[MAX_CAT], max[MAX_CAT], code[MAX_CAT], value, others, noData, noDataValue;
+
+ CSG_Table *pReTab;
+ CSG_Table_Record *pRecord = NULL;
+
+ if( bUser )
+ {
+ pReTab = Parameters("RETAB_2") ->asTable();
+ field_Min = Parameters("F_MIN") ->asInt();
+ field_Max = Parameters("F_MAX") ->asInt();
+ field_Code = Parameters("F_CODE") ->asInt();
+ }
+ else
+ {
+ pReTab = Parameters("RETAB") ->asTable();
+ field_Min = 0;
+ field_Max = 1;
+ field_Code = 2;
+ }
+
+ others = Parameters("OTHERS")->asDouble();
+ noData = Parameters("NODATA")->asDouble();
+ otherOpt = Parameters("OTHEROPT")->asBool();
+ noDataOpt = Parameters("NODATAOPT")->asBool();
+ opera = Parameters("TOPERATOR")->asInt();
+
+ noDataValue = m_pInput->Get_NoData_Value();
+
+
+ if( pReTab == NULL )
+ {
+ Error_Set(_TL("You must specify a reclass table with a minimium (field 1), a maximum (field 2) and a code value (field 3)!\n"));
+ return( false );
+ }
+
+ recCount = pReTab->Get_Record_Count();
+ if( recCount > MAX_CAT )
+ {
+ Error_Set(_TL("At the moment the reclass table is limited to 128 categories!\n"));
+ return( false );
+ }
+
+ if( recCount == 0 )
+ {
+ Error_Set(_TL("You must specify a reclass table with a minimium of one record!\n"));
+ return( false );
+ }
+
+ for(n=0; n<recCount ; n++) // initialize reclass arrays
+ {
+ pRecord = pReTab->Get_Record(n);
+ min[n] = pRecord->asDouble(field_Min);
+ max[n] = pRecord->asDouble(field_Max);
+ code[n] = pRecord->asDouble(field_Code);
+ count[n] = 0;
+ }
+
+
+ for (int i=0; i<m_pInput->Get_Point_Count(); i++)
+ {
+ value = m_pInput->Get_Value(i, m_AttrField);
+ set = false;
+
+ for(n=0; n< recCount; n++) // reclass
+ {
+ if( opera == 0 ) // min <= value < max
+ {
+ if( value >= min[n] && value < max[n] )
+ {
+ Set_Value(i, code[n]);
+ set = true;
+ count[n] += 1;
+ break;
+ }
+ }
+ else if( opera == 1 ) // min <= value <= max
+ {
+ if( value >= min[n] && value <= max[n] )
+ {
+ Set_Value(i, code[n]);
+ set = true;
+ count[n] += 1;
+ break;
+ }
+ }
+ else if( opera == 2 ) // min < value <= max
+ {
+ if( value > min[n] && value <= max[n] )
+ {
+ Set_Value(i, code[n]);
+ set = true;
+ count[n] += 1;
+ break;
+ }
+ }
+ else if( opera == 3 ) // min < value < max
+ {
+ if( value > min[n] && value < max[n] )
+ {
+ Set_Value(i, code[n]);
+ set = true;
+ count[n] += 1;
+ break;
+ }
+ }
+ }
+
+ if( set == false )
+ {
+ if( noDataOpt == true && value == noDataValue ) // noData option
+ Set_Value(i, noData);
+ else if( otherOpt == true && value != noDataValue) // other values option
+ Set_Value(i, others);
+ else
+ {
+ if (!m_bExtract)
+ Set_Value(i, value); // or original value
+ }
+ }
+ }
+
+ return (true);
+}
+
+
+//---------------------------------------------------------
+void CPC_Reclass_Extract::Set_Value(int i, double value)
+{
+ m_pResult->Add_Point(m_pInput->Get_X(i), m_pInput->Get_Y(i), m_pInput->Get_Z(i));
+
+ for (int j=0; j<m_pInput->Get_Attribute_Count(); j++)
+ m_pResult->Set_Attribute(j, m_pInput->Get_Attribute(i, j));
+
+ if (!m_bExtract)
+ m_pResult->Set_Value(m_AttrField, value);
+
+ return;
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_reclass_extract.h b/src/modules/pointcloud/pointcloud_tools/pc_reclass_extract.h
new file mode 100644
index 0000000..ce4f210
--- /dev/null
+++ b/src/modules/pointcloud/pointcloud_tools/pc_reclass_extract.h
@@ -0,0 +1,119 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_reclass_extract.h //
+// //
+// Copyright (C) 2009 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__PC_Reclass_Extract_H
+#define HEADER_INCLUDED__PC_Reclass_Extract_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPC_Reclass_Extract : public CSG_Module
+{
+public:
+ CPC_Reclass_Extract(void);
+ virtual ~CPC_Reclass_Extract(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Tools") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ int m_Single;
+ bool m_bExtract;
+ int m_AttrField;
+
+ CSG_PointCloud *m_pInput, *m_pResult;
+
+
+ bool Reclass_Single (void);
+ bool Reclass_Range (void);
+ bool Reclass_Table (bool bUser);
+ void Set_Value (int i, double value);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__PC_Reclass_Extract_H
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_thinning_simple.cpp b/src/modules/pointcloud/pointcloud_tools/pc_thinning_simple.cpp
new file mode 100644
index 0000000..c400a1d
--- /dev/null
+++ b/src/modules/pointcloud/pointcloud_tools/pc_thinning_simple.cpp
@@ -0,0 +1,147 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_thinning_simple.cpp //
+// //
+// Copyright (C) 2010 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "pc_thinning_simple.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// Construction/Destruction //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPC_Thinning_Simple::CPC_Thinning_Simple(void)
+{
+
+ Set_Name(_TL("Point Cloud Thinning (simple)"));
+
+ Set_Author(_TL("Volker Wichmann (c) 2010, LASERDATA GmbH"));
+
+ Set_Description (_TW(
+ "The module can be used to remove every i-th point from a point cloud. This thinning "
+ "method is most suited for data in chronological order.\n\n")
+ );
+
+
+ //-----------------------------------------------------
+ Parameters.Add_PointCloud(
+ NULL , "INPUT" ,_TL("Input"),
+ _TL("Point Cloud to drop attribute from."),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_PointCloud(
+ NULL , "RESULT" , _TL("Result"),
+ _TL("Resulting Point Cloud."),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Value(
+ NULL , "STEP" , _TL("Stepwidth"),
+ _TL("Remove every i-th point."),
+ PARAMETER_TYPE_Int, 2, 2, true
+ );
+
+}
+
+//---------------------------------------------------------
+CPC_Thinning_Simple::~CPC_Thinning_Simple(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPC_Thinning_Simple::On_Execute(void)
+{
+ CSG_PointCloud *pInput, *pResult;
+ int step;
+
+ pInput = Parameters("INPUT")->asPointCloud();
+ pResult = Parameters("RESULT")->asPointCloud();
+ step = Parameters("STEP")->asInt() - 1;
+
+
+ pResult->Create(pInput);
+ pResult->Set_Name(CSG_String::Format(SG_T("%s_thinned"), pInput->Get_Name()));
+ pResult->Assign(pInput);
+
+ for (int i=step; i<pInput->Get_Point_Count() && Set_Progress(i, pInput->Get_Point_Count()); i+=step)
+ {
+ pResult->Del_Point(i);
+ }
+
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_thinning_simple.h b/src/modules/pointcloud/pointcloud_tools/pc_thinning_simple.h
new file mode 100644
index 0000000..d9f7090
--- /dev/null
+++ b/src/modules/pointcloud/pointcloud_tools/pc_thinning_simple.h
@@ -0,0 +1,107 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_thinning_simple.h //
+// //
+// Copyright (C) 2010 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__PC_Thinning_Simple_H
+#define HEADER_INCLUDED__PC_Thinning_Simple_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPC_Thinning_Simple : public CSG_Module
+{
+public:
+ CPC_Thinning_Simple(void);
+ virtual ~CPC_Thinning_Simple(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Tools") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__PC_Thinning_Simple_H
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_transform.cpp b/src/modules/pointcloud/pointcloud_tools/pc_transform.cpp
new file mode 100644
index 0000000..d316cd9
--- /dev/null
+++ b/src/modules/pointcloud/pointcloud_tools/pc_transform.cpp
@@ -0,0 +1,246 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_transform.cpp //
+// //
+// Copyright (C) 2010 by //
+// Volker Wichmann //
+// //
+// Based on TransformShapes.cpp, (C) Victor Olaya //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "pc_transform.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// Construction/Destruction //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPC_Transform::CPC_Transform(void)
+{
+ CSG_Parameter *pNode_0, *pNode_1;
+
+ //-----------------------------------------------------
+ Set_Name(_TL("Transform Point Cloud"));
+
+ Set_Author(_TL("Volker Wichmann (c) 2010, LASERDATA GmbH"));
+
+ Set_Description (_TW(
+ "The module can be used to shift, rotate and/or scale a Point Cloud.\n\n")
+ );
+
+
+ //-----------------------------------------------------
+ Parameters.Add_PointCloud(
+ NULL , "IN" , _TL("Input"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_PointCloud(
+ NULL , "OUT" , _TL("Output"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ //-----------------------------------------------------
+ pNode_0 = Parameters.Add_Node(
+ NULL , "MOVE" , _TL("Move"),
+ _TL("")
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "DX" , _TL("dX"),
+ _TL("dX (Map Units)"),
+ PARAMETER_TYPE_Double, 0.0
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0, "DY" , _TL("dY"),
+ _TL("dY (Map Units)"),
+ PARAMETER_TYPE_Double, 0.0
+ );
+
+ //-----------------------------------------------------
+ pNode_0 = Parameters.Add_Node(
+ NULL , "ROTATE" ,
+ _TL("Rotate"),
+ _TL(""));
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "ANGLE" , _TL("Angle"),
+ _TL("Angle in degrees, counting clockwise from north"),
+ PARAMETER_TYPE_Double, 0.0
+ );
+
+ //-----------------------------------------------------
+ pNode_0 = Parameters.Add_Node(
+ NULL , "SCALE" , _TL("Scale"),
+ _TL("")
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "SCALEX" , _TL("Scale Factor X"),
+ _TL("Scale Factor X"),
+ PARAMETER_TYPE_Double, 1.0
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "SCALEY" , _TL("Scale Factor Y"),
+ _TL("Scale Factor Y"),
+ PARAMETER_TYPE_Double, 1.0
+ );
+
+ //-----------------------------------------------------
+ pNode_0 = Parameters.Add_Node(
+ NULL , "ANCHOR" , _TL("Anchor Point"),
+ _TL("")
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "ANCHORX" , _TL("X"),
+ _TL("X"),
+ PARAMETER_TYPE_Double, 0.0
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "ANCHORY" , _TL("Y"),
+ _TL("Y"),
+ PARAMETER_TYPE_Double, 0.0
+ );
+}
+
+//---------------------------------------------------------
+CPC_Transform::~CPC_Transform(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPC_Transform::On_Execute(void)
+{
+ bool bCopy;
+ double Angle;
+ TSG_Point_Z P, Q, Move, Scale, Anchor;
+ CSG_PointCloud *pIn, *pOut;
+
+ //-----------------------------------------------------
+ pIn = Parameters("IN") ->asPointCloud();
+ pOut = Parameters("OUT") ->asPointCloud();
+ Scale.x = Parameters("SCALEX") ->asDouble();
+ Scale.y = Parameters("SCALEY") ->asDouble();
+ Move.x = Parameters("DX") ->asDouble();
+ Move.y = Parameters("DY") ->asDouble();
+ Anchor.x = Parameters("ANCHORX") ->asDouble();
+ Anchor.y = Parameters("ANCHORY") ->asDouble();
+ Angle = Parameters("ANGLE") ->asDouble() * -M_DEG_TO_RAD;
+
+
+ if( pIn == pOut )
+ {
+ bCopy = true;
+ pOut = SG_Create_PointCloud();
+ }
+ else
+ bCopy = false;
+
+ pOut->Create(pIn);
+
+ pOut->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pIn->Get_Name(), _TL("Transformed")));
+
+
+ //-----------------------------------------------------
+ for (int iPoint=0; iPoint<pIn->Get_Point_Count(); ++iPoint)
+ {
+ P = pIn->Get_Point(iPoint);
+
+ P.x += Move.x - Anchor.x;
+ P.y += Move.y - Anchor.y;
+
+ Q.x = Anchor.x + Scale.x * (P.x * cos(Angle) - P.y * sin(Angle));
+ Q.y = Anchor.y + Scale.y * (P.x * sin(Angle) + P.y * cos(Angle));
+ Q.z = P.z;
+
+ pOut->Add_Point(Q.x, Q.y, Q.z);
+
+ for (int iField=0; iField<pIn->Get_Attribute_Count(); ++iField)
+ pOut->Set_Attribute(iField, pIn->Get_Attribute(iField));
+ }
+
+ //-----------------------------------------------------
+ if( bCopy )
+ {
+ pIn->Assign(pOut);
+ delete(pOut);
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/pointcloud/pointcloud_tools/pc_transform.h b/src/modules/pointcloud/pointcloud_tools/pc_transform.h
new file mode 100644
index 0000000..d757495
--- /dev/null
+++ b/src/modules/pointcloud/pointcloud_tools/pc_transform.h
@@ -0,0 +1,108 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// pointcloud_tools //
+// //
+//-------------------------------------------------------//
+// //
+// pc_transform.h //
+// //
+// Copyright (C) 2010 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata //
+// //
+// contact: Volker Wichmann //
+// LASERDATA GmbH //
+// Management and analysis of //
+// laserscanning data //
+// Innsbruck, Austria //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__PC_Transform_H
+#define HEADER_INCLUDED__PC_Transform_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPC_Transform : public CSG_Module
+{
+public:
+ CPC_Transform(void);
+ virtual ~CPC_Transform(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Tools") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__PC_Transform_H
diff --git a/src/modules/pointcloud/pointcloud_viewer/MLB_Interface.cpp b/src/modules/pointcloud/pointcloud_viewer/MLB_Interface.cpp
index b61f57b..2638e08 100644
--- a/src/modules/pointcloud/pointcloud_viewer/MLB_Interface.cpp
+++ b/src/modules/pointcloud/pointcloud_viewer/MLB_Interface.cpp
@@ -69,19 +69,19 @@ const SG_Char * Get_Info(int i)
switch( i )
{
case MLB_INFO_Name: default:
- return( _TL("Point Cloud - Viewer") );
+ return( _TL("Shapes - Point Clouds Viewer") );
case MLB_INFO_Author:
return( SG_T("O.Conrad (c) 2009") );
case MLB_INFO_Description:
- return( _TL("Point cloud viewer." ));
+ return( _TL("Point clouds viewer." ));
case MLB_INFO_Version:
return( SG_T("1.0") );
case MLB_INFO_Menu_Path:
- return( _TL("Point Cloud|Visualisation" ));
+ return( _TL("Shapes|Point Clouds|Visualisation" ));
}
}
diff --git a/src/modules/pointcloud/pointcloud_viewer/Makefile.am b/src/modules/pointcloud/pointcloud_viewer/Makefile.am
index c6f7da3..7b57188 100644
--- a/src/modules/pointcloud/pointcloud_viewer/Makefile.am
+++ b/src/modules/pointcloud/pointcloud_viewer/Makefile.am
@@ -11,7 +11,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = $(DEP_LFLG)
+AM_LDFLAGS = $(DEP_LFLG) -avoid-version
pkglib_LTLIBRARIES = libpointcloud_viewer.la
libpointcloud_viewer_la_SOURCES =\
MLB_Interface.cpp\
diff --git a/src/modules/pointcloud/pointcloud_viewer/Makefile.in b/src/modules/pointcloud/pointcloud_viewer/Makefile.in
index 3ce6b7f..7124b99 100644
--- a/src/modules/pointcloud/pointcloud_viewer/Makefile.in
+++ b/src/modules/pointcloud/pointcloud_viewer/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -75,7 +74,7 @@ am_libpointcloud_viewer_la_OBJECTS = MLB_Interface.lo \
points_view_extent.lo points_view_module.lo
libpointcloud_viewer_la_OBJECTS = \
$(am_libpointcloud_viewer_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -121,6 +120,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -130,6 +130,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -226,7 +227,7 @@ top_srcdir = @top_srcdir@
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = $(DEP_LFLG)
+AM_LDFLAGS = $(DEP_LFLG) -avoid-version
pkglib_LTLIBRARIES = libpointcloud_viewer.la
libpointcloud_viewer_la_SOURCES = \
MLB_Interface.cpp\
diff --git a/src/modules/pointcloud/pointcloud_viewer/points_view_control.cpp b/src/modules/pointcloud/pointcloud_viewer/points_view_control.cpp
index c6bfbd6..42924b1 100644
--- a/src/modules/pointcloud/pointcloud_viewer/points_view_control.cpp
+++ b/src/modules/pointcloud/pointcloud_viewer/points_view_control.cpp
@@ -95,6 +95,7 @@
BEGIN_EVENT_TABLE(CPoints_View_Control, wxPanel)
EVT_SIZE (CPoints_View_Control::On_Size)
EVT_PAINT (CPoints_View_Control::On_Paint)
+ EVT_KEY_DOWN (CPoints_View_Control::On_Key_Down)
EVT_LEFT_DOWN (CPoints_View_Control::On_Mouse_LDown)
EVT_LEFT_UP (CPoints_View_Control::On_Mouse_LUp)
EVT_RIGHT_DOWN (CPoints_View_Control::On_Mouse_RDown)
@@ -253,7 +254,7 @@ void CPoints_View_Control::Update_Extent(CSG_Rect Extent)
{
m_pPoints->Set_Cursor(i);
- TSG_Point_3D p = m_pPoints->Get_Point();
+ TSG_Point_Z p = m_pPoints->Get_Point();
if( m_Extent.Contains(p.x, p.y) )
{
@@ -280,12 +281,65 @@ void CPoints_View_Control::Update_Extent(CSG_Rect Extent)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+void CPoints_View_Control::On_Key_Down(wxKeyEvent &event)
+{
+ switch( event.GetKeyCode() )
+ {
+ default:
+ event.Skip();
+ return;
+
+ case WXK_NUMPAD_ADD:
+ case WXK_ADD: m_xRotate -= 4.0 * M_DEG_TO_RAD; break;
+ case WXK_NUMPAD_SUBTRACT:
+ case WXK_SUBTRACT: m_xRotate += 4.0 * M_DEG_TO_RAD; break;
+
+ case WXK_F3: m_yRotate -= 4.0 * M_DEG_TO_RAD; break;
+ case WXK_F4: m_yRotate += 4.0 * M_DEG_TO_RAD; break;
+
+ case WXK_NUMPAD_MULTIPLY:
+ case WXK_MULTIPLY: m_zRotate -= 4.0 * M_DEG_TO_RAD; break;
+ case WXK_NUMPAD_DIVIDE:
+ case WXK_DIVIDE: m_zRotate += 4.0 * M_DEG_TO_RAD; break;
+
+ case WXK_INSERT: m_xShift -= 10.0; break;
+ case WXK_DELETE: m_xShift += 10.0; break;
+
+ case WXK_HOME: m_yShift -= 10.0; break;
+ case WXK_END: m_yShift += 10.0; break;
+
+ case WXK_PRIOR: m_zShift -= 10.0; break;
+ case WXK_NEXT: m_zShift += 10.0; break;
+
+ case 'A': m_bStereo = !m_bStereo; break;
+ case 'S': m_bScale = !m_bScale; break;
+
+ case 'C': m_Settings("C_AS_RGB") ->Set_Value(m_Settings("C_AS_RGB")->asBool() ? 0.0 : 1.0); break;
+
+ case WXK_F1: m_Settings("EXAGGERATION")->Set_Value(m_Settings("EXAGGERATION")->asDouble() + 0.5); break;
+ case WXK_F2: m_Settings("EXAGGERATION")->Set_Value(m_Settings("EXAGGERATION")->asDouble() - 0.5); break;
+
+ case WXK_F5: m_Settings("SIZE_DEF") ->Set_Value(m_Settings("SIZE_DEF") ->asDouble() - 1.0); break;
+ case WXK_F6: m_Settings("SIZE_DEF") ->Set_Value(m_Settings("SIZE_DEF") ->asDouble() + 1.0); break;
+
+ case WXK_F7: m_Settings("SIZE_SCALE") ->Set_Value(m_Settings("SIZE_SCALE") ->asDouble() - 10.0); break;
+ case WXK_F8: m_Settings("SIZE_SCALE") ->Set_Value(m_Settings("SIZE_SCALE") ->asDouble() + 10.0); break;
+ }
+
+ Update_View();
+
+ ((CPoints_View_Dialog *)GetParent())->Update_Rotation();
+}
+
+//---------------------------------------------------------
#define GET_MOUSE_X_RELDIFF ((double)(m_Mouse_Down.x - event.GetX()) / (double)GetClientSize().x)
#define GET_MOUSE_Y_RELDIFF ((double)(m_Mouse_Down.y - event.GetY()) / (double)GetClientSize().y)
//---------------------------------------------------------
void CPoints_View_Control::On_Mouse_LDown(wxMouseEvent &event)
{
+ SetFocus();
+
m_Mouse_Down = event.GetPosition();
m_xDown = m_zRotate;
m_yDown = m_xRotate;
@@ -314,6 +368,8 @@ void CPoints_View_Control::On_Mouse_LUp(wxMouseEvent &event)
//---------------------------------------------------------
void CPoints_View_Control::On_Mouse_RDown(wxMouseEvent &event)
{
+ SetFocus();
+
m_Mouse_Down = event.GetPosition();
m_xDown = m_xShift;
m_yDown = m_yShift;
@@ -342,6 +398,8 @@ void CPoints_View_Control::On_Mouse_RUp(wxMouseEvent &event)
//---------------------------------------------------------
void CPoints_View_Control::On_Mouse_MDown(wxMouseEvent &event)
{
+ SetFocus();
+
m_Mouse_Down = event.GetPosition();
m_xDown = m_yRotate;
m_yDown = m_zShift;
@@ -577,7 +635,7 @@ inline void CPoints_View_Control::_Draw_Point(int iPoint)
{
int ix, iy, iColor;
double iz;
- TSG_Point_3D p;
+ TSG_Point_Z p;
m_pPoints->Set_Cursor(iPoint);
@@ -659,9 +717,9 @@ inline void CPoints_View_Control::_Draw_Pixel(int x, int y, double z, int color)
}
//---------------------------------------------------------
-inline TSG_Point_3D CPoints_View_Control::_Get_Projection(TSG_Point_3D &p)
+inline TSG_Point_Z CPoints_View_Control::_Get_Projection(TSG_Point_Z &p)
{
- TSG_Point_3D q;
+ TSG_Point_Z q;
p.x = (p.x - r_xc) * r_Scale;
p.y = (p.y - r_yc) * r_Scale;
diff --git a/src/modules/pointcloud/pointcloud_viewer/points_view_control.h b/src/modules/pointcloud/pointcloud_viewer/points_view_control.h
index 0700284..7e4e35d 100644
--- a/src/modules/pointcloud/pointcloud_viewer/points_view_control.h
+++ b/src/modules/pointcloud/pointcloud_viewer/points_view_control.h
@@ -111,6 +111,7 @@ public:
void On_Size (wxSizeEvent &event);
void On_Paint (wxPaintEvent &event);
+ void On_Key_Down (wxKeyEvent &event);
void On_Mouse_LDown (wxMouseEvent &event);
void On_Mouse_LUp (wxMouseEvent &event);
void On_Mouse_RDown (wxMouseEvent &event);
@@ -156,7 +157,7 @@ private:
void _Draw_Point (int x, int y, double z, int color, int Size);
void _Draw_Pixel (int x, int y, double z, int color);
- TSG_Point_3D _Get_Projection (TSG_Point_3D &p);
+ TSG_Point_Z _Get_Projection (TSG_Point_Z &p);
DECLARE_EVENT_TABLE()
diff --git a/src/modules/pointcloud/pointcloud_viewer/points_view_dialog.cpp b/src/modules/pointcloud/pointcloud_viewer/points_view_dialog.cpp
index cf1c792..cb25faa 100644
--- a/src/modules/pointcloud/pointcloud_viewer/points_view_dialog.cpp
+++ b/src/modules/pointcloud/pointcloud_viewer/points_view_dialog.cpp
@@ -72,7 +72,6 @@
//---------------------------------------------------------
BEGIN_EVENT_TABLE(CPoints_View_Dialog, CSGDI_Dialog)
EVT_MOUSEWHEEL (CPoints_View_Dialog::On_Mouse_Wheel)
- EVT_KEY_DOWN (CPoints_View_Dialog::On_Key_Down)
EVT_BUTTON (wxID_ANY , CPoints_View_Dialog::On_Button)
EVT_CHECKBOX (wxID_ANY , CPoints_View_Dialog::On_Update_Control)
EVT_TEXT_ENTER (wxID_ANY , CPoints_View_Dialog::On_Update_Control)
@@ -139,12 +138,6 @@ void CPoints_View_Dialog::On_Mouse_Wheel(wxMouseEvent &event)
}
//---------------------------------------------------------
-void CPoints_View_Dialog::On_Key_Down(wxKeyEvent &event)
-{
- event.Skip();
-}
-
-//---------------------------------------------------------
void CPoints_View_Dialog::On_Update_Control(wxCommandEvent &event)
{
if( event.GetEventObject() == m_pCheck_Central )
@@ -249,6 +242,9 @@ void CPoints_View_Dialog::Update_Rotation(void)
d = fmod(M_RAD_TO_DEG * m_pView->m_zRotate, 360.0); if( d < -180.0 ) d += 360.0; else if( d > 180.0 ) d -= 360.0;
m_pSlide_zRotate->Set_Value(d);
+
+ m_pCheck_Scale ->SetValue(m_pView->m_bScale);
+ m_pCheck_Stereo ->SetValue(m_pView->m_bStereo);
}
diff --git a/src/modules/pointcloud/pointcloud_viewer/points_view_dialog.h b/src/modules/pointcloud/pointcloud_viewer/points_view_dialog.h
index c14fef6..55116df 100644
--- a/src/modules/pointcloud/pointcloud_viewer/points_view_dialog.h
+++ b/src/modules/pointcloud/pointcloud_viewer/points_view_dialog.h
@@ -112,8 +112,6 @@ private:
void On_Button (wxCommandEvent &event);
void On_Mouse_Wheel (wxMouseEvent &event);
- void On_Key_Down (wxKeyEvent &event);
-
DECLARE_EVENT_TABLE()
diff --git a/src/modules/pointcloud/pointcloud_viewer/points_view_extent.cpp b/src/modules/pointcloud/pointcloud_viewer/points_view_extent.cpp
index 88aed55..a19c6b8 100644
--- a/src/modules/pointcloud/pointcloud_viewer/points_view_extent.cpp
+++ b/src/modules/pointcloud/pointcloud_viewer/points_view_extent.cpp
@@ -332,17 +332,27 @@ bool CPoints_View_Extent::_Draw_Image(void)
dy = Size.y / m_Extent.Get_YRange();
//-------------------------------------------------
+ bool bColorAsRGB = m_Settings("C_AS_RGB")->asBool();
+
for(int i=0; i<m_pPoints->Get_Count(); i++)
{
- TSG_Point_3D p = m_pPoints->Get_Point(i); p.z = m_pPoints->Get_Value(i, m_cField);
+ TSG_Point_Z p = m_pPoints->Get_Point(i); p.z = m_pPoints->Get_Value(i, m_cField);
int ix = (p.x - m_Extent.Get_XMin()) * dx;
int iy = (p.y - m_Extent.Get_YMin()) * dy;
if( ix >= 0 && ix <= m_Image.GetWidth() && iy >= 0 && iy < m_Image.GetHeight() )
{
- m_Image_Value[iy][ix] += p.z;
- m_Image_Count[iy][ix] ++;
+ if( !bColorAsRGB )
+ {
+ m_Image_Value[iy][ix] += p.z;
+ }
+ else
+ {
+ m_Image_Value[iy][ix] = p.z;
+ }
+
+ m_Image_Count[iy][ix]++;
}
}
@@ -358,10 +368,17 @@ bool CPoints_View_Extent::_Draw_Image(void)
{
if( m_Image_Count[iy][ix] > 0 )
{
- int ic = (int)(pColors->Get_Count() * (m_Image_Value[iy][ix] / m_Image_Count[iy][ix] - zMin) / zRange);
- int c = pColors->Get_Color(ic < 0 ? 0 : ic >= pColors->Get_Count() ? pColors->Get_Count() - 1 : ic);
-
- _Draw_Pixel(ix, iy, c);
+ if( !bColorAsRGB )
+ {
+ int ic = (int)(pColors->Get_Count() * (m_Image_Value[iy][ix] / m_Image_Count[iy][ix] - zMin) / zRange);
+ int c = pColors->Get_Color(ic < 0 ? 0 : ic >= pColors->Get_Count() ? pColors->Get_Count() - 1 : ic);
+
+ _Draw_Pixel(ix, iy, c);
+ }
+ else
+ {
+ _Draw_Pixel(ix, iy, m_Image_Value[iy][ix]);
+ }
}
else
{
diff --git a/src/modules/pointcloud/pointcloud_viewer/points_view_module.cpp b/src/modules/pointcloud/pointcloud_viewer/points_view_module.cpp
index 1675fa2..d3d1f90 100644
--- a/src/modules/pointcloud/pointcloud_viewer/points_view_module.cpp
+++ b/src/modules/pointcloud/pointcloud_viewer/points_view_module.cpp
@@ -105,20 +105,25 @@ CPoints_View_Module::CPoints_View_Module(void)
//---------------------------------------------------------
bool CPoints_View_Module::On_Execute(void)
{
- CSG_PointCloud *pPoints = Parameters("POINTS")->asPointCloud();
-
- if( SG_UI_Get_Window_Main() )
+ if( !SG_UI_Get_Window_Main() )
{
- CPoints_View_Dialog dlg(pPoints);
+ Message_Add(_TL("point cloud viewer can only be run from graphical user interface"));
- // return( dlg.ShowModal() == wxID_OK );
+ return( false );
+ }
- dlg.ShowModal();
+ CSG_PointCloud *pPoints = Parameters("POINTS")->asPointCloud();
- return( true );
+ if( pPoints->Get_Count() <= 0 )
+ {
+ Message_Add(_TL("point cloud viewer will not be started, because point cloud has no points"));
+
+ return( false );
}
- return( false );
+ CPoints_View_Dialog dlg(pPoints);
+
+ dlg.ShowModal();
}
diff --git a/src/modules/shapes/Makefile.am b/src/modules/shapes/Makefile.am
index 7b4d4f2..2848e99 100644
--- a/src/modules/shapes/Makefile.am
+++ b/src/modules/shapes/Makefile.am
@@ -1 +1 @@
-SUBDIRS = shapes_tools shapes_polygons shapes_points shapes_lines shapes_grid
+SUBDIRS = shapes_tools shapes_polygons shapes_points shapes_lines shapes_grid shapes_transect
diff --git a/src/modules/shapes/Makefile.in b/src/modules/shapes/Makefile.in
index 3e9ac2e..dc6dcc4 100644
--- a/src/modules/shapes/Makefile.in
+++ b/src/modules/shapes/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -202,7 +203,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = shapes_tools shapes_polygons shapes_points shapes_lines shapes_grid
+SUBDIRS = shapes_tools shapes_polygons shapes_points shapes_lines shapes_grid shapes_transect
all: all-recursive
.SUFFIXES:
diff --git a/src/modules/shapes/shapes_grid/Grid_Classes_To_Shapes.cpp b/src/modules/shapes/shapes_grid/Grid_Classes_To_Shapes.cpp
index 5dc60df..151794c 100644
--- a/src/modules/shapes/shapes_grid/Grid_Classes_To_Shapes.cpp
+++ b/src/modules/shapes/shapes_grid/Grid_Classes_To_Shapes.cpp
@@ -1,435 +1,439 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// Grid_Shapes //
-// //
-//-------------------------------------------------------//
-// //
-// Grid_Classes_To_Shapes.cpp //
-// //
-// Copyright (C) 2008 by //
-// Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "Grid_Classes_To_Shapes.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CGrid_Classes_To_Shapes::CGrid_Classes_To_Shapes(void)
-{
- //-----------------------------------------------------
- Set_Name (_TL("Vectorising Grid Classes"));
-
- Set_Author (SG_T("(c) 2008 by O.Conrad"));
-
- Set_Description (_TW(
- "Vectorising grid classes."
- ));
-
-
- //-----------------------------------------------------
- Parameters.Add_Grid(
- NULL , "GRID" , _TL("Grid"),
- _TL(""),
- PARAMETER_INPUT
- );
-
- Parameters.Add_Shapes(
- NULL , "SHAPES" , _TL("Shapes"),
- _TL(""),
- PARAMETER_OUTPUT, SHAPE_TYPE_Polygon
- );
-
- Parameters.Add_Choice(
- NULL , "CLASS_ALL" , _TL("Class Selection"),
- _TL(""),
- CSG_String::Format(SG_T("%s|%s|"),
- _TL("one single class specified by class identifier"),
- _TL("all classes")
- ), 1
- );
-
- Parameters.Add_Value(
- NULL , "CLASS_ID" , _TL("Class Identifier"),
- _TL(""),
- PARAMETER_TYPE_Double, 1
- );
-
- Parameters.Add_Choice(
- NULL , "SPLIT" , _TL("Vectorised class as..."),
- _TL(""),
- CSG_String::Format(SG_T("%s|%s|"),
- _TL("one single (multi-)polygon object"),
- _TL("each island as separated polygon")
- ), 1
- );
-}
-
-//---------------------------------------------------------
-CGrid_Classes_To_Shapes::~CGrid_Classes_To_Shapes(void)
-{}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CGrid_Classes_To_Shapes::On_Execute(void)
-{
- bool bSplit, bAll;
- double Class_ID, Value;
- CSG_String ID;
- CSG_Parameters gParms, sParms;
- CSG_Shapes *pShapes, Shapes(SHAPE_TYPE_Polygon);
-
- //-----------------------------------------------------
- m_pGrid = Parameters("GRID") ->asGrid();
- pShapes = Parameters("SHAPES") ->asShapes();
- bSplit = Parameters("SPLIT") ->asInt() == 1;
- bAll = Parameters("CLASS_ALL") ->asInt() == 1;
- Class_ID = Parameters("CLASS_ID") ->asDouble();
-
- //-----------------------------------------------------
- pShapes->Create(SHAPE_TYPE_Polygon);
- pShapes->Add_Field(m_pGrid->Get_Name() , SG_DATATYPE_Double);
- pShapes->Add_Field(_TL("ID") , SG_DATATYPE_Int);
- pShapes->Add_Field(_TL("Name") , SG_DATATYPE_String);
-
- if( DataObject_Get_Parameters(m_pGrid, gParms) && gParms("COLORS_TYPE") && gParms("LUT")
- && DataObject_Get_Parameters(pShapes, sParms) && sParms("COLORS_TYPE") && sParms("LUT") && sParms("COLORS_ATTRIB") )
- {
- sParms("LUT")->asTable()->Assign_Values(gParms("LUT")->asTable()); // Lookup Table
- sParms("COLORS_TYPE")->Set_Value(gParms("COLORS_TYPE")->asInt()); // Color Classification Type: Lookup Table
- sParms("COLORS_ATTRIB")->Set_Value(1); // Color Attribute
- DataObject_Set_Parameters(pShapes, sParms);
- }
-
- pShapes->Set_Name(m_pGrid->Get_Name());
-
- //-----------------------------------------------------
- m_pShape = NULL;
-
- Lock_Create();
-
- m_Edge.Create(SG_DATATYPE_Char, 2 * Get_NX() + 1, 2 * Get_NY() + 1, 0.5 * Get_Cellsize(), Get_XMin() - 0.5 * Get_Cellsize(), Get_YMin() - 0.5 * Get_Cellsize());
-
- for(int y=0, nClasses=0; y<Get_NY() && Process_Get_Okay(false); y++)
- {
- for(int x=0; x<Get_NX(); x++)
- {
- if( !m_pGrid->is_NoData(x, y) && !Lock_Get(x, y) && (Class_ID == (Value = m_pGrid->asDouble(x, y)) || bAll) )
- {
- ID = CSG_String::Format(SG_T("%d"), ++nClasses);
-
- if( bSplit )
- {
- if( m_pShape == NULL )
- m_pShape = Shapes.Add_Shape();
-
- m_pShape->Del_Parts();
- }
- else
- {
- m_pShape = pShapes->Add_Shape();
- m_pShape->Set_Value(0, Value);
- m_pShape->Set_Value(1, pShapes->Get_Count());
- m_pShape->Set_Value(2, ID);
- }
-
- //-----------------------------------------
- Process_Set_Text(CSG_String::Format(SG_T("%s %d: %f"), _TL("vectorising class"), nClasses, Value));
-
- Get_Class(Value);
-
- //-----------------------------------------
- if( bSplit )
- {
- Split_Polygons(pShapes, Value, ID);
- }
- }
- }
- }
-
- Lock_Destroy();
-
- m_Edge.Destroy();
-
- //-----------------------------------------------------
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CGrid_Classes_To_Shapes::Split_Polygons(CSG_Shapes *pShapes, double Value, const CSG_String &ID)
-{
- if( m_pShape && m_pShape->Get_Part_Count() > 0 )
- {
- int iPart, iPoint, jPart, iShape;
- CSG_Shape *pShape;
-
- for(iPart=0; iPart<m_pShape->Get_Part_Count() && Set_Progress(iPart, m_pShape->Get_Part_Count()); iPart++)
- {
- if( ((CSG_Shape_Polygon *)m_pShape)->is_Clockwise(iPart) == true ) // No Lake
- {
- pShape = pShapes->Add_Shape();
- pShape->Set_Value(0, Value);
- pShape->Set_Value(1, pShapes->Get_Count());
- pShape->Set_Value(2, ID);
-
- for(iPoint=0; iPoint<m_pShape->Get_Point_Count(iPart); iPoint++)
- {
- pShape->Add_Point(m_pShape->Get_Point(iPoint, iPart), 0);
- }
- }
- }
-
- for(iPart=0; iPart<m_pShape->Get_Part_Count() && Set_Progress(iPart, m_pShape->Get_Part_Count()); iPart++)
- {
- if( ((CSG_Shape_Polygon *)m_pShape)->is_Clockwise(iPart) == false ) // Lake
- {
- TSG_Point p = m_pShape->Get_Point(0, iPart);
-
- for(iShape=0, jPart=0; jPart==0 && iShape<pShapes->Get_Count(); iShape++)
- {
- pShape = pShapes->Get_Shape(iShape);
-
- if( pShape->asDouble(0) == Value && ((CSG_Shape_Polygon *)pShape)->is_Containing(p, 0) )
- {
- jPart = pShape->Get_Part_Count();
-
- for(iPoint=0; iPoint<m_pShape->Get_Point_Count(iPart); iPoint++)
- {
- pShape->Add_Point(m_pShape->Get_Point(iPoint, iPart), jPart);
- }
- }
- }
- }
- }
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CGrid_Classes_To_Shapes::Get_Class(double Value)
-{
- int x, y, i, ix, iy, n, nEdgeCells;
-
- //-----------------------------------------------------
- for(y=0, nEdgeCells=0; y<Get_NY() && Set_Progress(y); y++)
- {
- for(x=0; x<Get_NX(); x++)
- {
- if( !Lock_Get(x, y) && m_pGrid->asDouble(x, y) == Value )
- {
- Lock_Set(x, y);
-
- for(i=0, n=0; i<8; i+=2)
- {
- ix = Get_xTo(i, x);
- iy = Get_yTo(i, y);
-
- if( !m_pGrid->is_InGrid(ix, iy) || m_pGrid->asDouble(ix, iy) != Value )
- {
- ix = Get_xTo(i , 1 + 2 * x);
- iy = Get_yTo(i , 1 + 2 * y);
- m_Edge.Set_Value(ix, iy, i + 2);
-
- ix = Get_xTo(i - 1, 1 + 2 * x);
- iy = Get_yTo(i - 1, 1 + 2 * y);
- m_Edge.Set_Value(ix, iy, m_Edge.asInt(ix, iy) ? -1 : i + 2);
-
- n++;
- }
- }
-
- //-----------------------------------------
- if( n == 4 )
- {
- Get_Square(1 + 2 * x, 1 + 2 * y);
- }
- else
- {
- nEdgeCells++;
- }
- }
- }
- }
-
- //-----------------------------------------------------
- if( nEdgeCells > 0 )
- {
- Get_Polygons();
- }
-
- return( m_pShape->Get_Part_Count() > 0 );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CGrid_Classes_To_Shapes::Get_Square(int x, int y)
-{
- int i, ix, iy, iPart;
-
- iPart = m_pShape->Get_Part_Count();
-
- for(i=0; i<8; i++)
- {
- ix = Get_xTo(i, x);
- iy = Get_yTo(i, y);
-
- m_Edge.Set_Value(ix, iy, m_Edge.asInt(ix, iy) > 0 ? 0 : (i > 1 ? i - 1 : i + 7));
-
- if( i % 2 )
- {
- m_pShape->Add_Point(m_Edge.Get_System().Get_Grid_to_World(ix, iy), iPart);
- }
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CGrid_Classes_To_Shapes::Get_Polygons(void)
-{
- if( m_pShape )
- {
- for(int y=0; y<m_Edge.Get_NY() && Set_Progress(y, m_Edge.Get_NY()); y++)
- {
- for(int x=0; x<m_Edge.Get_NX(); x++)
- {
- if( m_Edge.asInt(x, y) > 0 )
- {
- Get_Polygon(x, y, m_pShape->Get_Part_Count());
- }
- }
- }
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-void CGrid_Classes_To_Shapes::Get_Polygon(int x, int y, int iPart)
-{
- int i, iLast;
-
- iLast = -1;
-
- while( (i = m_Edge.asInt(x, y)) != 0 )
- {
- if( i < 0 )
- {
- i = iLast + 2;
-
- m_Edge.Set_Value(x, y, (iLast == 2 ? 8 : iLast - 2));
- }
- else
- {
- m_Edge.Set_Value(x, y, 0);
- }
-
- if( i != iLast )
- {
- m_pShape->Add_Point(m_Edge.Get_System().Get_Grid_to_World(x, y), iPart);
-
- iLast = i;
- }
-
- x = Get_xTo(i, x);
- y = Get_yTo(i, y);
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_Shapes //
+// //
+//-------------------------------------------------------//
+// //
+// Grid_Classes_To_Shapes.cpp //
+// //
+// Copyright (C) 2008 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "Grid_Classes_To_Shapes.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGrid_Classes_To_Shapes::CGrid_Classes_To_Shapes(void)
+{
+ //-----------------------------------------------------
+ Set_Name (_TL("Vectorising Grid Classes"));
+
+ Set_Author (SG_T("(c) 2008 by O.Conrad"));
+
+ Set_Description (_TW(
+ "Vectorising grid classes."
+ ));
+
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid(
+ NULL , "GRID" , _TL("Grid"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Shapes(
+ NULL , "SHAPES" , _TL("Shapes"),
+ _TL(""),
+ PARAMETER_OUTPUT, SHAPE_TYPE_Polygon
+ );
+
+ Parameters.Add_Choice(
+ NULL , "CLASS_ALL" , _TL("Class Selection"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("one single class specified by class identifier"),
+ _TL("all classes")
+ ), 1
+ );
+
+ Parameters.Add_Value(
+ NULL , "CLASS_ID" , _TL("Class Identifier"),
+ _TL(""),
+ PARAMETER_TYPE_Double, 1
+ );
+
+ Parameters.Add_Choice(
+ NULL , "SPLIT" , _TL("Vectorised class as..."),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("one single (multi-)polygon object"),
+ _TL("each island as separated polygon")
+ ), 1
+ );
+}
+
+//---------------------------------------------------------
+CGrid_Classes_To_Shapes::~CGrid_Classes_To_Shapes(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Classes_To_Shapes::On_Execute(void)
+{
+ bool bSplit, bAll;
+ double Class_ID, Value;
+ CSG_String ID;
+ CSG_Parameters gParms, sParms;
+ CSG_Shapes *pShapes, Shapes(SHAPE_TYPE_Polygon);
+
+ //-----------------------------------------------------
+ m_pGrid = Parameters("GRID") ->asGrid();
+ pShapes = Parameters("SHAPES") ->asShapes();
+ bSplit = Parameters("SPLIT") ->asInt() == 1;
+ bAll = Parameters("CLASS_ALL") ->asInt() == 1;
+ Class_ID = Parameters("CLASS_ID") ->asDouble();
+
+ //-----------------------------------------------------
+ pShapes->Create(SHAPE_TYPE_Polygon);
+ pShapes->Add_Field(m_pGrid->Get_Name() , SG_DATATYPE_Double);
+ pShapes->Add_Field(_TL("ID") , SG_DATATYPE_Int);
+ pShapes->Add_Field(_TL("Name") , SG_DATATYPE_String);
+
+ if( DataObject_Get_Parameters(m_pGrid, gParms) && gParms("COLORS_TYPE") && gParms("LUT")
+ && DataObject_Get_Parameters(pShapes, sParms) && sParms("COLORS_TYPE") && sParms("LUT") && sParms("COLORS_ATTRIB") )
+ {
+ sParms("LUT")->asTable()->Assign_Values(gParms("LUT")->asTable()); // Lookup Table
+ sParms("COLORS_TYPE")->Set_Value(gParms("COLORS_TYPE")->asInt()); // Color Classification Type: Lookup Table
+ sParms("COLORS_ATTRIB")->Set_Value(1); // Color Attribute
+ DataObject_Set_Parameters(pShapes, sParms);
+ }
+
+ pShapes->Set_Name(m_pGrid->Get_Name());
+
+ //-----------------------------------------------------
+ m_pShape = NULL;
+
+ Lock_Create();
+
+ m_Edge.Create(SG_DATATYPE_Char, 2 * Get_NX() + 1, 2 * Get_NY() + 1, 0.5 * Get_Cellsize(), Get_XMin() - 0.5 * Get_Cellsize(), Get_YMin() - 0.5 * Get_Cellsize());
+
+ for(int y=0, nClasses=0; y<Get_NY() && Process_Get_Okay(false); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
+ {
+ if( !m_pGrid->is_NoData(x, y) && !Lock_Get(x, y) && (Class_ID == (Value = m_pGrid->asDouble(x, y)) || bAll) )
+ {
+ ID = CSG_String::Format(SG_T("%d"), ++nClasses);
+
+ if( bSplit )
+ {
+ if( m_pShape == NULL )
+ m_pShape = Shapes.Add_Shape();
+
+ m_pShape->Del_Parts();
+ }
+ else
+ {
+ m_pShape = pShapes->Add_Shape();
+ m_pShape->Set_Value(0, Value);
+ m_pShape->Set_Value(1, pShapes->Get_Count());
+ m_pShape->Set_Value(2, ID);
+ }
+
+ //-----------------------------------------
+ Process_Set_Text(CSG_String::Format(SG_T("%s %d: %f"), _TL("vectorising class"), nClasses, Value));
+
+ Get_Class(Value);
+
+ //-----------------------------------------
+ if( bSplit )
+ {
+ Split_Polygons(pShapes, Value, ID);
+ }
+ }
+ }
+ }
+
+ Lock_Destroy();
+
+ m_Edge.Destroy();
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Classes_To_Shapes::Split_Polygons(CSG_Shapes *pShapes, double Value, const CSG_String &ID)
+{
+ if( m_pShape && m_pShape->Get_Part_Count() > 0 )
+ {
+ int iPart, iPoint, jPart, iShape;
+ CSG_Shape *pShape;
+
+ for(iPart=0; iPart<m_pShape->Get_Part_Count() && Set_Progress(iPart, m_pShape->Get_Part_Count()); iPart++)
+ {
+ if( ((CSG_Shape_Polygon *)m_pShape)->is_Clockwise(iPart) == true ) // No Lake
+ {
+ pShape = pShapes->Add_Shape();
+ pShape->Set_Value(0, Value);
+ pShape->Set_Value(1, pShapes->Get_Count());
+ pShape->Set_Value(2, ID);
+
+ for(iPoint=0; iPoint<m_pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ pShape->Add_Point(m_pShape->Get_Point(iPoint, iPart), 0);
+ }
+ }
+ }
+
+ for(iPart=0; iPart<m_pShape->Get_Part_Count() && Set_Progress(iPart, m_pShape->Get_Part_Count()); iPart++)
+ {
+ if( ((CSG_Shape_Polygon *)m_pShape)->is_Clockwise(iPart) == false ) // Lake
+ {
+ TSG_Point p = m_pShape->Get_Point(0, iPart);
+
+ for(iShape=0, jPart=0; jPart==0 && iShape<pShapes->Get_Count(); iShape++)
+ {
+ pShape = pShapes->Get_Shape(iShape);
+
+ if( pShape->asDouble(0) == Value && ((CSG_Shape_Polygon *)pShape)->is_Containing(p, 0) )
+ {
+ jPart = pShape->Get_Part_Count();
+
+ for(iPoint=0; iPoint<m_pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ pShape->Add_Point(m_pShape->Get_Point(iPoint, iPart), jPart);
+ }
+ }
+ }
+ }
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Classes_To_Shapes::Get_Class(double Value)
+{
+ int x, y, i, ix, iy, n, nEdgeCells;
+
+ //-----------------------------------------------------
+ for(y=0, nEdgeCells=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ if( !Lock_Get(x, y) && m_pGrid->asDouble(x, y) == Value )
+ {
+ Lock_Set(x, y);
+
+ for(i=0, n=0; i<8; i+=2)
+ {
+ ix = Get_xTo(i, x);
+ iy = Get_yTo(i, y);
+
+ if( !m_pGrid->is_InGrid(ix, iy) || m_pGrid->asDouble(ix, iy) != Value )
+ {
+ ix = Get_xTo(i , 1 + 2 * x);
+ iy = Get_yTo(i , 1 + 2 * y);
+ m_Edge.Set_Value(ix, iy, i + 2);
+
+ ix = Get_xTo(i - 1, 1 + 2 * x);
+ iy = Get_yTo(i - 1, 1 + 2 * y);
+ m_Edge.Set_Value(ix, iy, m_Edge.asInt(ix, iy) ? -1 : i + 2);
+
+ n++;
+ }
+ }
+
+ //-----------------------------------------
+ if( n == 4 )
+ {
+ Get_Square(1 + 2 * x, 1 + 2 * y);
+ }
+ else
+ {
+ nEdgeCells++;
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ if( nEdgeCells > 0 )
+ {
+ Get_Polygons();
+ }
+
+ return( m_pShape->Get_Part_Count() > 0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CGrid_Classes_To_Shapes::Get_Square(int x, int y)
+{
+ int i, ix, iy, iPart;
+
+ iPart = m_pShape->Get_Part_Count();
+
+ for(i=0; i<8; i++)
+ {
+ ix = Get_xTo(i, x);
+ iy = Get_yTo(i, y);
+
+ m_Edge.Set_Value(ix, iy, m_Edge.asInt(ix, iy) > 0 ? 0 : (i > 1 ? i - 1 : i + 7));
+
+ if( i % 2 )
+ {
+ m_pShape->Add_Point(m_Edge.Get_System().Get_Grid_to_World(ix, iy), iPart);
+ }
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGrid_Classes_To_Shapes::Get_Polygons(void)
+{
+ if( m_pShape )
+ {
+ for(int y=0; y<m_Edge.Get_NY() && Set_Progress(y, m_Edge.Get_NY()); y++)
+ {
+ for(int x=0; x<m_Edge.Get_NX(); x++)
+ {
+ if( m_Edge.asInt(x, y) > 0 )
+ {
+ Get_Polygon(x, y, m_pShape->Get_Part_Count());
+ }
+ }
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+void CGrid_Classes_To_Shapes::Get_Polygon(int x, int y, int iPart)
+{
+ int i, iLast;
+ int first_x = x;
+ int first_y = y;
+
+ iLast = -1;
+
+ while( (i = m_Edge.asInt(x, y)) != 0 )
+ {
+ if( i < 0 )
+ {
+ i = iLast + 2;
+
+ m_Edge.Set_Value(x, y, (iLast == 2 ? 8 : iLast - 2));
+ }
+ else
+ {
+ m_Edge.Set_Value(x, y, 0);
+ }
+
+ if( i != iLast )
+ {
+ m_pShape->Add_Point(m_Edge.Get_System().Get_Grid_to_World(x, y), iPart);
+
+ iLast = i;
+ }
+
+ x = Get_xTo(i, x);
+ y = Get_yTo(i, y);
+ }
+
+ m_pShape->Add_Point(m_Edge.Get_System().Get_Grid_to_World(first_x, first_y), iPart);
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/shapes/shapes_grid/Grid_Statistics_AddTo_Polygon.cpp b/src/modules/shapes/shapes_grid/Grid_Statistics_AddTo_Polygon.cpp
index 63ab4e3..637d38e 100644
--- a/src/modules/shapes/shapes_grid/Grid_Statistics_AddTo_Polygon.cpp
+++ b/src/modules/shapes/shapes_grid/Grid_Statistics_AddTo_Polygon.cpp
@@ -256,9 +256,9 @@ bool CGrid_Statistics_AddTo_Polygon::On_Execute(void)
}
else
{
- pRecord->Set_Value(field_CELLS , 0.0);
- pRecord->Set_Value(field_MEAN , 0.0);
- pRecord->Set_Value(field_VARI , 0.0);
+ pRecord->Set_NoData(field_CELLS);
+ pRecord->Set_NoData(field_MEAN);
+ pRecord->Set_NoData(field_VARI);
}
}
diff --git a/src/modules/shapes/shapes_grid/Makefile.am b/src/modules/shapes/shapes_grid/Makefile.am
index 34e8cfb..1669b82 100644
--- a/src/modules/shapes/shapes_grid/Makefile.am
+++ b/src/modules/shapes/shapes_grid/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.7 2009/05/28 13:08:28 oconrad Exp $
+# $Id: Makefile.am,v 1.8 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libshapes_grid.la
libshapes_grid_la_SOURCES =\
Grid_Classes_To_Shapes.cpp\
diff --git a/src/modules/shapes/shapes_grid/Makefile.in b/src/modules/shapes/shapes_grid/Makefile.in
index 9fa7a70..e483ed6 100644
--- a/src/modules/shapes/shapes_grid/Makefile.in
+++ b/src/modules/shapes/shapes_grid/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -76,7 +75,7 @@ am_libshapes_grid_la_OBJECTS = Grid_Classes_To_Shapes.lo \
Grid_Values_AddTo_Points.lo Grid_Values_AddTo_Shapes.lo \
MLB_Interface.lo
libshapes_grid_la_OBJECTS = $(am_libshapes_grid_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -122,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -131,6 +131,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -221,14 +222,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.7 2009/05/28 13:08:28 oconrad Exp $
+# $Id: Makefile.am,v 1.8 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libshapes_grid.la
libshapes_grid_la_SOURCES = \
Grid_Classes_To_Shapes.cpp\
diff --git a/src/modules/shapes/shapes_lines/Makefile.am b/src/modules/shapes/shapes_lines/Makefile.am
index daed768..f9ca9be 100644
--- a/src/modules/shapes/shapes_lines/Makefile.am
+++ b/src/modules/shapes/shapes_lines/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.7 2009/05/28 13:08:29 oconrad Exp $
+# $Id: Makefile.am,v 1.8 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libshapes_lines.la
libshapes_lines_la_SOURCES =\
Lines_From_Points.cpp\
diff --git a/src/modules/shapes/shapes_lines/Makefile.in b/src/modules/shapes/shapes_lines/Makefile.in
index 40ecd09..8e28059 100644
--- a/src/modules/shapes/shapes_lines/Makefile.in
+++ b/src/modules/shapes/shapes_lines/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -72,7 +71,7 @@ libshapes_lines_la_DEPENDENCIES = \
am_libshapes_lines_la_OBJECTS = Lines_From_Points.lo \
Lines_From_Polygons.lo line_properties.lo MLB_Interface.lo
libshapes_lines_la_OBJECTS = $(am_libshapes_lines_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -118,6 +117,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -127,6 +127,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -217,14 +218,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.7 2009/05/28 13:08:29 oconrad Exp $
+# $Id: Makefile.am,v 1.8 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libshapes_lines.la
libshapes_lines_la_SOURCES = \
Lines_From_Points.cpp\
diff --git a/src/modules/shapes/shapes_points/AddCoordinates.cpp b/src/modules/shapes/shapes_points/AddCoordinates.cpp
index af043cd..7ff6190 100644
--- a/src/modules/shapes/shapes_points/AddCoordinates.cpp
+++ b/src/modules/shapes/shapes_points/AddCoordinates.cpp
@@ -1,65 +1,77 @@
-/*******************************************************************************
- AddCoordinates.cpp
- Copyright (C) Victor Olaya
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*******************************************************************************/
-
-#include "AddCoordinates.h"
-
-
-
-CAddCoordinates::CAddCoordinates(void){
-
-
- Parameters.Set_Name(_TL("Add Coordinates to points"));
- Parameters.Set_Description(_TW(
- "(c) 2004 by Victor Olaya."));
-
- Parameters.Add_Shapes(NULL,
- "POINTS",
- _TL("Points"),
- _TL(""),
- PARAMETER_INPUT);
-
-}//constructor
-
-
-CAddCoordinates::~CAddCoordinates(void)
-{}
-
-bool CAddCoordinates::On_Execute(void){
-
- int i;
- int iXField, iYField;
-// double dDist;
- CSG_Shape *pShape;
- CSG_Shapes *pShapes = Parameters("POINTS")->asShapes();
- CSG_Table *pTable = pShapes;
-
- pTable->Add_Field("X", SG_DATATYPE_Double);
- iXField = pTable->Get_Field_Count() - 1;
- pTable->Add_Field("Y", SG_DATATYPE_Double);
- iYField = pTable->Get_Field_Count() - 1;
-
- for(i = 0; i < pShapes->Get_Count(); i++){
- pShape = pShapes->Get_Shape(i);
- pTable->Get_Record(i)->Set_Value(iXField, pShape->Get_Point(0).x);
- pTable->Get_Record(i)->Set_Value(iYField, pShape->Get_Point(0).y);
- }//for
-
- return true;
-
-}//method
+/*******************************************************************************
+ AddCoordinates.cpp
+ Copyright (C) Victor Olaya
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*******************************************************************************/
+
+#include "AddCoordinates.h"
+
+//---------------------------------------------------------
+CAddCoordinates::CAddCoordinates(void)
+{
+ Set_Name (_TL("Add Coordinates to points"));
+
+ Set_Author (SG_T("Victor Olaya (c) 2004"));
+
+ Set_Description (_TW(
+ "(c) 2004 by Victor Olaya."
+ ));
+
+ Parameters.Add_Shapes(
+ NULL, "INPUT" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Shapes(
+ NULL, "OUTPUT" , _TL("Output"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+}
+
+//---------------------------------------------------------
+bool CAddCoordinates::On_Execute(void)
+{
+ CSG_Shapes *pShapes = Parameters("OUTPUT")->asShapes();
+
+ if( pShapes )
+ {
+ pShapes->Assign(Parameters("INPUT")->asShapes());
+ }
+ else
+ {
+ pShapes = Parameters("INPUT")->asShapes();
+ }
+
+ //-----------------------------------------------------
+ int xField = pShapes->Get_Field_Count();
+ pShapes->Add_Field("X", SG_DATATYPE_Double);
+
+ int yField = pShapes->Get_Field_Count();
+ pShapes->Add_Field("Y", SG_DATATYPE_Double);
+
+ //-----------------------------------------------------
+ for(int i=0; i<pShapes->Get_Count(); i++)
+ {
+ CSG_Shape *pShape = pShapes->Get_Shape(i);
+
+ pShape->Set_Value(xField, pShape->Get_Point(0).x);
+ pShape->Set_Value(yField, pShape->Get_Point(0).y);
+ }
+
+ return( true );
+}
diff --git a/src/modules/shapes/shapes_points/AddCoordinates.h b/src/modules/shapes/shapes_points/AddCoordinates.h
index fd83733..7e26cf2 100644
--- a/src/modules/shapes/shapes_points/AddCoordinates.h
+++ b/src/modules/shapes/shapes_points/AddCoordinates.h
@@ -17,20 +17,14 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
#include "MLB_Interface.h"
-class CAddCoordinates : public CSG_Module {
-
+class CAddCoordinates : public CSG_Module
+{
public:
CAddCoordinates(void);
- virtual ~CAddCoordinates(void);
- virtual bool is_ProjectDependent(void) {return( false );}
protected:
virtual bool On_Execute(void);
-};
\ No newline at end of file
+};
diff --git a/src/modules/shapes/shapes_points/MLB_Interface.cpp b/src/modules/shapes/shapes_points/MLB_Interface.cpp
index 76adc97..77a8d71 100644
--- a/src/modules/shapes/shapes_points/MLB_Interface.cpp
+++ b/src/modules/shapes/shapes_points/MLB_Interface.cpp
@@ -98,6 +98,7 @@ const SG_Char * Get_Info(int i)
#include "remove_duplicates.h"
#include "Clip_Points.h"
#include "separate_by_direction.h"
+#include "add_polygon_attributes.h"
//---------------------------------------------------------
@@ -107,16 +108,17 @@ CSG_Module * Create_Module(int i)
{
switch( i )
{
- case 0: return( new CPoints_From_Table );
- case 1: return( new CCountPoints );
- case 2: return( new CCreatePointGrid );
- case 3: return( new CDistanceMatrix );
- case 4: return( new CFitNPointsToShape );
- case 5: return( new CPoints_From_Lines );
- case 6: return( new CAddCoordinates );
- case 7: return( new CRemove_Duplicates );
- case 8: return( new CClip_Points );
- case 9: return( new CSeparate_by_Direction );
+ case 0: return( new CPoints_From_Table );
+ case 1: return( new CCountPoints );
+ case 2: return( new CCreatePointGrid );
+ case 3: return( new CDistanceMatrix );
+ case 4: return( new CFitNPointsToShape );
+ case 5: return( new CPoints_From_Lines );
+ case 6: return( new CAddCoordinates );
+ case 7: return( new CRemove_Duplicates );
+ case 8: return( new CClip_Points );
+ case 9: return( new CSeparate_by_Direction );
+ case 10: return( new CAdd_Polygon_Attributes );
}
return( NULL );
diff --git a/src/modules/shapes/shapes_points/Makefile.am b/src/modules/shapes/shapes_points/Makefile.am
index 0dc53c7..5a3e0dc 100644
--- a/src/modules/shapes/shapes_points/Makefile.am
+++ b/src/modules/shapes/shapes_points/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.8 2008/09/26 08:53:19 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,9 +10,10 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libshapes_points.la
libshapes_points_la_SOURCES =\
+add_polygon_attributes.cpp\
AddCoordinates.cpp\
Clip_Points.cpp\
CountPoints.cpp\
@@ -24,6 +25,7 @@ Points_From_Lines.cpp\
Points_From_Table.cpp\
remove_duplicates.cpp\
separate_by_direction.cpp\
+add_polygon_attributes.h\
AddCoordinates.h\
CountPoints.h\
Clip_Points.h\
diff --git a/src/modules/shapes/shapes_points/Makefile.in b/src/modules/shapes/shapes_points/Makefile.in
index e2b4266..6b5b70b 100644
--- a/src/modules/shapes/shapes_points/Makefile.in
+++ b/src/modules/shapes/shapes_points/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -69,13 +68,13 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)"
LTLIBRARIES = $(pkglib_LTLIBRARIES)
libshapes_points_la_DEPENDENCIES = \
$(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
-am_libshapes_points_la_OBJECTS = AddCoordinates.lo Clip_Points.lo \
- CountPoints.lo CreatePointGrid.lo DistanceMatrix.lo \
- FitNPointsToShape.lo MLB_Interface.lo Points_From_Lines.lo \
- Points_From_Table.lo remove_duplicates.lo \
- separate_by_direction.lo
+am_libshapes_points_la_OBJECTS = add_polygon_attributes.lo \
+ AddCoordinates.lo Clip_Points.lo CountPoints.lo \
+ CreatePointGrid.lo DistanceMatrix.lo FitNPointsToShape.lo \
+ MLB_Interface.lo Points_From_Lines.lo Points_From_Table.lo \
+ remove_duplicates.lo separate_by_direction.lo
libshapes_points_la_OBJECTS = $(am_libshapes_points_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -121,6 +120,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -130,6 +130,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -220,16 +221,17 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.8 2008/09/26 08:53:19 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libshapes_points.la
libshapes_points_la_SOURCES = \
+add_polygon_attributes.cpp\
AddCoordinates.cpp\
Clip_Points.cpp\
CountPoints.cpp\
@@ -241,6 +243,7 @@ Points_From_Lines.cpp\
Points_From_Table.cpp\
remove_duplicates.cpp\
separate_by_direction.cpp\
+add_polygon_attributes.h\
AddCoordinates.h\
CountPoints.h\
Clip_Points.h\
@@ -337,6 +340,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Points_From_Lines.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Points_From_Table.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/add_polygon_attributes.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/remove_duplicates.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/separate_by_direction.Plo at am__quote@
diff --git a/src/modules/shapes/shapes_points/add_polygon_attributes.cpp b/src/modules/shapes/shapes_points/add_polygon_attributes.cpp
new file mode 100644
index 0000000..1bb1c38
--- /dev/null
+++ b/src/modules/shapes/shapes_points/add_polygon_attributes.cpp
@@ -0,0 +1,207 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// shapes_points //
+// //
+//-------------------------------------------------------//
+// //
+// add_polygon_attributes.cpp //
+// //
+// Copyright (C) 2009 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "add_polygon_attributes.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CAdd_Polygon_Attributes::CAdd_Polygon_Attributes(void)
+{
+ Set_Name (_TL("Add Polygon Attributes to Points"));
+
+ Set_Author (SG_T("O.Conrad (c) 2009"));
+
+ Set_Description (_TW(
+ ""
+ ));
+
+ //-----------------------------------------------------
+ Parameters.Add_Shapes(
+ NULL , "INPUT" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Shapes(
+ NULL , "OUTPUT" , _TL("Result"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point
+ );
+
+ CSG_Parameter *pNode = Parameters.Add_Shapes(
+ NULL , "POLYGONS" , _TL("Polygons"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Polygon
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "FIELD" , _TL("Attribute"),
+ _TL("Attribute to add. Select none to add all"),
+ true
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CAdd_Polygon_Attributes::On_Execute(void)
+{
+ int inField, outField;
+ CSG_Shapes *pInput, *pOutput, *pPolygons;
+
+ //-----------------------------------------------------
+ pInput = Parameters("INPUT") ->asShapes();
+ pOutput = Parameters("OUTPUT") ->asShapes();
+ pPolygons = Parameters("POLYGONS") ->asShapes();
+ inField = Parameters("FIELD") ->asInt();
+
+ //-----------------------------------------------------
+ if( !pInput->is_Valid() )
+ {
+ Message_Add(_TL("Invalid points layer."));
+
+ return( false );
+ }
+ else if( !pPolygons->is_Valid() )
+ {
+ Message_Add(_TL("Invalid polygon layer."));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ if( pOutput && pOutput != pInput )
+ {
+ pOutput->Create(*pInput);
+ }
+ else
+ {
+ Parameters("RESULT")->Set_Value(pOutput = pInput);
+ }
+
+ pOutput->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pInput->Get_Name(), pPolygons->Get_Name()));
+
+ //-----------------------------------------------------
+ outField = pOutput->Get_Field_Count();
+
+ if( inField >= 0 && inField < pPolygons->Get_Field_Count() )
+ { // add single attribute
+ pOutput->Add_Field(pPolygons->Get_Field_Name(inField), pPolygons->Get_Field_Type(inField));
+ }
+ else
+ { // add all attributes
+ inField = -1;
+
+ for(int iField=0; iField<pPolygons->Get_Field_Count(); iField++)
+ {
+ pOutput->Add_Field(pPolygons->Get_Field_Name(iField), pPolygons->Get_Field_Type(iField));
+ }
+ }
+
+ //-----------------------------------------------------
+ for(int iPoint=0; iPoint<pOutput->Get_Count() && Set_Progress(iPoint, pOutput->Get_Count()); iPoint++)
+ {
+ CSG_Shape *pPoint = pOutput ->Get_Shape(iPoint);
+ CSG_Shape *pPolygon = pPolygons ->Get_Shape(pPoint->Get_Point(0));
+
+ if( pPolygon )
+ {
+ if( inField >= 0 )
+ { // add single attribute
+ pPoint->Set_Value(outField, pPolygon->asString(inField));
+ }
+ else
+ { // add all attributes
+ for(int iField=0; iField<pPolygons->Get_Field_Count(); iField++)
+ {
+ switch( pPolygons->Get_Field_Type(iField) )
+ {
+ case SG_DATATYPE_String:
+ case SG_DATATYPE_Date:
+ pPoint->Set_Value(outField + iField, pPolygon->asString(iField));
+ break;
+
+ default:
+ pPoint->Set_Value(outField + iField, pPolygon->asDouble(iField));
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/shapes/shapes_points/add_polygon_attributes.h b/src/modules/shapes/shapes_points/add_polygon_attributes.h
new file mode 100644
index 0000000..26a04a0
--- /dev/null
+++ b/src/modules/shapes/shapes_points/add_polygon_attributes.h
@@ -0,0 +1,90 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// shapes_tools //
+// //
+//-------------------------------------------------------//
+// //
+// add_polygon_attributes.h //
+// //
+// Copyright (C) 2009 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__add_polygon_attributes_H
+#define HEADER_INCLUDED__add_polygon_attributes_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CAdd_Polygon_Attributes : public CSG_Module
+{
+public:
+ CAdd_Polygon_Attributes(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__add_polygon_attributes_H
diff --git a/src/modules/shapes/shapes_polygons/Makefile.am b/src/modules/shapes/shapes_polygons/Makefile.am
index cc907f2..ed08d9c 100644
--- a/src/modules/shapes/shapes_polygons/Makefile.am
+++ b/src/modules/shapes/shapes_polygons/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.9 2008/09/03 13:27:08 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libshapes_polygons.la
libshapes_polygons_la_SOURCES =\
MLB_Interface.cpp\
diff --git a/src/modules/shapes/shapes_polygons/Makefile.in b/src/modules/shapes/shapes_polygons/Makefile.in
index 90de76d..0d8fec6 100644
--- a/src/modules/shapes/shapes_polygons/Makefile.in
+++ b/src/modules/shapes/shapes_polygons/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -75,7 +74,7 @@ am_libshapes_polygons_la_OBJECTS = MLB_Interface.lo \
Polygon_StatisticsFromPoints.lo Polygon_Union.lo \
Polygons_From_Lines.lo polygon_to_points.lo shape_index.lo
libshapes_polygons_la_OBJECTS = $(am_libshapes_polygons_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -121,6 +120,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -130,6 +130,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -220,14 +221,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.9 2008/09/03 13:27:08 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libshapes_polygons.la
libshapes_polygons_la_SOURCES = \
MLB_Interface.cpp\
diff --git a/src/modules/shapes/shapes_polygons/Polygon_StatisticsFromPoints.cpp b/src/modules/shapes/shapes_polygons/Polygon_StatisticsFromPoints.cpp
index f8b992a..8151f3b 100644
--- a/src/modules/shapes/shapes_polygons/Polygon_StatisticsFromPoints.cpp
+++ b/src/modules/shapes/shapes_polygons/Polygon_StatisticsFromPoints.cpp
@@ -1,6 +1,7 @@
/*******************************************************************************
CPolygonStatisticsFromPoints.cpp
- Copyright (C) Victor Olaya
+ Copyright (C) 2005 Victor Olaya
+ Reworked (C) 2010 Olaf Conrad
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,221 +17,268 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
-#include "Polygon_StatisticsFromPoints.h"
-#include <string>
-#define VERY_LARGE_NUMBER 9999999999.
-#define IS_OUTSIDE -1
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
-CSG_String sParamName[] = {"[Sum]", "[Average]", "[Variance]", "[Minimum]", "[Maximum]"};
+//---------------------------------------------------------
+#include "Polygon_StatisticsFromPoints.h"
-CPolygonStatisticsFromPoints::CPolygonStatisticsFromPoints(){
-
- Parameters.Set_Name(_TL("Polygon statistics from points"));
- Parameters.Set_Description(_TW(
- "Calculates statistics using a polygon and a points layer."
- "(c) 2005 by Victor Olaya\r\nemail: volaya at ya.com")
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+enum
+{
+ STAT_Sum = 0,
+ STAT_Avg,
+ STAT_Var,
+ STAT_Dev,
+ STAT_Min,
+ STAT_Max,
+ STAT_Num,
+ STAT_Count
+};
+
+//---------------------------------------------------------
+int STAT_Flag[STAT_Count] =
+{
+ 0x01,
+ 0x02,
+ 0x04,
+ 0x08,
+ 0x10,
+ 0x20,
+ 0x40
+};
+
+//---------------------------------------------------------
+CSG_String STAT_Name[STAT_Count] =
+{
+ SG_T("Sum"),
+ SG_T("Mean"),
+ SG_T("Variance"),
+ SG_T("Deviation"),
+ SG_T("Minimum"),
+ SG_T("Maximum"),
+ SG_T("Count")
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPolygonStatisticsFromPoints::CPolygonStatisticsFromPoints(void)
+{
+ Set_Name (_TL("Point Statistics for Polygons"));
+
+ Set_Author (SG_T("V. Olaya, O. Conrad (c) 2005, 2010"));
+
+ Set_Description (_TW(
+ "Calculates statistics over all points falling in a polygon."
+ ));
+
+ Parameters.Add_Shapes(
+ NULL, "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Point
);
- Parameters.Add_Shapes(NULL,
- "POLYGONS",
- _TL("Polygons"),
- _TL(""),
- PARAMETER_INPUT);
-
- Parameters.Add_Shapes(NULL,
- "POINTS",
- _TL("Points"),
- _TL(""),
- PARAMETER_INPUT);
-
- m_pExtraParameters = Add_Parameters("EXTRA",
- _TL("Fields to add"),
- _TL(""));
-
-}//constructor
-
-CPolygonStatisticsFromPoints::~CPolygonStatisticsFromPoints(){
-
-}//destructor
-
-bool CPolygonStatisticsFromPoints::On_Execute(void){
-
- int i,j;
- m_pPoints = Parameters("POINTS")->asShapes();
- m_pPolygons = Parameters("POLYGONS")->asShapes();
- CSG_Table *pShapesTable, *pTable;
- CSG_Parameter **pExtraParameter;
- CSG_String sName;
-
- pTable = m_pPoints;
- pShapesTable = m_pPolygons;
- m_bIncludeParam = new bool [pTable->Get_Field_Count() * 5];
- pExtraParameter = new CSG_Parameter* [pTable->Get_Field_Count() * 5];
-
- for (i = 0; i < pTable->Get_Field_Count(); i++){
- for (j = 0; j < 5; j++){
- if (pTable->Get_Field_Type(i) > 1 && pTable->Get_Field_Type(i) < 7){ //is numeric field
- sName.Printf(SG_T("%s%s"),
- pTable->Get_Field_Name(i),
- SG_STR_MBTOSG(sParamName[j])
- );
+ Parameters.Add_Shapes(
+ NULL, "POLYGONS" , _TL("Polygons"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Polygon
+ );
- pExtraParameter[i * 5 + j] = m_pExtraParameters->Add_Value(
- NULL,
- SG_Get_String(i * 5 + j,0).c_str(),
- sName.c_str(),
- _TL(""),
- PARAMETER_TYPE_Bool,
- false
- );
- }//if
- }//for
- }//for
- if(Dlg_Parameters("EXTRA")){
- for (i = 0; i < pTable->Get_Field_Count() * 5; i++){
- sName = SG_Get_String(i);
- try{
- m_bIncludeParam[i] = Get_Parameters("EXTRA")->Get_Parameter(sName.c_str())->asBool();
- }//try
- catch(...){
- m_bIncludeParam[i] = false;
- }//catch
- }//for
-
- CalculateStatistics();
-
- m_pExtraParameters->Destroy();
-
- delete [] m_bIncludeParam;
-
- return true;
- }//if
-
- m_pExtraParameters->Destroy();
-
- delete [] m_bIncludeParam;
-
- return false;
-
-
-}//method
-
-void CPolygonStatisticsFromPoints::CalculateStatistics(){
-
- int i,j;
- int iPoly;
- CSG_Shape *pPoly, *pShape;
- CSG_Table *pPointsTable, *pPolygonsTable;
- CSG_Table_Record *pRecord;
- CSG_String sName;
- float *pSum;
- float *pMin;
- float *pMax;
- float *pVar;
- float fValue;
- float fMean;
- int iLastField = -1;
- int iField;
- int iParam;
-
- pPointsTable = m_pPoints;
-
- pPolygonsTable = m_pPolygons;
- pPolygonsTable->Add_Field("Count", SG_DATATYPE_Int);
- m_pClasses = new int[pPointsTable->Get_Record_Count()];
- m_pCount = new int[pPolygonsTable->Get_Record_Count()];
- pSum = new float[pPolygonsTable->Get_Record_Count()];
- pMax = new float[pPolygonsTable->Get_Record_Count()];
- pMin = new float[pPolygonsTable->Get_Record_Count()];
- pVar = new float[pPolygonsTable->Get_Record_Count()];
-
- for (i = 0; i < pPointsTable->Get_Record_Count(); i++){
- m_pClasses[i] = IS_OUTSIDE;
- }//for
-
- for(iPoly = 0; iPoly < m_pPolygons->Get_Count(); iPoly++){
- pPoly = m_pPolygons->Get_Shape(iPoly);
- for(i = 0; i < m_pPoints->Get_Count(); i++){
- pShape = m_pPoints->Get_Shape(i);
- if (((CSG_Shape_Polygon*)pPoly)->is_Containing(pShape->Get_Point(0, 0))){
- m_pClasses[i] = iPoly;
- }//if
- }//for
- }//for
-
- for (i = 0; i < pPolygonsTable->Get_Record_Count(); i++){
- if (m_pClasses[i] != IS_OUTSIDE){
- m_pCount[i] = 0;
- }//if
- }//for
-
- for (i = 0; i < pPointsTable->Get_Record_Count(); i++){
- m_pCount[m_pClasses[i]]++;
- }//for
-
- for (i = 0; i < pPolygonsTable->Get_Record_Count(); i++){
- pRecord = pPolygonsTable->Get_Record(i);
- pRecord->Set_Value(pPolygonsTable->Get_Field_Count() - 1, m_pCount[i]);
- }//for
-
- for (i = 0; i < pPointsTable->Get_Field_Count() * 5; i++){
- if (m_bIncludeParam[i]){
- iField = (int) (i / 5);
- iParam = i % 5;
- sName.Printf(SG_T("%s%s"), pPointsTable->Get_Field_Name(iField), SG_STR_MBTOSG(sParamName[iParam]));
- pPolygonsTable->Add_Field(sName.c_str(), SG_DATATYPE_Double);
- if (iField != iLastField){
- for (j = 0; j < pPolygonsTable->Get_Record_Count(); j++){
- pSum[j] = 0;
- pMax[j] = -(float)VERY_LARGE_NUMBER;
- pMin[j] = (float)VERY_LARGE_NUMBER;
- pVar[j] = 0;
- }//for
- for (j = 0; j < pPointsTable->Get_Record_Count(); j++){
- if (m_pClasses[j] != IS_OUTSIDE){
- pRecord = pPointsTable->Get_Record(j);
- fValue = pRecord->asFloat(iField);
- pSum[m_pClasses[j]] += fValue;
- pVar[m_pClasses[j]] += (fValue * fValue);
- if (fValue > pMax[m_pClasses[j]]){
- pMax[m_pClasses[j]] = fValue;
- }//if
- if (fValue < pMin[m_pClasses[j]]){
- pMin[m_pClasses[j]] = fValue;
- }//if
- }//if
- }//for
- }//if
- iField = pPolygonsTable->Get_Field_Count() - 1;
- for (j = 0; j < pPolygonsTable->Get_Record_Count(); j++){
- pRecord = pPolygonsTable->Get_Record(j);
- switch (iParam){
- case 0: //sum
- pRecord->Set_Value(iField, pSum[j]);
- break;
- case 1: //average
- pRecord->Set_Value(iField, pSum[j] / (float) m_pCount[j]);
- break;
- case 2: //variance
- fMean = pSum[j] / (float) m_pCount[j];
- pRecord->Set_Value(iField, pVar[j] / (float) m_pCount[j] - fMean * fMean);
- break;
- case 3: //min
- pRecord->Set_Value(iField, pMin[j]);
- break;
- case 4: //max
- pRecord->Set_Value(iField, pMax[j]);
- break;
- default:
- break;
- }//switch
- }//for
-
- }//if
-
- }//for
-
-}//method
+ Parameters.Add_Shapes(
+ NULL, "STATISTICS" , _TL("Statistics"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon
+ );
+ Add_Parameters("ATTRIBUTES", _TL("Attributes"), _TL(""));
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPolygonStatisticsFromPoints::On_Execute(void)
+{
+ int i, j, n, Offset, *bAttribute;
+ CSG_Simple_Statistics *Statistics;
+ CSG_Parameters *pParameters;
+ CSG_Shapes *pPolygons, *pPoints;
+
+ //-----------------------------------------------------
+ pPoints = Parameters("POINTS") ->asShapes();
+ pPolygons = Parameters("POLYGONS") ->asShapes();
+
+ if( pPolygons->Get_Count() <= 0 || pPoints->Get_Count() <= 0 )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ pParameters = Get_Parameters("ATTRIBUTES");
+
+ pParameters->Del_Parameters();
+
+ for(i=0; i<pPoints->Get_Field_Count(); i++)
+ {
+ if( SG_Data_Type_is_Numeric(pPoints->Get_Field_Type(i)) )
+ {
+ CSG_Parameter *pNode = pParameters->Add_Node(NULL, CSG_String::Format(SG_T("%d"), i), pPoints->Get_Field_Name(i), _TL(""));
+
+ for(j=0; j<STAT_Count; j++)
+ {
+ pParameters->Add_Value(pNode,
+ CSG_String::Format(SG_T("%d|%d"), i, j),
+ CSG_String::Format(SG_T("[%s]"), STAT_Name[j].c_str()),
+ _TL(""), PARAMETER_TYPE_Bool, false
+ );
+ }
+ }
+ }
+
+ if( !Dlg_Parameters("ATTRIBUTES") )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ if( Parameters("STATISTICS")->asShapes() == NULL )
+ {
+ Parameters("STATISTICS")->Set_Value(pPolygons);
+ }
+ else if( pPolygons != Parameters("STATISTICS")->asShapes() )
+ {
+ Parameters("STATISTICS")->asShapes()->Assign(pPolygons);
+
+ pPolygons = Parameters("STATISTICS")->asShapes();
+ }
+
+ //-----------------------------------------------------
+ bAttribute = new int[pPoints->Get_Field_Count()];
+ Offset = pPolygons->Get_Field_Count();
+
+ for(i=0, n=0; i<pPoints->Get_Field_Count(); i++)
+ {
+ bAttribute[i] = 0;
+
+ if( SG_Data_Type_is_Numeric(pPoints->Get_Field_Type(i)) )
+ {
+ for(j=0; j<STAT_Count; j++)
+ {
+ CSG_Parameter *pParameter = pParameters->Get_Parameter(CSG_String::Format(SG_T("%d|%d"), i, j));
+
+ if( pParameter && pParameter->asBool() )
+ {
+ bAttribute[i] |= STAT_Flag[j];
+
+ pPolygons->Add_Field(CSG_String::Format(SG_T("%s_%s"), pPoints->Get_Field_Name(i), STAT_Name[j].c_str()), SG_DATATYPE_Double);
+
+ n++;
+ }
+ }
+ }
+ }
+
+ if( n == 0 )
+ {
+ delete[](bAttribute);
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Statistics = new CSG_Simple_Statistics[pPoints->Get_Field_Count()];
+
+ for(int iPolygon=0; iPolygon<pPolygons->Get_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++)
+ {
+ CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon);
+
+ //-------------------------------------------------
+ for(i=0; i<pPoints->Get_Field_Count(); i++)
+ {
+ Statistics[i].Invalidate();
+ }
+
+ //-------------------------------------------------
+ for(int iPoint=0; iPoint<pPoints->Get_Count() && Process_Get_Okay(); iPoint++)
+ {
+ CSG_Shape *pPoint = pPoints->Get_Shape(iPoint);
+
+ if( pPolygon->is_Containing(pPoint->Get_Point(0)) )
+ {
+ for(i=0; i<pPoints->Get_Field_Count(); i++)
+ {
+ if( bAttribute[i] )
+ {
+ Statistics[i].Add_Value(pPoint->asDouble(i));
+ }
+ }
+ }
+ }
+
+ //-------------------------------------------------
+ for(i=0, n=Offset; i<pPoints->Get_Field_Count(); i++)
+ {
+ if( bAttribute[i] )
+ {
+ if( Statistics[i].Get_Count() > 0 )
+ {
+ if( bAttribute[i] & STAT_Flag[STAT_Sum] ) { pPolygon->Set_Value(n++, Statistics[i].Get_Sum()); }
+ if( bAttribute[i] & STAT_Flag[STAT_Avg] ) { pPolygon->Set_Value(n++, Statistics[i].Get_Mean()); }
+ if( bAttribute[i] & STAT_Flag[STAT_Var] ) { pPolygon->Set_Value(n++, Statistics[i].Get_Variance()); }
+ if( bAttribute[i] & STAT_Flag[STAT_Dev] ) { pPolygon->Set_Value(n++, Statistics[i].Get_StdDev()); }
+ if( bAttribute[i] & STAT_Flag[STAT_Min] ) { pPolygon->Set_Value(n++, Statistics[i].Get_Minimum()); }
+ if( bAttribute[i] & STAT_Flag[STAT_Max] ) { pPolygon->Set_Value(n++, Statistics[i].Get_Maximum()); }
+ if( bAttribute[i] & STAT_Flag[STAT_Num] ) { pPolygon->Set_Value(n++, Statistics[i].Get_Count()); }
+ }
+ else
+ {
+ if( bAttribute[i] & STAT_Flag[STAT_Sum] ) { pPolygon->Set_NoData(n++); }
+ if( bAttribute[i] & STAT_Flag[STAT_Avg] ) { pPolygon->Set_NoData(n++); }
+ if( bAttribute[i] & STAT_Flag[STAT_Var] ) { pPolygon->Set_NoData(n++); }
+ if( bAttribute[i] & STAT_Flag[STAT_Dev] ) { pPolygon->Set_NoData(n++); }
+ if( bAttribute[i] & STAT_Flag[STAT_Min] ) { pPolygon->Set_NoData(n++); }
+ if( bAttribute[i] & STAT_Flag[STAT_Max] ) { pPolygon->Set_NoData(n++); }
+ if( bAttribute[i] & STAT_Flag[STAT_Num] ) { pPolygon->Set_NoData(n++); }
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ delete[](Statistics);
+ delete[](bAttribute);
+
+ DataObject_Update(pPolygons);
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules/shapes/shapes_polygons/Polygon_StatisticsFromPoints.h b/src/modules/shapes/shapes_polygons/Polygon_StatisticsFromPoints.h
index abb0cf1..9d6fe30 100644
--- a/src/modules/shapes/shapes_polygons/Polygon_StatisticsFromPoints.h
+++ b/src/modules/shapes/shapes_polygons/Polygon_StatisticsFromPoints.h
@@ -17,32 +17,50 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*******************************************************************************/
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__PolygonStatisticsFromPoints_H
+#define HEADER_INCLUDED__PolygonStatisticsFromPoints_H
+
+//---------------------------------------------------------
#include "MLB_Interface.h"
-class CPolygonStatisticsFromPoints : public CSG_Module {
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPolygonStatisticsFromPoints : public CSG_Module
+{
public:
CPolygonStatisticsFromPoints(void);
- virtual ~CPolygonStatisticsFromPoints(void);
- virtual bool is_ProjectDependent(void) {return( false );}
+
protected:
- virtual bool On_Execute(void);
-private:
+ virtual bool On_Execute (void);
- bool *m_bIncludeParam;
- int *m_pClasses;
- int *m_pCount;
- CSG_Shapes *m_pPolygons, *m_pPoints;
- CSG_Parameters *m_pExtraParameters;
- void AddPointDataToPolygon(CSG_Shape*, CSG_Shape*);
- void CalculateStatistics();
+private:
+
};
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__PolygonStatisticsFromPoints_H
diff --git a/src/modules/shapes/shapes_tools/CreateChartLayer.cpp b/src/modules/shapes/shapes_tools/CreateChartLayer.cpp
index e97789b..dec4b06 100644
--- a/src/modules/shapes/shapes_tools/CreateChartLayer.cpp
+++ b/src/modules/shapes/shapes_tools/CreateChartLayer.cpp
@@ -143,7 +143,6 @@ bool CCreateChartLayer::On_Execute(void){
bool CCreateChartLayer::GetExtraParameters(){
int i;
- CSG_Table *pShapesTable;
CSG_Shapes *pInput;
CSG_Parameter *pParam;
CSG_String sName;
@@ -151,21 +150,36 @@ bool CCreateChartLayer::GetExtraParameters(){
pInput = Parameters("INPUT")->asShapes();
- pShapesTable = pInput;
- m_bIncludeParam = new bool [pShapesTable->Get_Field_Count() ];
-
- for (i = 0; i < pShapesTable->Get_Field_Count(); i++){
- if (pShapesTable->Get_Field_Type(i) > 1 && pShapesTable->Get_Field_Type(i) < 7){ //is numeric field
- m_pExtraParameters->Add_Value(NULL,
- SG_Get_String(i,0).c_str(),
- pShapesTable->Get_Field_Name(i),
- _TL(""),
- PARAMETER_TYPE_Bool,
- false);
- }//if
+ m_pExtraParameters->Create(this, _TL("Fields for diagram"), _TL(""), SG_T("EXTRA"));
+
+ m_bIncludeParam = new bool [pInput->Get_Field_Count() ];
+
+ for (i = 0; i < pInput->Get_Field_Count(); i++)
+ {
+ switch( pInput->Get_Field_Type(i) )
+ {
+ default:
+ break;
+
+ case SG_DATATYPE_Byte:
+ case SG_DATATYPE_Char:
+ case SG_DATATYPE_Word:
+ case SG_DATATYPE_Short:
+ case SG_DATATYPE_DWord:
+ case SG_DATATYPE_Int:
+ case SG_DATATYPE_ULong:
+ case SG_DATATYPE_Long:
+ case SG_DATATYPE_Float:
+ case SG_DATATYPE_Double: // is numeric field
+ m_pExtraParameters->Add_Value(
+ NULL, SG_Get_String(i,0).c_str(), pInput->Get_Field_Name(i), _TL(""), PARAMETER_TYPE_Bool, false
+ );
+ break;
+ }
}//for
+
if(Dlg_Parameters("EXTRA")){
- for (i = 0; i < pShapesTable->Get_Field_Count(); i++){
+ for (i = 0; i < pInput->Get_Field_Count(); i++){
sName = SG_Get_String(i,0);
if (pParam = Get_Parameters("EXTRA")->Get_Parameter(sName.c_str())){
m_bIncludeParam[i] = pParam->asBool();
diff --git a/src/modules/shapes/shapes_tools/GraticuleBuilder.cpp b/src/modules/shapes/shapes_tools/GraticuleBuilder.cpp
index b7a4737..70e4532 100644
--- a/src/modules/shapes/shapes_tools/GraticuleBuilder.cpp
+++ b/src/modules/shapes/shapes_tools/GraticuleBuilder.cpp
@@ -115,33 +115,51 @@ bool CGraticuleBuilder::On_Execute(void){
CSG_Shapes *pGraticule = Parameters("LINES")->asShapes();
- if (iType == 0){
+ if (iType == 0)
+ {
pGraticule->Create(SHAPE_TYPE_Line, _TL("Graticule"));
pGraticule->Add_Field("ID", SG_DATATYPE_Int);
- for (x=dXMin; x<dXMax; x=x+dDistanceX){
+
+ for (x=dXMin; x<=dXMax; x=x+dDistanceX)
+ {
pShape = pGraticule->Add_Shape();
- pShape->Add_Point(x,dYMin);
- pShape->Add_Point(x,dYMax);
pShape->Set_Value(0,iElement++);
+
+ for (y=dYMin; y<=dYMax; y=y+dDistanceY)
+ {
+ pShape->Add_Point(x,y);
+ pShape->Add_Point(x,y);
+ }
}//for
- for (y=dYMin; y<dYMax; y=y+dDistanceY){
+
+ for (y=dYMin; y<=dYMax; y=y+dDistanceY)
+ {
pShape = pGraticule->Add_Shape();
- pShape->Add_Point(dXMin,y);
- pShape->Add_Point(dXMax,y);
pShape->Set_Value(0,iElement++);
+
+ for (x=dXMin; x<=dXMax; x=x+dDistanceX)
+ {
+ pShape->Add_Point(x,y);
+ pShape->Add_Point(x,y);
+ }
}//for
}//if
- else{
+ else
+ {
pGraticule->Create(SHAPE_TYPE_Polygon, _TL("Graticule"));
pGraticule->Add_Field("ID", SG_DATATYPE_Int);
- for (x=dXMin; x<dXMax-dDistanceX; x=x+dDistanceX){
- for (y=dYMin; y<dYMax-dDistanceY; y=y+dDistanceY){
+
+ for (x=dXMin; x<=dXMax-dDistanceX; x=x+dDistanceX)
+ {
+ for (y=dYMin; y<=dYMax-dDistanceY; y=y+dDistanceY)
+ {
pShape = pGraticule->Add_Shape();
+ pShape->Set_Value(0,iElement++);
+
pShape->Add_Point(x,y);
pShape->Add_Point(x,y+dDistanceY);
pShape->Add_Point(x+dDistanceX,y+dDistanceY);
pShape->Add_Point(x+dDistanceX,y);
- pShape->Set_Value(0,iElement++);
}//for
}//for
}//else
diff --git a/src/modules/shapes/shapes_tools/Makefile.am b/src/modules/shapes/shapes_tools/Makefile.am
index 1f912ac..f04483e 100644
--- a/src/modules/shapes/shapes_tools/Makefile.am
+++ b/src/modules/shapes/shapes_tools/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.14 2009/08/17 13:01:53 oconrad Exp $
+# $Id: Makefile.am,v 1.15 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libshapes_tools.la
libshapes_tools_la_SOURCES =\
CreateChartLayer.cpp\
diff --git a/src/modules/shapes/shapes_tools/Makefile.in b/src/modules/shapes/shapes_tools/Makefile.in
index feb7687..dbca321 100644
--- a/src/modules/shapes/shapes_tools/Makefile.in
+++ b/src/modules/shapes/shapes_tools/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -80,7 +79,7 @@ am_libshapes_tools_la_OBJECTS = CreateChartLayer.lo \
shapes_cut_interactive.lo shapes_extents.lo shapes_split.lo \
shapes_split_by_attribute.lo shapes_split_randomly.lo
libshapes_tools_la_OBJECTS = $(am_libshapes_tools_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -126,6 +125,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -135,6 +135,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -225,14 +226,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.14 2009/08/17 13:01:53 oconrad Exp $
+# $Id: Makefile.am,v 1.15 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libshapes_tools.la
libshapes_tools_la_SOURCES = \
CreateChartLayer.cpp\
diff --git a/src/modules/shapes/shapes_tools/QueryBuilder.cpp b/src/modules/shapes/shapes_tools/QueryBuilder.cpp
index 081c74c..26e28f8 100644
--- a/src/modules/shapes/shapes_tools/QueryBuilder.cpp
+++ b/src/modules/shapes/shapes_tools/QueryBuilder.cpp
@@ -1,116 +1,133 @@
-/*******************************************************************************
- QueryBuilder.cpp
- Copyright (C) Victor Olaya
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*******************************************************************************/
-#include "QueryBuilder.h"
-#include "QueryParser.h"
-
-#define METHOD_NEW_SEL 0
-#define METHOD_ADD_TO_SEL 1
-#define METHOD_SELECT_FROM_SEL 2
-
-CQueryBuilder::CQueryBuilder(void){
-
- Parameters.Set_Name(_TL("Query builder for shapes"));
-
- Parameters.Set_Description(_TW("(c) 2004 by Victor Olaya. Query builder for shapes"));
-
- Parameters.Add_Shapes(NULL,
- "SHAPES",
- _TL("Shapes"),
- _TL(""),
- PARAMETER_INPUT);
-
- Parameters.Add_String(NULL, "QUERY", _TL("Expression"), _TL(""), _TL(""));
-
- Parameters.Add_Choice(NULL,
- "METHOD",
- _TL("Method"),
- _TL(""),
- _TW(
- "New selection|"
- "Add to current selection|"
- "Select from current selection|"),
- 0);
-
-}//constructor
-
-CQueryBuilder::~CQueryBuilder(void){}
-
-bool CQueryBuilder::On_Execute(void){
-
- CSG_Shapes* pShapes;
- CSG_Table *pTable;
- CSG_String sExpression;
- CQueryParser *pParser;
- bool *pRecordWasSelected;
- int *pSelectedRecords;
- int iNumSelectedRecords = 0;
- int iMethod;
- int iRecord;
- int i;
-
- pShapes = Parameters("SHAPES")->asShapes();
- pTable = pShapes;
- sExpression = Parameters("QUERY")->asString();
- iMethod = Parameters("METHOD")->asInt();
-
- pRecordWasSelected = new bool[pTable->Get_Record_Count()];
-
- if (iMethod == METHOD_SELECT_FROM_SEL){
- for (i = 0; i < pTable->Get_Record_Count(); i++){
- if (pTable->Get_Record(i)->is_Selected()){
- pRecordWasSelected[i] = true;
- }//if
- else{
- pRecordWasSelected[i] = false;
- }//else
- }//for
- }//if
-
- if (iMethod != METHOD_ADD_TO_SEL){
- for (i = 0; i < pTable->Get_Record_Count(); i++){
- if (pTable->Get_Record(i)->is_Selected()){
- pTable->Select(i, true);
- }//if
- }//for
- }//if
-
- pParser = new CQueryParser(pShapes, sExpression);
- pSelectedRecords = &pParser->GetSelectedRecords();
- iNumSelectedRecords = pParser->GetSelectedRecordsCount();
-
- for (i = 0; i < iNumSelectedRecords; i++){
- iRecord = pSelectedRecords[i];
- if (!pTable->Get_Record(iRecord)->is_Selected()){
- if (iMethod == METHOD_SELECT_FROM_SEL){
- if (pRecordWasSelected[iRecord]){
- pTable->Select(iRecord, true);
- }//if
- }//if
- else{
- pTable->Select(iRecord, true);
- }//else
- }//if
- }//for
-
- DataObject_Update(pShapes, true);
- //DataObject_Update(pTable, false);
-
- return true;
-
-}//method
+/*******************************************************************************
+ QueryBuilder.cpp
+ Copyright (C) Victor Olaya
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*******************************************************************************/
+#include "QueryBuilder.h"
+#include "QueryParser.h"
+
+#define METHOD_NEW_SEL 0
+#define METHOD_ADD_TO_SEL 1
+#define METHOD_SELECT_FROM_SEL 2
+
+CQueryBuilder::CQueryBuilder(void){
+
+ Parameters.Set_Name(_TL("Query builder for shapes"));
+
+ Parameters.Set_Description(_TW("(c) 2004 by Victor Olaya. Query builder for shapes"));
+
+ Parameters.Add_Shapes(NULL,
+ "SHAPES",
+ _TL("Shapes"),
+ _TL(""),
+ PARAMETER_INPUT);
+
+ Parameters.Add_String(NULL, "QUERY", _TL("Expression"), _TL(""), _TL(""));
+
+ Parameters.Add_Choice(NULL,
+ "METHOD",
+ _TL("Method"),
+ _TL(""),
+ _TW(
+ "New selection|"
+ "Add to current selection|"
+ "Select from current selection|"),
+ 0);
+
+}//constructor
+
+CQueryBuilder::~CQueryBuilder(void){}
+
+bool CQueryBuilder::On_Execute(void){
+
+ CSG_Shapes *pShapes;
+ CSG_Table *pTable;
+ CSG_String sExpression;
+ CQueryParser *pParser;
+ bool *pRecordWasSelected;
+ int *pSelectedRecords;
+ int iNumSelectedRecords = 0;
+ int iMethod;
+ int iRecord;
+ int i;
+
+ pShapes = Parameters("SHAPES")->asShapes();
+ pTable = Parameters("SHAPES")->asTable();
+ sExpression = Parameters("QUERY")->asString();
+ iMethod = Parameters("METHOD")->asInt();
+
+ pRecordWasSelected = new bool[pTable->Get_Record_Count()];
+
+ if (iMethod == METHOD_SELECT_FROM_SEL){
+ for (i = 0; i < pTable->Get_Record_Count(); i++){
+ if (pTable->Get_Record(i)->is_Selected()){
+ pRecordWasSelected[i] = true;
+ }//if
+ else{
+ pRecordWasSelected[i] = false;
+ }//else
+ }//for
+ }//if
+
+ if (iMethod != METHOD_ADD_TO_SEL){
+ for (i = 0; i < pTable->Get_Record_Count(); i++){
+ if (pTable->Get_Record(i)->is_Selected()){
+ pTable->Select(i, true);
+ }//if
+ }//for
+ }//if
+
+ pParser = new CQueryParser(pShapes, sExpression);
+ if( pParser->is_Initialized() )
+ {
+ iNumSelectedRecords = pParser->GetSelectedRecordsCount();
+
+ if( iNumSelectedRecords <= 0 )
+ {
+ SG_UI_Msg_Add(_TL("No records selected."), true);
+ delete (pRecordWasSelected);
+ return (true);
+ }
+
+ pSelectedRecords = &pParser->GetSelectedRecords();
+
+ for (i = 0; i < iNumSelectedRecords; i++){
+ iRecord = pSelectedRecords[i];
+ if (!pTable->Get_Record(iRecord)->is_Selected()){
+ if (iMethod == METHOD_SELECT_FROM_SEL){
+ if (pRecordWasSelected[iRecord]){
+ pTable->Select(iRecord, true);
+ }//if
+ }//if
+ else{
+ pTable->Select(iRecord, true);
+ }//else
+ }//if
+ }//for
+
+ pTable = NULL;
+ DataObject_Update(pShapes, true);
+
+ delete (pRecordWasSelected);
+ return (true);
+ }
+ else
+ {
+ delete (pRecordWasSelected);
+ return (false);
+ }
+
+}//method
diff --git a/src/modules/shapes/shapes_tools/QueryParser.cpp b/src/modules/shapes/shapes_tools/QueryParser.cpp
index ae12940..ad1b72f 100644
--- a/src/modules/shapes/shapes_tools/QueryParser.cpp
+++ b/src/modules/shapes/shapes_tools/QueryParser.cpp
@@ -1,67 +1,103 @@
-/*******************************************************************************
- QueryParser.cpp
- Copyright (C) Victor Olaya
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*******************************************************************************/
-
-#include "QueryParser.h"
-
-CQueryParser::CQueryParser(CSG_Shapes *pShapes, CSG_String sExpression){
-
- CSG_Formula Formula;
- int i,j;
- int iFields;
- CSG_Table *pTable;
- CSG_Table_Record *pRecord;
- double *pFieldValues;
- double dValue;
-
- pTable = pShapes;
- iFields = pTable->Get_Field_Count();
- Formula.Set_Formula(sExpression.c_str());
- pFieldValues= new double[iFields];
-
- for (i = 0; i < pTable->Get_Record_Count(); i++){
- pRecord = pTable->Get_Record(i);
- for (j = 0; j < iFields; j++){
- pFieldValues[j] = pRecord->asDouble(j);
- }//for
- dValue = Formula.Get_Value(pFieldValues, iFields);
- if (dValue){
- m_pSelectedRecords.push_back(i);
- }//if
- }//for
-
-}//constructor
-
-CQueryParser::~CQueryParser(){
-
- //delete [] m_pSelectedFields;
-
-}//destructor
-
-int& CQueryParser::GetSelectedRecords(){
-
- return m_pSelectedRecords[0];
-
-}//method
-
-int CQueryParser::GetSelectedRecordsCount(){
-
- return m_pSelectedRecords.size();
- //m_iSelectedFieldsCount;
-
-}//method
+/*******************************************************************************
+ QueryParser.cpp
+ Copyright (C) Victor Olaya
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*******************************************************************************/
+
+#include "QueryParser.h"
+
+CQueryParser::CQueryParser(CSG_Shapes *pShapes, CSG_String sExpression){
+
+ CSG_Formula Formula;
+ int i,j;
+ int iFields;
+ CSG_Table *pTable;
+ CSG_Table_Record *pRecord;
+ double *pFieldValues;
+ double dValue;
+
+ m_bInit = false;
+ pTable = pShapes;
+ iFields = pTable->Get_Field_Count();
+
+ //-----------------------------------------------------
+ if( !Formula.Set_Formula(sExpression.c_str()) )
+ {
+ int Position;
+ CSG_String Message, s;
+
+ s += _TL("Error in formula");
+ s += SG_T("\n") + Formula.Get_Formula();
+
+ if( Formula.Get_Error(&Position, &Message) )
+ {
+ s += SG_T("\n") + Message;
+ s += CSG_String::Format(SG_T("\n%s: %d"), _TL("Position") , Position);
+
+ if( Position >= 0 && Position < (int)Formula.Get_Formula().Length() )
+ {
+ s += SG_T("\n")
+ + Formula.Get_Formula().Left(Position - 1) + SG_T("[")
+ + Formula.Get_Formula()[Position] + SG_T("]")
+ + Formula.Get_Formula().Right(Formula.Get_Formula().Length() - (Position + 1));
+ }
+ }
+
+ SG_UI_Msg_Add_Error(s);
+ }
+ else
+ {
+ pFieldValues= new double[iFields];
+
+ for (i = 0; i < pTable->Get_Record_Count(); i++){
+ pRecord = pTable->Get_Record(i);
+ for (j = 0; j < iFields; j++){
+ pFieldValues[j] = pRecord->asDouble(j);
+ }//for
+ dValue = Formula.Get_Value(pFieldValues, iFields);
+ if (dValue){
+ m_pSelectedRecords.push_back(i);
+ }//if
+ }//for
+
+ m_bInit = true;
+ }
+}//constructor
+
+CQueryParser::~CQueryParser(){
+
+ //delete [] m_pSelectedFields;
+
+}//destructor
+
+int& CQueryParser::GetSelectedRecords(){
+
+ return m_pSelectedRecords[0];
+
+}//method
+
+int CQueryParser::GetSelectedRecordsCount(){
+
+ return m_pSelectedRecords.size();
+ //m_iSelectedFieldsCount;
+
+}//method
+
+
+bool CQueryParser::is_Initialized()
+{
+ return (m_bInit);
+}
\ No newline at end of file
diff --git a/src/modules/shapes/shapes_tools/QueryParser.h b/src/modules/shapes/shapes_tools/QueryParser.h
index 8e8902b..4f0e09a 100644
--- a/src/modules/shapes/shapes_tools/QueryParser.h
+++ b/src/modules/shapes/shapes_tools/QueryParser.h
@@ -1,41 +1,43 @@
-/*******************************************************************************
- QueryParser.h
- Copyright (C) Victor Olaya
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*******************************************************************************/
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-#include <saga_api/saga_api.h>
-#include <vector>
-
-class CQueryParser
-{
-public:
-
- CQueryParser(CSG_Shapes*, CSG_String);
- virtual ~CQueryParser();
- int& GetSelectedRecords();
- int GetSelectedRecordsCount();
-
-private:
-
- std::vector <int> m_pSelectedRecords;
-
-};
-
+/*******************************************************************************
+ QueryParser.h
+ Copyright (C) Victor Olaya
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*******************************************************************************/
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#include <saga_api/saga_api.h>
+#include <vector>
+
+class CQueryParser
+{
+public:
+
+ CQueryParser(CSG_Shapes*, CSG_String);
+ virtual ~CQueryParser();
+ int& GetSelectedRecords();
+ int GetSelectedRecordsCount();
+ bool is_Initialized();
+
+private:
+
+ std::vector<int> m_pSelectedRecords;
+ bool m_bInit;
+
+};
+
diff --git a/src/modules/shapes/shapes_transect/MLB_Interface.cpp b/src/modules/shapes/shapes_transect/MLB_Interface.cpp
new file mode 100644
index 0000000..aca5f79
--- /dev/null
+++ b/src/modules/shapes/shapes_transect/MLB_Interface.cpp
@@ -0,0 +1,135 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Transect //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.cpp //
+// //
+// Copyright (C) 2009 by //
+// Johan Van de Wauw //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// The Module Link Library Interface //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+// 1. Include the appropriate SAGA-API header...
+
+#include "MLB_Interface.h"
+
+
+//---------------------------------------------------------
+// 2. Place general module library informations here...
+
+const SG_Char * Get_Info(int i)
+{
+ switch( i )
+ {
+ case MLB_INFO_Name: default:
+ return( _TL("Shapes - Transects" ));
+
+ case MLB_INFO_Author:
+ return( _TL("Johan Van de Wauw (c) 2009" ));
+
+ case MLB_INFO_Description:
+ return( _TL("A SAGA module to create transects through polygon files." ));
+
+ case MLB_INFO_Version:
+ return( SG_T("1.0") );
+
+ case MLB_INFO_Menu_Path:
+ return( _TL("Shapes|Lines|Transects" ));
+ }
+}
+
+
+//---------------------------------------------------------
+// 3. Include the headers of your modules here...
+
+#include "Polygon_Transect.h"
+
+
+//---------------------------------------------------------
+// 4. Allow your modules to be created here...
+
+CSG_Module * Create_Module(int i)
+{
+ // Don't forget to continuously enumerate the case switches
+ // when adding new modules! Also bear in mind that the
+ // enumeration always has to start with [case 0:] and
+ // that [default:] must return NULL!...
+
+ CSG_Module *pModule;
+
+ switch( i )
+ {
+ case 0:
+ pModule = new CPolygon_Transect;
+ break;
+
+ default:
+ pModule = NULL;
+ break;
+ }
+
+ return( pModule );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+//{{AFX_SAGA
+
+ MLB_INTERFACE
+
+//}}AFX_SAGA
diff --git a/src/modules/shapes/shapes_transect/MLB_Interface.h b/src/modules/shapes/shapes_transect/MLB_Interface.h
new file mode 100644
index 0000000..0a8fdce
--- /dev/null
+++ b/src/modules/shapes/shapes_transect/MLB_Interface.h
@@ -0,0 +1,82 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Shapes Transect //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.h //
+// //
+// Copyright (C) 2009 by //
+// Johan Van de Wauw //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// Include the SAGA-API here //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__transect_H
+#define HEADER_INCLUDED__transect_H
+
+//---------------------------------------------------------
+#include <saga_api/saga_api.h>
+
+//---------------------------------------------------------
+#ifdef transect_EXPORTS
+ #define transect_EXPORT _SAGA_DLL_EXPORT
+#else
+ #define transect_EXPORT _SAGA_DLL_IMPORT
+#endif
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__transect_H
diff --git a/src/modules/shapes/shapes_transect/Makefile.am b/src/modules/shapes/shapes_transect/Makefile.am
new file mode 100644
index 0000000..c4bebda
--- /dev/null
+++ b/src/modules/shapes/shapes_transect/Makefile.am
@@ -0,0 +1,22 @@
+#
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:48 johanvdw Exp $
+#
+if DEBUG
+DBGFLAGS = -g -DDEBUG
+endif
+if SAGA_UNICODE
+UC_DEFS = -D_SAGA_UNICODE
+endif
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -avoid-version -avoid-version
+pkglib_LTLIBRARIES = libtransect.la
+libtransect_la_SOURCES =\
+Polygon_Transect.h\
+MLB_Interface.h\
+Polygon_Transect.cpp\
+MLB_Interface.cpp
+
+libtransect_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+
diff --git a/src/modules/shapes/shapes_transect/Makefile.in b/src/modules/shapes/shapes_transect/Makefile.in
new file mode 100644
index 0000000..0e951e9
--- /dev/null
+++ b/src/modules/shapes/shapes_transect/Makefile.in
@@ -0,0 +1,544 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/modules/shapes/shapes_transect
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+libtransect_la_DEPENDENCIES = \
+ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+am_libtransect_la_OBJECTS = Polygon_Transect.lo MLB_Interface.lo
+libtransect_la_OBJECTS = $(am_libtransect_la_OBJECTS)
+DEFAULT_INCLUDES = -I. at am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libtransect_la_SOURCES)
+DIST_SOURCES = $(libtransect_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+HARU_LIB = @HARU_LIB@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POW_LIB = @POW_LIB@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:48 johanvdw Exp $
+#
+ at DEBUG_TRUE@DBGFLAGS = -g -DDEBUG
+ at SAGA_UNICODE_TRUE@UC_DEFS = -D_SAGA_UNICODE
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -avoid-version -avoid-version
+pkglib_LTLIBRARIES = libtransect.la
+libtransect_la_SOURCES = \
+Polygon_Transect.h\
+MLB_Interface.h\
+Polygon_Transect.cpp\
+MLB_Interface.cpp
+
+libtransect_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/modules/shapes/shapes_transect/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/modules/shapes/shapes_transect/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \
+ }
+
+uninstall-pkglibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \
+ done
+
+clean-pkglibLTLIBRARIES:
+ -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+ @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libtransect.la: $(libtransect_la_OBJECTS) $(libtransect_la_DEPENDENCIES)
+ $(CXXLINK) -rpath $(pkglibdir) $(libtransect_la_OBJECTS) $(libtransect_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Polygon_Transect.Plo at am__quote@
+
+.cpp.o:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+ at am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(pkglibdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+ 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 uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+
+# 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:
diff --git a/src/modules/shapes/shapes_transect/Polygon_Transect.cpp b/src/modules/shapes/shapes_transect/Polygon_Transect.cpp
new file mode 100644
index 0000000..e6d38d8
--- /dev/null
+++ b/src/modules/shapes/shapes_transect/Polygon_Transect.cpp
@@ -0,0 +1,276 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Transect //
+// //
+//-------------------------------------------------------//
+// //
+// Polygon_Transect.cpp //
+// //
+// Copyright (C) 2009 by //
+// Johan Van de Wauw //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "Polygon_Transect.h"
+#include <map>
+#include <list>
+
+using std::map;
+using std::list;
+using std::pair;
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPolygon_Transect::CPolygon_Transect(void)
+{
+ //-----------------------------------------------------
+ // Give some information about your module...
+
+ Set_Name (_TL("Transect through polygon shapefile"));
+
+ Set_Author (_TL("Copyrights (c) 2009 Johan Van de Wauw"));
+
+ Set_Description (_TW(
+ "Transect for lines and polygon shapefiles\n"
+ "\n"
+ "The goal of this module is to create a transect along a line through a polygon map.\n"
+ "Eg\n"
+ "\n"
+ "|____ST1_____!_ST2_!__ST1__!_______ST#_____|\n"
+ "\n"
+ "(Soil type 1 etc...)\n"
+ "\n"
+ "This is done by creating a table with the ID of each line, the distance \n"
+ "to the starting point and the different transects:\n"
+ "\n"
+ "<pre>| line_id | start | end | code/field |\n"
+ "| 0 | 0 | 124 | ST1 |\n"
+ "| 0 | 124 | 300 | ST2 |\n"
+ "| 0 | 300 | 1223 | ST1 |\n"
+ "| 0 | 1223 | 2504 | ST3 |\n"
+ "| 1 | 0 | 200 | ST4 |\n"
+ "| ... | ... | ... | ... |</pre>\n"
+ "\n"
+ "\n"
+ "The module requires an input shape with all the line transects [Transect_Line] \n"
+ "and a polygon theme [Theme]. You also have to select which field you want to have in \n"
+ "the resulting table [Transect_Result]. This can be an ID of the polygon theme if you \n"
+ "want to link the tables later on, or any other field [Theme_Field].\n")
+ );
+
+
+ //-----------------------------------------------------
+ // Define your parameters list...
+ CSG_Parameter *pTheme;
+ Parameters.Add_Shapes(
+ NULL, "TRANSECT", _TL("Line Transect(s)"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Line
+ );
+
+ pTheme = Parameters.Add_Shapes(
+ NULL, "THEME", _TL("Theme"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Polygon
+ );
+
+ Parameters.Add_Table_Field(
+ pTheme , "THEME_FIELD" , _TL("Theme Field"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+ Parameters.Add_Table(
+ NULL, "TRANSECT_RESULT", _TL("Result table"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+}
+
+//---------------------------------------------------------
+CPolygon_Transect::~CPolygon_Transect(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPolygon_Transect::On_Execute(void)
+{
+ CSG_Table *pTransect_Result;
+ CSG_Shapes *pTheme, *pTransect;
+
+ CSG_Shape_Line *pLine;
+ CSG_Shape_Polygon *pTheme_Shape;
+ int Theme_Field;
+
+ pTransect = Parameters("TRANSECT")->asShapes();
+ pTheme = Parameters("THEME")->asShapes();
+
+ pTransect_Result = Parameters("TRANSECT_RESULT")->asTable();
+ Theme_Field = Parameters("THEME_FIELD")->asInt();
+
+ //-----------------------------------------------------
+ // Check for valid parameter settings...
+ //-----------------------------------------------------
+ if (pTheme->Get_Type() != SHAPE_TYPE_Polygon){
+ Error_Set(CSG_String("[THEME] is not a polygon file"));
+ return(false);
+ }
+ if (pTransect->Get_Type() != SHAPE_TYPE_Line){
+ Error_Set(CSG_String("[TRANSECT] is not a line shapefile"));
+ return(false);
+ }
+ if (pTheme->Get_Count() ==0 || pTransect->Get_Count()==0)
+ {
+ Error_Set(CSG_String("[TRANSECT] or [THEME] is empty"));
+ return(false);
+ }
+ if (!(pTheme->Get_Extent().Intersects(pTransect->Get_Extent())))
+ {
+ Error_Set(CSG_String("[TRANSECT] and [THEME] do not intersect"));
+ return(false);
+ }
+
+ const int LINE_ID = pTransect_Result->Get_Field_Count();
+ pTransect_Result->Add_Field(SG_T("line_id"), SG_DATATYPE_Int);
+ const int START = pTransect_Result->Get_Field_Count();
+ pTransect_Result->Add_Field(SG_T("start"), SG_DATATYPE_Double);
+ const int END = pTransect_Result->Get_Field_Count();
+ pTransect_Result->Add_Field(SG_T("end"), SG_DATATYPE_Double);
+ const int POLY_ID = pTransect_Result->Get_Field_Count();
+ pTransect_Result->Add_Field(SG_T("poly_id"), SG_DATATYPE_Int);
+ const int FIELD = pTransect_Result->Get_Field_Count();
+ pTransect_Result->Add_Field(SG_T("field"), pTheme->Get_Field_Type(Theme_Field));
+
+ // Short description of the algorithm:
+ // For every line it is checked whether it crosses a polygon. If it does,
+ // the points where it crosses are recorded in the map LineBorders, with
+ // the polygon_id as key.
+
+ for (int iLine=0; iLine<pTransect->Get_Count() && Set_Progress(iLine, pTransect->Get_Count());
+ iLine++)
+ {
+ pLine =(CSG_Shape_Line *) pTransect->Get_Shape(iLine);
+ for (int iLinePart=0;iLinePart<pLine->Get_Part_Count();iLinePart++)
+ {
+ CSG_Shape_Part *pLinePart =pLine->Get_Part(iLinePart);
+ CSG_Rect LinePartExtent = pLinePart->Get_Extent();
+ map<int,list<double> > LineBorders;
+ for (int iShape=0; iShape<pTheme->Get_Count();iShape++)
+ {
+ pTheme_Shape = (CSG_Shape_Polygon *) pTheme->Get_Shape(iShape);
+ if (pLinePart->Get_Extent().Intersects(pTheme_Shape->Get_Extent())>0)
+ {
+ for (int iPart=0; iPart<pTheme_Shape->Get_Part_Count(); iPart++)
+ {
+ CSG_Shape_Polygon_Part *pPart = (CSG_Shape_Polygon_Part *) pTheme_Shape->Get_Part(iPart);
+ if (pPart->is_Containing(pLinePart->Get_Point(0)))
+ LineBorders[iShape].push_back(0);
+ if (pPart->is_Containing(pLinePart->Get_Point(pLinePart->Get_Count())))
+ LineBorders[iShape].push_back(pLine->Get_Length(iLinePart));
+ for (int iPoint=0; iPoint<pPart->Get_Count();iPoint++)
+ {
+ int iPoint2 = (iPoint!=pPart->Get_Count()-1)?iPoint+1:0;
+ TSG_Point Crossing;
+ double Length=0;
+ for (int iLinePartPoint=0; iLinePartPoint<pLinePart->Get_Count(); iLinePartPoint++)
+ {
+ if (SG_Get_Crossing(Crossing,pPart->Get_Point(iPoint),pPart->Get_Point(iPoint2),
+ pLinePart->Get_Point(iLinePartPoint), pLinePart->Get_Point(iLinePartPoint+1)))
+ {
+ LineBorders[iShape].push_back(Length+SG_Get_Distance(Crossing, pLinePart->Get_Point(iLinePartPoint)));
+ }
+ Length+=SG_Get_Distance(pLinePart->Get_Point(iLinePartPoint), pLinePart->Get_Point(iLinePartPoint+1));
+ }
+ }
+ }
+ }
+ }
+ // convert LineBorders to the result table
+ // the table contains the lineids and the distance to the origin of the line,
+ // and it is sorted by lineid, polygonid
+ CSG_Table_Record *pRecord;
+ for (map<int,list<double> >::iterator shapeit=LineBorders.begin();shapeit!=LineBorders.end();++shapeit)
+ {
+ //shapeit->second.sort();
+ bool start=1;
+ for (list<double>::iterator i=shapeit->second.begin(); i!=shapeit->second.end();++i)
+ {
+ if (start){
+ pRecord =pTransect_Result->Add_Record();
+ pRecord->Set_Value(LINE_ID, iLine);
+ pRecord->Set_Value(START, *i);
+ pRecord->Set_Value(POLY_ID, shapeit->first);
+ CSG_Table_Record *pTheme_Record =pTheme->Get_Shape(shapeit->first) ;
+ if(pTheme->Get_Field_Type(Theme_Field)== SG_DATATYPE_String )
+ pRecord->Set_Value(FIELD, pTheme_Record->asString(Theme_Field));
+ else
+ pRecord->Set_Value(FIELD, pTheme_Record->asDouble(Theme_Field));
+ start = 0;
+ }
+ else
+ {
+ pRecord->Set_Value(END, *i);
+ start=1;
+ }
+ }
+ }
+ }
+ }
+ return( true );
+}
diff --git a/src/modules/shapes/shapes_transect/Polygon_Transect.h b/src/modules/shapes/shapes_transect/Polygon_Transect.h
new file mode 100644
index 0000000..d481f49
--- /dev/null
+++ b/src/modules/shapes/shapes_transect/Polygon_Transect.h
@@ -0,0 +1,88 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Transect //
+// //
+//-------------------------------------------------------//
+// //
+// Polygon_Transect.h //
+// //
+// Copyright (C) 2009 by //
+// Johan Van de Wauw //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Polygon_Transect_H
+#define HEADER_INCLUDED__Polygon_Transect_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+//---------------------------------------------------------
+class CPolygon_Transect : public CSG_Module
+{
+public: ////// public members and functions: //////////////
+
+ CPolygon_Transect(void); // constructor
+ virtual ~CPolygon_Transect(void); // destructor
+
+
+protected: /// protected members and functions: ///////////
+
+ virtual bool On_Execute(void); // always override this function
+
+
+private: ///// private members and functions: /////////////
+
+
+};
+
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Polygon_Transect_H
diff --git a/src/modules/table/Makefile.in b/src/modules/table/Makefile.in
index 305b091..205263f 100644
--- a/src/modules/table/Makefile.in
+++ b/src/modules/table/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules/table/table_calculus/Makefile.am b/src/modules/table/table_calculus/Makefile.am
index 8f69d14..0205cd4 100644
--- a/src/modules/table/table_calculus/Makefile.am
+++ b/src/modules/table/table_calculus/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.6 2009/01/16 14:18:44 oconrad Exp $
+# $Id: Makefile.am,v 1.7 2010/07/08 14:11:48 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libtable_calculus.la
libtable_calculus_la_SOURCES =\
Fit.cpp\
diff --git a/src/modules/table/table_calculus/Makefile.in b/src/modules/table/table_calculus/Makefile.in
index 8144463..b091176 100644
--- a/src/modules/table/table_calculus/Makefile.in
+++ b/src/modules/table/table_calculus/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,7 +72,7 @@ am_libtable_calculus_la_OBJECTS = Fit.lo LMFit.lo MLB_Interface.lo \
Table_Calculator.lo Table_CalculatorShapes.lo \
table_running_average.lo Table_Trend.lo
libtable_calculus_la_OBJECTS = $(am_libtable_calculus_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +128,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,14 +219,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.6 2009/01/16 14:18:44 oconrad Exp $
+# $Id: Makefile.am,v 1.7 2010/07/08 14:11:48 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libtable_calculus.la
libtable_calculus_la_SOURCES = \
Fit.cpp\
diff --git a/src/modules/table/table_tools/Makefile.am b/src/modules/table/table_tools/Makefile.am
index 665d217..7ebc588 100644
--- a/src/modules/table/table_tools/Makefile.am
+++ b/src/modules/table/table_tools/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:21 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libtable_tools.la
libtable_tools_la_SOURCES =\
MLB_Interface.cpp\
diff --git a/src/modules/table/table_tools/Makefile.in b/src/modules/table/table_tools/Makefile.in
index 2564517..e0aafd7 100644
--- a/src/modules/table/table_tools/Makefile.in
+++ b/src/modules/table/table_tools/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -72,7 +71,7 @@ libtable_tools_la_DEPENDENCIES = \
am_libtable_tools_la_OBJECTS = MLB_Interface.lo Table_Create_Empty.lo \
Table_Enumerate.lo Table_Rotate.lo
libtable_tools_la_OBJECTS = $(am_libtable_tools_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -118,6 +117,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -127,6 +127,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -217,14 +218,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:21 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libtable_tools.la
libtable_tools_la_SOURCES = \
MLB_Interface.cpp\
diff --git a/src/modules/tin/Makefile.in b/src/modules/tin/Makefile.in
index 49d8dde..b2e0be5 100644
--- a/src/modules/tin/Makefile.in
+++ b/src/modules/tin/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules/tin/tin_tools/Makefile.am b/src/modules/tin/tin_tools/Makefile.am
index 5229180..21dc894 100644
--- a/src/modules/tin/tin_tools/Makefile.am
+++ b/src/modules/tin/tin_tools/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:21 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:48 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libtin_tools.la
libtin_tools_la_SOURCES =\
MLB_Interface.cpp\
diff --git a/src/modules/tin/tin_tools/Makefile.in b/src/modules/tin/tin_tools/Makefile.in
index eb5bbb0..b769b48 100644
--- a/src/modules/tin/tin_tools/Makefile.in
+++ b/src/modules/tin/tin_tools/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -74,7 +73,7 @@ am_libtin_tools_la_OBJECTS = MLB_Interface.lo TIN_Flow_Parallel.lo \
TIN_From_Grid_Specific_Points.lo TIN_From_Shapes.lo \
TIN_Gradient.lo TIN_To_Shapes.lo
libtin_tools_la_OBJECTS = $(am_libtin_tools_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -120,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -129,6 +129,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -219,14 +220,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:21 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:48 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libtin_tools.la
libtin_tools_la_SOURCES = \
MLB_Interface.cpp\
diff --git a/src/modules/tin/tin_tools/TIN_To_Shapes.cpp b/src/modules/tin/tin_tools/TIN_To_Shapes.cpp
index 1830acc..a321eb5 100644
--- a/src/modules/tin/tin_tools/TIN_To_Shapes.cpp
+++ b/src/modules/tin/tin_tools/TIN_To_Shapes.cpp
@@ -171,7 +171,7 @@ bool CTIN_To_Shapes::On_Execute(void)
//-----------------------------------------------------
pShapes = Parameters("EDGES") ->asShapes();
- pShapes->Create(SHAPE_TYPE_Line, CSG_String::Format(_TL("%s [TIN]"), pTIN->Get_Name()));
+ pShapes->Create(SHAPE_TYPE_Line, CSG_String::Format(_TL("%s [TIN Edges]"), pTIN->Get_Name()));
pShapes->Add_Field("ID" , SG_DATATYPE_Int);
pShapes->Add_Field("POINT_ID_A" , SG_DATATYPE_Int);
@@ -192,7 +192,7 @@ bool CTIN_To_Shapes::On_Execute(void)
//-----------------------------------------------------
pShapes = Parameters("TRIANGLES") ->asShapes();
- pShapes->Create(SHAPE_TYPE_Polygon, CSG_String::Format(_TL("%s [TIN]"), pTIN->Get_Name()));
+ pShapes->Create(SHAPE_TYPE_Polygon, CSG_String::Format(_TL("%s [TIN Triangles]"), pTIN->Get_Name()));
pShapes->Add_Field("ID" , SG_DATATYPE_Int);
pShapes->Add_Field("POINT_ID_A" , SG_DATATYPE_Int);
@@ -216,7 +216,7 @@ bool CTIN_To_Shapes::On_Execute(void)
//-----------------------------------------------------
pShapes = Parameters("CENTER") ->asShapes();
- pShapes->Create(SHAPE_TYPE_Point, CSG_String::Format(_TL("%s [TIN]"), pTIN->Get_Name()));
+ pShapes->Create(SHAPE_TYPE_Point, CSG_String::Format(_TL("%s [TIN Centroids]"), pTIN->Get_Name()));
pShapes->Add_Field("ID" , SG_DATATYPE_Int);
pShapes->Add_Field("POINT_ID_A" , SG_DATATYPE_Int);
@@ -240,7 +240,7 @@ bool CTIN_To_Shapes::On_Execute(void)
CSG_Points Points;
pShapes = Parameters("POLYGONS") ->asShapes();
- pShapes->Create(SHAPE_TYPE_Polygon, CSG_String::Format(_TL("%s [TIN]"), pTIN->Get_Name()));
+ pShapes->Create(SHAPE_TYPE_Polygon, CSG_String::Format(_TL("%s [TIN Voronoi]"), pTIN->Get_Name()));
pShapes->Add_Field("POINT_ID", SG_DATATYPE_Int);
for(j=0; j<pTIN->Get_Field_Count(); j++)
diff --git a/src/modules_contrib/Makefile.am b/src/modules_contrib/Makefile.am
index 2e43c7f..d7074e4 100644
--- a/src/modules_contrib/Makefile.am
+++ b/src/modules_contrib/Makefile.am
@@ -1 +1 @@
-SUBDIRS = contrib_a_perego
+SUBDIRS = contrib_a_perego contrib_s_liersch
diff --git a/src/modules_contrib/Makefile.in b/src/modules_contrib/Makefile.in
index 47b3fe2..d64935f 100644
--- a/src/modules_contrib/Makefile.in
+++ b/src/modules_contrib/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -202,7 +203,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = contrib_a_perego
+SUBDIRS = contrib_a_perego contrib_s_liersch
all: all-recursive
.SUFFIXES:
diff --git a/src/modules_contrib/contrib_a_perego/Makefile.in b/src/modules_contrib/contrib_a_perego/Makefile.in
index 3877eb0..aae53c5 100644
--- a/src/modules_contrib/contrib_a_perego/Makefile.in
+++ b/src/modules_contrib/contrib_a_perego/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile.am b/src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile.am
index 7383372..a64acd9 100644
--- a/src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile.am
+++ b/src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.1 2007/08/01 13:46:40 oconrad Exp $
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:50 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libcontrib_a_perego.la
libcontrib_a_perego_la_SOURCES =\
A1WiTh.cpp\
diff --git a/src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile.in b/src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile.in
index 44a7ec5..0fbc9f5 100644
--- a/src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile.in
+++ b/src/modules_contrib/contrib_a_perego/contrib_a_perego/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,7 +72,7 @@ am_libcontrib_a_perego_la_OBJECTS = A1WiTh.lo A2WiTh.lo A3WiTh.lo \
AvWiMa1.lo AvWiMa2.lo destriping1.lo destriping2.lo \
directional1.lo MLB_Interface.lo
libcontrib_a_perego_la_OBJECTS = $(am_libcontrib_a_perego_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +128,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,14 +219,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.1 2007/08/01 13:46:40 oconrad Exp $
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:50 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libcontrib_a_perego.la
libcontrib_a_perego_la_SOURCES = \
A1WiTh.cpp\
diff --git a/src/modules_contrib/contrib_s_liersch/Makefile.am b/src/modules_contrib/contrib_s_liersch/Makefile.am
new file mode 100644
index 0000000..9ee970b
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = ihacres
diff --git a/src/modules_contrib/contrib_s_liersch/Makefile.in b/src/modules_contrib/contrib_s_liersch/Makefile.in
new file mode 100644
index 0000000..92f123c
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/Makefile.in
@@ -0,0 +1,556 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/modules_contrib/contrib_s_liersch
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+ distdir
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+HARU_LIB = @HARU_LIB@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POW_LIB = @POW_LIB@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = ihacres
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/modules_contrib/contrib_s_liersch/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/modules_contrib/contrib_s_liersch/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+ install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+ all all-am check check-am clean clean-generic clean-libtool \
+ ctags ctags-recursive distclean distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ 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-recursive \
+ uninstall uninstall-am
+
+
+# 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:
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/MLB_Interface.cpp b/src/modules_contrib/contrib_s_liersch/ihacres/MLB_Interface.cpp
new file mode 100644
index 0000000..b651035
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/MLB_Interface.cpp
@@ -0,0 +1,197 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ihacres //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.cpp //
+// //
+// Copyright (C) 2003 by //
+// Author //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: author at email.de //
+// //
+// contact: Author //
+// Sesame Street. 7 //
+// 12345 Metropolis //
+// Nirvana //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// The Module Link Library Interface //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+// 1. Include the appropriate SAGA-API header...
+
+#include "MLB_Interface.h"
+
+
+//---------------------------------------------------------
+// 2. Place general module library informations here...
+
+const SG_Char * Get_Info(int i)
+{
+ switch( i )
+ {
+ case MLB_INFO_Name: default:
+ return( _TL("Simulation - Hydrology: IHACRES") );
+
+ case MLB_INFO_Author:
+ return( SG_T("Stefan Liersch (c) 2008") );
+
+ case MLB_INFO_Description:
+ return( _TW(
+ "The metric conceptual rainfall-runoff model <b>IHACRES</b> "
+ "(Identification of unit Hydrographs and Component flows "
+ "from Rainfall, Evaporation and Streamflow data) has been "
+ "implemented as a module library. The IHACRES model was "
+ "developed by: Jakeman, A.J. and G.M. Hornberger (1993); Jakeman et al. (1990).\n"
+ "\n"
+ "<b>Purpose</b>\n"
+ "The module can be used to simulate streamflow (catchment runoff) "
+ "on the basis of daily rainfall and temperature data. No spatial "
+ "data, such as elevation models, soil or land use maps are required.\n"
+ "\n"
+ "IHACRES has been applied to catchments with a wide range of climatologies "
+ "and sizes (Croke et al., 2004). It has been used to predict streamflow in "
+ "ungauged catchments (Kokkonen et al., 2003; Post and Jakeman, 1999; "
+ "Post et al., 1998), to study land cover effects on hydrologic processes "
+ "(Croke et al., 2004; Kokkonen and Jakeman, 2002), and to investigate dynamic "
+ "response characteristics and physical catchment descriptors (Kokkonen et al., "
+ "2003; Sefton and Howarth, 1998).\n"
+ "\n"
+ "More recently, the model has been used to develop a "
+ "<a target=\"_blank\" href=\"http://www.ufz.de/index.php?en=17175\">rainfall-runoff database</a> "
+ "for flood risk assessment and forecasting by Liersch, S. and M. Volk (2008) "
+ "(<a target=\"_blank\" href=\"http://www.iemss.org/iemss2008/uploads/Main/S05-12_Liersch_et_al-IEMSS2008.pdf\">pdf</a>).\n"
+ "\n"
+ "<b>References</b>\n<ul>"
+ "<li>Croke, B.F.W., Merritt, W.S., Jakeman, A.J., 2004. A dynamic model for predicting hydrologic response to land cover changes in gauged and ungauged catchments. Journal Of Hydrology 291 (1), 115-31.</li>\n"
+ "<li>Jakeman, A.J., Littlewood, I.G., Whitehead, P.G., 1990. Computation of the instantaneous unit hydrograph and identifiable component flows with application to two small upland catchments. Journal of Hydrology 117 (1-4), 275-300.</li>\n"
+ "<li>Jakeman, A.J. and Hornberger, G.M., 1993. How Much Complexity Is Warranted in a Rainfall-Runoff Model?. Water Resources Research 29 (8), 2637-49.</li>\n"
+ "<li>Kokkonen, T.S., Jakeman, A.J., Young, P.C., Koivusalo, H.J., 2003. Predicting daily flows in ungauged catchments: model regionalization from catchment descriptors at the Coweeta Hydrologic Laboratory. North Carolina Hydrological Processes 17 (11), 2219-38.</li>\n"
+ "<li>Kokkonen, T.S. and Jakeman, A.J., 2002. Structural Effects of Landscape and Land Use on Streamflow Response. In: Environmental Foresight and Models: A Manifesto, 303-321.</li>\n"
+ "<li>Liersch, S. and M. Volk, 2008. A rainfall-runoff database to support flood risk assessment. iEMSs 2008: International Congress on Environmental Modelling and Software. In: M. Sànchez-Marrè, J. Béjar, J. Comas, A. Rizzoli and G. Guariso (Eds.): Proceedings of the iEMSs Fourth Biennial Meeting: International Congress on Environmental Modelling and Software (iEMSs 2008). International Environmental Modelling and Software Society, Barcelona, Catalonia, July 2008. Vol. 1: 494-502. ISBN: 978-84-7653-074-0. (PEER reviewed).</li>\n"
+ "<li>Post, D.A. and Jakeman, A.J., 1999. Predicting the daily streamflow of ungauged catchments in S.E. Australia by regionalising the parameters of a lumped conceptual rainfall-runoff model. Ecological Modelling 123 (2-3), 91-104.</li>\n"
+ "<li>Post, D.A., Jones, J.A. and Grant, G.E., 1998. An improved methodology for predicting the daily hydrologic response of ungauged catchments. Environmental Modelling & Software 13 (3-4), 395-403.</li>\n"
+ "<li>Sefton, C.E.M. and Howarth, S.M., 1998. Relationships between dynamic response characteristics and physical descriptors of catchments in England and Wales. Journal of Hydrology 211 (1-4), 1-16.</li>\n"
+ "</ul>"
+ ));
+
+ case MLB_INFO_Version:
+ return( SG_T("1.0") );
+
+ case MLB_INFO_Menu_Path:
+ return( _TL("Simulation|Hydrology|IHACRES") );
+ }
+}
+
+
+//---------------------------------------------------------
+// 3. Include the headers of your modules here...
+
+//#include "ihacres_cal.h"
+#include "ihacres_cal2.h"
+#include "ihacres_v1.h"
+#include "ihacres_elev.h"
+#include "ihacres_elev_cal.h"
+//#include "ihacres_climate_scen.h"
+//#include "ihacres_climate_scen_db.h"
+#include "ihacres_basin.h"
+//#include "ihacres_auto_cal.h"
+
+//---------------------------------------------------------
+// 4. Allow your modules to be created here...
+
+CSG_Module * Create_Module(int i)
+{
+ // Don't forget to continuously enumerate the case switches
+ // when adding new modules! Also bear in mind that the
+ // enumeration always has to start with [case 0:] and
+ // that [default:] must return NULL!...
+
+ CSG_Module *pModule;
+
+ switch( i )
+ {
+ //case 0:
+ // pModule = new Cihacres_cal;
+ // break;
+ case 0:
+ pModule = new Cihacres_cal2;
+ break;
+ case 1:
+ pModule = new Cihacres_v1;
+ break;
+ case 2:
+ pModule = new Cihacres_basin;
+ break;
+ case 3:
+ pModule = new Cihacres_elev;
+ break;
+ case 4:
+ pModule = new Cihacres_elev_cal;
+ break;
+ //case 6:
+ // pModule = new Cihacres_climate_scen;
+ // break;
+ //case 7:
+ // pModule = new Cihacres_climate_scen_db;
+ // break;
+
+ default:
+ pModule = NULL;
+ break;
+ }
+
+ return( pModule );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+//{{AFX_SAGA
+
+ MLB_INTERFACE
+
+//}}AFX_SAGA
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/MLB_Interface.h b/src/modules_contrib/contrib_s_liersch/ihacres/MLB_Interface.h
new file mode 100644
index 0000000..f6fb895
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/MLB_Interface.h
@@ -0,0 +1,98 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// IHACRES //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.h //
+// //
+// Copyright (C) 2003 by //
+// Author //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: author at email.de //
+// //
+// contact: Author //
+// Sesame Street. 7 //
+// 12345 Metropolis //
+// Nirvana //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+/* $Log: MLB_Interface.h,v $
+/* Revision 1.2 2009/10/29 19:45:11 reklov_w
+/* fixed to compile on linux
+/*
+/* Revision 1.1 2009/10/20 07:40:39 oconrad
+/* no message
+/*
+/* Revision 1.1.1.1 2005/08/31 14:00:48 oconrad
+/* no message
+/*
+/* Revision 1.1.1.1 2005/08/17 08:25:03 oconrad
+/* no message
+/*
+/* Revision 1.1.1.1 2005/08/15 13:35:24 oconrad
+/* no message
+/*
+ */
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__ihacres_H
+#define HEADER_INCLUDED__ihacres_H
+
+//---------------------------------------------------------
+#include <saga_api/saga_api.h>
+
+//---------------------------------------------------------
+#ifdef ihacres_noDB_EXPORTS
+ #define ihacres_noDB_EXPORT _SAGA_DLL_EXPORT
+#else
+ #define ihacres_noDB_EXPORT _SAGA_DLL_IMPORT
+#endif
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__ihacres_H
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/Makefile.am b/src/modules_contrib/contrib_s_liersch/ihacres/Makefile.am
new file mode 100644
index 0000000..de28e42
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/Makefile.am
@@ -0,0 +1,40 @@
+#
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:48 johanvdw Exp $
+#
+if DEBUG
+DBGFLAGS = -g -DDEBUG
+endif
+if SAGA_UNICODE
+UC_DEFS = -D_SAGA_UNICODE
+endif
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -avoid-version
+pkglib_LTLIBRARIES = libihacres.la
+libihacres_la_SOURCES =\
+convert_sl.cpp\
+ihacres_basin.cpp\
+ihacres_cal2.cpp\
+ihacres_elev.cpp\
+ihacres_elev_bands.cpp\
+ihacres_elev_cal.cpp\
+ihacres_eq.cpp\
+ihacres_v1.cpp\
+MLB_Interface.cpp\
+model_tools.cpp\
+snow_module.cpp\
+convert_sl.h\
+ihacres_basin.h\
+ihacres_cal2.h\
+ihacres_elev.h\
+ihacres_elev_bands.h\
+ihacres_elev_cal.h\
+ihacres_eq.h\
+ihacres_v1.h\
+MLB_Interface.h\
+model_tools.h\
+snow_module.h
+
+libihacres_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/Makefile.in b/src/modules_contrib/contrib_s_liersch/ihacres/Makefile.in
new file mode 100644
index 0000000..0e16aa6
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/Makefile.in
@@ -0,0 +1,574 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/modules_contrib/contrib_s_liersch/ihacres
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+libihacres_la_DEPENDENCIES = \
+ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+am_libihacres_la_OBJECTS = convert_sl.lo ihacres_basin.lo \
+ ihacres_cal2.lo ihacres_elev.lo ihacres_elev_bands.lo \
+ ihacres_elev_cal.lo ihacres_eq.lo ihacres_v1.lo \
+ MLB_Interface.lo model_tools.lo snow_module.lo
+libihacres_la_OBJECTS = $(am_libihacres_la_OBJECTS)
+DEFAULT_INCLUDES = -I. at am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libihacres_la_SOURCES)
+DIST_SOURCES = $(libihacres_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+HARU_LIB = @HARU_LIB@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POW_LIB = @POW_LIB@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:48 johanvdw Exp $
+#
+ at DEBUG_TRUE@DBGFLAGS = -g -DDEBUG
+ at SAGA_UNICODE_TRUE@UC_DEFS = -D_SAGA_UNICODE
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -avoid-version
+pkglib_LTLIBRARIES = libihacres.la
+libihacres_la_SOURCES = \
+convert_sl.cpp\
+ihacres_basin.cpp\
+ihacres_cal2.cpp\
+ihacres_elev.cpp\
+ihacres_elev_bands.cpp\
+ihacres_elev_cal.cpp\
+ihacres_eq.cpp\
+ihacres_v1.cpp\
+MLB_Interface.cpp\
+model_tools.cpp\
+snow_module.cpp\
+convert_sl.h\
+ihacres_basin.h\
+ihacres_cal2.h\
+ihacres_elev.h\
+ihacres_elev_bands.h\
+ihacres_elev_cal.h\
+ihacres_eq.h\
+ihacres_v1.h\
+MLB_Interface.h\
+model_tools.h\
+snow_module.h
+
+libihacres_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/modules_contrib/contrib_s_liersch/ihacres/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/modules_contrib/contrib_s_liersch/ihacres/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \
+ }
+
+uninstall-pkglibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \
+ done
+
+clean-pkglibLTLIBRARIES:
+ -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+ @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libihacres.la: $(libihacres_la_OBJECTS) $(libihacres_la_DEPENDENCIES)
+ $(CXXLINK) -rpath $(pkglibdir) $(libihacres_la_OBJECTS) $(libihacres_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/convert_sl.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ihacres_basin.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ihacres_cal2.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ihacres_elev.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ihacres_elev_bands.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ihacres_elev_cal.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ihacres_eq.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ihacres_v1.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/model_tools.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/snow_module.Plo at am__quote@
+
+.cpp.o:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+ at am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(pkglibdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+ 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 uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+
+# 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:
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/convert_sl.cpp b/src/modules_contrib/contrib_s_liersch/ihacres/convert_sl.cpp
new file mode 100644
index 0000000..f4889a7
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/convert_sl.cpp
@@ -0,0 +1,141 @@
+#include "convert_sl.h"
+
+//---------------------------------------------------------------------
+//
+// DATA TYPE
+// CONVERTING FUNCTIONS
+//
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+// Converting a string to an integer value
+int convert_sl::StringToInt(string str)
+{
+ int i;
+
+ sscanf(str.c_str(),"%d",&i);
+ return i;
+}
+//---------------------------------------------------------------------
+
+
+//---------------------------------------------------------------------
+// Converting a string to a double value
+
+double convert_sl::StringToDouble (string s)
+{
+ // function adopted from:
+ // http://episteme.arstechnica.com/groupee/forums/a/tpc/f/6330927813/m/736000556631/p/2
+ double d_return_value;
+ istringstream iss(s);
+
+ // Extract a double from the input string stream
+ iss >> d_return_value;
+ if (iss.fail())
+ {
+ return -9999.0;
+ }
+
+ return d_return_value;
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+// Any number to string
+//---------------------------------------------------------------------
+
+string convert_sl::Number2String(double d)
+{
+ std::ostringstream s;
+ s << d;
+ return(s.str());
+}
+//---------------------------------------------------------------------
+
+string convert_sl::Number2String(float f)
+{
+ std::ostringstream s;
+ s << f;
+ return(s.str());
+}
+//---------------------------------------------------------------------
+
+string convert_sl::Number2String(int i)
+{
+ std::ostringstream s;
+ s << i;
+ return(s.str());
+}
+//---------------------------------------------------------------------
+
+string convert_sl::Number2String(long l)
+{
+ std::ostringstream s;
+ s << l;
+ return(s.str());
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+
+string convert_sl::Double2String(double d)
+{
+ std::ostringstream s;
+ s << d;
+ return(s.str());
+}
+//---------------------------------------------------------------------
+
+string convert_sl::Float2String(float f)
+{
+ std::ostringstream s;
+ s << f;
+ return(s.str());
+}
+//---------------------------------------------------------------------
+
+string convert_sl::Int2String(int i)
+{
+ // Bjarne Stroustrup's C++ Style and Technique FAQ
+ // http://www.research.att.com/~bs/bs_faq2.html#int-to-string
+ std::ostringstream s;
+ s << i;
+ return(s.str());
+}
+//---------------------------------------------------------------------
+
+bool convert_sl::StringToBool(string str)
+{
+ if ( (str.substr(0,1) == "0") ||
+ (str == "false") ||
+ (str == "FALSE") ||
+ (str == "False") ||
+ (str == "f") ||
+ (str == "F") )
+ {
+ return(false);
+ } else {
+ return(true);
+ }
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+// Converting a date string 'YYYYMMDD' to three separate integer values
+
+void convert_sl::Get_Date_Int(string date, int &year, int &month, int &day)
+{
+ year = StringToInt(date.substr(0,4));
+ month = StringToInt(date.substr(4,2));
+ day = StringToInt(date.substr(6,2));
+ // divide date string to year, month, and day string
+ //string y(date.c_str(),0,4);
+ //string m(date.c_str(),4,2);
+ //string d(date.c_str(),6,2);
+
+ //// convert to integer
+ //sscanf(y.c_str(),"%d",&year);
+ //sscanf(m.c_str(),"%d",&month);
+ //sscanf(d.c_str(),"%d",&day);
+}
+//---------------------------------------------------------------------
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/convert_sl.h b/src/modules_contrib/contrib_s_liersch/ihacres/convert_sl.h
new file mode 100644
index 0000000..a1b5489
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/convert_sl.h
@@ -0,0 +1,64 @@
+#ifndef __convert_sl_h
+#define __convert_sl_h
+
+#include <iostream>
+#include <string>
+#include <sstream> // function StringToDouble
+#ifdef _SAGA_LINUX
+ #include <cstdio>
+#endif
+
+using std::string;
+using std::istringstream; // function StringToDouble
+using std::stringstream; // used by function Double2String(), Int2String()
+
+
+namespace convert_sl
+{
+
+ // if a string is a char* then:
+ // sprintf(myString, "%d", myInt);
+ // or:
+ // _itoa(myInt, myString, 10);
+
+ //---------------------------------------------------------------------
+ // Converting a string to an integer value
+ int StringToInt(string str);
+
+ //---------------------------------------------------------------------
+ // Converting a string to a double value
+ double StringToDouble (string s);
+
+ //---------------------------------------------------------------------
+ // Any Number to std::string
+ //---------------------------------------------------------------------
+ string Number2String(double d);
+ string Number2String(float f);
+ string Number2String(int i);
+ string Number2String(long l);
+ //---------------------------------------------------------------------
+
+ //---------------------------------------------------------------------
+ // Converting a double to a string value
+ string Double2String(double d);
+
+ //---------------------------------------------------------------------
+ // Converting a float to a string value
+ string Float2String(float f);
+
+ //---------------------------------------------------------------------
+ // Converting an integer to a string value
+ string Int2String(int i);
+
+ //---------------------------------------------------------------------
+ // Converting a string value to bool
+ bool StringToBool(string str);
+
+
+ //---------------------------------------------------------------------
+ // Converting a date string 'YYYYMMDD' to three separate integer values
+ void Get_Date_Int(string date, int &year, int &month, int &day);
+
+};
+
+#endif /* __convert_sl_h */
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_basin.cpp b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_basin.cpp
new file mode 100644
index 0000000..e464e7b
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_basin.cpp
@@ -0,0 +1,915 @@
+///////////////////////////////////////////////////////////
+// ihacres_basin.cpp //
+// //
+// Copyright (C) 2008 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// 2008-01-30 //
+///////////////////////////////////////////////////////////
+
+//*******************************************************//
+// ToDo //
+//-------------------------------------------------------//
+// - lag COEFFICIENT in write output table IMPLEMENTIEREN !!!!!!!
+
+//*******************************************************//
+
+
+#define NULL 0
+
+#include "ihacres_basin.h"
+#include "convert_sl.h"
+#include "model_tools.h"
+//---------------------------------------------------------------------
+
+Cihacres_basin::Cihacres_basin()
+{
+ //-----------------------------------------------------
+ // 1. Info...
+ Set_Name(_TL("IHACRES Basin"));
+
+ Set_Author(SG_T("copyrights (c) 2008 Stefan Liersch"));
+
+ Set_Description(_TW(
+ "The Rainfall-Runoff Model IHACRES \n \n \n"
+ "Reference: \n \n"
+ "Jakeman, A.J. / Hornberger, G.M. (1993). \n"
+ "How Much Complexity Is Warranted in a Rainfall-Runoff Model? \n"
+ "Water Resources Research, (29), NO. 8 (2637-2649) \n \n"
+ "Croke, B. F. W., W. S. Merritt, et al. (2004).\n"
+ "A dynamic model for predicting hydrologic response "
+ "to land cover changes in gauged and "
+ "ungauged catchments. \n"
+ "Journal Of Hydrology 291(1-2): 115-131."
+ ));
+
+ Parameters.Add_Table_Output(
+ NULL , "TABLEout" , _TL("Table"),
+ _TL("")
+ );
+
+ ///////////////////////////////////////////////////////////////////
+ // FIRST MODULE DIALOG
+ _CreateDialog1();
+ ///////////////////////////////////////////////////////////////////
+}
+//---------------------------------------------------------------------
+
+Cihacres_basin::~Cihacres_basin()
+{}
+//---------------------------------------------------------------------
+
+
+
+
+//---------------------------------------------------------------------
+// ON_EXECUTE
+//---------------------------------------------------------------------
+
+bool Cihacres_basin::On_Execute()
+{
+ CSG_Parameters P;
+ //std::ofstream f("_out_elev.txt");
+
+ // Assign Parameters from first Module Dialog
+ //---------------------------------------------------------
+ int nSBS = Parameters("NSUBBASINS") ->asInt();
+ m_nSubbasins = nSBS + 2; // because list starts with 2 !
+ m_IHAC_version = Parameters("IHACVERS") ->asInt();
+ m_StorConf = Parameters("STORAGE") ->asInt();
+ m_bSnowModule = Parameters("SNOW_MODULE") ->asBool();
+ //---------------------------------------------------------
+
+
+ //---------------------------------------------------------
+ // Assign number of storages
+ m_nStorages = ihacres.Assign_nStorages(m_StorConf);
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // Initialize pointers
+ _Init_Subbasins(m_nSubbasins);
+ m_p_linparms = new C_IHAC_LinearParms(m_nSubbasins,m_nStorages);
+ m_p_nonlinparms = new C_IHAC_NonLinearParms(m_nSubbasins);
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // open second and third user dialog
+ if ( _CreateDialog2() && _CreateDialog3())
+ {
+ //---------------------------------------------------------
+ // searching the first and the last record of the time range
+ ihacres.AssignFirstLastRec(*m_p_InputTable, m_first, m_last, m_date1, m_date2, m_dateField);
+ m_nValues = m_last - m_first + 1;
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ _Init_Pointers(m_nValues);
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // read input table
+ _ReadInputFile();
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // PERFORM STREAMFLOW SIMULATION
+ // FOR EACH ELEVATION BAND
+ //---------------------------------------------------------
+ // Convert Streamflow vector from m3/s*day-1 to mm/day
+ //m_p_Q_obs_mmday = model_tools::m3s_to_mmday(m_p_Q_obs_m3s, m_p_Q_obs_mmday, m_nValues, m_Area_tot);
+
+ //---------------------------------------------------------
+ // SNOW MODULE
+ //---------------------------------------------------------
+ double Q_init = 1.0; // ???
+ for (int i = 0; i < m_nSubbasins; i++)
+ {
+ if (m_bSnowModule)
+ {
+ _CalcSnowModule(i);
+ }
+
+ _Simulate_NonLinearModule(i);
+
+ _Simulate_Streamflow(i, Q_init);
+ }
+
+ //---------------------------------------------------------
+
+ m_pTable = SG_Create_Table();
+ _CreateTableSim();
+ // add tables to SAGA Workspace
+ m_pTable->Set_Name(_TL("IHACRES_Basin_output"));
+ Parameters("TABLEout")->Set_Value(m_pTable);
+
+ delete[] m_pSubbasin; // sämtliche Unter-Pointer noch löschen
+ delete[] m_p_pcpField;
+ delete[] m_p_tmpField;
+ delete m_p_linparms;
+ delete m_p_nonlinparms;
+ if (m_bSnowModule) delete m_pSnowparms;
+
+ return(true);
+ } // end if ( _CreateDialog2() )
+
+ return(false);
+}
+
+
+//---------------------------------------------------------------------
+
+void Cihacres_basin::_Init_Subbasins(int n)
+{
+ // instantiate elevation bands
+ m_pSubbasin = new Cihacres_subbasin[n];
+
+ // instantiate field numbers
+ m_p_pcpField = new int[n];
+ m_p_tmpField = new int[n];
+
+ if (m_bSnowModule)
+ {
+ m_pSnowparms = new CSnowParms[n];
+ }
+}
+//---------------------------------------------------------------------
+
+void Cihacres_basin::_Init_Pointers(int n)
+{
+ m_vec_date.resize(n);
+ m_p_Q_obs_m3s = new double[n];
+ m_p_Q_obs_mmday = new double[n];
+
+ for (int i = 0; i < m_nSubbasins; i++)
+ {
+ m_pSubbasin[i].m_pPCP = new double[n];
+ m_pSubbasin[i].m_pTMP = new double[n];
+ m_pSubbasin[i].m_pER = new double[n];
+ m_pSubbasin[i].m_p_Q_sim_mmday = new double[n];
+ m_pSubbasin[i].m_pTw = new double[n];
+ m_pSubbasin[i].m_pWI = new double[n];
+ }
+ if (m_bSnowModule)
+ {
+ for (int eb = 0; eb < m_nSubbasins; eb++)
+ {
+ m_pSubbasin[eb].m_pSnowStorage = new double[n];
+ m_pSubbasin[eb].m_pMeltRate = new double[n];
+ }
+ }
+}
+//---------------------------------------------------------------------
+
+
+void Cihacres_basin::_ReadInputFile()
+{
+ for (int j = 0, k = m_first; j < m_nValues, k < m_last + 1; j++, k++)
+ {
+ m_vec_date[j].append(SG_STR_SGTOMB(m_p_InputTable->Get_Record(k)->asString(m_dateField)));
+ m_p_Q_obs_m3s[j] = m_p_InputTable->Get_Record(k)->asDouble(m_streamflowField);
+
+ for (int eb = 0; eb < m_nSubbasins; eb++)
+ {
+ m_pSubbasin[eb].m_pPCP[j] = m_p_InputTable->Get_Record(k)->asDouble(m_p_pcpField[eb]);
+ m_pSubbasin[eb].m_pTMP[j] = m_p_InputTable->Get_Record(k)->asDouble(m_p_tmpField[eb]);
+ }
+ }
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+
+void Cihacres_basin::_CalcSnowModule(int iSBS)
+{
+ m_p_SnowModule = new CSnowModule(m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pPCP, m_nValues,
+ m_pSnowparms[iSBS].T_Rain, m_pSnowparms[iSBS].T_Melt, m_pSnowparms[iSBS].DD_FAC);
+
+ m_pSubbasin[iSBS].m_pMeltRate = m_p_SnowModule->Get_MeltRate(m_pSubbasin[iSBS].m_pMeltRate, m_nValues);
+ m_pSubbasin[iSBS].m_pSnowStorage = m_p_SnowModule->Get_SnowStorage(m_pSubbasin[iSBS].m_pSnowStorage, m_nValues);
+
+ delete m_p_SnowModule;
+}
+//---------------------------------------------------------------------
+
+
+//---------------------------------------------------------------------
+
+void Cihacres_basin::_Simulate_NonLinearModule(int iSBS)
+{
+ double eR_init = 0.0;
+ double WI_init = 0.5;
+ //----------------------------------------------------------
+ // calculate excess rainfall time series
+ //----------------------------------------------------------
+ switch(m_IHAC_version)
+ {
+ case 0: // Jakeman & Hornberger (1993)
+ // The parameter index (fourth parameter) is zero here, because
+ // the parameter settings of the non-linear module are in all elevationbands equal.
+ // If they should be different the index parameter can be used to identify the
+ // corresponding elevation band.
+ ihacres.CalcWetnessTimeConst(m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pTw,
+ m_p_nonlinparms, iSBS, m_nValues);
+ // 0 = index (only one instance of m_p_nonlinparms)
+
+ if (m_bSnowModule)
+ {
+ ihacres.CalcWetnessIndex(m_pSubbasin[iSBS].m_pTw, m_pSubbasin[iSBS].m_pPCP,
+ m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pWI, WI_init, m_p_nonlinparms->mp_c[iSBS],
+ m_bSnowModule, m_pSnowparms[iSBS].T_Rain, m_nValues);
+
+ ihacres.CalcExcessRain(m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pTMP,
+ m_pSubbasin[iSBS].m_pWI, m_pSubbasin[iSBS].m_pER, eR_init,
+ m_pSubbasin[iSBS].m_sum_eRainGTpcp, m_nValues, m_bSnowModule,
+ m_pSnowparms[iSBS].T_Rain, m_pSnowparms[iSBS].T_Melt,
+ m_pSubbasin[iSBS].m_pMeltRate);
+ } else {
+
+ ihacres.CalcWetnessIndex(m_pSubbasin[iSBS].m_pTw, m_pSubbasin[iSBS].m_pPCP,
+ m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pWI, WI_init, m_p_nonlinparms->mp_c[iSBS],
+ m_bSnowModule, 0, m_nValues);
+
+ ihacres.CalcExcessRain(m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pTMP,
+ m_pSubbasin[iSBS].m_pWI, m_pSubbasin[iSBS].m_pER, eR_init,
+ m_pSubbasin[iSBS].m_sum_eRainGTpcp, m_nValues, m_bSnowModule,
+ 0,0,0);
+ }
+ break;
+ case 1: // Croke et al. (2005)
+ ihacres.CalcWetnessTimeConst_Redesign(m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pTw,
+ m_p_nonlinparms, iSBS, m_nValues); // 0 = index (only one instance of m_p_nonlinparms)
+
+ if (m_bSnowModule)
+ {
+ ihacres.CalcWetnessIndex_Redesign(m_pSubbasin[iSBS].m_pTw, m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pWI, WI_init,
+ m_bSnowModule, m_pSnowparms[iSBS].T_Rain, m_nValues);
+
+ ihacres.CalcExcessRain_Redesign(m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pWI,
+ m_pSubbasin[iSBS].m_pER, eR_init, m_pSubbasin[iSBS].m_sum_eRainGTpcp, m_nValues,
+ m_p_nonlinparms->mp_c[iSBS], m_p_nonlinparms->mp_l[iSBS], m_p_nonlinparms->mp_p[iSBS],
+ m_bSnowModule, m_pSnowparms[iSBS].T_Rain, m_pSnowparms[iSBS].T_Melt, m_pSubbasin[iSBS].m_pMeltRate);
+ } else {
+ ihacres.CalcWetnessIndex_Redesign(m_pSubbasin[iSBS].m_pTw, m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pWI, WI_init,
+ m_bSnowModule, 0, m_nValues);
+
+ ihacres.CalcExcessRain_Redesign(m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pWI,
+ m_pSubbasin[iSBS].m_pER, eR_init, m_pSubbasin[iSBS].m_sum_eRainGTpcp, m_nValues,
+ m_p_nonlinparms->mp_c[iSBS], m_p_nonlinparms->mp_l[iSBS], m_p_nonlinparms->mp_p[iSBS],
+ m_bSnowModule, 0,0,0);
+ }
+ break;
+ } // end switch(m_IHAC_vers)
+}
+//---------------------------------------------------------------------
+
+
+//---------------------------------------------------------------------
+
+void Cihacres_basin::_Simulate_Streamflow(int iSBS, double Q_init)
+{
+ //----------------------------------------------------------
+
+ //----------------------------------------------------------
+ // calculate streamflow
+ //----------------------------------------------------------
+ switch(m_StorConf)
+ {
+ case 0: // single storage
+ ihacres.SimStreamflowSingle(m_pSubbasin[iSBS].m_pER, Q_init,
+ m_pSubbasin[iSBS].m_p_Q_sim_mmday, m_pSubbasin[iSBS].m_delay,
+ m_p_linparms->a[iSBS], m_p_linparms->b[iSBS], m_nValues);
+ break;
+ case 1: // two storages in parallel
+ ihacres.SimStreamflow2Parallel(m_pSubbasin[iSBS].m_pER,
+ m_pSubbasin[iSBS].m_p_Q_sim_mmday, Q_init,
+ m_p_linparms, iSBS, m_vq, m_vs, m_nValues, m_pSubbasin[iSBS].m_delay);
+ break;
+ case 2: // two storages in series
+ break;
+ } // end switch(m_StorConf)
+}
+//---------------------------------------------------------------------
+
+
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// CREATE TABLE
+//
+///////////////////////////////////////////////////////////////////////
+
+//---------------------------------------------------------------------
+
+void Cihacres_basin::_CreateTableSim()
+{
+ int i = 0; // used in function Get_Record(i)
+ CSG_Table_Record *pRecord;
+ CSG_String tmpName;
+ double sim_sbs, sim;
+
+ // creating the column titles
+ m_pTable->Add_Field("Date", SG_DATATYPE_String);
+ m_pTable->Add_Field("Flow_OBS", SG_DATATYPE_Double);
+
+ for (int sbs = 0; sbs < m_nSubbasins; sbs++)
+ {
+ tmpName = "SBS_";
+ tmpName += convert_sl::Int2String(sbs+1).c_str();
+ m_pTable->Add_Field(tmpName.c_str(), SG_DATATYPE_Double);
+ }
+ m_pTable->Add_Field("Flow_SIM", SG_DATATYPE_Double);
+
+ for (int j = 0; j < m_nValues; j++)
+ {
+ m_pTable->Add_Record();
+ pRecord = m_pTable->Get_Record(i);
+
+ // writing the data into the rows
+ pRecord->Set_Value(0,SG_STR_MBTOSG(m_vec_date[j].c_str()));
+ pRecord->Set_Value(1,m_p_Q_obs_m3s[j]);
+ sim_sbs = 0.0;
+ sim = 0.0;
+ for (int sbs = 0; sbs < m_nSubbasins; sbs++)
+ {
+ sim_sbs = model_tools::mmday_to_m3s(m_pSubbasin[sbs].m_p_Q_sim_mmday[j],m_pSubbasin[sbs].m_area);
+ //pRecord->Set_Value(3+eb,model_tools::mmday_to_m3s(m_p_elevbands[eb].m_p_streamflow_sim[j],m_p_elevbands[eb].m_area));
+ pRecord->Set_Value(2+sbs, sim_sbs);
+ sim += sim_sbs;
+ }
+ pRecord->Set_Value(2+m_nSubbasins,sim);
+ i++;
+ }
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// DIALOGS
+//
+///////////////////////////////////////////////////////////////////////
+//---------------------------------------------------------------------
+// DIALOG 1
+//---------------------------------------------------------------------
+void Cihacres_basin::_CreateDialog1()
+{
+ CSG_Parameter *pNode;
+ CSG_String s;
+
+ pNode = Parameters.Add_Choice(
+ NULL , "NSUBBASINS" , _TL("Number of sub-basins"),
+ _TL(""),
+ SG_T("2|3|4|5|6|7|8|9|10")
+ );
+
+ s.Printf(SG_T("Node1"), 1);
+ pNode = Parameters.Add_Node(NULL,s,_TL("IHACRES Version"),_TL(""));
+
+ Parameters.Add_Choice(
+ pNode , "IHACVERS" , _TL("IHACRES Version"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("Jakeman & Hornberger (1993)"), // 0
+ _TL("Croke et al. (2005) !!! not yet implemented !!!") // 1
+ )
+ );
+
+ s.Printf(SG_T("Node2"), 2);
+ pNode = Parameters.Add_Node(NULL,s,_TL("Storage Configuration"),_TL(""));
+
+ Parameters.Add_Choice(
+ pNode , "STORAGE" , _TL("Storage"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("Single Storage"), // 0
+ _TL("Two Parallel Storages"), // 1
+ _TL("Two Storages in Series !!! not yet implemented !!!") // 2
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode, "SNOW_MODULE", _TL("Using the snow-melt module?"),
+ _TL("If checked, snow-melt module is used."),
+ PARAMETER_TYPE_Bool, false
+ );
+}
+
+
+//---------------------------------------------------------------------
+// DIALOG 2
+//---------------------------------------------------------------------
+
+bool Cihacres_basin::_CreateDialog2()
+{
+ //std::ofstream f("_out_elev.txt");
+
+ int i;
+ CSG_Parameters P; // used to add Parameters in the second dialog
+ CSG_Parameter *pNode, *pNode1;
+ CSG_String s;
+ CSG_String tmpNode, tmpName;
+
+ P.Set_Name(_TL("IHACRES Basin (Dialog 2)"));
+ // Input file ----------------------------------------------
+ pNode = P.Add_Table(
+ NULL , "TABLE" , _TL("IHACRES Input Table"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ P.Add_Table_Field(
+ pNode , "DATE_Field" , _TL("Date Column"),
+ _TL("Select the column containing the Date")
+ );
+
+ P.Add_Table_Field(
+ pNode , "DISCHARGE_Field" , _TL("Streamflow (obs.) Column"),
+ _TL("Select the column containing the observed streamflow time series")
+ );
+
+ for (i = 0; i < m_nSubbasins; i++)
+ {
+ tmpNode = convert_sl::Int2String(i+1).c_str();
+
+ tmpName = _TL("PCP Column: Subbasin: ");
+ tmpName+=tmpNode;
+ P.Add_Table_Field(
+ pNode , tmpName.c_str(), tmpName.c_str(),
+ _TL("Select Precipitation Column")
+ );
+
+ tmpName = _TL("TMP Column: Subbasin: ");
+ tmpName+=tmpNode;
+ P.Add_Table_Field(
+ pNode , tmpName.c_str() , tmpName.c_str(),
+ _TL("Select Temperature Column")
+ );
+ }
+ // Input file ----------------------------------------------
+
+ for (i = 0; i < m_nSubbasins; i++)
+ {
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+100).c_str();
+ tmpName = _TL("Subbasin ");
+ tmpName+=convert_sl::Int2String(i+1).c_str();
+
+ s.Printf(tmpNode.c_str(), i+100);
+ pNode = P.Add_Node(NULL,s,tmpName.c_str(),_TL(""));
+
+ tmpName = _TL("Area [km2] Subbasin(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode, tmpName, _TL("Area [km2]"),
+ _TL(""),
+ PARAMETER_TYPE_Double
+ );
+
+ tmpName = "Lag Subbasin(";
+ tmpName += tmpNode;
+ tmpName += ")";
+ P.Add_Value(
+ pNode, tmpName, _TL("Lag coefficient"),
+ _TL(""),
+ PARAMETER_TYPE_Int
+ );
+
+
+ // Parameters of non-linear module -------------------------
+
+ tmpNode = "Node";
+ tmpNode+=convert_sl::Int2String(i+150).c_str();
+ s.Printf(tmpNode.c_str(), i+150);
+ pNode1 = P.Add_Node(pNode,s,_TL("Non-Linear Module"),_TL(""));
+
+ tmpName = _TL("TwFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Wetness decline time constant (Tw)"),
+ _TW("Tw is approximately the time constant, or inversely,"
+ "the rate at which the catchment wetness declines in the absence of rainfall"),
+ PARAMETER_TYPE_Double,
+ 1.0, 0.01, true, 150.0, true
+ );
+
+ tmpName = _TL("TFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1 , tmpName , _TL("Temperature Modulation Factor (f)"),
+ _TL("Temperature Modulation Factor f"),
+ PARAMETER_TYPE_Double,
+ 1.0, 0.0001, true, 10.0, true
+ );
+
+ tmpName = _TL("CFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Parameter (c)"),
+ _TL("Parameter (c) to fit streamflow volume"),
+ PARAMETER_TYPE_Double,
+ 0.001, 0.0, true, 1.0, true
+ );
+
+ switch(m_IHAC_version)
+ {
+ case 0: // Jakeman & Hornberger (1993)
+ break;
+ case 1: // Croke et al. (2005)
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+200).c_str();
+ s.Printf(tmpNode.c_str(), i+200);
+ pNode1 = P.Add_Node(pNode,s,_TL("Soil Moisture Power Eq."),_TL(""));
+
+ tmpName = "LFAC(";
+ tmpName += tmpNode;
+ tmpName += ")";
+ P.Add_Value(
+ pNode1, tmpName, _TL("Parameter (l)"),
+ _TL("Soil moisture index threshold"),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 5.0, true
+ );
+
+ tmpName = "PFAC(";
+ tmpName += tmpNode;
+ tmpName += ")";
+ P.Add_Value(
+ pNode1, tmpName, _TL("Parameter (p)"),
+ _TL("non-linear response term"),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 5.0, true
+ );
+ break;
+ }
+ // Parameters of non-linear module -------------------------
+
+ // Parameters of linear module -----------------------------
+ switch(m_StorConf)
+ {
+ case 0: // single storage
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+250).c_str();
+ s.Printf(tmpNode.c_str(), i+250);
+ pNode1 = P.Add_Node(pNode,s,_TL("Linear Module"),_TL(""));
+
+ tmpName = _TL("AFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("(a)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.8, -0.99, true, -0.01, true
+ );
+
+ tmpName = _TL("BFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("(b)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.2, 0.001, true, 1.0, true
+ );
+ break;
+
+ case 1: // two parallel storages
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+250).c_str();
+ s.Printf(tmpNode.c_str(), i+250);
+ pNode1 = P.Add_Node(pNode,s,_TL("Linear Module"),_TL(""));
+
+ // Parameter a
+
+ tmpName = _TL("AQ(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("a(q)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.7, -0.99, true, -0.01, true
+ );
+
+ tmpName = _TL("AS(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("a(s)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.9, -0.99, true, -0.01, true
+ );
+
+ // Parameter b
+
+ tmpName = _TL("BQ(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("b(q)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 1.0, true
+ );
+ break;
+
+ case 2: // two storages in series
+ break;
+ } // end switch (storconf)
+ // Parameters of linear module -----------------------------
+
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+300).c_str();
+ s.Printf(tmpNode.c_str(), i+300);
+ pNode1 = P.Add_Node(pNode,s,_TL("Time Delay after Start of Rainfall (INTEGER)"),_TL(""));
+
+ tmpName = _TL("DELAY(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Time Delay (Rain-Runoff)"),
+ _TL("The delay after the start of rainfall, before the discharge starts to rise."),
+ PARAMETER_TYPE_Int,
+ 0, 1, true, 100, true
+ );
+
+ // snow module parameters ----------------------------------
+ if (m_bSnowModule)
+ {
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+350).c_str();
+ s.Printf(tmpNode.c_str(), i+350);
+ pNode1 = P.Add_Node(pNode,s,_TL("Snow Module Parameters"),_TL(""));
+
+ tmpName = _TL("T_RAIN(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Temperature Threshold for Rainfall"),
+ _TL("Below this threshold precipitation will fall as snow"),
+ PARAMETER_TYPE_Double,
+ -1.0, -10.0, true, 10.0, true
+ );
+
+ tmpName = _TL("T_MELT(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Temperature Threshold for Melting"),
+ _TL("Above this threshold snow will start to melt"),
+ PARAMETER_TYPE_Double,
+ 1.0, -5.0, true, 10.0, true
+ );
+
+ tmpName = _TL("DD_FAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Day-Degree Factor"),
+ _TL("Day-Degree Factor depends on catchment characteristics"),
+ PARAMETER_TYPE_Double,
+ 0.7, 0.7, true, 9.2, true
+ );
+ }
+ // snow module parameters ----------------------------------
+ }
+
+ if( SG_UI_Dlg_Parameters(&P, _TL("IHACRES Distributed Input Dialog 2")) )
+ {
+ // input table
+ m_p_InputTable = P("TABLE") ->asTable();
+ // field numbers
+ m_dateField = P("DATE_Field") ->asInt();
+ m_streamflowField = P("DISCHARGE_Field") ->asInt();
+ for (int i = 0; i < m_nSubbasins; i++)
+ {
+ tmpNode = convert_sl::Int2String(i+1).c_str();
+
+ // get precipitation column of Subbasin[i]
+ tmpName = _TL("PCP Column: Subbasin: ");
+ tmpName+=tmpNode;
+ m_p_pcpField[i] = P(tmpName) ->asInt();
+
+ // get temperature column of Subbasin[i]
+ tmpName = _TL("TMP Column: Subbasin: ");
+ tmpName+=tmpNode;
+ m_p_tmpField[i] = P(tmpName) ->asInt();
+
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+100).c_str();
+
+ // get area[km2] of Subbasin[i]
+ tmpName = _TL("Area [km2] Subbasin(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSubbasin[i].m_area = P(tmpName) ->asDouble();
+
+ // get lag coefficient of Subbasin[i]
+ tmpName = _TL("Lag Subbasin(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSubbasin[i].m_lag = P(tmpName) ->asInt();
+
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+150).c_str();
+ // get Tw
+ tmpName = _TL("TwFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nonlinparms->mp_tw[i] = P(tmpName) ->asDouble();
+
+ // get f
+ tmpName = _TL("TFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nonlinparms->mp_f[i] = P(tmpName) ->asDouble();
+
+ // get c
+ tmpName = _TL("CFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nonlinparms->mp_c[i] = P(tmpName) ->asDouble();
+
+ switch(m_IHAC_version)
+ {
+ case 0: // Jakeman & Hornberger (1993)
+ break;
+ case 1: // Croke et al. (2005)
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+200).c_str();
+ // get l
+ tmpName = _TL("LFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nonlinparms->mp_l[i]= P(tmpName) ->asDouble();
+
+ // get p
+ tmpName = _TL("PFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nonlinparms->mp_p[i]= P(tmpName) ->asDouble();
+ }
+
+ // linear module parameters
+ switch(m_nStorages)
+ {
+ case 1: // single storage
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+250).c_str();
+ // get a
+ tmpName = _TL("AFAC()");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_linparms->a[i] = P(tmpName) ->asDouble();
+
+ // get b
+ tmpName = _TL("BFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_linparms->b[i] = P(tmpName) ->asDouble();
+ break;
+ case 2: // two storages
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+250).c_str();
+ // get aq
+ tmpName = _TL("AQ(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_linparms->aq[i] = P(tmpName) ->asDouble();
+
+ // get bq
+ tmpName = _TL("BQ(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_linparms->bq[i] = P(tmpName) ->asDouble();
+
+ // get as
+ tmpName = _TL("AS(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_linparms->as[i] = P(tmpName) ->asDouble();
+ m_p_linparms->bs[i] = ihacres.Calc_Parm_BS(m_p_linparms->aq[i],m_p_linparms->as[i],m_p_linparms->bq[i]);
+ break;
+ }
+
+ // get delay
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+300).c_str();
+ tmpName = _TL("DELAY(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSubbasin[i].m_delay = P(tmpName) ->asInt();
+
+ if (m_bSnowModule)
+ {
+ tmpNode = _TL("Node");
+ tmpNode+=convert_sl::Int2String(i+350).c_str();
+ tmpName = _TL("T_RAIN(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSnowparms[i].T_Rain = P(tmpName) ->asDouble();
+ tmpName = _TL("T_MELT(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSnowparms[i].T_Melt = P(tmpName) ->asDouble();
+ tmpName = _TL("DD_FAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSnowparms[i].DD_FAC = P(tmpName) ->asDouble();
+ }
+
+ } // end for (int i = 0; i < m_nSubbasins; i++)
+
+ return(true);
+ }
+ return(false);
+}
+
+//---------------------------------------------------------------------
+// DIALOG 3
+//---------------------------------------------------------------------
+
+bool Cihacres_basin::_CreateDialog3()
+{
+ CSG_String s;
+ CSG_Parameters P; // used to add Parameters in the second dialog
+ CSG_Parameter *pNode;
+
+ // Dialog design
+ P.Set_Name(_TL("Choose Time Range"));
+
+ s.Printf(SG_T("Node"), 1);
+ pNode = P.Add_Node(NULL,s,_TL("Time Range"),_TL(""));
+
+ s.Printf(SG_T("FDAY") , 1-1);
+ P.Add_String(pNode,s,_TL("First Day"),_TL(""),
+ m_p_InputTable->Get_Record(0)->asString(m_dateField));
+
+ s.Printf(SG_T("LDAY") , 1-2);
+ P.Add_String(pNode,s,_TL("Last Day"),_TL(""),
+ m_p_InputTable->Get_Record(m_p_InputTable->Get_Record_Count()-1)->asString(m_dateField));
+
+ if( SG_UI_Dlg_Parameters(&P, _TL("Choose Time Range")) )
+ {
+ ///////////////////////////////////////////////////////////////
+ //
+ // ASSIGN DATA FROM SECOND DIALOG
+ //
+ ///////////////////////////////////////////////////////////////
+ m_date1 = P(CSG_String::Format(SG_T("FDAY"),m_dateField).c_str())->asString();
+ m_date2 = P(CSG_String::Format(SG_T("LDAY"),m_streamflowField).c_str())->asString();
+ return(true);
+ }
+ return(false);
+}
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_basin.h b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_basin.h
new file mode 100644
index 0000000..927ee06
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_basin.h
@@ -0,0 +1,243 @@
+///////////////////////////////////////////////////////////
+// ihacres_basin.h //
+// //
+// Copyright (C) 2008 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// 2008-01-30 //
+//-------------------------------------------------------//
+
+//*******************************************************//
+// ToDo //
+//-------------------------------------------------------//
+// -
+//*******************************************************//
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__ihacres_basin_H
+#define HEADER_INCLUDED__ihacres_basin_H
+//---------------------------------------------------------
+
+#include "MLB_Interface.h"
+#include "ihacres_eq.h"
+
+//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////////////////
+//
+// CLASS Cihacres_sub_basin
+//
+///////////////////////////////////////////////////////////////////////
+
+class Cihacres_subbasin
+{
+public:
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CONSTRUCTORS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ // default
+ Cihacres_subbasin(void) {
+ m_pPCP = NULL;
+ m_pTMP = NULL;
+ m_pER = NULL;
+ m_p_Q_sim_mmday = NULL;
+ m_pTw = NULL;
+ m_pWI = NULL;
+ m_pMeltRate = NULL;
+ m_pSnowStorage = NULL;
+ }
+
+ Cihacres_subbasin(int nvals) {
+ Initialize(nvals);
+ }
+
+ // destructor
+ ~Cihacres_subbasin(void) {
+ if (m_pPCP) delete[] m_pPCP;
+ if (m_pTMP) delete[] m_pTMP;
+ if (m_pER) delete[] m_pER;
+ if (m_p_Q_sim_mmday) delete[] m_p_Q_sim_mmday;
+ if (m_pTw) delete[] m_pTw;
+ if (m_pWI) delete[] m_pWI;
+ if (m_pMeltRate) delete[] m_pMeltRate;
+ if (m_pSnowStorage) delete[] m_pSnowStorage;
+
+ }
+
+ void Initialize(int nvals) {
+ m_nValues = nvals;
+ m_pPCP = new double[nvals];
+ m_pTMP = new double[nvals];
+ m_pER = new double[nvals];
+ m_p_Q_sim_mmday = new double[nvals];
+ m_pTw = new double[nvals];
+ m_pWI = new double[nvals];
+ m_pMeltRate = new double[nvals];
+ m_pSnowStorage = new double[nvals];
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // PARAMETERS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ //-----------------------------------------------------------------
+ // TIME SERIES
+ //-----------------------------------------------------------------
+ int m_nValues;
+ double* m_pPCP; // precipitation time series
+ double* m_pTMP; // temperature time series
+ double* m_pER; // excess rainfall time series
+ double* m_p_Q_sim_mmday; // simulated streamflow time series [mm] !!!
+ double* m_pTw; //
+ double* m_pWI; // Wetness Index
+ double* m_pMeltRate;
+ double* m_pSnowStorage;
+ //-----------------------------------------------------------------
+ //
+ //-----------------------------------------------------------------
+ // lag coefficient
+ // this parameter is to account for the time lag between the streamflow signal
+ // at the subbasin outlet and the time of this signal at
+ // the catchment/bain outlet
+ int m_lag;
+ int m_delay;
+ double m_area; // sub-catchment area [km2]
+ double m_sum_eRainGTpcp;
+
+
+private:
+
+};
+//-------------------------------------------------------------------
+
+
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// CLASS Cihacres_basin
+//
+///////////////////////////////////////////////////////////////////////
+//-------------------------------------------------------------------
+
+class Cihacres_basin : public CSG_Module
+{
+public:
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CONSTRUCTORS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ // default
+ Cihacres_basin(void);
+
+ // destructor
+ ~Cihacres_basin(void);
+
+protected:
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // PROTECTED FUNCTIONS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ // execute module
+ virtual bool On_Execute (void);
+
+private:
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // PRIVATE PARAMETERS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ //-----------------------------------------------------------------
+
+ //----------------------------------
+ // parameters of first module dialog
+ //----------------------------------
+ int m_nSubbasins; // number of sub-basins
+ //double m_Area_tot; // total catchment area [km2]
+ int m_IHAC_version; // Different versions of IHACRES exist, corresponding
+ // to the version...
+ int m_StorConf; // Storage configuration
+ // 0 = single, 1 = two in parallel, 2 = two in series
+ bool m_bSnowModule; // true if snow module is active
+
+ int m_nStorages; // number of storages
+
+ //----------------------------------
+ // parameters of second module dialog
+ //----------------------------------
+ // time series variables
+ CSG_Table* m_p_InputTable; // IHACRES input table
+ int m_nValues; // number of selected records
+ date_array m_vec_date;
+ double* m_p_Q_obs_m3s; // pointer containing observed streamflow in [m3/s]
+ double* m_p_Q_obs_mmday; // pointer containing observed streamflow in [mm]
+ Cihacres_subbasin* m_pSubbasin; // Class Cihacres_elev_bands
+
+ // Field numbers
+ int m_dateField; // table field numbers
+ int m_streamflowField;
+ // subbasin band parameters
+ int* m_p_pcpField;
+ int* m_p_tmpField;
+ //double* m_p_mean_elev;
+
+ //----------------------------------
+ // parameters of third module dialog
+ //----------------------------------
+ CSG_String m_date1; // first day of time series YYYYMMDD
+ CSG_String m_date2; // last day
+
+ int m_first;
+ int m_last;
+
+ //----------------------------------
+ // Model parameter (in: ihacres_eq.h)
+ //----------------------------------
+ C_IHAC_LinearParms* m_p_linparms; // parameters of the linear storage module
+ C_IHAC_NonLinearParms* m_p_nonlinparms; // parameters of the non-linear rainfall loss module
+ CSnowParms* m_pSnowparms; // 3 snow module paramters
+ CSnowModule* m_p_SnowModule;
+ //int m_delay;
+ double m_vq;
+ double m_vs;
+
+ CSG_Table* m_pTable;
+
+
+ //--------------------------------------------------------
+ // PRIVATE MEMBER FUNCTIONS
+ //--------------------------------------------------------
+
+ void _Init_Subbasins(int n); // n = m_nElevBands
+ void _Init_Pointers(int nvals);
+ void _CreateDialog1();
+ bool _CreateDialog2();
+ bool _CreateDialog3();
+ void _ReadInputFile();
+ void _CalcSnowModule(int nSubbasins);
+ void _Simulate_NonLinearModule(int nSubbasins);
+ void _Simulate_Streamflow(int nSubbasins, double Q_init);
+ void _CreateTableSim();
+
+ // Class ihacres_eq
+ Cihacres_eq ihacres;
+};
+
+#endif /* HEADER_INCLUDED__ihacres_basin_H */
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_cal2.cpp b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_cal2.cpp
new file mode 100644
index 0000000..f96545b
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_cal2.cpp
@@ -0,0 +1,1119 @@
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ihacres_cal2 //
+// //
+//-------------------------------------------------------//
+// //
+// ihacres_cal.cpp //
+// //
+// Copyright (C) 2008 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// //
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// //
+// 2008-01-15 //
+///////////////////////////////////////////////////////////
+//
+//-------------------------------------------------------//
+// References:
+// Jakeman, A.J. / Hornberger, G.M (1993).
+// How Much Complexity Is Warranted in a
+// Rainfall-Runoff Model?
+// Water Resources Research, (29), NO. 8 (2637-2649)
+// Kokkonen, T. S. et al. (2003).
+// Predicting daily flows in ungauged catchments:
+// model regionalization from catchment descriptors
+// at the Coweeta Hydrologic Laboratory, North Carolina
+// Hydrological Processes (17), 2219-2238
+// Croke, B. F. W., W. S. Merritt, et al. (2004).
+// A dynamic model for predicting hydrologic response
+// to land cover changes in gauged and
+// ungauged catchments.
+// Journal Of Hydrology 291(1-2): 115-131.
+//-------------------------------------------------------//
+
+//---------------------------------------------------------
+// ToDo
+//---------------------------------------------------------
+// - beste Simulation automatisch rausschreiben
+//---------------------------------------------------------
+#include <iostream> // used for textfile output (test only)
+#include <fstream> // used for textfile output (test only)
+
+#include <stdlib.h> // random numbers
+#include <time.h> // random numbers
+
+#include "ihacres_cal2.h"
+// #include "model_tools.h" // already in ihacres_eq.h
+#include "convert_sl.h"
+//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////////////////
+//
+// Constructor
+//
+///////////////////////////////////////////////////////////////////////
+
+Cihacres_cal2::Cihacres_cal2(void)
+{
+ //-----------------------------------------------------
+ // 1. Info...
+ Set_Name(_TL("IHACRES Calibration (2)"));
+
+ Set_Author(SG_T("copyrights (c) 2008 Stefan Liersch"));
+
+ Set_Description(_TW("Calibration Tool for the Model IHACRES \n \n \n"
+ "Reference: \n \n"
+ "Jakeman, A.J. / Hornberger, G.M. (1993). \n"
+ "How Much Complexity Is Warranted in a Rainfall-Runoff Model? \n"
+ "Water Resources Research, (29), NO. 8 (2637-2649) \n \n"
+ "Croke, B. F. W., W. S. Merritt, et al. (2004).\n"
+ "A dynamic model for predicting hydrologic response "
+ "to land cover changes in gauged and "
+ "ungauged catchments. \n"
+ "Journal Of Hydrology 291(1-2): 115-131."
+ ));
+
+ Parameters.Add_Table_Output(
+ NULL , "TABLEout" , _TL("Table"),
+ _TL("")
+ );
+
+ //-----------------------------------------------------
+ // Create First Module Dialog
+ _CreateDialog1();
+ //-----------------------------------------------------
+}
+
+///////////////////////////////////////////////////////////////////////
+//
+// Destructor
+//
+///////////////////////////////////////////////////////////////////////
+
+Cihacres_cal2::~Cihacres_cal2(void)
+{
+ //if (m_bSnowModule)
+ //{
+ // delete m_pSnowModule;
+ // delete[] m_pMeltRate;
+ //}
+}
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// On_Execute()
+//
+///////////////////////////////////////////////////////////////////////
+
+
+//---------------------------------------------------------
+// This function is executed when the user is pressing the OK button
+// in the first module dialog
+bool Cihacres_cal2::On_Execute(void)
+{
+ int first, last;
+ double NSE_temp = 0.0;
+ double NSE_max = -9999.9;
+ string nse, nse_text;
+
+ //---------------------------------------------------------
+ // Assign parameters from First Module Dialog
+ m_pTable = Parameters("TABLE") ->asTable();
+ // Field numbers
+ m_dateField = Parameters("DATE_Field") ->asInt();
+ m_dischargeField= Parameters("DISCHARGE_Field") ->asInt();
+ m_pcpField = Parameters("PCP_Field") ->asInt();
+ m_tmpField = Parameters("TMP_Field") ->asInt();
+ m_inflowField = Parameters("INFLOW_Field") ->asInt();
+
+ m_bUpstream = Parameters("bUPSTREAM") ->asBool();
+
+ m_bTMP = Parameters("USE_TMP") ->asBool();
+
+ m_nsim = Parameters("NSIM") ->asInt();
+ m_area = Parameters("AREA") ->asDouble();
+ //m_dev_eRainDis = Parameters("DEV_ERAINDIS") ->asDouble();
+ //m_dev_eRainPCP = Parameters("DEV_ERAINPCP") ->asDouble();
+ m_storconf = Parameters("STORAGE") ->asInt();
+ m_IHAC_version = Parameters("IHACVERS") ->asInt();
+ m_bSnowModule = Parameters("SNOW_MODULE") ->asBool();
+ first = last = 0;
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // After pressing OK in the first Dialog Dialog2 appears.
+ // In the sec
+ if ( _CreateDialog2() )
+ //---------------------------------------------------------
+ {
+ //---------------------------------------------------------
+ // Searching the first and the last record of the time range
+ ihacres.AssignFirstLastRec(*m_pTable, first, last, m_date1, m_date2, m_dateField);
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // Initialize arrays
+ m_nValues = last - first + 1;
+ _InitPointers();
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // Assign selected time range to vector m_vec_date,
+ // discharge[], pcp[], and tmp[]
+ _ReadInputTable(first, last);
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // Convert streamflow from m3/s to mm/day
+ if (m_bUpstream)
+ {
+ // if the subbasin is upstream (without external inflow) then everything
+ // is as it should be.
+ m_p_Q_obs_mmday = model_tools::m3s_to_mmday(m_p_Q_obs_m3s,m_p_Q_obs_mmday,m_nValues,m_area);
+ } else {
+ // if the subbasin is downstream of other subbasins, thus there
+ // are external inflows the array m_p_Q_obs_mmday must be calculated as following:
+ // m_p_Q_obs_mmday =
+ // (observed streamflow at the outlet of the subbasin) - (observed inflow from the upstream subbasin(s))
+ _Calc_ObsMinInflow();
+ m_p_Q_obs_mmday = model_tools::m3s_to_mmday(m_p_Q_dif_m3s, m_p_Q_obs_mmday, m_nValues, m_area);
+ }
+ // calculate sum of observed discharge in [mm]
+ m_sum_obsDisMM = ihacres.SumVector(m_p_Q_obs_mmday, m_nValues);
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ m_pTable = SG_Create_Table();
+ _CreateOutputTable();
+ m_counter = 0;
+ //---------------------------------------------------------
+
+ ///////////////////////////////////////////////////////////
+ //
+ // SIMULATION
+ //
+ ///////////////////////////////////////////////////////////
+
+ // initialize random function
+ srand((unsigned) time(NULL)); // using time.h
+
+ for (int sim = 0; sim < m_nsim && Set_Progress(sim, m_nsim); sim++)
+ {
+ _CalcNonLinearModule();
+
+ _CalcLinearModule();
+
+ _CalcEfficiency();
+
+ // write in output table if criterion is fulfilled
+ NSE_temp = ihacres._Assign_NSE_temp(m_obj_func, m_NSE, m_NSE_highflow, m_NSE_lowflow);
+
+ if (NSE_temp > m_NSEmin)
+ {
+ if (NSE_temp > NSE_max)
+ {
+ NSE_max = NSE_temp;
+ nse = convert_sl::Double2String(NSE_max).c_str();
+ nse_text = "max. NSE ";
+ nse_text += nse;
+ Process_Set_Text(SG_STR_MBTOSG(nse_text.c_str()));
+ }
+
+ _WriteOutputTable();
+ }
+ }
+ //---------------------------------------------------------
+ m_pTable->Set_Name(SG_T("IHACRES_cal2"));
+ Parameters("TABLEout")->Set_Value(m_pTable);
+
+
+
+ //---------------------------------------------------------
+ _DeletePointers();
+ //---------------------------------------------------------
+
+ return(true);
+
+ } // end if (_CreateDialog2())
+
+
+ return(false);
+}
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// PRIVATE FUNCTIONS
+//
+///////////////////////////////////////////////////////////////////////
+
+
+//---------------------------------------------------------------------
+// InitPointers()
+//---------------------------------------------------------------------
+void Cihacres_cal2::_InitPointers()
+{
+ int n = m_nValues;
+
+ m_vec_date.resize(n);
+ if (!m_bUpstream)
+ {
+ m_p_Q_Inflow_m3s = new double[n];
+ m_p_Q_dif_m3s = new double[n];
+ }
+ m_p_Q_obs_m3s = new double[n];
+ m_p_Q_obs_mmday = new double[n];
+ m_p_Q_sim_mmday = new double[n];
+ m_pPCP = new double[n];
+ m_pTMP = new double[n];
+ m_pExcessRain = new double[n];
+ m_pTw = new double[n];
+ m_pWI = new double[n];
+ if (m_bSnowModule)
+ m_pMeltRate = new double[n];
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+// DeletePointers()
+//---------------------------------------------------------------------
+void Cihacres_cal2::_DeletePointers()
+{
+ m_vec_date.resize(0);
+ if (!m_bUpstream)
+ {
+ delete[] m_p_Q_Inflow_m3s;
+ delete[] m_p_Q_dif_m3s;
+ }
+ delete[] m_p_Q_obs_m3s;
+ delete[] m_p_Q_obs_mmday;
+ delete[] m_p_Q_sim_mmday;
+ delete[] m_pPCP;
+ delete[] m_pTMP;
+ delete[] m_pExcessRain;
+ delete[] m_pTw;
+ delete[] m_pWI;
+ if (m_bSnowModule)
+ delete[] m_pMeltRate;
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+// ReadInputTable()
+//---------------------------------------------------------------------
+void Cihacres_cal2::_ReadInputTable(int first, int last)
+{
+ int j, k;
+
+ for (j = 0, k = first; j < m_nValues, k < last + 1; j++, k++)
+ {
+ // put the date string into the vector
+ m_vec_date[j].append(SG_STR_SGTOMB(m_pTable->Get_Record(k)->asString(m_dateField)));
+ m_p_Q_obs_m3s[j]= m_pTable->Get_Record(k)->asDouble(m_dischargeField);
+ m_pPCP[j] = m_pTable->Get_Record(k)->asDouble(m_pcpField);
+ m_pTMP[j] = m_pTable->Get_Record(k)->asDouble(m_tmpField);
+ if (!m_bUpstream)
+ m_p_Q_Inflow_m3s[j] = m_pTable->Get_Record(k)->asDouble(m_inflowField);
+ }
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+// Calculate observed streamflow time series if inflow occurs
+//---------------------------------------------------------------------
+void Cihacres_cal2::_Calc_ObsMinInflow()
+{
+ for (int i = 0; i < m_nValues; i++)
+ {
+ m_p_Q_dif_m3s[i] = m_p_Q_obs_m3s[i] - m_p_Q_Inflow_m3s[i];
+ if (m_p_Q_dif_m3s[i] < 0.0) m_p_Q_obs_mmday[i] = 0;
+ }
+}
+//---------------------------------------------------------------------
+
+
+
+///////////////////////////////////////////////////////////////////////
+//
+//
+// SIMULATION
+//
+//
+///////////////////////////////////////////////////////////////////////
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// NON-LINEAR MODULE
+//
+///////////////////////////////////////////////////////////////////////
+
+void Cihacres_cal2::_CalcNonLinearModule()
+{
+ double eR_init = 0.0;
+ //-------------------------------------------------------------
+ // Assign random values
+ //-------------------------------------------------------------
+ if (m_bSnowModule)
+ {
+ m_SnowParms.T_Rain = model_tools::Random_double(m_T_Rain_lb, m_T_Rain_ub);
+ m_SnowParms.T_Melt = model_tools::Random_double(m_T_Melt_lb, m_T_Melt_ub);
+ m_SnowParms.DD_FAC = model_tools::Random_double(m_DD_FAC_lb, m_DD_FAC_ub);
+
+ m_pSnowModule = new CSnowModule(m_pTMP, m_pPCP, m_nValues,
+ m_SnowParms.T_Rain, m_SnowParms.T_Melt, m_SnowParms.DD_FAC);
+
+ m_pMeltRate = m_pSnowModule->Get_MeltRate(m_pMeltRate, m_nValues);
+ delete m_pSnowModule;
+ }
+
+ m_Tw = model_tools::Random_double(m_TwConst_lb, m_TwConst_ub);
+ m_f = model_tools::Random_double(m_f_lb, m_f_ub);
+ m_c = model_tools::Random_double(m_c_lb, m_c_ub);
+
+ if (m_IHAC_version == 1) { // Croke etal. (2005)
+ m_l = model_tools::Random_double(m_l_lb, m_l_ub);
+ m_p = model_tools::Random_double(m_p_lb, m_p_ub);
+ }
+ //-------------------------------------------------------------
+
+ //-------------------------------------------------------------
+ // Simulation (non-linear module)
+ //-------------------------------------------------------------
+ switch(m_IHAC_version)
+ {
+ case 0: // Jakeman & Hornberger (1993)
+ if (m_bTMP)
+ {
+ ihacres.CalcWetnessTimeConst(m_pTMP, m_pTw, m_Tw, m_f, m_nValues);
+ }
+
+ if (m_bSnowModule)
+ {
+ ihacres.CalcWetnessIndex(m_pTw, m_pPCP, m_pTMP, m_pWI, 0.5, m_c,
+ m_bSnowModule, m_SnowParms.T_Rain, m_nValues);
+
+ ihacres.CalcExcessRain(m_pPCP, m_pTMP, m_pWI,m_pExcessRain,eR_init,
+ m_sum_eRainGTpcp, m_nValues, m_bSnowModule,
+ m_SnowParms.T_Rain, m_SnowParms.T_Melt, m_pMeltRate);
+ } else {
+ ihacres.CalcWetnessIndex(m_pTw, m_pPCP, m_pTMP, m_pWI, 0.5, m_c,
+ m_bSnowModule, 0, m_nValues);
+
+ ihacres.CalcExcessRain(m_pPCP, m_pTMP, m_pWI, m_pExcessRain,eR_init,
+ m_sum_eRainGTpcp, m_nValues, m_bSnowModule,
+ 0,0,0);
+ } // end if (m_bSnowModule)
+
+ break;
+ case 1: // Croke et al. (2005) Redesign
+ if (m_bTMP)
+ {
+ ihacres.CalcWetnessTimeConst_Redesign(m_pTMP, m_pTw, m_Tw, m_f, m_nValues);
+ }
+
+ if (m_bSnowModule)
+ {
+ ihacres.CalcWetnessIndex_Redesign(m_pTw, m_pPCP, m_pWI, 0.5,
+ m_bSnowModule, m_SnowParms.T_Rain, m_nValues);
+
+ ihacres.CalcExcessRain_Redesign(m_pPCP, m_pTMP, m_pWI, m_pExcessRain, eR_init,
+ m_sum_eRainGTpcp, m_nValues,
+ m_c, m_l, m_p,
+ m_bSnowModule, m_SnowParms.T_Rain, m_SnowParms.T_Melt, m_pMeltRate);
+ } else {
+ ihacres.CalcWetnessIndex_Redesign(m_pTw, m_pPCP, m_pWI, 0.5,
+ m_bSnowModule, 0, m_nValues);
+
+ ihacres.CalcExcessRain_Redesign(m_pPCP, m_pTMP, m_pWI, m_pExcessRain, eR_init,
+ m_sum_eRainGTpcp, m_nValues,
+ m_c, m_l, m_p,
+ m_bSnowModule, 0,0,0);
+ }
+ break;
+ } // end switch(m_IHAC_version)
+}
+//---------------------------------------------------------------------
+
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// LINEAR MODULE
+//
+///////////////////////////////////////////////////////////////////////
+
+void Cihacres_cal2::_CalcLinearModule()
+{
+ //-------------------------------------------------------------
+ // Assign random values
+ //-------------------------------------------------------------
+ switch(m_storconf)
+ {
+ case 0: // single storage
+ m_a = model_tools::Random_double(m_a_lb, m_a_ub);
+ m_b = model_tools::Random_double(m_b_lb, m_b_ub);
+ break;
+ case 1: // two storages in parallel
+ do
+ {
+ m_aq = model_tools::Random_double(m_aq_lb, m_aq_ub);
+ m_as = model_tools::Random_double(m_as_lb, m_as_ub);
+ m_bq = model_tools::Random_double(m_bq_lb, m_bq_ub);
+ // Calculate parameter m_vq to check parms aq and bq
+ // Equation after Jakeman & Hornberger (1993)
+ m_vq = m_bq / ( 1 + m_aq );
+ }
+ while (m_vq < 0.0 || m_vq > 1.0);
+ m_bs = ihacres.Calc_Parm_BS(m_aq, m_as, m_bq);
+ break;
+ }
+ //-------------------------------------------------------------
+
+ //-------------------------------------------------------------
+ // Simulate streamflow (linear module)
+ //-------------------------------------------------------------
+ switch(m_storconf)
+ {
+ case 0: // single storage
+ ihacres.SimStreamflowSingle(m_pExcessRain, m_p_Q_obs_mmday[0],
+ m_p_Q_sim_mmday, m_delay, m_a, m_b, m_nValues);
+ break;
+ case 1: // two storages in parallel
+ ihacres.SimStreamflow2Parallel(m_pExcessRain, m_p_Q_sim_mmday, m_p_Q_obs_mmday[0],
+ m_aq, m_as, m_bq, m_bs, m_vq, m_vs, m_IHAC_version, m_nValues, m_delay);
+ break;
+ case 2: // two storages in series
+ break;
+ } // end switch(m_StorConf)
+}
+//---------------------------------------------------------------------
+
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// EFFICIENCY
+//
+///////////////////////////////////////////////////////////////////////
+
+//---------------------------------------------------------------------
+// Nash-Sutcliffe efficiency
+//---------------------------------------------------------------------
+void Cihacres_cal2::_CalcEfficiency()
+{
+ m_NSE = model_tools::CalcEfficiency(m_p_Q_obs_mmday, m_p_Q_sim_mmday,m_nValues);
+ m_NSE_highflow = model_tools::Calc_NSE_HighFlow(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues);
+ m_NSE_lowflow = model_tools::Calc_NSE_LowFlow(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues);
+ m_PBIAS = model_tools::Calc_PBIAS(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues);
+}
+//---------------------------------------------------------------------
+
+
+
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// CREATE TABLES
+//
+/////////////////////////////////////////////////////////////////////////////
+
+//---------------------------------------------------------------------
+// Create output table
+//---------------------------------------------------------------------
+void Cihacres_cal2::_CreateOutputTable()
+{
+ // creating the column titles
+ m_pTable->Add_Field("NSE", SG_DATATYPE_Double);
+ m_pTable->Add_Field("NSE_high", SG_DATATYPE_Double);
+ m_pTable->Add_Field("NSE_low", SG_DATATYPE_Double);
+ m_pTable->Add_Field("PBIAS", SG_DATATYPE_Double);
+ m_pTable->Add_Field("eR_ovest", SG_DATATYPE_Double);
+ m_pTable->Add_Field("vq", SG_DATATYPE_Double);
+ m_pTable->Add_Field("vs", SG_DATATYPE_Double);
+ m_pTable->Add_Field("T(q)", SG_DATATYPE_Double);
+ m_pTable->Add_Field("T(s)", SG_DATATYPE_Double);
+ m_pTable->Add_Field("Tw", SG_DATATYPE_Double);
+ m_pTable->Add_Field("f", SG_DATATYPE_Double);
+ m_pTable->Add_Field("c", SG_DATATYPE_Double);
+ if ( m_IHAC_version == 1 ) // Croke etal. (2005)
+ {
+ m_pTable->Add_Field("l", SG_DATATYPE_Double);
+ m_pTable->Add_Field("p", SG_DATATYPE_Double);
+ }
+ if (m_bSnowModule)
+ {
+ m_pTable->Add_Field("T_Rain", SG_DATATYPE_Double);
+ m_pTable->Add_Field("T_Melt", SG_DATATYPE_Double);
+ m_pTable->Add_Field("DD_FAC", SG_DATATYPE_Double);
+ }
+ switch(m_storconf)
+ {
+ case 0: // single
+ m_pTable->Add_Field("a", SG_DATATYPE_Double);
+ m_pTable->Add_Field("b", SG_DATATYPE_Double);
+ break;
+ case 1: // two storages in parallel
+ m_pTable->Add_Field("aq", SG_DATATYPE_Double);
+ m_pTable->Add_Field("as", SG_DATATYPE_Double);
+ m_pTable->Add_Field("bq", SG_DATATYPE_Double);
+ m_pTable->Add_Field("bs", SG_DATATYPE_Double);
+ break;
+ }
+}
+//---------------------------------------------------------------------
+
+
+//---------------------------------------------------------------------
+// Create output table
+//---------------------------------------------------------------------
+void Cihacres_cal2::_WriteOutputTable()
+{
+ int field = 0;
+ CSG_Table_Record *pRecord;
+
+ // add a new record to the table
+ m_pTable->Add_Record();
+ pRecord = m_pTable->Get_Record(m_counter);
+
+ // writing the data to the current row
+ pRecord->Set_Value(field,m_NSE); field++;
+ pRecord->Set_Value(field,m_NSE_highflow); field++;
+ pRecord->Set_Value(field,m_NSE_lowflow); field++;
+ pRecord->Set_Value(field,m_PBIAS); field++;
+ pRecord->Set_Value(field,m_sum_eRainGTpcp); field++;
+ pRecord->Set_Value(field,m_vq); field++;
+ pRecord->Set_Value(field,m_vs); field++;
+ pRecord->Set_Value(field,ihacres.Calc_TimeOfDecay(m_aq)); field++;
+ pRecord->Set_Value(field,ihacres.Calc_TimeOfDecay(m_as)); field++;
+ pRecord->Set_Value(field,m_Tw); field++;
+ pRecord->Set_Value(field,m_f); field++;
+ pRecord->Set_Value(field,m_c); field++;
+ if ( m_IHAC_version == 1 ) // Croke et al. (2005)
+ {
+ pRecord->Set_Value(field,m_l); field++;
+ pRecord->Set_Value(field,m_p); field++;
+ }
+ if ( m_bSnowModule )
+ {
+ pRecord->Set_Value(field,m_SnowParms.T_Rain); field++;
+ pRecord->Set_Value(field,m_SnowParms.T_Melt); field++;
+ pRecord->Set_Value(field,m_SnowParms.DD_FAC); field++;
+ }
+ switch(m_storconf)
+ {
+ case 0: // single
+ pRecord->Set_Value(field,m_a); field++;
+ pRecord->Set_Value(field,m_b); field++;
+ break;
+ case 1: // two storages in parallel
+ pRecord->Set_Value(field,m_aq); field++;
+ pRecord->Set_Value(field,m_as); field++;
+ pRecord->Set_Value(field,m_bq); field++;
+ pRecord->Set_Value(field,m_bs); field++;
+ break;
+ }
+ m_counter++; // record counter
+}
+//---------------------------------------------------------------------
+
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// DIALOGS
+//
+///////////////////////////////////////////////////////////////////////
+
+
+//---------------------------------------------------------------------
+// DIALOG 1
+//---------------------------------------------------------------------
+void Cihacres_cal2::_CreateDialog1()
+{
+ CSG_Parameter *pNode;
+ CSG_String s;
+
+ pNode = Parameters.Add_Table(
+ NULL , "TABLE" , _TL("Table"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "DATE_Field" , _TL("Date Column"),
+ _TL("Select the column containing the Date")
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "DISCHARGE_Field" , _TL("Streamflow Column"),
+ _TL("Select the Column containing Discharge Values")
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "PCP_Field" , _TL("Precipitation Column"),
+ _TL("Select the Column containing precipitation Values")
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "TMP_Field" , _TL("Temperature Column"),
+ _TL("Select the Column containing Temperature Values")
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "INFLOW_Field" , _TL("Subbasin Inflow"),
+ _TL("Select the column containing inflow data to the subbasin")
+ );
+
+ Parameters.Add_Value(
+ pNode, "bUPSTREAM", _TL("Is the subbasin upstream (no external inflow)"),
+ _TL("If checked, it means there is no external inflow to the subbasin"),
+ PARAMETER_TYPE_Bool, true
+ );
+
+ Parameters.Add_Value(
+ pNode, "USE_TMP", _TL("Using temperature data?"),
+ _TL("If checked, then temperature data are used."),
+ PARAMETER_TYPE_Bool, true
+ );
+
+ pNode = Parameters.Add_Value(
+ NULL, "NSIM", _TL("Number of Simulations"),
+ _TL("Number of Simulations for Calibration"),
+ PARAMETER_TYPE_Int,
+ 1000, 1, true, 10000000, true
+ );
+
+ pNode = Parameters.Add_Value(
+ NULL, "AREA", _TL("Area of the Watershed in [km2]"),
+ _TL("Area of the Watershed in [km2] used for unit conversion"),
+ PARAMETER_TYPE_Double,
+ 100.0, 0.00001, true, 0.0, false
+ );
+
+ //s.Printf(SG_T("Node2", 2);
+ // pNode = Parameters.Add_Node(NULL,s,SG_T("Non-Linear Module",_TL(""));
+
+ //Parameters.Add_Value(
+ // pNode, "DEV_ERAINDIS", _TL("Maximum Deviation: ExcessRain-Streamflow [%]"),
+ // _TL("Maximum Deviation between estimated excess rainfall and observed streamflow volumes"),
+ // PARAMETER_TYPE_Double,
+ // 5.0, 0.0, true, 50.0, true
+ //);
+
+ //Parameters.Add_Value(
+ // pNode, "DEV_ERAINPCP", _TL("Maximum Overestimation of ExcessRain [%]"),
+ // _TL("Maximum Sum of overestimated ExcessRain to total ExcessRain in [%]"),
+ // PARAMETER_TYPE_Double,
+ // 5.0, 0.0, true, 50.0, true
+ //);
+
+ s.Printf(SG_T("Node3"), 3);
+ pNode = Parameters.Add_Node(NULL,s,SG_T("Storage Configuration"),_TL(""));
+
+ Parameters.Add_Choice(
+ pNode , "STORAGE" , _TL("Storage"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("Single Storage"), // 0
+ _TL("Two Parallel Storages"), // 1
+ _TL("Two Storages in Series") // 2
+ )
+ );
+
+ s.Printf(SG_T("Node4"), 4);
+ pNode = Parameters.Add_Node(NULL,s,_TL("IHACRES Version"),_TL(""));
+
+ Parameters.Add_Choice(
+ pNode , "IHACVERS" , _TL("IHACRES Version"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("Jakeman & Hornberger (1993)"), // 0
+ _TL("Croke et al. (2005)") // 1
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode, "SNOW_MODULE", _TL("Snow Module on/off"),
+ _TL("If checked the snow module is active"),
+ PARAMETER_TYPE_Bool, true
+ );
+
+ Parameters.Add_Table_Output(
+ NULL , "TABLEout" , _TL("Table"),
+ _TL("")
+ );
+ Parameters.Add_Table_Output(
+ NULL , "TABLEparms" , _TL("Table"),
+ _TL("")
+ );
+}
+//---------------------------------------------------------------------
+
+
+//---------------------------------------------------------------------
+// DIALOG 2
+//---------------------------------------------------------------------
+bool Cihacres_cal2::_CreateDialog2()
+{
+ CSG_String s;
+ CSG_Parameters P; // used to add Parameters in the second dialog
+ CSG_Parameter *pNode, *pNode1;
+
+
+ // Dialog design
+ P.Set_Name(_TL("IHACRES Model Parameters"));
+
+ s.Printf(SG_T("Node1"), 1);
+ pNode = P.Add_Node(NULL,s,SG_T("Time Range"),_TL(""));
+
+ s.Printf(SG_T("FDAY") , 1-1);
+ P.Add_String(pNode,s,_TL("First Day"),_TL(""),
+ m_pTable->Get_Record(0)->asString(m_dateField));
+
+ s.Printf(SG_T("LDAY") , 1-2);
+ P.Add_String(pNode,s,_TL("Last Day"),_TL(""),
+ m_pTable->Get_Record(m_pTable->Get_Record_Count()-1)->asString(m_dateField));
+
+ //-----------------------------------------------------------------
+ // Non-linear parameters
+ //-----------------------------------------------------------------
+ s.Printf(SG_T("Node2"), 2);
+ pNode = P.Add_Node(NULL,s,SG_T("Non-Linear Module"),_TL(""));
+
+ P.Add_Value(
+ pNode, "TwFAC_lb", _TL("(Tw) wetness decline time constant [lower bound]"),
+ _TW("Tw is approximately the time constant, or inversely,"
+ "the rate at which the catchment wetness declines in the absence of rainfall"),
+ PARAMETER_TYPE_Double,
+ 1.0, 0.01, true, 150.0, true
+ );
+ P.Add_Value(
+ pNode, "TwFAC_ub", _TL("(Tw) wetness decline time constant [upper bound]"),
+ _TW("Tw is approximately the time constant, or inversely,SG_T("
+ "the rate at which the catchment wetness declines in the absence of rainfall"),
+ PARAMETER_TYPE_Double,
+ 50.0, 0.01, true, 150.0, true
+ );
+
+ if (m_bTMP) // if observed temperature data are used
+ {
+ P.Add_Value(
+ pNode , "TFAC_lb" , _TL("(f) Temperature Modulation Factor [lower bound]"),
+ _TL("Temperature Modulation Factor f"),
+ PARAMETER_TYPE_Double,
+ 0.05, 0.0001, true, 5.0, true
+ );
+ P.Add_Value(
+ pNode , "TFAC_ub" , _TL("(f) Temperature Modulation Factor [upper bound]"),
+ _TL("Temperature Modulation Factor f"),
+ PARAMETER_TYPE_Double,
+ 0.5, 0.0001, true, 5.0, true
+ );
+ }
+
+ P.Add_Value(
+ pNode, "CFAC_lb", _TL("(c) Parameter [lower bound]"),
+ _TL("Parameter (c) to fit streamflow volume"),
+ PARAMETER_TYPE_Double,
+ 0.001, 0.0, true, 1.0, true
+ );
+ P.Add_Value(
+ pNode, "CFAC_ub", _TL("(c) Parameter [upper bound]"),
+ _TL("Parameter (c) to fit streamflow volume"),
+ PARAMETER_TYPE_Double,
+ 0.01, 0.0, true, 1.0, true
+ );
+
+ if (m_IHAC_version == 1) // Croke et al. (2005) Redesign
+ {
+ s.Printf(SG_T("Node2-2"), 2-2);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Soil moisture index threshold"),_TL(""));
+
+ P.Add_Value(
+ pNode1 , "SMI_L_lb" , _TL("Soil moisture index (l) [lower bound]"),
+ _TL("Soil moisture index threshold (l), lower bound"),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 5.0, true
+ );
+ P.Add_Value(
+ pNode1 , "SMI_L_ub" , _TL("Soil moisture index (l) [upper bound]"),
+ _TL("Soil moisture index threshold (l), upper bound"),
+ PARAMETER_TYPE_Double,
+ 5.0, 0.0, true, 5.0, true
+ );
+ s.Printf(SG_T("Node2-3"), 2-3);
+ pNode1 = P.Add_Node(pNode,s,_TL("Power on soil moisture"),_TL(""));
+
+ P.Add_Value(
+ pNode1 , "SM_P_lb" , _TL("Power on soil (p) [lower bound]"),
+ _TL("Power on soil moisture (p), lower bound"),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 5.0, true
+ );
+ P.Add_Value(
+ pNode1 , "SM_P_ub" , _TL("Power on soil (p) [upper bound]"),
+ _TL("Power on soil moisture (p), upper bound"),
+ PARAMETER_TYPE_Double,
+ 5.0, 0.0, true, 5.0, true
+ );
+ }
+ //-----------------------------------------------------------------
+ // Linear module
+ //-----------------------------------------------------------------
+ switch(m_storconf)
+ {
+ case 0: // single storage
+ s.Printf(SG_T("Node3"), 3);
+ pNode = P.Add_Node(NULL,s,_TL("Linear Module"),_TL(""));
+
+ s.Printf(SG_T("Node3-1"), 3-1);
+ pNode1 = P.Add_Node(pNode,s,_TL("Parameter (a)"),_TL(""));
+
+ P.Add_Value(
+ pNode1, "AFAC_lb", _TL("(a) [lower bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.5, -0.99, true, -0.01, true
+ );
+ P.Add_Value(
+ pNode1, "AFAC_ub", _TL("(a) [upper bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.9, -0.99, true, -0.01, true
+ );
+
+ s.Printf(SG_T("Node3-2"), 3-2);
+ pNode1 = P.Add_Node(pNode,s,_TL("Parameter (b)"),_TL(""));
+
+ P.Add_Value(
+ pNode1, "BFAC_lb", _TL("(b) [lower bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.001, true, 1.0, true
+ );
+ P.Add_Value(
+ pNode1, "BFAC_ub", _TL("(b) [upper bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 1.0, 0.001, true, 1.0, true
+ );
+ break;
+
+ case 1: // two parallel storages
+ s.Printf(SG_T("Node3"), 3);
+ pNode = P.Add_Node(NULL,s,_TL("Linear Module"),_TL(""));
+
+ // Parameter a
+ s.Printf(SG_T("Node3-1"), 3-1);
+ pNode1 = P.Add_Node(pNode,s,_TL("Parameter (a)"),_TL(""));
+
+ P.Add_Value(
+ pNode1, "AQ_lb", _TL("a(q) [lower bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.5, -0.99, true, -0.01, true
+ );
+ P.Add_Value(
+ pNode1, "AQ_ub", _TL("a(q) [upper bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.7, -0.99, true, -0.01, true
+ );
+ P.Add_Value(
+ pNode1, "AS_lb", _TL("a(s) [lower bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.7, -0.99, true, -0.01, true
+ );
+ P.Add_Value(
+ pNode1, "AS_ub", _TL("a(s) [upper bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.99, -0.99, true, -0.01, true
+ );
+
+ // Parameter b
+ s.Printf(SG_T("Node3-2"), 3-2);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Parameter (b)"),_TL(""));
+
+ P.Add_Value(
+ pNode1, "BQ_lb", _TL("b(q) [lower bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 1.0, true
+ );
+ P.Add_Value(
+ pNode1, "BQ_ub", _TL("b(q) [upper bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.5, 0.0, true, 1.0, true
+ );
+ break;
+ case 2: // two storages in series
+ break;
+ } // end switch (m_storconf)
+
+
+ //-----------------------------------------------------------------
+ // Snow module
+ //-----------------------------------------------------------------
+ if (m_bSnowModule) // if snow module is active
+ {
+ s.Printf(SG_T("Node2-4"), 2-4);
+ pNode = P.Add_Node(NULL,s,SG_T("Snow Module"),_TL(""));
+
+ P.Add_Value(
+ pNode, "T_RAIN_lb", _TL("Temperature Threshold for Rainfall (lower bound)"),
+ _TL("Below this threshold precipitation will fall as snow"),
+ PARAMETER_TYPE_Double,
+ -1.0, -10.0, true, 10.0, true
+ );
+ P.Add_Value(
+ pNode, "T_RAIN_ub", _TL("Temperature Threshold for Rainfall (upper bound)"),
+ _TL("Below this threshold precipitation will fall as snow"),
+ PARAMETER_TYPE_Double,
+ 1.0, -10.0, true, 10.0, true
+ );
+ P.Add_Value(
+ pNode, "T_MELT_lb", _TL("Temperature Threshold for Melting (lower bound)"),
+ _TL("Above this threshold snow will start to melt"),
+ PARAMETER_TYPE_Double,
+ -1.0, -5.0, true, 10.0, true
+ );
+ P.Add_Value(
+ pNode, "T_MELT_ub", _TL("Temperature Threshold for Melting (upper bound)"),
+ _TL("Above this threshold snow will start to melt"),
+ PARAMETER_TYPE_Double,
+ 1.0, -5.0, true, 10.0, true
+ );
+ P.Add_Value(
+ pNode, "DD_FAC_lb", _TL("Day-Degree Factor (lower bound)"),
+ _TL("Day-Degree Factor depends on catchment characteristics"),
+ PARAMETER_TYPE_Double,
+ 0.7, 0.7, true, 9.2, true
+ );
+ P.Add_Value(
+ pNode, "DD_FAC_ub", _TL("Day-Degree Factor (upper bound)"),
+ _TL("Day-Degree Factor depends on catchment characteristics"),
+ PARAMETER_TYPE_Double,
+ 9.2, 0.7, true, 9.2, true
+ );
+ }
+
+
+
+ s.Printf(SG_T("Node4"), 4);
+ pNode = P.Add_Node(NULL,s,SG_T("Time Delay after Start of Rainfall (INTEGER)"),_TL(""));
+
+ P.Add_Value(
+ pNode1, "DELAY", _TL("Time Delay (Rain-Runoff)"),
+ _TL("The delay after the start of rainfall, before the discharge starts to rise."),
+ PARAMETER_TYPE_Int,
+ 1, 1, true, 100, true
+ );
+
+ s.Printf(SG_T("Node6"), 6);
+ pNode = P.Add_Node(NULL,s,SG_T("Nash-Sutcliffe Efficiency"),_TL(""));
+
+ P.Add_Choice(
+ pNode, "OBJ_FUNC" , _TL("Objective Function"),
+ _TL(""),
+ _TL("NSE|NSE high flow|NSE low flow")
+ );
+
+ P.Add_Value(
+ pNode, "NSEMIN", _TL("Minimum Nash-Sutcliffe Efficiency"),
+ _TL("Minimum Nash-Sutcliffe Efficiency required to print simulation to calibration table"),
+ PARAMETER_TYPE_Double,
+ 0.7, 0.1, true, 1.0, true
+ );
+ // End of second dialog design
+
+
+ if( SG_UI_Dlg_Parameters(&P, _TL("Choose Time Range")) )
+ {
+ // assign data from second dialog
+
+ m_date1 = P(CSG_String::Format(SG_T("FDAY"),m_dateField).c_str())->asString();
+ m_date2 = P(CSG_String::Format(SG_T("LDAY"),m_dischargeField).c_str())->asString();
+
+ //-------------------------------------------------
+ // assign non-linear module parameters
+ //-------------------------------------------------
+ m_TwConst_lb = P("TwFAC_lb") ->asDouble();
+ m_TwConst_ub = P("TwFAC_ub") ->asDouble();
+ m_c_lb = P("CFAC_lb") ->asDouble();
+ m_c_ub = P("CFAC_ub") ->asDouble();
+
+ if (m_bTMP) // if observed temperature data are used
+ {
+ m_f_lb = P("TFAC_lb") ->asDouble();
+ m_f_ub = P("TFAC_ub") ->asDouble();
+ }
+ if (m_IHAC_version == 1)
+ {
+ m_l_lb = P("SMI_L_lb") ->asDouble();
+ m_l_ub = P("SMI_L_ub") ->asDouble();
+ m_p_lb = P("SM_P_lb") ->asDouble();
+ m_p_ub = P("SM_P_ub") ->asDouble();
+ }
+ //-------------------------------------------------
+
+ //-------------------------------------------------
+ // assign linear module parameters
+ //-------------------------------------------------
+ switch (m_storconf)
+ {
+ case 0:
+ m_a_lb = P("AFAC_lb") ->asDouble();
+ m_a_ub = P("AFAC_ub") ->asDouble();
+ m_b_lb = P("BFAC_lb") ->asDouble();
+ m_b_ub = P("BFAC_ub") ->asDouble();
+ m_delay = P("DELAY") ->asInt();
+ m_NSEmin = P("NSEMIN") ->asDouble();
+ break;
+ case 1: // two parallel storages
+ m_aq_lb = P("AQ_lb") ->asDouble();
+ m_aq_ub = P("AQ_ub") ->asDouble();
+ m_as_lb = P("AS_lb") ->asDouble();
+ m_as_ub = P("AS_ub") ->asDouble();
+ m_bq_lb = P("BQ_lb") ->asDouble();
+ m_bq_ub = P("BQ_ub") ->asDouble();
+
+ m_delay = P("DELAY") ->asInt();
+ m_obj_func = P("OBJ_FUNC") ->asInt();
+ m_NSEmin = P("NSEMIN") ->asDouble();
+ break;
+ case 2: // two storages in series
+ break;
+ } // end switch
+ //-------------------------------------------------
+
+ if (m_bSnowModule)
+ {
+ m_T_Rain_lb = P("T_RAIN_lb") ->asDouble();
+ m_T_Rain_ub = P("T_RAIN_ub") ->asDouble();
+ m_T_Melt_lb = P("T_MELT_lb") ->asDouble();
+ m_T_Melt_ub = P("T_MELT_ub") ->asDouble();
+ m_DD_FAC_lb = P("DD_FAC_lb") ->asDouble();
+ m_DD_FAC_ub = P("DD_FAC_ub") ->asDouble();
+ }
+ return(true);
+ } else {
+ return(false);
+ }
+}
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_cal2.h b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_cal2.h
new file mode 100644
index 0000000..c0ff903
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_cal2.h
@@ -0,0 +1,256 @@
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// IHACRES //
+// //
+//-------------------------------------------------------//
+// //
+// ihacres_cal2.h //
+// //
+// Copyright (C) 2008 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// //
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// //
+// 2008-01-15 //
+// //
+///////////////////////////////////////////////////////////
+
+
+//*******************************************************//
+// ToDo //
+//-------------------------------------------------------//
+// -
+//*******************************************************//
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__ihacres_cal2_H
+#define HEADER_INCLUDED__ihacres_cal2_H
+//---------------------------------------------------------
+
+#include "MLB_Interface.h"
+#include "ihacres_eq.h"
+
+#include <vector> // used for storing date string values in array
+//using namespace std;
+typedef std::vector<std::string> date_array;
+//typedef std::vector<double> vector_d;
+//typedef std::vector<int> vector_i;
+//typedef std::vector<bool> vector_b;
+//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////////////////
+//
+// CLASS Cihacres_cal2
+//
+///////////////////////////////////////////////////////////////////////
+
+class Cihacres_cal2 : public CSG_Module
+{
+public:
+
+ // constructor
+ Cihacres_cal2(void);
+
+ // destructor
+ virtual ~Cihacres_cal2(void);
+
+protected:
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // PROTECTED FUNCTIONS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ // execute module
+ virtual bool On_Execute (void);
+
+private:
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // PRIVATE PARAMETERS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ //-----------------------------------------------------------------
+ // EXTERNAL CLASSES
+ //-----------------------------------------------------------------
+ Cihacres_eq ihacres; // all IHACRES equations are defined here
+
+ CSnowModule* m_pSnowModule; // (snow_module.h/.cpp)
+ CSnowParms m_SnowParms;
+ //-----------------------------------------------------------------
+
+ //-----------------------------------------------------------------
+ // TIME SERIES PARAMETERS
+ //-----------------------------------------------------------------
+ int m_nValues; // number of values / time steps in simulation
+ date_array m_vec_date; // Vector containing date values
+ double* m_p_Q_Inflow_m3s;
+ double* m_p_Q_dif_m3s;
+ double* m_p_Q_obs_m3s; // Array containing observed discharge values in [m3/s]
+ double* m_p_Q_obs_mmday;// Array containing observed discharge values in [mm]
+ double* m_p_Q_sim_mmday; // simulated streamflow [mm/day]
+ double* m_pPCP; // Array containing observed precipitation values
+ double* m_pTMP; // Array containing temperature values
+
+ // non-linear module time series
+ double* m_pExcessRain; // "excess" or effective rainfall [mm]
+ double* m_pTw; // Tw is approximately the time constant, or inversely,
+ // the rate at which the catchment wetness declines
+ // in the absence of rainfall.
+ double* m_pWI; // catchment wetness index
+
+ double* m_pMeltRate; // if snow module is active
+
+ double m_sum_obsDisMM;
+ double m_sum_eRainGTpcp;
+ //-----------------------------------------------------------------
+
+ //-----------------------------------------------------------------
+ // MODEL PARAMETERS / Cihacres_eq
+ //-----------------------------------------------------------------
+ // NON-LINEAR MODULE
+ double m_Tw;
+ double m_f;
+ double m_c;
+ double m_l;
+ double m_p;
+
+ // LINEAR MODULE
+ double m_a;
+ double m_b;
+ double m_aq;
+ double m_as;
+ double m_bq;
+ double m_bs;
+
+ double m_vq;
+ double m_vs;
+ //-----------------------------------------------------------------
+
+ //-----------------------------------------------------------------
+ // PARAMETERS DIALOG 1
+ //-----------------------------------------------------------------
+ CSG_Table* m_pTable;
+ int m_dateField;
+ int m_dischargeField;
+ int m_pcpField;
+ int m_tmpField;
+
+ int m_inflowField;
+ bool m_bUpstream; // true = upstream, false = downstream
+
+ bool m_bTMP;
+
+ int m_nsim; // number of simulations
+ double m_area; // area of the watershed in [km2]
+ //double m_dev_eRainDis;
+ //double m_dev_eRainPCP;
+ int m_storconf;
+ int m_IHAC_version;
+ bool m_bSnowModule;
+ //-----------------------------------------------------------------
+
+ //-----------------------------------------------------------------
+ // PARAMETERS DIALOG 2
+ //-----------------------------------------------------------------
+ CSG_String m_date1, m_date2;
+ //-----------------------------------------------------------------
+ // CALIBRATION PARAMETERS
+ //-----------------------------------------------------------------
+ // non linear module parameters
+ double m_TwConst_ub; // Tw is approximately the time constant, or inversely,
+ double m_TwConst_lb; // the rate at which the catchment wetness declines
+ // in the absence of rainfall.
+ double m_f_lb; // temperature modulation factor which
+ double m_f_ub; // determines how Tw changes with temperature
+ double m_c_lb; // Parameter c is chosen so that the volume
+ double m_c_ub; // of excess rainfall is equal to the total
+ // streamflow over the calibration period
+ // Croke et al. (2005) Redesign of non-linear module
+ double m_l_lb; // soil moisture index threshold
+ double m_l_ub;
+ double m_p_lb; // power on soil moisture
+ double m_p_ub;
+
+ // linear module parameters (single storage)
+ double m_a_lb;
+ double m_a_ub;
+ double m_b_lb;
+ double m_b_ub;
+ // linear module parameters (2 storages)
+ double m_aq_lb;
+ double m_aq_ub;
+ double m_as_lb;
+ double m_as_ub;
+ double m_bq_lb;
+ double m_bq_ub;
+ // SnowModule calibration parameters
+ double m_T_Rain_lb;
+ double m_T_Rain_ub;
+ double m_T_Melt_lb;
+ double m_T_Melt_ub;
+ double m_DD_FAC_lb;
+ double m_DD_FAC_ub;
+
+ int m_delay;
+ int m_obj_func;
+ double m_NSEmin;
+ double m_NSE;
+ double m_NSE_highflow;
+ double m_NSE_lowflow;
+ double m_PBIAS; // percent bias
+
+ int m_counter; // used by writing output table
+ //-----------------------------------------------------------------
+
+
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // PRIVATE FUNCTIONS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ //-----------------------------------------------------------------
+ void _InitPointers();
+ void _DeletePointers();
+ void _ReadInputTable(int first, int last);
+ void _Calc_ObsMinInflow();
+ //-----------------------------------------------------------------
+
+ //-----------------------------------------------------------------
+ // Simulation
+ //-----------------------------------------------------------------
+ void _CalcNonLinearModule();
+ void _CalcLinearModule();
+ void _CalcEfficiency();
+ //-----------------------------------------------------------------
+
+ //-----------------------------------------------------------------
+ // Output
+ //-----------------------------------------------------------------
+ void _CreateOutputTable();
+ //void _CreateTable2Storages();
+ void _WriteOutputTable();
+ //void _WriteTable2Storages();
+ //-----------------------------------------------------------------
+
+ //-----------------------------------------------------------------
+ // Dialogs
+ //-----------------------------------------------------------------
+ void _CreateDialog1();
+ bool _CreateDialog2();
+ //-----------------------------------------------------------------
+};
+
+#endif /* HEADER_INCLUDED__ihacres_cal2_H */
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev.cpp b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev.cpp
new file mode 100644
index 0000000..7bd3b51
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev.cpp
@@ -0,0 +1,890 @@
+///////////////////////////////////////////////////////////
+// ihacres_elev.cpp //
+// //
+// Copyright (C) 2008 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// 2008-01-08 //
+///////////////////////////////////////////////////////////
+
+#include "ihacres_elev.h"
+#include "convert_sl.h"
+#include "model_tools.h"
+
+// TEST OUTPUT ONLY
+#include <fstream>
+
+//---------------------------------------------------------------------
+
+Cihacres_elev::Cihacres_elev()
+{
+ //-----------------------------------------------------
+ // 1. Info...
+ Set_Name(_TL("IHACRES Elevation Bands"));
+
+ Set_Author(SG_T("copyrights (c) 2008 Stefan Liersch"));
+
+ Set_Description(_TW("The Rainfall-Runoff Model IHACRES \n \n \n"
+ "Reference: \n \n"
+ "Jakeman, A.J. / Hornberger, G.M. (1993). \n"
+ "How Much Complexity Is Warranted in a Rainfall-Runoff Model? \n"
+ "Water Resources Research, (29), NO. 8 (2637-2649) \n \n"
+ "Croke, B. F. W., W. S. Merritt, et al. (2004).\n"
+ "A dynamic model for predicting hydrologic response "
+ "to land cover changes in gauged and "
+ "ungauged catchments. \n"
+ "Journal Of Hydrology 291(1-2): 115-131."
+ ));
+
+ Parameters.Add_Table_Output(
+ NULL , "TABLEout" , _TL("Table"),
+ _TL("")
+ );
+
+ ///////////////////////////////////////////////////////////////////
+ // FIRST MODULE DIALOG
+ _CreateDialog1();
+ ///////////////////////////////////////////////////////////////////
+}
+
+Cihacres_elev::~Cihacres_elev()
+{}
+//---------------------------------------------------------------------
+
+bool Cihacres_elev::On_Execute()
+{
+ CSG_Parameters P;
+ //std::ofstream f("_out_elev.txt");
+
+ // Assign Parameters from first Module Dialog
+ //---------------------------------------------------------
+ int eb = Parameters("NELEVBANDS") ->asInt();
+ m_nElevBands = eb + 2; // because list starts with 2 !
+ m_Area_tot = Parameters("AREA_tot") ->asDouble();
+ m_IHAC_version = Parameters("IHACVERS") ->asInt();
+ m_StorConf = Parameters("STORAGE") ->asInt();
+ m_bSnowModule = Parameters("SNOW_MODULE") ->asBool();
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // Assign number of storages
+ m_nStorages = ihacres.Assign_nStorages(m_StorConf);
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // Initialize pointers
+ _Init_ElevBands(m_nElevBands);
+ m_p_linparms = new C_IHAC_LinearParms(m_nElevBands,m_nStorages);
+ m_p_nonlinparms = new C_IHAC_NonLinearParms(m_nElevBands);
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // open second and third user dialog
+ if ( _CreateDialog2() && _CreateDialog3())
+ {
+ //---------------------------------------------------------
+ // searching the first and the last record of the time range
+ ihacres.AssignFirstLastRec(*m_p_InputTable, m_first, m_last, m_date1, m_date2, m_dateField);
+ m_nValues = m_last - m_first + 1;
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ _Init_Pointers(m_nValues);
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // read input table
+ _ReadInputFile();
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // PERFORM STREAMFLOW SIMULATION
+ // FOR EACH ELEVATION BAND
+ //---------------------------------------------------------
+ // Convert Streamflow vector from m3/s*day-1 to mm/day
+ m_p_Q_obs_mmday = model_tools::m3s_to_mmday(m_p_Q_obs_m3s, m_p_Q_obs_mmday, m_nValues, m_Area_tot);
+
+ //---------------------------------------------------------
+ // SNOW MODULE
+ //---------------------------------------------------------
+ for (int i = 0; i < m_nElevBands; i++)
+ {
+ if (m_bSnowModule)
+ {
+ _CalcSnowModule(i);
+ }
+
+ _Simulate_NonLinearModule(i);
+
+ _Simulate_Streamflow(i);
+ }
+
+ //---------------------------------------------------------
+
+ m_pTable = SG_Create_Table();
+ _CreateTableSim();
+ // add tables to SAGA Workspace
+ m_pTable->Set_Name(SG_T("IHACRES_ElevBands_output"));
+ Parameters("TABLEout")->Set_Value(m_pTable);
+
+ delete[] m_p_elevbands; // sämtliche Unter-Pointer noch löschen
+ delete[] m_p_pcpField;
+ delete[] m_p_tmpField;
+ delete m_p_linparms;
+ delete m_p_nonlinparms;
+ if (m_bSnowModule) delete[] m_pSnowparms;
+
+ return(true);
+ } // end if ( _CreateDialog2() )
+
+ // delete[] m_p_elevbands;
+ // delete[] m_p_pcpFields;
+ // delete[] m_p_tmpFields;
+ // delete m_p_linparms;
+ // delete m_p_nonlinparms;
+ return(false);
+}
+
+//---------------------------------------------------------------------
+
+void Cihacres_elev::_Init_ElevBands(int n)
+{
+ // instantiate elevation bands
+ m_p_elevbands = new Cihacres_elev_bands[n];
+
+ // instantiate field numbers
+ m_p_pcpField = new int[n];
+ m_p_tmpField = new int[n];
+
+ if ( m_bSnowModule) {
+ m_pSnowparms = new CSnowParms[n];
+ }
+
+}
+//---------------------------------------------------------------------
+
+void Cihacres_elev::_Init_Pointers(int nvals)
+{
+ m_vec_date.resize(nvals);
+ m_p_Q_obs_m3s = new double[nvals];
+ m_p_Q_obs_mmday = new double[nvals];
+
+ for (int eb = 0; eb < m_nElevBands; eb++)
+ {
+ m_p_elevbands[eb].m_p_pcp = new double[nvals];
+ m_p_elevbands[eb].m_p_tmp = new double[nvals];
+ m_p_elevbands[eb].m_p_ER = new double[nvals];
+ m_p_elevbands[eb].m_p_streamflow_sim = new double[nvals];
+ m_p_elevbands[eb].m_p_Tw = new double[nvals];
+ m_p_elevbands[eb].m_p_WI = new double[nvals];
+
+ if (m_bSnowModule) {
+ m_p_elevbands[eb].m_p_SnowStorage = new double[nvals];
+ m_p_elevbands[eb].m_p_MeltRate = new double[nvals];
+ }
+ }
+}
+//---------------------------------------------------------------------
+
+void Cihacres_elev::_ReadInputFile()
+{
+ for (int j = 0, k = m_first; j < m_nValues, k < m_last + 1; j++, k++)
+ {
+ m_vec_date[j].append(SG_STR_SGTOMB(m_p_InputTable->Get_Record(k)->asString(m_dateField)));
+ m_p_Q_obs_m3s[j] = m_p_InputTable->Get_Record(k)->asDouble(m_streamflowField);
+
+ for (int eb = 0; eb < m_nElevBands; eb++)
+ {
+ m_p_elevbands[eb].m_p_pcp[j] = m_p_InputTable->Get_Record(k)->asDouble(m_p_pcpField[eb]);
+ m_p_elevbands[eb].m_p_tmp[j] = m_p_InputTable->Get_Record(k)->asDouble(m_p_tmpField[eb]);
+ }
+ }
+}
+//---------------------------------------------------------------------
+
+void Cihacres_elev::_CalcSnowModule(int eb)
+{
+ m_p_SnowModule = new CSnowModule(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_pcp, m_nValues,
+ m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt, m_pSnowparms[eb].DD_FAC);
+
+ m_p_elevbands[eb].m_p_MeltRate = m_p_SnowModule->Get_MeltRate(m_p_elevbands[eb].m_p_MeltRate, m_nValues);
+ m_p_elevbands[eb].m_p_SnowStorage = m_p_SnowModule->Get_SnowStorage(m_p_elevbands[eb].m_p_SnowStorage, m_nValues);
+
+ delete m_p_SnowModule;
+}
+//---------------------------------------------------------------------
+
+void Cihacres_elev::_Simulate_NonLinearModule(int eb)
+{
+ double eR_init = 0.0;
+ //----------------------------------------------------------
+ // calculate excess rainfall time series
+ //----------------------------------------------------------
+ switch(m_IHAC_version)
+ {
+ case 0: // Jakeman & Hornberger (1993)
+ // The parameter index (fourth parameter) is zero here, because
+ // the parameter settings of the non-linear module are in all elevationbands equal.
+ // If they should be different the index parameter can be used to identify the
+ // corresponding elevation band.
+ ihacres.CalcWetnessTimeConst(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_Tw,
+ m_p_nonlinparms, eb, m_nValues);
+ // 0 = index (only one instance of m_p_nonlinparms)
+
+ if (m_bSnowModule)
+ {
+ ihacres.CalcWetnessIndex(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp,
+ m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, 0.5, m_p_nonlinparms->mp_c[eb],
+ m_bSnowModule, m_pSnowparms[eb].T_Rain, m_nValues);
+
+ ihacres.CalcExcessRain(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp,
+ m_p_elevbands[eb].m_p_WI, m_p_elevbands[eb].m_p_ER, eR_init,
+ m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues, m_bSnowModule,
+ m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt,
+ m_p_elevbands[eb].m_p_MeltRate);
+ } else {
+
+ ihacres.CalcWetnessIndex(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp,
+ m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, 0.5, m_p_nonlinparms->mp_c[eb],
+ m_bSnowModule, 0, m_nValues);
+
+ ihacres.CalcExcessRain(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp,
+ m_p_elevbands[eb].m_p_WI, m_p_elevbands[eb].m_p_ER, eR_init,
+ m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues, m_bSnowModule,
+ 0,0,0);
+ }
+ break;
+ case 1: // Croke et al. (2005)
+ ihacres.CalcWetnessTimeConst_Redesign(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_Tw,
+ m_p_nonlinparms, eb, m_nValues); // 0 = index (only one instance of m_p_nonlinparms)
+
+ if (m_bSnowModule)
+ {
+ ihacres.CalcWetnessIndex_Redesign(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_WI, 0.5,
+ m_bSnowModule, m_pSnowparms[eb].T_Rain, m_nValues);
+
+ ihacres.CalcExcessRain_Redesign(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI,
+ m_p_elevbands[eb].m_p_ER, eR_init, m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues,
+ m_p_nonlinparms->mp_c[eb], m_p_nonlinparms->mp_l[eb], m_p_nonlinparms->mp_p[eb],
+ m_bSnowModule, m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt, m_p_elevbands[eb].m_p_MeltRate);
+ } else {
+ ihacres.CalcWetnessIndex_Redesign(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_WI, 0.5,
+ m_bSnowModule, 0, m_nValues);
+
+ ihacres.CalcExcessRain_Redesign(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI,
+ m_p_elevbands[eb].m_p_ER, eR_init, m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues,
+ m_p_nonlinparms->mp_c[eb], m_p_nonlinparms->mp_l[eb], m_p_nonlinparms->mp_p[eb],
+ m_bSnowModule, 0,0,0);
+ }
+ break;
+ } // end switch(m_IHAC_vers)
+}
+//---------------------------------------------------------------------
+
+void Cihacres_elev::_Simulate_Streamflow(int eb)
+{
+ //----------------------------------------------------------
+
+ //----------------------------------------------------------
+ // calculate streamflow
+ //----------------------------------------------------------
+ switch(m_StorConf)
+ {
+ case 0: // single storage
+ ihacres.SimStreamflowSingle(m_p_elevbands[eb].m_p_ER, m_p_Q_obs_mmday[0],
+ m_p_elevbands[eb].m_p_streamflow_sim, m_delay,
+ m_p_linparms->a[eb], m_p_linparms->b[eb], m_nValues);
+ break;
+ case 1: // two storages in parallel
+ ihacres.SimStreamflow2Parallel(m_p_elevbands[eb].m_p_ER,
+ m_p_elevbands[eb].m_p_streamflow_sim, m_p_Q_obs_mmday[0],
+ m_p_linparms, eb, m_vq, m_vs, m_nValues, m_delay);
+ break;
+ case 2: // two storages in series
+ break;
+ } // end switch(m_StorConf)
+}
+//---------------------------------------------------------------------
+
+void Cihacres_elev::_CreateTableSim()
+{
+ int i = 0; // used in function Get_Record(i)
+ CSG_Table_Record *pRecord;
+ CSG_String tmpName;
+ double sim_eb, sim;
+
+ // creating the column titles
+ m_pTable->Add_Field("Date", SG_DATATYPE_String);
+ m_pTable->Add_Field("Flow_OBS", SG_DATATYPE_Double);
+
+ for (int eb = 0; eb < m_nElevBands; eb++)
+ {
+ tmpName = SG_T("ELEVB_");
+ tmpName += convert_sl::Int2String(eb+1).c_str();
+ m_pTable->Add_Field(tmpName.c_str(), SG_DATATYPE_Double);
+ }
+ m_pTable->Add_Field(SG_T("Flow_SIM"), SG_DATATYPE_Double);
+
+ for (int j = 0; j < m_nValues; j++)
+ {
+ m_pTable->Add_Record();
+ pRecord = m_pTable->Get_Record(i);
+
+ // writing the data into the rows
+ pRecord->Set_Value(0,SG_STR_MBTOSG(m_vec_date[j].c_str()));
+ pRecord->Set_Value(1,m_p_Q_obs_m3s[j]);
+ sim_eb = 0.0;
+ sim = 0.0;
+ for (int eb = 0; eb < m_nElevBands; eb++)
+ {
+ sim_eb = model_tools::mmday_to_m3s(m_p_elevbands[eb].m_p_streamflow_sim[j],m_p_elevbands[eb].m_area);
+ //pRecord->Set_Value(3+eb,model_tools::mmday_to_m3s(m_p_elevbands[eb].m_p_streamflow_sim[j],m_p_elevbands[eb].m_area));
+ pRecord->Set_Value(2+eb, sim_eb);
+ sim += sim_eb;
+ }
+ pRecord->Set_Value(2+m_nElevBands,sim);
+ i++;
+ }
+}
+
+
+//---------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////
+//
+// DIALOGS
+//
+///////////////////////////////////////////////////////////////////////
+//---------------------------------------------------------------------
+// DIALOG 1
+//---------------------------------------------------------------------
+void Cihacres_elev::_CreateDialog1()
+{
+ CSG_Parameter *pNode;
+ CSG_String s;
+
+ pNode = Parameters.Add_Choice(
+ NULL , "NELEVBANDS" , SG_T("Number of elevation bands"),
+ _TL(""),
+ SG_T("2|3|4|5|6|7|8|9|10")
+ );
+
+ pNode = Parameters.Add_Value(
+ pNode, "AREA_tot", _TL("Total Catchment Area [km2]"),
+ _TL(""),
+ PARAMETER_TYPE_Double
+ );
+
+ s.Printf(SG_T("Node1"), 1);
+ pNode = Parameters.Add_Node(NULL,s,SG_T("IHACRES Version"),_TL(""));
+
+ Parameters.Add_Choice(
+ pNode , "IHACVERS" , SG_T("IHACRES Version"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("Jakeman & Hornberger (1993)"), // 0
+ _TL("Croke et al. (2005) !!! not yet implemented !!!") // 1
+ )
+ );
+
+ s.Printf(SG_T("Node2"), 2);
+ pNode = Parameters.Add_Node(NULL,s,SG_T("Storage Configuration"),_TL(""));
+
+ Parameters.Add_Choice(
+ pNode , "STORAGE" , SG_T("Storage"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("Single Storage"), // 0
+ _TL("Two Parallel Storages"), // 1
+ _TL("Two Storages in Series !!! not yet implemented !!!") // 2
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode, "SNOW_MODULE", _TL("Using the snow-melt module?"),
+ _TL("If checked, snow-melt module is used."),
+ PARAMETER_TYPE_Bool, false
+ );
+}
+//---------------------------------------------------------------------
+// DIALOG 2
+//---------------------------------------------------------------------
+
+bool Cihacres_elev::_CreateDialog2()
+{
+ int i;
+
+ //std::ofstream f("_out_elev.txt");
+
+ CSG_Parameters P; // used to add Parameters in the second dialog
+ CSG_Parameter *pNode, *pNode1;
+ CSG_String s;
+ CSG_String tmpNode, tmpName;
+
+ P.Set_Name(_TL("IHACRES Elevation Bands (Dialog 2)"));
+ // Input file ----------------------------------------------
+ pNode = P.Add_Table(
+ NULL , "TABLE" , _TL("IHACRES Input Table"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ P.Add_Table_Field(
+ pNode , "DATE_Field" , _TL("Date Column"),
+ SG_T("Select the column containing the Date")
+ );
+
+ P.Add_Table_Field(
+ pNode , "DISCHARGE_Field" , _TL("Streamflow (obs.) Column"),
+ SG_T("Select the column containing the observed streamflow time series)")
+ );
+
+ for (i = 0; i < m_nElevBands; i++)
+ {
+ tmpNode = convert_sl::Int2String(i+1).c_str();
+ //s.Printf(tmpNode.c_str(), i);
+ //pNode1 = P.Add_Node(NULL,s,SG_T("Elevation Band Input",_TL(""));
+
+ tmpName = SG_T("PCP Column: Elevation Band: ");
+ tmpName+=tmpNode;
+ P.Add_Table_Field(
+ pNode , tmpName.c_str(), tmpName.c_str(),
+ SG_T("Select Precipitation Column")
+ );
+
+ tmpName = SG_T("TMP Column: Elevation Band: ");
+ tmpName+=tmpNode;
+ P.Add_Table_Field(
+ pNode , tmpName.c_str() , tmpName.c_str(),
+ SG_T("Select Temperature Column")
+ );
+ }
+ // Input file ----------------------------------------------
+
+ for (i = 0; i < m_nElevBands; i++)
+ {
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+100).c_str();
+ tmpName = SG_T("Elevation Band ");
+ tmpName+=convert_sl::Int2String(i+1).c_str();
+
+ s.Printf(tmpNode.c_str(), i+100);
+ pNode = P.Add_Node(NULL,s,tmpName.c_str(),_TL(""));
+
+ tmpName = SG_T("Area [km2] Elev(");
+ tmpName += tmpNode;
+ tmpName += SG_T(")");
+ P.Add_Value(
+ pNode, tmpName, _TL("Area [km2]"),
+ _TL(""),
+ PARAMETER_TYPE_Double
+ );
+
+ tmpName = SG_T("Mean Elevation [m.a.s.l] Elev(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode, tmpName, _TL("Mean Elevation [m.a.s.l]"),
+ _TL(""),
+ PARAMETER_TYPE_Double
+ );
+ //}
+
+ // Parameters of non-linear module -------------------------
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+150).c_str();
+ s.Printf(tmpNode.c_str(), i+150);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Non-Linear Module"),_TL(""));
+
+ tmpName = SG_T("TwFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Wetness decline time constant (Tw)"),
+ _TW("Tw is approximately the time constant, or inversely, "
+ "the rate at which the catchment wetness declines in the absence of rainfall"),
+ PARAMETER_TYPE_Double,
+ 1.0, 0.01, true, 150.0, true
+ );
+
+ tmpName = SG_T("TFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, SG_T("Temperature Modulation Factor (f)"),
+ _TL("Temperature Modulation Factor f"),
+ PARAMETER_TYPE_Double,
+ 1.0, 0.0001, true, 10.0, true
+ );
+
+ tmpName = SG_T("CFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1,tmpName, _TL("Parameter (c)"),
+ _TL("Parameter (c) to fit streamflow volume"),
+ PARAMETER_TYPE_Double,
+ 0.001, 0.0, true, 1.0, true
+ );
+
+ switch(m_IHAC_version)
+ {
+ case 0: // Jakeman & Hornberger (1993)
+ break;
+ case 1: // Croke et al. (2005)
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+200).c_str();
+ s.Printf(tmpNode.c_str(), i+200);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Soil Moisture Power Eq."),_TL(""));
+
+ tmpName = SG_T("LFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Parameter (l)"),
+ _TL("Soil moisture index threshold"),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 5.0, true
+ );
+
+ tmpName = SG_T("PFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Parameter (p)"),
+ _TL("non-linear response term"),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 5.0, true
+ );
+ break;
+ }
+ // Parameters of non-linear module -------------------------
+
+ // Parameters of linear module -----------------------------
+ switch(m_StorConf)
+ {
+ case 0: // single storage
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+250).c_str();
+ s.Printf(tmpNode.c_str(), i+250);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Linear Module"),_TL(""));
+
+ tmpName = SG_T("AFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("(a)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.8, -0.99, true, -0.01, true
+ );
+
+ tmpName = SG_T("BFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("(b)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.2, 0.001, true, 1.0, true
+ );
+ break;
+
+ case 1: // two parallel storages
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+250).c_str();
+ s.Printf(tmpNode.c_str(), i+250);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Linear Module"),_TL(""));
+
+ // Parameter a
+ tmpName = SG_T("AQ(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1,tmpName, _TL("a(q)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.7, -0.99, true, -0.01, true
+ );
+
+ tmpName = SG_T("AS(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("a(s)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.9, -0.99, true, -0.01, true
+ );
+
+ // Parameter b
+ tmpName = SG_T("BQ(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("b(q)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 1.0, true
+ );
+ break;
+
+ case 2: // two storages in series
+ break;
+ } // end switch (storconf)
+ // Parameters of linear module -----------------------------
+
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+300).c_str();
+ s.Printf(tmpNode.c_str(), i+300);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Time Delay after Start of Rainfall (INTEGER)"),_TL(""));
+
+ tmpName = SG_T("DELAY(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1,tmpName, SG_T("Time Delay (Rain-Runoff)"),
+ SG_T("The delay after the start of rainfall, before the discharge starts to rise."),
+ PARAMETER_TYPE_Int,
+ 0, 1, true, 100, true
+ );
+
+ // snow module parameters ----------------------------------
+ if (m_bSnowModule)
+ {
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+350).c_str();
+ s.Printf(tmpNode.c_str(), i+350);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Snow Module Parameters"),_TL(""));
+
+ tmpName = SG_T("T_RAIN(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1,tmpName, SG_T("Temperature Threshold for Rainfall)"),
+ SG_T("Below this threshold precipitation will fall as snow"),
+ PARAMETER_TYPE_Double,
+ -1.0, -10.0, true, 10.0, true
+ );
+
+ tmpName = SG_T("T_MELT(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1,tmpName, SG_T("Temperature Threshold for Melting"),
+ SG_T("Above this threshold snow will start to melt"),
+ PARAMETER_TYPE_Double,
+ 1.0, -5.0, true, 10.0, true
+ );
+
+ tmpName = SG_T("DD_FAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1,tmpName, SG_T("Day-Degree Factor"),
+ SG_T("Day-Degree Factor depends on catchment characteristics"),
+ PARAMETER_TYPE_Double,
+ 0.7, 0.7, true, 9.2, true
+ );
+ }
+ // snow module parameters ----------------------------------
+ }
+
+
+ if( SG_UI_Dlg_Parameters(&P, _TL("IHACRES Distributed Input Dialog 2")) )
+ {
+ // input table
+ m_p_InputTable = P("TABLE") ->asTable();
+ // field numbers
+ m_dateField = P("DATE_Field") ->asInt();
+ m_streamflowField = P("DISCHARGE_Field") ->asInt();
+ for (int i = 0; i < m_nElevBands; i++)
+ {
+ tmpNode = convert_sl::Int2String(i+1).c_str();
+
+ // get precipitation column of Elevation Band[i]
+ tmpName = SG_T("PCP Column: Elevation Band: ");
+ tmpName+=tmpNode;
+ m_p_pcpField[i] = P(tmpName) ->asInt();
+
+ // get temperature column of Elevation Band[i]
+ tmpName = SG_T("TMP Column: Elevation Band: ");
+ tmpName+=tmpNode;
+ m_p_tmpField[i] = P(tmpName) ->asInt();
+
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+100).c_str();
+
+ // get area[km2] of Elevation Band[i]
+ tmpName = SG_T("Area [km2] Elev(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_elevbands[i].m_area = P(tmpName) ->asDouble();
+
+ // get mean elevation of Elevation Band[i]
+ tmpName = SG_T("Mean Elevation [m.a.s.l] Elev(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_elevbands[i].m_mean_elev =P(tmpName) ->asDouble();
+
+
+ // non-linear module parameters
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+150).c_str();
+ // get Tw
+ tmpName = SG_T("TwFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nonlinparms->mp_tw[i] = P(tmpName) ->asDouble();
+
+ // get f
+ tmpName = SG_T("TFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nonlinparms->mp_f[i] = P(tmpName) ->asDouble();
+
+ // get c
+ tmpName = SG_T("CFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nonlinparms->mp_c[i] = P(tmpName) ->asDouble();
+
+ switch(m_IHAC_version)
+ {
+ case 0: // Jakeman & Hornberger (1993)
+ break;
+ case 1: // Croke et al. (2005)
+ // get l
+ tmpName = SG_T("LFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nonlinparms->mp_l[i]= P(tmpName) ->asDouble();
+
+ // get p
+ tmpName = SG_T("PFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nonlinparms->mp_p[i]= P(tmpName) ->asDouble();
+ }
+
+ // linear module parameters
+ switch(m_nStorages)
+ {
+ case 1: // single storage
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+250).c_str();
+ // get a
+ tmpName = SG_T("AFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_linparms->a[i] = P(tmpName) ->asDouble();
+
+ // get b
+ tmpName = SG_T("BFAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_linparms->b[i] = P(tmpName) ->asDouble();
+ break;
+ case 2: // two storages
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+250).c_str();
+ // get aq
+ tmpName = SG_T("AQ(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_linparms->aq[i] = P(tmpName) ->asDouble();
+
+ // get bq
+ tmpName = SG_T("BQ(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_linparms->bq[i] = P(tmpName) ->asDouble();
+
+ // get as
+ tmpName = SG_T("AS(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_linparms->as[i] = P(tmpName) ->asDouble();
+
+ // get bs
+ m_p_linparms->bs[i] = ihacres.Calc_Parm_BS(m_p_linparms->aq[i],m_p_linparms->as[i],m_p_linparms->bq[i]);
+ break;
+ }
+
+ // get delay
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+300).c_str();
+
+ tmpName = SG_T("DELAY(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_delay = P(tmpName) ->asInt();
+
+ if (m_bSnowModule)
+ {
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+350).c_str();
+
+ // get T_RAIN
+ tmpName = SG_T("T_RAIN(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSnowparms[i].T_Rain = P(tmpName) ->asDouble();
+
+ // get T_MELT
+ tmpName = SG_T("T_MELT(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSnowparms[i].T_Melt = P(tmpName) ->asDouble();
+
+ // get DD_FAC
+ tmpName = SG_T("DD_FAC(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSnowparms[i].DD_FAC = P(tmpName) ->asDouble();
+ }
+ }
+
+ return(true);
+ }
+ return(false);
+}
+
+//---------------------------------------------------------------------
+// DIALOG 3
+//---------------------------------------------------------------------
+
+bool Cihacres_elev::_CreateDialog3()
+{
+ CSG_String s;
+ CSG_Parameters P; // used to add Parameters in the second dialog
+ CSG_Parameter *pNode;
+
+ // Dialog design
+ P.Set_Name(_TL("Choose Time Range"));
+
+ s.Printf(SG_T("Node1"), 1);
+ pNode = P.Add_Node(NULL,s,SG_T("Time Range"),_TL(""));
+
+ s.Printf(SG_T("FDAY") , 1-1);
+ P.Add_String(pNode,s,_TL("First Day"),_TL(""),
+ m_p_InputTable->Get_Record(0)->asString(m_dateField));
+
+ s.Printf(SG_T("LDAY") , 1-2);
+ P.Add_String(pNode,s,_TL("Last Day"),_TL(""),
+ m_p_InputTable->Get_Record(m_p_InputTable->Get_Record_Count()-1)->asString(m_dateField));
+
+ if( SG_UI_Dlg_Parameters(&P, _TL("Choose Time Range")) )
+ {
+ ///////////////////////////////////////////////////////////////
+ //
+ // ASSIGN DATA FROM SECOND DIALOG
+ //
+ ///////////////////////////////////////////////////////////////
+ m_date1 = P(CSG_String::Format(SG_T("FDAY"),m_dateField).c_str())->asString();
+ m_date2 = P(CSG_String::Format(SG_T("LDAY"),m_streamflowField).c_str())->asString();
+ return(true);
+ }
+ return(false);
+}
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev.h b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev.h
new file mode 100644
index 0000000..35c3edf
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev.h
@@ -0,0 +1,135 @@
+///////////////////////////////////////////////////////////
+// ihacres_elev.h //
+// //
+// Copyright (C) 2008 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// 2008-01-08 //
+//-------------------------------------------------------//
+
+//*******************************************************//
+// ToDo //
+//-------------------------------------------------------//
+// - m_delay is not yet implemented for each elevation band
+// as it is suggested by the user dialog. The delay value
+// of the last elevation band is used instead for all bands.
+//*******************************************************//
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__ihacres_elev_H
+#define HEADER_INCLUDED__ihacres_elev_H
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+#include "ihacres_eq.h"
+#include "ihacres_elev_bands.h"
+#include "snow_module.h"
+
+#include <vector> // used for storing date string values in array
+//using namespace std;
+
+typedef std::vector<std::string> date_array;
+
+
+class Cihacres_elev : public CSG_Module
+{
+public:
+
+ //--------------------------------------------------------
+ // CONSTRUCTORS
+ //--------------------------------------------------------
+
+ // default
+ Cihacres_elev();
+
+ // destructor
+ virtual ~Cihacres_elev(void);
+
+protected:
+
+ // execute module
+ virtual bool On_Execute(void);
+
+private:
+
+ //--------------------------------------------------------
+ // PRIVATE MEMBER VARIABLES
+ //--------------------------------------------------------
+
+ //----------------------------------
+ // parameters of first module dialog
+ //----------------------------------
+ int m_nElevBands; // number of used elevation bands
+ double m_Area_tot; // total catchment area [km2]
+ int m_IHAC_version; // Different versions of IHACRES exist, corresponding
+ // to the version...
+ int m_StorConf; // Storage configuration
+ // 0 = single, 1 = two in parallel, 2 = two in series
+ bool m_bSnowModule; // true if snow module is active
+
+ int m_nStorages; // number of storages
+
+ //----------------------------------
+ // parameters of second module dialog
+ //----------------------------------
+ // time series variables
+ CSG_Table* m_p_InputTable; // IHACRES input table
+ int m_nValues; // number of selected records
+ date_array m_vec_date;
+ double* m_p_Q_obs_m3s; // pointer containing observed streamflow in [m3/s]
+ double* m_p_Q_obs_mmday; // pointer containing observed streamflow in [mm]
+ Cihacres_elev_bands* m_p_elevbands; // Class Cihacres_elev_bands
+
+ // Field numbers
+ int m_dateField; // table field numbers
+ int m_streamflowField;
+ // elevation band parameters
+ int* m_p_pcpField;
+ int* m_p_tmpField;
+ //double* m_p_Area;
+ //double* m_p_mean_elev;
+
+ //----------------------------------
+ // parameters of third module dialog
+ //----------------------------------
+ CSG_String m_date1; // first day of time series YYYYMMDD
+ CSG_String m_date2; // last day
+
+ int m_first;
+ int m_last;
+
+ //----------------------------------
+ // Model parameter (in: ihacres_eq.h)
+ //----------------------------------
+ C_IHAC_LinearParms* m_p_linparms; // parameters of the linear storage module
+ C_IHAC_NonLinearParms* m_p_nonlinparms; // parameters of the non-linear rainfall loss module
+ CSnowParms* m_pSnowparms; // 3 snow module paramters
+ CSnowModule* m_p_SnowModule;
+ int m_delay;
+ double m_vq;
+ double m_vs;
+
+ CSG_Table* m_pTable;
+
+ //--------------------------------------------------------
+ // PRIVATE MEMBER FUNCTIONS
+ //--------------------------------------------------------
+
+ void _Init_ElevBands(int n); // n = m_nElevBands
+ void _Init_Pointers(int nvals);
+ void _CreateDialog1();
+ bool _CreateDialog2();
+ bool _CreateDialog3();
+ void _ReadInputFile();
+ void _CalcSnowModule(int elevband);
+ void _Simulate_NonLinearModule(int elevband);
+ void _Simulate_Streamflow(int elevband);
+ void _CreateTableSim();
+
+ // Class ihacres_eq
+ Cihacres_eq ihacres;
+
+};
+
+#endif /* HEADER_INCLUDED__ihacres_elev_H */
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev_bands.cpp b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev_bands.cpp
new file mode 100644
index 0000000..28519ef
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev_bands.cpp
@@ -0,0 +1,27 @@
+#define NULL 0
+
+#include "ihacres_elev_bands.h"
+
+Cihacres_elev_bands::Cihacres_elev_bands()
+{
+ m_p_pcp = NULL;
+ m_p_tmp = NULL;
+ m_p_ER = NULL;
+ m_p_streamflow_sim = NULL;
+ m_p_Tw = NULL;
+ m_p_WI = NULL;
+ m_p_MeltRate = NULL;
+ m_p_SnowStorage = NULL;
+}
+
+Cihacres_elev_bands::~Cihacres_elev_bands()
+{
+ //if (m_p_pcp) delete[] m_p_pcp;
+ //if (m_p_tmp) delete[] m_p_tmp;
+ //if (m_p_ER) delete[] m_p_ER;
+ //if (m_p_streamflow_sim) delete[] m_p_streamflow_sim;
+ //if (m_p_Tw) delete[] m_p_Tw;
+ //if (m_p_WI) delete[] m_p_WI;
+ //if (m_p_MeltRate) delete[] m_p_MeltRate;
+ //if (m_p_SnowStorage) delete[] m_p_SnowStorage;
+}
\ No newline at end of file
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev_bands.h b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev_bands.h
new file mode 100644
index 0000000..1810faf
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev_bands.h
@@ -0,0 +1,80 @@
+///////////////////////////////////////////////////////////
+// ihacres_elev_bands.h //
+// //
+// Copyright (C) 2008 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// 2008-01-08 //
+//-------------------------------------------------------//
+
+//*******************************************************//
+// ToDo //
+//-------------------------------------------------------//
+// -
+//*******************************************************//
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__ihacres_elev_bands_H
+#define HEADER_INCLUDED__ihacres_elev_bands_H
+//---------------------------------------------------------
+
+
+class Cihacres_elev_bands
+{
+public:
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CONSTRUCTORS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ // default
+ Cihacres_elev_bands();
+
+ // destructor
+ ~Cihacres_elev_bands();
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // PARAMETERS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ //bool m_b_SnowModule; // true, if snow module is active
+ //int m_IHAC_version; // IHACRES version (Jakeman & Hornberger, 1993 / Croke, B. 2005 /...)
+
+ // time series variables
+ //double m_nValues; // number of pointer elements (time steps / days / ...)
+ double* m_p_pcp; // precipitation time series
+ double* m_p_tmp; // temperature time series
+ double* m_p_ER; // excess rainfall time series
+ double* m_p_streamflow_sim; // simulated streamflow time series [mm] !!!
+ double* m_p_Tw; //
+ double* m_p_WI; // Wetness Index
+
+ double* m_p_MeltRate;
+ double* m_p_SnowStorage;
+
+ double m_sum_eRainGTpcp;
+
+ double m_mean_elev; // mean elevation of elevation band [m.a.s.l.]
+ double m_area;
+ ///////////////////////////////////////////////////////////////////
+ //
+ // PUBLIC FUNCTIONS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ //double Get_Elevation() { return(m_mean_elev); }
+ //double Get_Area() { return(m_area); }
+
+private:
+ // elevation band area [km2]
+
+};
+
+
+#endif /* HEADER_INCLUDED__ihacres_elev_bands_H */
\ No newline at end of file
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev_cal.cpp b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev_cal.cpp
new file mode 100644
index 0000000..f0a2a48
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev_cal.cpp
@@ -0,0 +1,1394 @@
+///////////////////////////////////////////////////////////
+// ihacres_elev_cal.cpp //
+// //
+// Copyright (C) 2008 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// 2008-01-08 //
+///////////////////////////////////////////////////////////
+
+#include "ihacres_elev_cal.h"
+#include "convert_sl.h"
+#include "model_tools.h"
+
+#include <stdlib.h> // random numbers
+#include <time.h> // random numbers
+
+// TEST OUTPUT ONLY
+#include <fstream>
+
+//---------------------------------------------------------------------
+
+Cihacres_elev_cal::Cihacres_elev_cal()
+{
+ //-----------------------------------------------------
+ // 1. Info...
+ Set_Name(_TL("IHACRES Elevation Bands Calibration"));
+
+ Set_Author(SG_T("copyrights (c) 2008 Stefan Liersch"));
+
+ Set_Description(_TW("The Rainfall-Runoff Model IHACRES \n \n \n"
+ "Reference: \n \n"
+ "Jakeman, A.J. / Hornberger, G.M. (1993). \n"
+ "How Much Complexity Is Warranted in a Rainfall-Runoff Model? \n"
+ "Water Resources Research, (29), NO. 8 (2637-2649) \n \n"
+ "Kokkonen, T. S. et al. (2003). \n"
+ "Predicting daily flows in ungauged catchments:"
+ "model regionalization from catchment descriptors"
+ "at the Coweeta Hydrologic Laboratory, North Carolina \n "
+ "Hydrological Processes (17), 2219-2238 \n \n"
+ "Croke, B. F. W., W. S. Merritt, et al. (2004).\n"
+ "A dynamic model for predicting hydrologic response"
+ "to land cover changes in gauged and"
+ "ungauged catchments. \n"
+ "Journal Of Hydrology 291(1-2): 115-131."
+ ));
+
+ Parameters.Add_Table_Output(
+ NULL , "TABLEout" , _TL("Table"),
+ _TL("")
+ );
+ Parameters.Add_Table_Output(
+ NULL , "TABLEparms" , _TL("Table"),
+ _TL("")
+ );
+
+ ///////////////////////////////////////////////////////////////////
+ // FIRST MODULE DIALOG
+ _CreateDialog1();
+ ///////////////////////////////////////////////////////////////////
+}
+
+Cihacres_elev_cal::~Cihacres_elev_cal()
+{}
+//---------------------------------------------------------------------
+
+bool Cihacres_elev_cal::On_Execute()
+{
+ double NSE_temp = 0.0;
+ double NSE_max = -9999.9;
+ string nse, nse_text;
+
+ CSG_Parameters P;
+ //std::ofstream f("_out_elev.txt");
+
+ // Assign Parameters from first Module Dialog
+ //---------------------------------------------------------
+ int eb = Parameters("NELEVBANDS") ->asInt();
+ m_nElevBands = eb + 2; // because list starts with 2 !
+ m_nsim = Parameters("NSIM") ->asInt();
+ m_Area_tot = Parameters("AREA_tot") ->asDouble();
+ m_IHAC_version = Parameters("IHACVERS") ->asInt();
+ m_StorConf = Parameters("STORAGE") ->asInt();
+ m_bSnowModule = Parameters("SNOW_MODULE") ->asBool();
+ m_obj_func = Parameters("OBJ_FUNC") ->asInt();
+ m_NSEmin = Parameters("NSEMIN") ->asDouble();
+
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // Assign number of storages
+ m_nStorages = ihacres.Assign_nStorages(m_StorConf);
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // Initialize pointers
+ _Init_ElevBands(m_nElevBands);
+ m_p_linparms = new C_IHAC_LinearParms(m_nElevBands,m_nStorages);
+ m_p_lin_lb = new C_IHAC_LinearParms(m_nElevBands,m_nStorages);
+ m_p_lin_ub = new C_IHAC_LinearParms(m_nElevBands,m_nStorages);
+ m_p_nonlinparms = new C_IHAC_NonLinearParms(m_nElevBands);
+ m_p_nl_lb = new C_IHAC_NonLinearParms(m_nElevBands);
+ m_p_nl_ub = new C_IHAC_NonLinearParms(m_nElevBands);
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // open second and third user dialog
+ if ( _CreateDialog2() && _CreateDialog3())
+ {
+ //---------------------------------------------------------
+ // searching the first and the last record of the time range
+ ihacres.AssignFirstLastRec(*m_p_InputTable, m_first, m_last, m_date1, m_date2, m_dateField);
+ m_nValues = m_last - m_first + 1;
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ _Init_Pointers(m_nValues);
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // read input table
+ _ReadInputFile();
+ //---------------------------------------------------------
+
+ //---------------------------------------------------------
+ // PERFORM STREAMFLOW SIMULATION
+ // FOR EACH ELEVATION BAND
+ //---------------------------------------------------------
+ // Convert Streamflow vector from m3/s*day-1 to mm/day
+ m_p_Q_obs_mmday = model_tools::m3s_to_mmday(m_p_Q_obs_m3s, m_p_Q_obs_mmday, m_nValues, m_Area_tot);
+
+ //---------------------------------------------------------
+ m_pTable_parms = SG_Create_Table();
+ _CreateTableParms();
+ m_counter = 0;
+ //---------------------------------------------------------
+
+ ///////////////////////////////////////////////////////////
+ //
+ // SIMULATION
+ //
+ ///////////////////////////////////////////////////////////
+
+ // initialize random function
+ srand((unsigned) time(NULL)); // using time.h
+
+ for (int sim = 0; sim < m_nsim && Set_Progress(sim, m_nsim); sim++)
+ {
+ _Simulate_NonLinearModule();
+
+ _Simulate_Streamflow();
+
+ _Sum_Streamflow();
+
+ m_NSE = m_NSE_lowflow = m_NSE_highflow = m_PBIAS = 0;
+ _CalcEfficiency();
+
+
+ // write in output table if criterion is fulfilled
+ NSE_temp = ihacres._Assign_NSE_temp(m_obj_func, m_NSE, m_NSE_highflow, m_NSE_lowflow);
+
+ if (NSE_temp > m_NSEmin)
+ {
+ if (NSE_temp > NSE_max)
+ {
+ NSE_max = NSE_temp;
+ nse = convert_sl::Double2String(NSE_max).c_str();
+ nse_text = "max. NSE ";
+ nse_text += nse;
+ Process_Set_Text(SG_STR_MBTOSG(nse_text.c_str()));
+ }
+
+ _WriteTableParms();
+ }
+ }
+ //---------------------------------------------------------
+
+ m_pTable_parms->Set_Name(SG_T("ihacres_elevbands_cal"));
+ Parameters("TABLEparms")->Set_Value(m_pTable_parms);
+
+ //m_pTable = SG_Create_Table();
+ //_CreateTableSim();
+ //// add tables to SAGA Workspace
+ //m_pTable->Set_Name("ihacres_elevBands_output");
+ //Parameters("TABLEout")->Set_Value(m_pTable);
+
+ delete[] m_p_elevbands; // sämtliche Unter-Pointer noch löschen
+ delete[] m_p_pcpField;
+ delete[] m_p_tmpField;
+ delete[] m_p_Q_obs_m3s;
+ delete[] m_p_Q_obs_mmday;
+ delete[] m_p_Q_sim_mmday;
+ delete m_p_linparms;
+ delete m_p_nonlinparms;
+ delete m_p_lin_lb;
+ delete m_p_lin_ub;
+ delete m_p_nl_lb;
+ delete m_p_nl_ub;
+ if (m_bSnowModule) {
+ delete[] m_pSnowparms;
+ delete[] m_pSnowparms_lb;
+ delete[] m_pSnowparms_ub;
+ }
+ delete[] m_vq;
+ delete[] m_vs;
+
+ return(true);
+ } // end if ( _CreateDialog2() )
+
+ // delete[] m_p_elevbands;
+ // delete[] m_p_pcpFields;
+ // delete[] m_p_tmpFields;
+ // delete m_p_linparms;
+ // delete m_p_nonlinparms;
+ return(false);
+}
+
+//---------------------------------------------------------------------
+
+void Cihacres_elev_cal::_Init_ElevBands(int nvals)
+{
+ // instantiate elevation bands
+ m_p_elevbands = new Cihacres_elev_bands[nvals];
+
+ // instantiate field numbers
+ m_p_pcpField = new int[nvals];
+ m_p_tmpField = new int[nvals];
+
+ if (m_bSnowModule)
+ {
+ m_pSnowparms = new CSnowParms[nvals];
+ m_pSnowparms_lb = new CSnowParms[nvals];
+ m_pSnowparms_ub = new CSnowParms[nvals];
+ }
+
+ m_vq = new double[nvals];
+ m_vs = new double[nvals];
+}
+//---------------------------------------------------------------------
+
+void Cihacres_elev_cal::_Init_Pointers(int nvals)
+{
+ m_vec_date.resize(nvals);
+ m_p_Q_obs_m3s = new double[nvals];
+ m_p_Q_obs_mmday = new double[nvals];
+ m_p_Q_sim_mmday = new double[nvals];
+
+ for (int eb = 0; eb < m_nElevBands; eb++)
+ {
+ m_p_elevbands[eb].m_p_pcp = new double[nvals];
+ m_p_elevbands[eb].m_p_tmp = new double[nvals];
+ m_p_elevbands[eb].m_p_ER = new double[nvals];
+ m_p_elevbands[eb].m_p_streamflow_sim = new double[nvals];
+ m_p_elevbands[eb].m_p_Tw = new double[nvals];
+ m_p_elevbands[eb].m_p_WI = new double[nvals];
+
+ if (m_bSnowModule) {
+ m_p_elevbands[eb].m_p_SnowStorage = new double[nvals];
+ m_p_elevbands[eb].m_p_MeltRate = new double[nvals];
+ }
+ }
+}
+//---------------------------------------------------------------------
+
+void Cihacres_elev_cal::_ReadInputFile()
+{
+ for (int j = 0, k = m_first; j < m_nValues, k < m_last + 1; j++, k++)
+ {
+ m_vec_date[j].append(SG_STR_SGTOMB(m_p_InputTable->Get_Record(k)->asString(m_dateField)));
+ m_p_Q_obs_m3s[j] = m_p_InputTable->Get_Record(k)->asDouble(m_streamflowField);
+
+ for (int eb = 0; eb < m_nElevBands; eb++)
+ {
+ m_p_elevbands[eb].m_p_pcp[j] = m_p_InputTable->Get_Record(k)->asDouble(m_p_pcpField[eb]);
+ m_p_elevbands[eb].m_p_tmp[j] = m_p_InputTable->Get_Record(k)->asDouble(m_p_tmpField[eb]);
+ }
+ }
+}
+//---------------------------------------------------------------------
+
+void Cihacres_elev_cal::_CalcSnowModule(int eb)
+{
+ m_p_SnowModule = new CSnowModule(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_pcp, m_nValues,
+ m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt, m_pSnowparms[eb].DD_FAC);
+
+ m_p_elevbands[eb].m_p_MeltRate = m_p_SnowModule->Get_MeltRate(m_p_elevbands[eb].m_p_MeltRate, m_nValues);
+ m_p_elevbands[eb].m_p_SnowStorage = m_p_SnowModule->Get_SnowStorage(m_p_elevbands[eb].m_p_SnowStorage, m_nValues);
+
+ delete m_p_SnowModule;
+}
+//---------------------------------------------------------------------
+
+void Cihacres_elev_cal::_Simulate_NonLinearModule()
+{
+ double eR_init = 0.0;
+ for (int eb = 0; eb < m_nElevBands; eb++)
+ {
+ //-------------------------------------------------------------
+ // Assign random values
+ //-------------------------------------------------------------
+ if (m_bSnowModule)
+ {
+ m_pSnowparms[eb].T_Rain = model_tools::Random_double(m_pSnowparms_lb[eb].T_Rain,m_pSnowparms_ub[eb].T_Rain);
+ m_pSnowparms[eb].T_Melt = model_tools::Random_double(m_pSnowparms_lb[eb].T_Melt,m_pSnowparms_ub[eb].T_Melt);
+ m_pSnowparms[eb].DD_FAC = model_tools::Random_double(m_pSnowparms_lb[eb].DD_FAC,m_pSnowparms_ub[eb].DD_FAC);
+
+ m_p_SnowModule = new CSnowModule(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_pcp, m_nValues,
+ m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt, m_pSnowparms[eb].DD_FAC);
+
+ m_p_elevbands[eb].m_p_MeltRate = m_p_SnowModule->Get_MeltRate(m_p_elevbands[eb].m_p_MeltRate, m_nValues);
+ delete m_p_SnowModule;
+ }
+
+ m_p_nonlinparms->mp_tw[eb] = model_tools::Random_double(m_p_nl_lb->mp_tw[eb], m_p_nl_ub->mp_tw[eb]);
+ m_p_nonlinparms->mp_f[eb] = model_tools::Random_double(m_p_nl_lb->mp_f[eb], m_p_nl_ub->mp_f[eb]);
+ m_p_nonlinparms->mp_c[eb] = model_tools::Random_double(m_p_nl_lb->mp_c[eb], m_p_nl_ub->mp_c[eb]);
+
+ if (m_IHAC_version == 1) { // Croke etal. (2005)
+ m_p_nonlinparms->mp_l[eb]= model_tools::Random_double(m_p_nl_ub->mp_l[eb],m_p_nl_ub->mp_l[eb]);
+ m_p_nonlinparms->mp_p[eb]= model_tools::Random_double(m_p_nl_ub->mp_p[eb],m_p_nl_ub->mp_p[eb]);
+ }
+
+ //----------------------------------------------------------
+ // calculate excess rainfall time series
+ //----------------------------------------------------------
+ switch(m_IHAC_version)
+ {
+ case 0: // Jakeman & Hornberger (1993)
+ // The parameter index (fourth parameter) is zero here, because
+ // the parameter settings of the non-linear module are in all elevationbands equal.
+ // If they should be different the index parameter can be used to identify the
+ // corresponding elevation band.
+ ihacres.CalcWetnessTimeConst(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_Tw,
+ m_p_nonlinparms, eb, m_nValues);
+ // 0 = index (only one instance of m_p_nonlinparms)
+
+ if (m_bSnowModule)
+ {
+ ihacres.CalcWetnessIndex(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp,
+ m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, 0.5, m_p_nonlinparms->mp_c[eb],
+ m_bSnowModule, m_pSnowparms[eb].T_Rain, m_nValues);
+
+ ihacres.CalcExcessRain(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp,
+ m_p_elevbands[eb].m_p_WI, m_p_elevbands[eb].m_p_ER, eR_init,
+ m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues, m_bSnowModule,
+ m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt,
+ m_p_elevbands[eb].m_p_MeltRate);
+ } else {
+
+ ihacres.CalcWetnessIndex(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp,
+ m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, 0.5, m_p_nonlinparms->mp_c[eb],
+ m_bSnowModule, 0, m_nValues);
+
+ ihacres.CalcExcessRain(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp,
+ m_p_elevbands[eb].m_p_WI, m_p_elevbands[eb].m_p_ER, eR_init,
+ m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues, m_bSnowModule,
+ 0,0,0);
+ }
+ break;
+ case 1: // Croke et al. (2005)
+ ihacres.CalcWetnessTimeConst_Redesign(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_Tw,
+ m_p_nonlinparms, eb, m_nValues); // 0 = index (only one instance of m_p_nonlinparms)
+
+ if (m_bSnowModule)
+ {
+ ihacres.CalcWetnessIndex_Redesign(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_WI, 0.5,
+ m_bSnowModule, m_pSnowparms[eb].T_Rain, m_nValues);
+
+ ihacres.CalcExcessRain_Redesign(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI,
+ m_p_elevbands[eb].m_p_ER, eR_init, m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues,
+ m_p_nonlinparms->mp_c[eb], m_p_nonlinparms->mp_l[eb], m_p_nonlinparms->mp_p[eb],
+ m_bSnowModule, m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt, m_p_elevbands[eb].m_p_MeltRate);
+ } else {
+ ihacres.CalcWetnessIndex_Redesign(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_WI, 0.5,
+ m_bSnowModule, 0, m_nValues);
+
+ ihacres.CalcExcessRain_Redesign(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI,
+ m_p_elevbands[eb].m_p_ER, eR_init, m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues,
+ m_p_nonlinparms->mp_c[eb], m_p_nonlinparms->mp_l[eb], m_p_nonlinparms->mp_p[eb],
+ m_bSnowModule, 0,0,0);
+ }
+ break;
+ } // end switch(m_IHAC_vers)
+ }
+}
+//---------------------------------------------------------------------
+
+void Cihacres_elev_cal::_Simulate_Streamflow()
+{
+ //-------------------------------------------------------------
+ // Assign random values
+ //-------------------------------------------------------------
+ for (int eb = 0; eb < m_nElevBands; eb++)
+ {
+ switch(m_StorConf)
+ {
+ case 0: // single storage
+ m_p_linparms->a[eb] = model_tools::Random_double(m_p_lin_lb->a[eb],m_p_lin_ub->a[eb]);
+ m_p_linparms->b[eb] = model_tools::Random_double(m_p_lin_lb->b[eb],m_p_lin_ub->b[eb]);
+ break;
+ case 1: // two storages in parallel
+ do
+ {
+ m_p_linparms->aq[eb] = model_tools::Random_double(m_p_lin_lb->aq[eb], m_p_lin_ub->aq[eb]);
+ m_p_linparms->as[eb] = model_tools::Random_double(m_p_lin_lb->as[eb], m_p_lin_ub->as[eb]);
+ m_p_linparms->bq[eb] = model_tools::Random_double(m_p_lin_lb->bq[eb], m_p_lin_ub->bq[eb]);
+ // Calculate parameter m_vq to check parms aq and bq
+ // Equation after Jakeman & Hornberger (1993)
+ m_vq[eb] = m_p_linparms->bq[eb] / ( 1 + m_p_linparms->aq[eb] );
+ }
+ while (m_vq[eb] < 0.0 || m_vq[eb] > 1.0);
+ m_p_linparms->bs[eb] = ihacres.Calc_Parm_BS(m_p_linparms->aq[eb], m_p_linparms->as[eb], m_p_linparms->bq[eb]);
+ break;
+ }
+
+
+ //----------------------------------------------------------
+ // calculate streamflow
+ //----------------------------------------------------------
+ switch(m_StorConf)
+ {
+ case 0: // single storage
+ ihacres.SimStreamflowSingle(m_p_elevbands[eb].m_p_ER, m_p_Q_obs_mmday[0],
+ m_p_elevbands[eb].m_p_streamflow_sim, m_delay,
+ m_p_linparms->a[eb], m_p_linparms->b[eb], m_nValues);
+ break;
+ case 1: // two storages in parallel
+ ihacres.SimStreamflow2Parallel(m_p_elevbands[eb].m_p_ER,
+ m_p_elevbands[eb].m_p_streamflow_sim, m_p_Q_obs_mmday[0],
+ m_p_linparms, eb, m_vq[eb], m_vs[eb], m_nValues, m_delay);
+ break;
+ case 2: // two storages in series
+ break;
+ } // end switch(m_StorConf)
+ }// end for (int eb...
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+// Summarize streamflow from elevation bands
+//---------------------------------------------------------------------
+void Cihacres_elev_cal::_Sum_Streamflow()
+{
+ //std::ofstream f("_cal_elev.txt");
+
+ double sum = 0.0;
+ for (int n = 0; n < m_nValues; n++)
+ {
+ for (int eb = 0; eb < m_nElevBands; eb++) {
+ sum += m_p_elevbands[eb].m_p_streamflow_sim[n] * m_p_elevbands[eb].m_area / m_Area_tot;
+ //f << m_p_elevbands[eb].m_p_streamflow_sim[n] << ", ");
+ }
+ //f << std::endl;
+ m_p_Q_sim_mmday[n] = sum;
+ sum = 0.0;
+ }
+}
+//---------------------------------------------------------------------
+
+
+//---------------------------------------------------------------------
+// Nash-Sutcliffe efficiency
+//---------------------------------------------------------------------
+void Cihacres_elev_cal::_CalcEfficiency()
+{
+ m_NSE = model_tools::CalcEfficiency(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues);
+ m_NSE_highflow = model_tools::Calc_NSE_HighFlow(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues);
+ m_NSE_lowflow = model_tools::Calc_NSE_LowFlow(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues);
+ m_PBIAS = model_tools::Calc_PBIAS(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues);
+}
+//---------------------------------------------------------------------
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// CREATE TABLES
+//
+/////////////////////////////////////////////////////////////////////////////
+
+//---------------------------------------------------------------------
+// Create output table
+//---------------------------------------------------------------------
+void Cihacres_elev_cal::_CreateTableParms()
+{
+ char c[12];
+
+ // creating the column titles
+ m_pTable_parms->Add_Field("NSE", SG_DATATYPE_Double);
+ m_pTable_parms->Add_Field("NSE_high", SG_DATATYPE_Double);
+ m_pTable_parms->Add_Field("NSE_low", SG_DATATYPE_Double);
+ m_pTable_parms->Add_Field("PBIAS", SG_DATATYPE_Double);
+ //m_pTable_parms->Add_Field("eR_ovest", SG_DATATYPE_Double);
+
+ for (int i = 0; i < m_nElevBands; i++)
+ {
+ sprintf(c,"%s_%d","vq",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","vs",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","T(q)",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","T(s)",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","Tw",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","f",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","c",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ if ( m_IHAC_version == 1 ) // Croke etal. (2005)
+ {
+ sprintf(c,"%s_%d","l",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","p",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ }
+ if (m_bSnowModule)
+ {
+ sprintf(c,"%s_%d","T_Rain",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","T_Melt",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","DD_FAC",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ }
+ switch(m_StorConf)
+ {
+ case 0: // single
+ sprintf(c,"%s_%d","a",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","b",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ break;
+ case 1: // two storages in parallel
+ sprintf(c,"%s_%d","aq",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","as",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","bq",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ sprintf(c,"%s_%d","bs",i+1);
+ m_pTable_parms->Add_Field(c, SG_DATATYPE_Double);
+ break;
+ }
+ }
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+// Create output table
+//---------------------------------------------------------------------
+void Cihacres_elev_cal::_WriteTableParms()
+{
+ int field = 0;
+ CSG_Table_Record *pRecord;
+
+ // add a new record to the table
+ m_pTable_parms->Add_Record();
+ pRecord = m_pTable_parms->Get_Record(m_counter);
+
+ // writing the data to the current row
+ pRecord->Set_Value(field,m_NSE); field++;
+ pRecord->Set_Value(field,m_NSE_highflow); field++;
+ pRecord->Set_Value(field,m_NSE_lowflow); field++;
+ pRecord->Set_Value(field,m_PBIAS); field++;
+ //pRecord->Set_Value(field,m_sum_eRainGTpcp); field++;
+
+ for (int eb = 0; eb < m_nElevBands; eb++)
+ {
+ pRecord->Set_Value(field,m_vq[eb]); field++;
+ pRecord->Set_Value(field,m_vs[eb]); field++;
+ pRecord->Set_Value(field,ihacres.Calc_TimeOfDecay(m_p_linparms->aq[eb])); field++;
+ pRecord->Set_Value(field,ihacres.Calc_TimeOfDecay(m_p_linparms->as[eb])); field++;
+ pRecord->Set_Value(field,m_p_nonlinparms->mp_tw[eb]); field++;
+ pRecord->Set_Value(field,m_p_nonlinparms->mp_f[eb]); field++;
+ pRecord->Set_Value(field,m_p_nonlinparms->mp_c[eb]); field++;
+ if ( m_IHAC_version == 1 )
+ {
+ pRecord->Set_Value(field,m_p_nonlinparms->mp_l[eb]); field++;
+ pRecord->Set_Value(field,m_p_nonlinparms->mp_p[eb]); field++;
+ }
+ if ( m_bSnowModule )
+ {
+ pRecord->Set_Value(field,m_pSnowparms[eb].T_Rain); field++;
+ pRecord->Set_Value(field,m_pSnowparms[eb].T_Melt); field++;
+ pRecord->Set_Value(field,m_pSnowparms[eb].DD_FAC); field++;
+ }
+ switch ( m_StorConf )
+ {
+ case 0: // single storage
+ pRecord->Set_Value(field,m_p_linparms->a[eb]); field++;
+ pRecord->Set_Value(field,m_p_linparms->b[eb]); field++;
+ break;
+ case 1:
+ pRecord->Set_Value(field,m_p_linparms->aq[eb]); field++;
+ pRecord->Set_Value(field,m_p_linparms->as[eb]); field++;
+ pRecord->Set_Value(field,m_p_linparms->bq[eb]); field++;
+ pRecord->Set_Value(field,m_p_linparms->bs[eb]); field++;
+ break;
+ }
+ }
+ m_counter++;
+}
+//---------------------------------------------------------------------
+
+
+
+//---------------------------------------------------------------------
+void Cihacres_elev_cal::_CreateTableSim()
+{
+ int i = 0; // used in function Get_Record(i)
+ CSG_Table_Record *pRecord;
+ CSG_String tmpName;
+ double sim_eb, sim;
+
+ // creating the column titles
+ m_pTable->Add_Field("Date", SG_DATATYPE_String);
+ m_pTable->Add_Field("Flow_OBS", SG_DATATYPE_Double);
+
+ for (int eb = 0; eb < m_nElevBands; eb++)
+ {
+ tmpName = SG_T("ELEVB_");
+ tmpName += convert_sl::Int2String(eb+1).c_str();
+ m_pTable->Add_Field(tmpName.c_str(), SG_DATATYPE_Double);
+ }
+ m_pTable->Add_Field("Flow_SIM", SG_DATATYPE_Double);
+
+ for (int j = 0; j < m_nValues; j++)
+ {
+ m_pTable->Add_Record();
+ pRecord = m_pTable->Get_Record(i);
+
+ // writing the data into the rows
+ pRecord->Set_Value(0,SG_STR_MBTOSG(m_vec_date[j].c_str()));
+ pRecord->Set_Value(1,m_p_Q_obs_m3s[j]);
+ sim_eb = 0.0;
+ sim = 0.0;
+ for (int eb = 0; eb < m_nElevBands; eb++)
+ {
+ sim_eb = model_tools::mmday_to_m3s(m_p_elevbands[eb].m_p_streamflow_sim[j],m_p_elevbands[eb].m_area);
+ //pRecord->Set_Value(3+eb,model_tools::mmday_to_m3s(m_p_elevbands[eb].m_p_streamflow_sim[j],m_p_elevbands[eb].m_area));
+ pRecord->Set_Value(2+eb, sim_eb);
+ sim += sim_eb;
+ }
+ pRecord->Set_Value(2+m_nElevBands,sim);
+ i++;
+ }
+}
+
+
+//---------------------------------------------------------------------
+///////////////////////////////////////////////////////////////////////
+//
+// DIALOGS
+//
+///////////////////////////////////////////////////////////////////////
+//---------------------------------------------------------------------
+// DIALOG 1
+//---------------------------------------------------------------------
+void Cihacres_elev_cal::_CreateDialog1()
+{
+ CSG_Parameter *pNode;
+ CSG_String s;
+
+ pNode = Parameters.Add_Choice(
+ NULL , "NELEVBANDS" , SG_T("Number of elevation bands"),
+ _TL(""),
+ SG_T("2|3|4|5|6|7|8|9|10")
+ );
+
+ pNode = Parameters.Add_Value(
+ NULL, "NSIM", _TL("Number of Simulations"),
+ _TL("Number of Simulations for Calibration"),
+ PARAMETER_TYPE_Int,
+ 1000, 1, true, 10000000, true
+ );
+
+ pNode = Parameters.Add_Value(
+ pNode, "AREA_tot", _TL("Total Catchment Area [km2]"),
+ _TL(""),
+ PARAMETER_TYPE_Double
+ );
+
+ s.Printf(SG_T("Node1"), 1);
+ pNode = Parameters.Add_Node(NULL,s,SG_T("IHACRES Version"),_TL(""));
+
+ Parameters.Add_Choice(
+ pNode , "IHACVERS" , SG_T("IHACRES Version"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("Jakeman & Hornberger (1993)"), // 0
+ _TL("Croke et al. (2005) !!! not yet implemented !!!") // 1
+ )
+ );
+
+ s.Printf(SG_T("Node2"), 2);
+ pNode = Parameters.Add_Node(NULL,s,SG_T("Storage Configuration"),_TL(""));
+
+ Parameters.Add_Choice(
+ pNode , "STORAGE" , SG_T("Storage"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("Single Storage"), // 0
+ _TL("Two Parallel Storages"), // 1
+ _TL("Two Storages in Series !!! not yet implemented !!!") // 2
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode, "SNOW_MODULE", _TL("Using the snow-melt module?"),
+ _TL("If checked, snow-melt module is used."),
+ PARAMETER_TYPE_Bool, false
+ );
+
+ s.Printf(SG_T("Node6"), 6);
+ pNode = Parameters.Add_Node(NULL,s,SG_T("Nash-Sutcliffe Efficiency"),_TL(""));
+
+ Parameters.Add_Choice(
+ pNode, "OBJ_FUNC" , SG_T("Objective Function"),
+ _TL(""),
+ SG_T("NSE|NSE high flow|NSE low flow")
+ );
+
+ Parameters.Add_Value(
+ pNode, "NSEMIN", SG_T("Minimum Nash-Sutcliffe Efficiency"),
+ SG_T("Minimum Nash-Sutcliffe Efficiency required to print simulation to calibration table"),
+ PARAMETER_TYPE_Double,
+ 0.7, 0.1, true, 1.0, true
+ );
+}
+//---------------------------------------------------------------------
+// DIALOG 2
+//---------------------------------------------------------------------
+
+bool Cihacres_elev_cal::_CreateDialog2()
+{
+ int i;
+
+ //std::ofstream f("_out_elev.txt");
+
+ CSG_Parameters P; // used to add Parameters in the second dialog
+ CSG_Parameter *pNode, *pNode1;
+ CSG_String s;
+ CSG_String tmpNode, tmpName;
+
+ P.Set_Name(_TL("IHACRES Elevation Bands (Dialog 2)"));
+ // Input file ----------------------------------------------
+ pNode = P.Add_Table(
+ NULL , "TABLE" , _TL("IHACRES Input Table"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ P.Add_Table_Field(
+ pNode , "DATE_Field" , _TL("Date Column"),
+ SG_T("Select the column containing the Date")
+ );
+
+ P.Add_Table_Field(
+ pNode , "DISCHARGE_Field" , _TL("Streamflow (obs.) Column"),
+ SG_T("Select the column containing the observed streamflow time series")
+ );
+
+ for (i = 0; i < m_nElevBands; i++)
+ {
+ tmpNode = convert_sl::Int2String(i+1).c_str();
+ //s.Printf(tmpNode.c_str(), i);
+ //pNode1 = P.Add_Node(NULL,s,SG_T("Elevation Band Input",_TL(""));
+
+ tmpName = SG_T("PCP Column: Elevation Band: ");
+ tmpName+=tmpNode;
+ P.Add_Table_Field(
+ pNode , tmpName.c_str(), tmpName.c_str(),
+ SG_T("Select Precipitation Column")
+ );
+
+ tmpName = SG_T("TMP Column: Elevation Band: ");
+ tmpName+=tmpNode;
+ P.Add_Table_Field(
+ pNode , tmpName.c_str() , tmpName.c_str(),
+ SG_T("Select Temperature Column")
+ );
+ }
+ // Input file ----------------------------------------------
+
+ for (i = 0; i < m_nElevBands; i++)
+ {
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+100).c_str();
+ tmpName = SG_T("Elevation Band ");
+ tmpName+=convert_sl::Int2String(i+1).c_str();
+
+ s.Printf(tmpNode.c_str(), i+100);
+ pNode = P.Add_Node(NULL,s,tmpName.c_str(),_TL(""));
+
+ tmpName = SG_T("Area [km2] Elev(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode, tmpName, _TL("Area [km2]"),
+ _TL(""),
+ PARAMETER_TYPE_Double
+ );
+
+ tmpName = SG_T("Mean Elevation [m.a.s.l] Elev(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode, tmpName, _TL("Mean Elevation [m.a.s.l]"),
+ _TL(""),
+ PARAMETER_TYPE_Double
+ );
+
+
+ // Parameters of non-linear module -------------------------
+
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+150).c_str();
+ s.Printf(tmpNode.c_str(), i+150);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Non-Linear Module"),_TL(""));
+
+ tmpName = SG_T("TwFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("(Tw) wetness decline time constant [lower bound]"),
+ _TW("Tw is approximately the time constant, or inversely,"
+ "the rate at which the catchment wetness declines in the absence of rainfall"),
+ PARAMETER_TYPE_Double,
+ 1.0, 0.01, true, 150.0, true
+ );
+ tmpName = SG_T("TwFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("(Tw) wetness decline time constant [upper bound]"),
+ _TW("Tw is approximately the time constant, or inversely,"
+ "the rate at which the catchment wetness declines in the absence of rainfall"),
+ PARAMETER_TYPE_Double,
+ 1.0, 0.01, true, 150.0, true
+ );
+
+ tmpName = SG_T("TFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, SG_T("(f) Temperature Modulation Factor [lower bound]"),
+ _TL("Temperature Modulation Factor f"),
+ PARAMETER_TYPE_Double,
+ 0.05, 0.0001, true, 5.0, true
+ );
+
+ tmpName = SG_T("TFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, SG_T("(f) Temperature Modulation Factor [upper bound]"),
+ _TL("Temperature Modulation Factor f"),
+ PARAMETER_TYPE_Double,
+ 0.5, 0.0001, true, 5.0, true
+ );
+
+ tmpName = SG_T("CFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1,tmpName, _TL("(c) Parameter [lower bound]"),
+ _TL("Parameter (c) to fit streamflow volume"),
+ PARAMETER_TYPE_Double,
+ 0.001, 0.0, true, 1.0, true
+ );
+ tmpName = SG_T("CFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1,tmpName, _TL("(c) Parameter [upper bound]"),
+ _TL("Parameter (c) to fit streamflow volume"),
+ PARAMETER_TYPE_Double,
+ 0.01, 0.0, true, 1.0, true
+ );
+
+ switch(m_IHAC_version)
+ {
+ case 0: // Jakeman & Hornberger (1993)
+ break;
+ case 1: // Croke et al. (2005)
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+200).c_str();
+ s.Printf(tmpNode.c_str(), i+200);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Soil Moisture Power Eq."),_TL(""));
+
+ tmpName = SG_T("LFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Parameter (l) [lower bound]"),
+ _TL("Soil moisture index threshold"),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 5.0, true
+ );
+ tmpName = SG_T("LFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Parameter (l) [upper bound]"),
+ _TL("Soil moisture index threshold"),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 5.0, true
+ );
+
+ tmpName = SG_T("PFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Parameter (p) [lower bound]"),
+ _TL("non-linear response term"),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 5.0, true
+ );
+ tmpName = SG_T("PFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("Parameter (p) [upper bound]"),
+ _TL("non-linear response term"),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 5.0, true
+ );
+ break;
+ }
+ // Parameters of non-linear module -------------------------
+
+ // Parameters of linear module -----------------------------
+ switch(m_StorConf)
+ {
+ case 0: // single storage
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+250).c_str();
+ s.Printf(tmpNode.c_str(), i+250);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Linear Module"),_TL(""));
+
+ tmpName = SG_T("AFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("(a) [lower bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.8, -0.99, true, -0.01, true
+ );
+ tmpName = SG_T("AFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("(a) [upper bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.8, -0.99, true, -0.01, true
+ );
+
+ tmpName = SG_T("BFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("(b) [lower bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.2, 0.001, true, 1.0, true
+ );
+ tmpName = SG_T("BFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("(b) [upper bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.2, 0.001, true, 1.0, true
+ );
+ break;
+
+ case 1: // two parallel storages
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+250).c_str();
+ s.Printf(tmpNode.c_str(), i+250);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Linear Module"),_TL(""));
+
+ // Parameter a
+
+ tmpName = SG_T("AQ_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("a(q) [lower bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.7, -0.99, true, -0.01, true
+ );
+ tmpName = SG_T("AQ_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("a(q) [upper bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.7, -0.99, true, -0.01, true
+ );
+
+ tmpName = SG_T("AS_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("a(s) [lower bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.9, -0.99, true, -0.01, true
+ );
+ tmpName = SG_T("AS_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("a(s) [upper bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.9, -0.99, true, -0.01, true
+ );
+
+ // Parameter b
+
+ tmpName = SG_T("BQ_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("b(q) [lower bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 1.0, true
+ );
+ tmpName = SG_T("BQ_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, _TL("b(q) [upper bound]"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 1.0, true
+ );
+ break;
+
+ case 2: // two storages in series
+ break;
+ } // end switch (storconf)
+ // Parameters of linear module -----------------------------
+
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+300).c_str();
+ s.Printf(tmpNode.c_str(), i+300);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Time Delay after Start of Rainfall (INTEGER)"),_TL(""));
+
+ tmpName = SG_T("DELAY(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, SG_T("Time Delay (Rain-Runoff)"),
+ SG_T("The delay after the start of rainfall, before the discharge starts to rise."),
+ PARAMETER_TYPE_Int,
+ 0, 1, true, 100, true
+ );
+
+ // snow module parameters ----------------------------------
+ if (m_bSnowModule)
+ {
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+350).c_str();
+ s.Printf(tmpNode.c_str(), i+350);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Snow Module Parameters"),_TL(""));
+
+ tmpName = SG_T("T_RAIN_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, SG_T("Temperature Threshold for Rainfall [lower bound]"),
+ SG_T("Below this threshold precipitation will fall as snow"),
+ PARAMETER_TYPE_Double,
+ -1.0, -10.0, true, 10.0, true
+ );
+ tmpName = SG_T("T_RAIN_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, SG_T("Temperature Threshold for Rainfall [upper bound]"),
+ SG_T("Below this threshold precipitation will fall as snow"),
+ PARAMETER_TYPE_Double,
+ -1.0, -10.0, true, 10.0, true
+ );
+
+ tmpName = SG_T("T_MELT_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, SG_T("Temperature Threshold for Melting [lower bound]"),
+ SG_T("Above this threshold snow will start to melt"),
+ PARAMETER_TYPE_Double,
+ 1.0, -5.0, true, 10.0, true
+ );
+ tmpName = SG_T("T_MELT_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, SG_T("Temperature Threshold for Melting [upper bound]"),
+ SG_T("Above this threshold snow will start to melt"),
+ PARAMETER_TYPE_Double,
+ 1.0, -5.0, true, 10.0, true
+ );
+
+ tmpName = SG_T("DD_FAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, SG_T("Day-Degree Factor [lower bound]"),
+ SG_T("Day-Degree Factor depends on catchment characteristics"),
+ PARAMETER_TYPE_Double,
+ 0.7, 0.7, true, 9.2, true
+ );
+ tmpName = SG_T("DD_FAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ P.Add_Value(
+ pNode1, tmpName, SG_T("Day-Degree Factor [upper bound]"),
+ SG_T("Day-Degree Factor depends on catchment characteristics"),
+ PARAMETER_TYPE_Double,
+ 0.7, 0.7, true, 9.2, true
+ );
+ }
+ // snow module parameters ----------------------------------
+ }
+
+ if( SG_UI_Dlg_Parameters(&P, _TL("IHACRES Distributed Input Dialog 2")) )
+ {
+ // input table
+ m_p_InputTable = P("TABLE") ->asTable();
+ // field numbers
+ m_dateField = P("DATE_Field") ->asInt();
+ m_streamflowField = P("DISCHARGE_Field") ->asInt();
+ for (int i = 0; i < m_nElevBands; i++)
+ {
+ tmpNode = convert_sl::Int2String(i+1).c_str();
+
+ // get precipitation column of Elevation Band[i]
+ tmpName = SG_T("PCP Column: Elevation Band: ");
+ tmpName+=tmpNode;
+ m_p_pcpField[i] = P(tmpName) ->asInt();
+
+ // get temperature column of Elevation Band[i]
+ tmpName = SG_T("TMP Column: Elevation Band: ");
+ tmpName+=tmpNode;
+ m_p_tmpField[i] = P(tmpName) ->asInt();
+
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+100).c_str();
+
+ // get area[km2] of Elevation Band[i]
+ tmpName = SG_T("Area [km2] Elev(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_elevbands[i].m_area = P(tmpName) ->asDouble();
+
+ // get mean elevation of Elevation Band[i]
+ tmpName = SG_T("Mean Elevation [m.a.s.l] Elev(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_elevbands[i].m_mean_elev =P(tmpName) ->asDouble();
+
+
+ // non-linear module parameters
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+150).c_str();
+ // get Tw
+ tmpName = SG_T("TwFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nl_lb->mp_tw[i] = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("TwFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nl_ub->mp_tw[i] = P(tmpName) ->asDouble();
+
+ // get f
+ tmpName = SG_T("TFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nl_lb->mp_f[i] = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("TFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nl_ub->mp_f[i] = P(tmpName) ->asDouble();
+
+ // get c
+ tmpName = SG_T("CFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nl_lb->mp_c[i] = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("CFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nl_ub->mp_c[i] = P(tmpName) ->asDouble();
+
+ switch(m_IHAC_version)
+ {
+ case 0: // Jakeman & Hornberger (1993)
+ break;
+ case 1: // Croke et al. (2005)
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+200).c_str();
+ // get l
+ tmpName = SG_T("LFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nl_lb->mp_l[i]= P(tmpName) ->asDouble();
+
+ tmpName = SG_T("LFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nl_ub->mp_l[i]= P(tmpName) ->asDouble();
+
+ // get p
+ tmpName = SG_T("PFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nl_lb->mp_p[i]= P(tmpName) ->asDouble();
+
+ tmpName = SG_T("PFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_nl_ub->mp_p[i]= P(tmpName) ->asDouble();
+ }
+
+ // linear module parameters
+ switch(m_nStorages)
+ {
+ case 1: // single storage
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+250).c_str();
+ // get a
+ tmpName = SG_T("AFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_lin_lb->a[i] = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("AFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_lin_ub->a[i] = P(tmpName) ->asDouble();
+
+ // get b
+ tmpName = SG_T("BFAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_lin_lb->b[i] = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("BFAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_lin_ub->b[i] = P(tmpName) ->asDouble();
+ break;
+ case 2: // two storages
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+250).c_str();
+ // get aq
+ tmpName = SG_T("AQ_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_lin_lb->aq[i] = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("AQ_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_lin_ub->aq[i] = P(tmpName) ->asDouble();
+
+ // get bq
+ tmpName = SG_T("BQ_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_lin_lb->bq[i] = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("BQ_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_lin_ub->bq[i] = P(tmpName) ->asDouble();
+
+ // get as
+ tmpName = SG_T("AS_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_lin_lb->as[i] = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("AS_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_p_lin_ub->as[i] = P(tmpName) ->asDouble();
+ break;
+ }
+
+ // get delay
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+300).c_str();
+ tmpName = SG_T("DELAY(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_delay = P(tmpName) ->asInt();
+
+ if (m_bSnowModule)
+ {
+ tmpNode = SG_T("Node");
+ tmpNode+=convert_sl::Int2String(i+350).c_str();
+
+ tmpName = SG_T("T_RAIN_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSnowparms_lb[i].T_Rain = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("T_RAIN_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSnowparms_ub[i].T_Rain = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("T_MELT_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSnowparms_lb[i].T_Melt = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("T_MELT_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSnowparms_ub[i].T_Melt = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("DD_FAC_lb(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSnowparms_lb[i].DD_FAC = P(tmpName) ->asDouble();
+
+ tmpName = SG_T("DD_FAC_ub(");
+ tmpName += tmpNode;
+ tmpName += _TL(")");
+ m_pSnowparms_ub[i].DD_FAC = P(tmpName) ->asDouble();
+ }
+
+ } // end for (int i = 0; i < m_nSubbasins; i++)
+
+ return(true);
+ }
+ return(false);
+}
+
+//---------------------------------------------------------------------
+// DIALOG 3
+//---------------------------------------------------------------------
+
+bool Cihacres_elev_cal::_CreateDialog3()
+{
+ CSG_String s;
+ CSG_Parameters P; // used to add Parameters in the second dialog
+ CSG_Parameter *pNode;
+
+ // Dialog design
+ P.Set_Name(_TL("Choose Time Range"));
+
+ s.Printf(SG_T("Node1"), 1);
+ pNode = P.Add_Node(NULL,s,SG_T("Time Range"),_TL(""));
+
+ s.Printf(SG_T("FDAY") , 1-1);
+ P.Add_String(pNode,s,_TL("First Day"),_TL(""),
+ m_p_InputTable->Get_Record(0)->asString(m_dateField));
+
+ s.Printf(SG_T("LDAY") , 1-2);
+ P.Add_String(pNode,s,_TL("Last Day"),_TL(""),
+ m_p_InputTable->Get_Record(m_p_InputTable->Get_Record_Count()-1)->asString(m_dateField));
+
+ if( SG_UI_Dlg_Parameters(&P, _TL("Choose Time Range")) )
+ {
+ ///////////////////////////////////////////////////////////////
+ //
+ // ASSIGN DATA FROM SECOND DIALOG
+ //
+ ///////////////////////////////////////////////////////////////
+ m_date1 = P(CSG_String::Format(SG_T("FDAY"),m_dateField).c_str())->asString();
+ m_date2 = P(CSG_String::Format(SG_T("LDAY"),m_streamflowField).c_str())->asString();
+ return(true);
+ }
+ return(false);
+}
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev_cal.h b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev_cal.h
new file mode 100644
index 0000000..324cb0a
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_elev_cal.h
@@ -0,0 +1,157 @@
+///////////////////////////////////////////////////////////
+// ihacres_elev_cal.h //
+// //
+// Copyright (C) 2008 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// 2008-02-13 //
+//-------------------------------------------------------//
+
+//*******************************************************//
+// ToDo //
+//-------------------------------------------------------//
+// -
+//*******************************************************//
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__ihacres_elev_cal_H
+#define HEADER_INCLUDED__ihacres_elev_cal_H
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+#include "ihacres_eq.h"
+#include "ihacres_elev_bands.h"
+#include "snow_module.h"
+
+#include <vector> // used for storing date string values in array
+//using namespace std;
+
+typedef std::vector<std::string> date_array;
+
+
+class Cihacres_elev_cal : public CSG_Module
+{
+public:
+
+ //--------------------------------------------------------
+ // CONSTRUCTORS
+ //--------------------------------------------------------
+
+ // default
+ Cihacres_elev_cal();
+
+ // destructor
+ virtual ~Cihacres_elev_cal(void);
+
+protected:
+
+ // execute module
+ virtual bool On_Execute(void);
+
+private:
+
+ //--------------------------------------------------------
+ // PRIVATE MEMBER VARIABLES
+ //--------------------------------------------------------
+
+ int m_counter;
+
+ //----------------------------------
+ // parameters of first module dialog
+ //----------------------------------
+ int m_nElevBands; // number of used elevation bands
+ int m_nsim; // number of simulations
+ double m_Area_tot; // total catchment area [km2]
+ int m_IHAC_version; // Different versions of IHACRES exist, corresponding
+ // to the version...
+ int m_StorConf; // Storage configuration
+ // 0 = single, 1 = two in parallel, 2 = two in series
+ bool m_bSnowModule; // true if snow module is active
+
+ int m_nStorages; // number of storages
+
+ int m_obj_func;
+
+ double m_NSEmin;
+
+ //----------------------------------
+ // parameters of second module dialog
+ //----------------------------------
+ // time series variables
+ CSG_Table* m_p_InputTable; // IHACRES input table
+ int m_nValues; // number of selected records
+ date_array m_vec_date;
+ double* m_p_Q_obs_m3s; // pointer containing observed streamflow in [m3/s]
+ double* m_p_Q_obs_mmday; // pointer containing observed streamflow in [mm]
+ double* m_p_Q_sim_mmday;
+ Cihacres_elev_bands* m_p_elevbands; // Class Cihacres_elev_cal_bands
+
+ // Field numbers
+ int m_dateField; // table field numbers
+ int m_streamflowField;
+ // elevation band parameters
+ int* m_p_pcpField;
+ int* m_p_tmpField;
+ //double* m_p_Area;
+ //double* m_p_mean_elev;
+
+ //----------------------------------
+ // parameters of third module dialog
+ //----------------------------------
+ CSG_String m_date1; // first day of time series YYYYMMDD
+ CSG_String m_date2; // last day
+
+ int m_first;
+ int m_last;
+
+ //----------------------------------
+ // Model parameter (in: ihacres_eq.h)
+ //----------------------------------
+ C_IHAC_LinearParms* m_p_lin_lb;
+ C_IHAC_LinearParms* m_p_lin_ub;
+ C_IHAC_LinearParms* m_p_linparms; // parameters of the linear storage module
+ C_IHAC_NonLinearParms* m_p_nl_lb;
+ C_IHAC_NonLinearParms* m_p_nl_ub;
+ C_IHAC_NonLinearParms* m_p_nonlinparms; // parameters of the non-linear rainfall loss module
+ CSnowParms* m_pSnowparms_lb;
+ CSnowParms* m_pSnowparms_ub;
+ CSnowParms* m_pSnowparms; // 3 snow module paramters
+ CSnowModule* m_p_SnowModule;
+ int m_delay;
+ double* m_vq;
+ double* m_vs;
+
+ double m_NSE;
+ double m_NSE_highflow;
+ double m_NSE_lowflow;
+ double m_PBIAS;
+
+ CSG_Table* m_pTable;
+ CSG_Table* m_pTable_parms;
+
+ //--------------------------------------------------------
+ // PRIVATE MEMBER FUNCTIONS
+ //--------------------------------------------------------
+
+ void _Init_ElevBands(int n); // n = m_nElevBands
+ void _Init_Pointers(int nvals);
+ void _CreateDialog1();
+ bool _CreateDialog2();
+ bool _CreateDialog3();
+ void _ReadInputFile();
+ void _CalcSnowModule(int elevband);
+ void _Simulate_NonLinearModule();
+ void _Simulate_Streamflow();
+ void _Sum_Streamflow();
+ void _CalcEfficiency();
+ void _CreateTableSim();
+ void _CreateTableParms();
+ void _WriteTableParms();
+
+ // Class ihacres_eq
+ Cihacres_eq ihacres;
+
+};
+
+#endif /* HEADER_INCLUDED__ihacres_elev_cal_H */
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_eq.cpp b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_eq.cpp
new file mode 100644
index 0000000..a33d972
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_eq.cpp
@@ -0,0 +1,1215 @@
+///////////////////////////////////////////////////////////
+// //
+// ihacres_eq.cpp //
+// //
+// Copyright (C) 2006 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// //
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// //
+// 2006-08-27 //
+// //
+//-------------------------------------------------------//
+
+#include <iostream> // used for textfile output (test only)
+#include <fstream> // used for textfile output (test only)
+
+#include "ihacres_eq.h"
+#include <math.h> // exp()
+//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+//
+// COMMENTS
+//
+//---------------------------------------------------------
+// 2007-11-08
+// added to function CalcWetnessIndex()
+// if (WetnessIndex[i] > 1.0) WetnessIndex[i] = 1.0;
+//---------------------------------------------------------
+///////////////////////////////////////////////////////////
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// CONSTRUCTORS
+//
+///////////////////////////////////////////////////////////////////////
+
+//---------------------------------------------------------------------
+// DEFAULT CONSTRUCTOR
+//---------------------------------------------------------------------
+Cihacres_eq::Cihacres_eq()
+{};
+
+//---------------------------------------------------------------------
+// two storages
+// using vector<double> as input
+// if no temperature data are available
+Cihacres_eq::Cihacres_eq(date_array date_in,
+ vector_d streamflow,
+ vector_d pcp,
+ double TwConst, double f, double c,
+ double l, double p,
+ double aq, double as, double bq, double bs)
+{
+ sizeAll = streamflow.size();
+ date = date_in;
+ streamflow_obs = streamflow;
+ precipitation = pcp;
+ this->TwConst = TwConst;
+ this->f = f;
+ this->c = c;
+ this->l = l;
+ this->p = p;
+ this->aq = aq;
+ this->as = as;
+ this->bq = bq;
+ this->bs = bs;
+ // Initialize Vectors
+ _InitVectorsStart(streamflow_obs.size());
+}
+//---------------------------------------------------------------------
+// two storages
+// using vector<double> as input
+// if temperature data are available
+Cihacres_eq::Cihacres_eq(date_array date_in,
+ vector_d streamflow,
+ vector_d pcp,
+ vector_d tmp,
+ double TwConst, double f, double c,
+ double l, double p,
+ double aq, double as, double bq, double bs,
+ double area, bool TMP_data_exist,
+ int IHAC_vers,
+ int storconf,
+ bool bSnowModule,
+ CSnowModule *SnowMod,
+ //double T_Rain, double T_Melt, double DD_FAC,
+ int delay)
+{
+ // Initialize Parameters and Vectors
+ sizeAll = streamflow.size();
+ date = date_in;
+ streamflow_obs = streamflow;
+ precipitation = pcp;
+ temperature = tmp;
+ this->TwConst = TwConst;
+ this->f = f;
+ this->c = c;
+ this->l = l;
+ this->p = p;
+ this->aq = aq;
+ this->as = as;
+ this->bq = bq;
+ this->bs = bs;
+ this->delay = delay;
+ this->area = area;
+ IHAC_version = IHAC_vers;
+ this->bSnowModule = bSnowModule;
+ m_pSnowMod = SnowMod;
+
+ // Initialize Vectors containing calculated values
+ _InitVectorsStart(sizeAll);
+
+ // Convert Streamflow vector from m3/s*day-1 to mm/day
+ streamflowMM_obs = model_tools::m3s_to_mmday(streamflow_obs, streamflowMM_obs, area);
+
+ // perform simulation
+ if (bSnowModule)
+ {
+ RunNonLinearModule(TMP_data_exist, bSnowModule, m_pSnowMod->Get_T_Rain());
+ } else {
+ RunNonLinearModule(TMP_data_exist, bSnowModule, 0.0);
+ }
+ //switch (IHAC_version)
+ //{
+ //case 0: // Jakeman & Hornberger (1993)
+ // if (bSnowModule)
+ // {
+ // RunNonLinearModule(TMP_data_exist, bSnowModule, m_pSnowMod->Get_T_Rain());
+ // } else {
+ // RunNonLinearModule(TMP_data_exist, bSnowModule, 0.0);
+ // }
+ // break;
+ //case 1: // Croke et al. (2005) Redesign
+ // //RunNonLinearModule5Parms();
+ // break;
+ //}
+
+ switch(storconf)
+ {
+ case 0: // single storage
+ this->a = aq;
+ this->b = bq;
+ SimStreamflowSingle(excessRain, streamflowMM_obs[0], streamflow_sim, delay, a, b);
+ break;
+ case 1: // two storages in parallel
+ SimStreamflow2Parallel(excessRain, streamflow_sim,
+ streamflowMM_obs[0],
+ aq, as, bq, bs,
+ vq, vs,
+ IHAC_vers,
+ delay);
+ break;
+ } // end switch(storconf)
+
+ NSE = model_tools::CalcEfficiency(streamflowMM_obs, streamflow_sim);
+}
+//---------------------------------------------------------------------
+// two storages
+// using double arrays as input
+// if no temperature data are available
+Cihacres_eq::Cihacres_eq(int size, // array size
+ date_array date_in,
+ double *streamflow,
+ double *pcp,
+ double TwConst, double f, double c,
+ double aq, double as, double bq, double bs)
+{
+ // assign values to global parameters
+ sizeAll = size;
+ date = date_in;
+ streamflow_obs.resize(sizeAll);
+ precipitation.resize(sizeAll);
+ for (int i = 0; i < sizeAll; i++)
+ {
+ streamflow_obs[i] = streamflow[i];
+ precipitation[i] = pcp[i];
+ }
+ this->TwConst = TwConst;
+ this->f = f;
+ this->c = c;
+ this->aq = aq;
+ this->as = as;
+ this->bq = bq;
+ this->bs = bs;
+ // Initialize Vectors
+ _InitVectorsStart(sizeAll);
+}
+//---------------------------------------------------------------------
+// two storages
+// using double arrays as input
+// if temperature data are available
+Cihacres_eq::Cihacres_eq(int size, // array size
+ date_array date_in,
+ double *streamflow,
+ double *pcp,
+ double *tmp,
+ double TwConst, double f, double c,
+ double aq, double as, double bq, double bs)
+{
+ sizeAll = size;
+ date = date_in;
+ streamflow_obs.resize(size);
+ precipitation.resize(size);
+ temperature.resize(size);
+ for (int i = 0; i < size; i++)
+ {
+ streamflow_obs[i] = streamflow[i];
+ precipitation[i] = pcp[i];
+ temperature[i] = tmp[i];
+ }
+ this->TwConst = TwConst;
+ this->f = f;
+ this->c = c;
+ this->aq = aq;
+ this->as = as;
+ this->bq = bq;
+ this->bs = bs;
+ // Initialize Vectors
+ _InitVectorsStart(streamflow_obs.size());
+}
+//---------------------------------------------------------------------
+// end constructors ///////////////////////////////////////////////////
+
+// destructor
+Cihacres_eq::~Cihacres_eq(void)
+{
+ _ZeroAllVectors();
+}
+
+///////////////////////////////////////////////////////////////////////
+//
+// PUBLIC MEMBER FUNCTIONS
+//
+///////////////////////////////////////////////////////////////////////
+
+//---------------------------------------------------------------------
+// Run Non-Linear Module
+//---------------------------------------------------------------------
+void Cihacres_eq::RunNonLinearModule(bool TMP_data_exist, bool bSnowModule, double T_Rain)
+{
+ double WI_init = 0.5;
+ double eR_init = 0.0;
+
+ switch (IHAC_version)
+ {
+ case 0: // Jakeman & Hornberger (1993)
+ // if temperature data are available (TMP_data_exist = true), then adjust the rate
+ // at which the catchment wetness declines in the absence of rainfall
+ // to daily temperature
+ if (TMP_data_exist){
+ CalcWetnessTimeConst(temperature, Tw, TwConst, f);
+ }
+ if (bSnowModule)
+ {
+ // calculate the catchment wetness index
+ CalcWetnessIndex(Tw, precipitation, temperature,
+ WetnessIndex, WI_init, c,
+ bSnowModule, m_pSnowMod->Get_T_Rain());
+ // calculate effective rainfall
+ sum_eRainMM = CalcExcessRain(precipitation, temperature, WetnessIndex, excessRain, eR_init,
+ sum_eRainGTpcp, bSnowModule, m_pSnowMod);
+ } else {
+ CalcWetnessIndex(Tw, precipitation, temperature, WetnessIndex, WI_init, c,
+ bSnowModule, 0.0);
+ sum_eRainMM = CalcExcessRain(precipitation, temperature, WetnessIndex, excessRain, eR_init,
+ sum_eRainGTpcp, bSnowModule, m_pSnowMod);
+ }
+ break;
+
+ case 1: // Croke et al. (2005)
+ if (TMP_data_exist) {
+ CalcWetnessTimeConst_Redesign(temperature, Tw, TwConst, f);
+ }
+ if (bSnowModule)
+ {
+ // calculate the catchment wetness index
+ CalcWetnessIndex_Redesign(Tw, precipitation, WetnessIndex, bSnowModule, m_pSnowMod->Get_T_Rain());
+ // calculate effective rainfall
+ sum_eRainMM = CalcExcessRain_Redesign(precipitation, temperature,
+ WetnessIndex, excessRain, eR_init, sum_eRainGTpcp,
+ c, l, p, bSnowModule, m_pSnowMod);
+ } else {
+ // calculate the catchment wetness index
+ CalcWetnessIndex_Redesign(Tw, precipitation, WetnessIndex, bSnowModule, 0.0);
+ // calculate effective rainfall
+ sum_eRainMM = CalcExcessRain_Redesign(precipitation, temperature,
+ WetnessIndex, excessRain, eR_init, sum_eRainGTpcp,
+ c, l, p, bSnowModule, m_pSnowMod);
+ }
+ break;
+ }
+}
+
+//---------------------------------------------------------------------
+// Simulate Streamflow (single storage)
+//---------------------------------------------------------------------
+void Cihacres_eq::SimStreamflowSingle(vector_d &excessRain, double initVal,
+ vector_d &streamflow_sim, int delay,
+ double a, double b)
+{
+ int i;
+ int size = streamflow_sim.size();
+ // using the first observed streamflow value as initial simulation value
+ for (i = 0; i < delay; i++)
+ streamflow_sim[i] = initVal;
+ // start calculation with second value
+ for (i = delay; i < size; i++)
+ {
+ streamflow_sim[i] = -a * streamflow_sim[i-1] + b * excessRain[i-delay];
+ }
+}
+//---------------------------------------------------------------------
+// Simulate Streamflow (single storage)
+//---------------------------------------------------------------------
+void Cihacres_eq::SimStreamflowSingle(double *excessRain, double initVal,
+ double *streamflow_sim, int delay,
+ double a, double b, int size)
+{
+ int i;
+ // using the first observed streamflow value as initial simulation value
+ for (i = 0; i < delay; i++)
+ streamflow_sim[i] = initVal;
+ // start calculation with second value
+ for (i = delay; i < size; i++)
+ {
+ streamflow_sim[i] = -a * streamflow_sim[i-1] + b * excessRain[i-delay];
+ }
+}
+
+//---------------------------------------------------------------------
+// Simulate Streamflow (2 parallel storages)
+//---------------------------------------------------------------------
+void Cihacres_eq::SimStreamflow2Parallel(vector_d &excessRain, vector_d &streamflow_sim,
+ double initVal,
+ double aq, double as, double bq, double bs,
+ double &vq, double &vs,
+ int IHAC_vers, int delay)
+{
+ int i;
+ int size = streamflow_sim.size();
+ double *sf_q = new double[size]; // quick streamflow component
+ double *sf_s = new double[size]; // slow streamflow component
+
+ // calculate the dependent b-value
+ // after Jakeman etc.
+ vq = bq / (1 + aq);
+ vs = 1 - vq;
+
+ // using the first observed streamflow value as initial simulation value
+ for (i = 0; i < delay; i++)
+ {
+ streamflow_sim[i] = initVal;
+ sf_q[i] = initVal * vq;
+ sf_s[i] = initVal * vs;
+ }
+
+ // using the first observed streamflow value as initial simulation value
+ //for (i = 0; i < delay; i++)
+ //{
+ // streamflow_sim[i] = initVal;
+ // sf_q[i] = initVal / 2;
+ // sf_s[i] = initVal / 2;
+ //}
+
+ //// calculate the dependent b-value
+ //if (IHAC_vers == 1) // after Kokkonen
+ //{
+ // vq = bq / (bq + bs);
+ // vs = 1 - vq;
+ //} else { // after Jakeman etc.
+ // vq = bq / (1 + aq);
+ // vs = 1 - vq;
+ //}
+
+ // calculate streamflow
+ for (i = delay; i < size; i++)
+ {
+ sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay];
+ sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay];
+ streamflow_sim[i] = sf_q[i] + sf_s[i];
+ }
+/*
+ switch(IHAC_vers)
+ {
+ case 0 : // after Jakeman & Hornberger (1993)
+ vq = bq / (1 + aq);
+ vs = 1 - vq;
+ if (!b_freebee)
+ bs = vs * (1 + as);
+
+ // calculate quick and slow components
+ for (i = delay; i < size; i++)
+ {
+ sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay];
+ sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay];
+ streamflow_sim[i] = sf_q[i] + sf_s[i];
+ }
+ break;
+ case 1 : // after Kokkonen et al. (2003)
+ vq = bq / (bq + bs);
+ vs = 1 - vq;
+ if (!b_freebee)
+ bs = vs * (1 + as);
+ // calculate quick and slow components
+ for (i = delay; i < size; i++)
+ {
+ sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay];
+ sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay];
+ streamflow_sim[i] = sf_q[i] + sf_s[i];
+ }
+ break;
+ case 2: // Ahandere Mahn
+ vq = bq / (1 + aq);
+ vs = 1 - vq;
+ if (!b_freebee)
+ bs = vs * (1 + as);
+
+ // calculate quick and slow components
+ for (i = delay; i < size; i++)
+ {
+ sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay];
+ sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay];
+ streamflow_sim[i] = sf_q[i] + sf_s[i];
+ }
+ break;
+ case 3 : // after Croke et al. (2005)
+ vq = bq / (1 + aq);
+ vs = 1 - vq;
+ if (!b_freebee)
+ bs = vs * (1 + as);
+
+ // calculate quick and slow components
+ for (i = delay; i < size; i++)
+ {
+ sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay];
+ sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay];
+ streamflow_sim[i] = sf_q[i] + sf_s[i];
+ }
+ break;
+ }
+*/
+ delete[] sf_q;
+ delete[] sf_s;
+}
+//---------------------------------------------------------------------
+// Simulate Streamflow (2 parallel storages)
+//---------------------------------------------------------------------
+void Cihacres_eq::SimStreamflow2Parallel(double *excessRain, double *streamflow_sim,
+ double initVal,
+ double aq, double as, double bq, double bs,
+ double &vq, double &vs,
+ int IHAC_vers, int size, int delay)
+{
+ int i;
+ double *sf_q = new double[size]; // quick streamflow component
+ double *sf_s = new double[size]; // slow streamflow component
+
+ // calculate the dependent b-value
+ // after Jakeman etc.
+ vq = bq / (1 + aq);
+ vs = 1 - vq;
+
+ // using the first observed streamflow value as initial simulation value
+ for (i = 0; i < delay; i++)
+ {
+ streamflow_sim[i] = initVal;
+ sf_q[i] = initVal * vq;
+ sf_s[i] = initVal * vs;
+ }
+
+ //// using the first observed streamflow value as initial simulation value
+ //for (i = 0; i < delay; i++)
+ //{
+ // streamflow_sim[i] = initVal;
+ // sf_q[i] = initVal / 2;
+ // sf_s[i] = initVal / 2;
+ //}
+
+ //// calculate the dependent b-value
+ //if (IHAC_vers == 1) // after Kokkonen
+ //{
+ // vq = bq / (bq + bs);
+ // vs = 1 - vq;
+ //} else { // after Jakeman etc.
+ // vq = bq / (1 + aq);
+ // vs = 1 - vq;
+ //}
+
+ // calculate streamflow
+ for (i = delay; i < size; i++)
+ {
+ sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay];
+ sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay];
+ streamflow_sim[i] = sf_q[i] + sf_s[i];
+ }
+/*
+ switch(IHAC_vers)
+ {
+ case 0 : // after Jakeman & Hornberger (1993)
+ vq = bq / (1 + aq);
+ vs = 1 - vq;
+ if (!b_freebee)
+ bs = vs * (1 + as);
+
+ // calculate quick and slow components
+ for (i = delay; i < size; i++)
+ {
+ sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay];
+ sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay];
+ streamflow_sim[i] = sf_q[i] + sf_s[i];
+ }
+ break;
+ case 1 : // after Kokkonen et al. (2003)
+ vq = bq / (bq + bs);
+ vs = 1 - vq;
+ if (!b_freebee)
+ bs = vs * (1 + as);
+ // calculate quick and slow components
+ for (i = delay; i < size; i++)
+ {
+ sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay];
+ sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay];
+ streamflow_sim[i] = sf_q[i] + sf_s[i];
+ }
+ break;
+ case 2: // Jakeman & SnowModule
+ vq = bq / (1 + aq);
+ vs = 1 - vq;
+ if (!b_freebee)
+ bs = vs * (1 + as);
+
+ // calculate quick and slow components
+ for (i = delay; i < size; i++)
+ {
+ sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay];
+ sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay];
+ streamflow_sim[i] = sf_q[i] + sf_s[i];
+ }
+ break;
+ case 3 : // after Croke et al. (2005)
+ vq = bq / (1 + aq);
+ vs = 1 - vq;
+ if (!b_freebee)
+ bs = vs * (1 + as);
+
+ // calculate quick and slow components
+ for (i = delay; i < size; i++)
+ {
+ sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay];
+ sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay];
+ streamflow_sim[i] = sf_q[i] + sf_s[i];
+ }
+ break;
+ }
+*/
+ delete[] sf_q;
+ delete[] sf_s;
+}
+
+//---------------------------------------------------------------------
+// Simulate Streamflow (2 parallel storages)
+//---------------------------------------------------------------------
+void Cihacres_eq::SimStreamflow2Parallel(double *excessRain, double *streamflow_sim,
+ double initVal, // first observed streamflow value
+ C_IHAC_LinearParms* linparms, int index,
+ double &vq, double &vs, int size, int delay)
+{
+ int i;
+ double *sf_q = new double[size]; // quick streamflow component
+ double *sf_s = new double[size]; // slow streamflow component
+
+ // calculate the dependent b-value
+ // after Jakeman etc.
+ vq = linparms->bq[index] / (1 + linparms->aq[index]);
+ vs = 1 - vq;
+
+ // using the first observed streamflow value as initial simulation value
+ for (i = 0; i < delay; i++)
+ {
+ streamflow_sim[i] = initVal;
+ sf_q[i] = initVal * vq;
+ sf_s[i] = initVal * vs;
+ }
+
+ // calculate streamflow
+ for (i = delay; i < size; i++)
+ {
+ sf_q[i] = -linparms->aq[index] * sf_q[i-1] + linparms->bq[index] * excessRain[i-delay];
+ sf_s[i] = -linparms->as[index] * sf_s[i-1] + linparms->bs[index] * excessRain[i-delay];
+ streamflow_sim[i] = sf_q[i] + sf_s[i];
+ }
+ delete[] sf_q;
+ delete[] sf_s;
+}
+
+
+//---------------------------------------------------------------------
+// Calculate Parameter b(q)
+//---------------------------------------------------------------------
+double Cihacres_eq::Calc_Parm_BS(double aq, double as, double bq)
+{
+ return( (1 - (bq / (1 + aq))) * (1 + as) );
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+// Calculate time of decay (quick or slow)
+//---------------------------------------------------------------------
+double Cihacres_eq::Calc_TimeOfDecay(double a)
+{
+ return( -1 / log(-a) );
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+// Calculate Wetness Time Constant
+//---------------------------------------------------------------------
+void Cihacres_eq::CalcWetnessTimeConst(vector_d &temperature,
+ vector_d &Tw,
+ double TwConst,
+ double f)
+{
+ for (unsigned int i = 0; i < Tw.size(); i++)
+ {
+ Tw[i] = TwConst * exp((20.0 - temperature[i]) * f);
+ }
+}
+//---------------------------------------------------------------------
+// Calculate Wetness Time Constant
+//---------------------------------------------------------------------
+void Cihacres_eq::CalcWetnessTimeConst(double *temperature,
+ double *Tw,
+ double TwConst,
+ double f,
+ int size)
+{
+ for (int i = 0; i < size; i++)
+ {
+ Tw[i] = TwConst * exp((20.0 - temperature[i]) * f);
+ }
+}
+
+//---------------------------------------------------------------------
+// Calculate Wetness Time Constant
+//---------------------------------------------------------------------
+void Cihacres_eq::CalcWetnessTimeConst(double *temperature, double *Tw,
+ C_IHAC_NonLinearParms* nonlinparms, int index,
+ int size)
+{
+ for (int i = 0; i < size; i++)
+ {
+ Tw[i] = nonlinparms->mp_tw[index] * exp((20.0 - temperature[i]) * nonlinparms->mp_f[index]);
+ }
+}
+
+//---------------------------------------------------------------------
+// Calculate Wetness Time Constant
+// For ihacres_climate_scen
+//---------------------------------------------------------------------
+void Cihacres_eq::CalcWetnessTimeConst_scen(double *temperature, double *Tw,
+ C_IHAC_NonLinearParms* nonlinparms, int index,
+ int size)
+{
+ Tw[0] = 0.0;
+ for (int i = 1; i < size; i++)
+ {
+ Tw[i] = nonlinparms->mp_tw[index] * exp((20.0 - temperature[i]) * nonlinparms->mp_f[index]);
+ }
+}
+
+//---------------------------------------------------------------------
+// Calculate Wetness Time Constant (Croke et al. 2005)
+//---------------------------------------------------------------------
+void Cihacres_eq::CalcWetnessTimeConst_Redesign(vector_d &temperature,
+ vector_d &Tw,
+ double TwConst,
+ double f)
+{
+ double Tr = 20.0; // reference temperature
+ for (unsigned int i = 0; i < Tw.size(); i++)
+ {
+ Tw[i] = TwConst * exp(0.062 * f * (Tr - temperature[i]));
+ }
+}
+
+//---------------------------------------------------------------------
+// Calculate Wetness Time Constant (Croke et al. 2005)
+//---------------------------------------------------------------------
+void Cihacres_eq::CalcWetnessTimeConst_Redesign(double *temperature,
+ double *Tw,
+ double TwConst,
+ double f,
+ int size)
+{
+ double Tr = 20.0; // reference temperature
+ for (int i = 0; i < size; i++)
+ {
+ Tw[i] = TwConst * exp(0.062 * f * (Tr - temperature[i]));
+ }
+}
+//---------------------------------------------------------------------
+// Calculate Wetness Time Constant (Croke et al. 2005)
+//---------------------------------------------------------------------
+void Cihacres_eq::CalcWetnessTimeConst_Redesign(double *temperature, double *Tw,
+ C_IHAC_NonLinearParms* nonlinparms, int index,
+ int size)
+{
+ double Tr = 20.0; // reference temperature
+ for (int i = 0; i < size; i++)
+ {
+ Tw[i] = nonlinparms->mp_tw[index] * exp(0.062 * nonlinparms->mp_f[index] * (Tr - temperature[i]));
+ }
+}
+
+//---------------------------------------------------------------------
+// Calculate Wetness Index
+//---------------------------------------------------------------------
+void Cihacres_eq::CalcWetnessIndex(vector_d &Tw,
+ vector_d &precipitation, vector_d &temperature,
+ vector_d &WetnessIndex, double WI_init,
+ double c, bool bSnowModule, double T_Rain)
+{
+ WetnessIndex[0] = WI_init;
+ // starting at the second value (i=1)
+ for (unsigned int i = 1; i < WetnessIndex.size(); i++)
+ {
+ if (bSnowModule && temperature[i] < T_Rain)
+ {
+ WetnessIndex[i] = (1 - (1 / Tw[i])) * WetnessIndex[i-1];
+ } else {
+ WetnessIndex[i] = c * precipitation[i] + (1 - (1 / Tw[i])) * WetnessIndex[i-1];
+ }
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // if (WetnessIndex[i] > 1.0) WetnessIndex[i] = 1.0;
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ }
+}
+//---------------------------------------------------------------------
+// Calculate Wetness Index
+//---------------------------------------------------------------------
+void Cihacres_eq::CalcWetnessIndex(double *Tw,
+ double *precipitation, double *temperature,
+ double *WetnessIndex, double WI_init,
+ double c, bool bSnowModule, double T_Rain,
+ int size)
+{
+ //WetnessIndex[0] = 0.5;
+ WetnessIndex[0] = WI_init;
+ // starting at the second value (i=1)
+ for (int i = 1; i < size; i++)
+ {
+ if (bSnowModule && temperature[i] < T_Rain)
+ {
+ WetnessIndex[i] = (1 - (1 / Tw[i])) * WetnessIndex[i-1];
+ } else {
+ WetnessIndex[i] = c * precipitation[i] + (1 - (1 / Tw[i])) * WetnessIndex[i-1];
+ }
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // if (WetnessIndex[i] > 1.0) WetnessIndex[i] = 1.0;
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ }
+}
+
+//---------------------------------------------------------------------
+// Calculate Wetness Index after Croke et al. (2005)
+//---------------------------------------------------------------------
+void Cihacres_eq::CalcWetnessIndex_Redesign(vector_d &Tw,
+ vector_d &precipitation,
+ vector_d &WetnessIndex, bool bSnowModule,double T_Rain)
+{
+ WetnessIndex[0] = 0.5;
+ // starting at the second value (i=1)
+ for (unsigned int i = 1; i < WetnessIndex.size(); i++)
+ {
+ WetnessIndex[i] = precipitation[i] + (1 - (1 / Tw[i])) * WetnessIndex[i-1];
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // if (WetnessIndex[i] > 1.0) WetnessIndex[i] = 1.0;
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ }
+}
+//---------------------------------------------------------------------
+// Calculate Wetness Index after Croke et al. (2005)
+//---------------------------------------------------------------------
+void Cihacres_eq::CalcWetnessIndex_Redesign(double *Tw,
+ double *precipitation,double *WetnessIndex, double WI_init,
+ bool bSnowModule,double T_Rain,
+ int size)
+{
+ //WetnessIndex[0] = 0.5;
+ WetnessIndex[0] = WI_init;
+ // starting at the second value (i=1)
+ for (int i = 1; i < size; i++)
+ {
+ WetnessIndex[i] = precipitation[i] + (1 - (1 / Tw[i])) * WetnessIndex[i-1];
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // if (WetnessIndex[i] > 1.0) WetnessIndex[i] = 1.0;
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ }
+}
+//---------------------------------------------------------------------
+// Calculate Effective or Excess Rainfall
+//---------------------------------------------------------------------
+double Cihacres_eq::CalcExcessRain(vector_d &precipitation, vector_d &temperature, vector_d &WetnessIndex,
+ vector_d &excessRain, double eR_init, double &sum_eRainGTpcp,
+ bool bSnowModule, CSnowModule* pSnowModule)
+ //double T_Rain, double T_Melt, double* MeltRate)
+{
+ double sum = 0.0; // sum of total ExcessRain of the period
+ sum_eRainGTpcp = 0.0;
+
+ excessRain[0] = eR_init;
+ if (precipitation[0] > 0.0) excessRain[0] = precipitation[0] / 2;
+ // starting at the second value (i=1)
+ for (unsigned int i = 1; i < excessRain.size(); i++)
+ {
+ // "excess" rainfall after Jakeman & Hornberger (1993)
+ // ExcessRain[i] = pcp[i] * WetnessIndex[i];
+
+ // "excess" rainfall after Croke et al. (2004)
+ excessRain[i] = precipitation[i] * ((WetnessIndex[i] + WetnessIndex[i-1]) / 2);
+
+ if (excessRain[i] > precipitation[i])
+ {
+ // if calculated excess rain volume is greater than observed precipitation,
+ // then summarize volume differences and set to current pcp value
+ sum_eRainGTpcp += excessRain[i] - precipitation[i];
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // if excess rainfall is greater than observed precip, then
+ // it is reduced to precip!
+ //excessRain[i] = precipitation[i];
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ }
+
+ if (excessRain[i] < 0.0) excessRain[i] = 0.0;
+
+ // snow module ********************************************
+ if (bSnowModule)
+ {
+ if (temperature[i] < pSnowModule->Get_T_Rain()) excessRain[i] = 0.0;
+ if (temperature[i] > pSnowModule->Get_T_Melt()) excessRain[i] += pSnowModule->Get_MeltRate(i);
+ if ((temperature[i] < pSnowModule->Get_T_Melt()) && (temperature[i] > pSnowModule->Get_T_Rain()))
+ excessRain[i] += pSnowModule->Get_MeltRate(i);
+ }
+ // end snow module ****************************************
+
+ sum += excessRain[i];
+ }
+ sum += excessRain[0]; // add the initial value
+ return sum;
+}
+//---------------------------------------------------------------------
+// Calculate Effective or Excess Rainfall
+//---------------------------------------------------------------------
+double Cihacres_eq::CalcExcessRain(double *precipitation, double* temperature, double *WetnessIndex,
+ double *excessRain, double eR_init,
+ double &sum_eRainGTpcp, int size,
+ bool bSnowModule, double T_Rain, double T_Melt, double* MeltRate)
+{
+ double sum = 0.0; // sum of total ExcessRain of the period
+ sum_eRainGTpcp = 0.0;
+
+ //excessRain[0] = 0.0;
+ excessRain[0] = eR_init;
+ //if (precipitation[0] > 0.0) excessRain[0] = precipitation[0] / 2;
+ // starting at the second value (i=1)
+ for (int i = 1; i < size; i++)
+ {
+ // "excess" rainfall after Jakeman & Hornberger (1993)
+ // ExcessRain[i] = pcp[i] * WetnessIndex[i];
+
+ // "excess" rainfall after Croke et al. (2004)
+ excessRain[i] = precipitation[i] * ((WetnessIndex[i] + WetnessIndex[i-1]) / 2);
+
+ if (excessRain[i] > precipitation[i])
+ {
+ // if calculated excess rain volume is greater than observed precipitation,
+ // then summarize volume differences and set to current pcp value
+ sum_eRainGTpcp += excessRain[i] - precipitation[i];
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // if excess rainfall is greater than observed precip, then
+ // it is reduced to precip!
+ //excessRain[i] = precipitation[i];
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ }
+ if (excessRain[i] < 0.0) excessRain[i] = 0.0;
+
+ // snow module ********************************************
+ if (bSnowModule)
+ {
+ if (temperature[i] < T_Rain) excessRain[i] = 0.0;
+ if (temperature[i] > T_Melt) excessRain[i] += MeltRate[i];
+ if ((temperature[i] < T_Melt) && (temperature[i] > T_Rain))
+ excessRain[i] += MeltRate[i];
+ }
+ // end snow module ****************************************
+
+ sum += excessRain[i];
+ }
+ sum += excessRain[0]; // add the initial value
+ return sum;
+}
+
+//---------------------------------------------------------------------
+// Calculate Effective or Excess Rainfall after Croke et al. (2005)
+//---------------------------------------------------------------------
+double Cihacres_eq::CalcExcessRain_Redesign(vector_d &precipitation, vector_d& temperature, vector_d &WetnessIndex,
+ vector_d &excessRain, double eR_init, double &sum_eRainGTpcp,
+ double c, double l, double p, bool bSnowModule, CSnowModule* pSnowMod)
+{
+ double sum = 0.0; // sum of total ExcessRain of the period
+ sum_eRainGTpcp = 0.0;
+
+ excessRain[0] = eR_init;
+ if (precipitation[0] > 0.0) excessRain[0] = precipitation[0] / 2;
+ // starting at the second value (i=1)
+ for (unsigned int i = 1; i < excessRain.size(); i++)
+ {
+ // "excess" rainfall after Jakeman & Hornberger (1993)
+ // ExcessRain[i] = pcp[i] * WetnessIndex[i];
+
+ // "excess" rainfall after Croke et al. (2004)
+ // excessRain[i] = precipitation[i] * ((WetnessIndex[i] + WetnessIndex[i-1]) / 2);
+
+ // excess rainfall after Croke et al. (2005)
+ // The first equation is as described in the paper,
+ // but Barry Croke told me that parameter "c" must be outside the brackets !!!
+ // excessRain[i] = pow((c *(WetnessIndex[i] - l)),p) * precipitation[i];
+ if ( WetnessIndex[i] - l < 0.0 ) {
+ excessRain[i] = 0.0;
+ } else {
+ excessRain[i] = c * pow((WetnessIndex[i] - l),p) * precipitation[i];
+ }
+
+ if (excessRain[i] > precipitation[i])
+ {
+ // if calculated excess rain volume is greater than observed precipitation,
+ // then summarize volume differences and set to current pcp value
+ sum_eRainGTpcp += excessRain[i] - precipitation[i];
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // if excess rainfall is greater than observed precip, then
+ // it is reduced to precip!
+ //excessRain[i] = precipitation[i];
+ // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ }
+ if (excessRain[i] < 0.0) excessRain[i] = 0.0;
+
+ // snow module ********************************************
+ if (bSnowModule)
+ {
+ if (temperature[i] < pSnowMod->Get_T_Rain()) excessRain[i] = 0.0;
+ if (temperature[i] > pSnowMod->Get_T_Melt()) excessRain[i] += pSnowMod->Get_MeltRate(i);
+ if ((temperature[i] < pSnowMod->Get_T_Melt()) && (temperature[i] > pSnowMod->Get_T_Rain()))
+ excessRain[i] += pSnowMod->Get_MeltRate(i);
+ }
+ // end snow module ****************************************
+
+ sum += excessRain[i];
+ }
+ sum += excessRain[0]; // add the initial value
+ return sum;
+}
+//---------------------------------------------------------------------
+// Calculate Effective or Excess Rainfall after Croke et al. (2005)
+//---------------------------------------------------------------------
+double Cihacres_eq::CalcExcessRain_Redesign(double *precipitation, double* temperature, double *WetnessIndex,
+ double *excessRain, double eR_init,
+ double &sum_eRainGTpcp,
+ int size, double c, double l, double p,
+ bool bSnowModule, double T_Rain, double T_Melt, double* MeltRate)
+{
+ double sum = 0.0; // sum of total ExcessRain of the period
+ sum_eRainGTpcp = 0.0;
+
+ //excessRain[0] = 0.0;
+ excessRain[0] = eR_init;
+ //if (precipitation[0] > 0.0) excessRain[0] = precipitation[0] / 2;
+ // starting at the second value (i=1)
+ for (int i = 1; i < size; i++)
+ {
+ // excess rainfall after Croke et al. (2005)
+ // The first equation is as described in the paper,
+ // but Barry Croke told me that parameter "c" must be outside the brackets !!!
+ // excessRain[i] = pow((c *(WetnessIndex[i] - l)),p) * precipitation[i];
+ excessRain[i] = c * pow((WetnessIndex[i] - l),p) * precipitation[i];
+
+ if (excessRain[i] > precipitation[i])
+ {
+ // if calculated excess rain volume is greater than observed precipitation,
+ // then summarize volume differences and set to current pcp value
+ sum_eRainGTpcp += excessRain[i] - precipitation[i];
+ excessRain[i] = precipitation[i];
+ }
+ if (excessRain[i] < 0.0) excessRain[i] = 0.0;
+
+ // snow module ********************************************
+ if (bSnowModule)
+ {
+ if (temperature[i] < T_Rain) excessRain[i] = 0.0;
+ if (temperature[i] > T_Melt) excessRain[i] += MeltRate[i];
+ if ((temperature[i] < T_Melt) && (temperature[i] > T_Rain))
+ excessRain[i] += MeltRate[i];
+ }
+ // end snow module ****************************************
+
+ sum += excessRain[i];
+ }
+ sum += excessRain[0]; // add the initial value
+ return sum;
+}
+
+
+
+//---------------------------------------------------------------------
+// Assign first and last record (user selection)
+//---------------------------------------------------------------------
+void Cihacres_eq::AssignFirstLastRec(CSG_Table &pTable, int &first, int &last,
+ CSG_String date1, CSG_String date2, int dateField)
+{
+ int j;
+ ///////////////////////////////////////////////////////////////
+ // searching the first and the last record of the time range
+ ///////////////////////////////////////////////////////////////
+
+ for (j = 0; j < pTable.Get_Record_Count(); j++)
+ {
+ if (!date1.Cmp(pTable.Get_Record(j)->asString(dateField)))
+ {
+ first = j;
+ }
+ else if (!date2.Cmp(pTable.Get_Record(j)->asString(dateField)))
+ {
+ last = j;
+ }
+ }
+}
+
+//---------------------------------------------------------------------
+
+int Cihacres_eq::Assign_nStorages(int storconf)
+{
+ switch(storconf)
+ {
+ case 0: return(1); break;
+ case 1: return(2); break;
+ case 2: return(2); break;
+ default : return(1);
+ }
+}
+//---------------------------------------------------------------------
+
+
+//---------------------------------------------------------------------
+// Summarize all Values in a Vector
+//---------------------------------------------------------------------
+double Cihacres_eq::SumVector(vector_d &input)
+{
+ double sum = 0;
+ for (unsigned int j = 0; j < input.size(); j++)
+ {
+ sum += input[j];
+ }
+ return sum;
+}
+
+//---------------------------------------------------------------------
+// Summarize all Values in an Array
+//---------------------------------------------------------------------
+double Cihacres_eq::SumVector(double *input, int size)
+{
+ double sum = 0;
+ for (int j = 0; j < size; j++)
+ {
+ sum += input[j];
+ }
+ return sum;
+}
+
+
+//---------------------------------------------------------------------
+// Assign temporary Nash-Sutcliffe efficiency according to
+// objective function (NSE, NSE_highflow, NSE_lowflow)
+//---------------------------------------------------------------------
+double Cihacres_eq::_Assign_NSE_temp(int obj_func, double NSE, double NSE_highflow, double NSE_lowflow)
+{
+ switch(obj_func)
+ {
+ case 0: // NSE
+ return(NSE);
+ case 1: // NSE high flow
+ return(NSE_highflow);
+ case 2: // NSE low flow (not yet implemented!)
+ return(NSE_lowflow);
+ break;
+ default: return(NSE);
+ } // end switch(m_obj_func)
+}
+//---------------------------------------------------------------------
+
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// GET FUNCTIONS
+//
+///////////////////////////////////////////////////////////////////////
+double Cihacres_eq::get_vq()
+{
+ // return (bq / (bq + bs));
+ return(vq);
+}
+//---------------------------------------------------------------------
+double Cihacres_eq::get_vs()
+{
+ // return (1 - get_vq());
+ return(vs);
+}
+//---------------------------------------------------------------------
+//---------------------------------------------------------------------
+double Cihacres_eq::get_sum_streamflowMM_obs(int size)
+{
+ double sum_streamflowMM_obs = 0.0;
+ // calculate sum of observed streamflow in [mm]
+ for (int j = 0; j < size; j++)
+ {
+ sum_streamflowMM_obs += streamflowMM_obs[j];
+ }
+ return(sum_streamflowMM_obs);
+}
+//---------------------------------------------------------------------
+double Cihacres_eq::get_sum_precipitation(int size)
+{
+ double sum_pcp = 0.0;
+ for (int i = 0; i < size; i++)
+ {
+ sum_pcp += precipitation[i];
+ }
+ return(sum_pcp);
+}
+//---------------------------------------------------------------------
+double Cihacres_eq::get_NSE()
+{
+ return(NSE);
+}
+//---------------------------------------------------------------------
+vector_d Cihacres_eq::get_streamflow_sim()
+{
+ return(streamflow_sim);
+}
+//---------------------------------------------------------------------
+vector_d Cihacres_eq::get_excessRain()
+{
+ return(excessRain);
+}
+//---------------------------------------------------------------------
+vector_d Cihacres_eq::get_WetnessIndex()
+{
+ return(WetnessIndex);
+}
+//---------------------------------------------------------------------
+vector_d Cihacres_eq::get_Tw()
+{
+ return(Tw);
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+
+///////////////////////////////////////////////////////////////////////
+//
+// PRIVATE MEMBER FUNCTIONS
+//
+///////////////////////////////////////////////////////////////////////
+
+//---------------------------------------------------------------------
+// Initialize (Resize) global Vectors
+//---------------------------------------------------------------------
+void Cihacres_eq::_InitVectorsStart(int size)
+{
+ streamflow_sim.resize(size);
+ excessRain.resize(size);
+ WetnessIndex.resize(size);
+ Tw.resize(size);
+ streamflowMM_obs.resize(size);
+ //if (IHAC_version == 2)
+ //{
+ // m_pSnowMod->SnowStorage = new double[size];
+ // m_pSnowMod->MeltRate = new double[size];
+ // for (int i = 0; i < size; i++)
+ // {
+ // m_pSnowMod->SnowStorage[i] = 0.0;
+ // m_pSnowMod->MeltRate[i] = 0.0;
+ // }
+ // //SnowModule(m_pSnowMod->SnowStorage,m_pSnowMod->MeltRate,temperature,precipitation, m_pSnowMod->T_Rain,m_pSnowMod->T_Melt,m_pSnowMod->DD_FAC, size);
+ //}
+}
+
+//---------------------------------------------------------------------
+// Zero all Vectors
+//---------------------------------------------------------------------
+void Cihacres_eq::_ZeroAllVectors()
+{
+ // Resize all Vectors to Zero
+ streamflow_sim.resize(0);
+ excessRain.resize(0);
+ WetnessIndex.resize(0);
+ Tw.resize(0);
+ date.resize(0);
+ streamflow_obs.resize(0);
+ precipitation.resize(0);
+ temperature.resize(0);
+}
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_eq.h b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_eq.h
new file mode 100644
index 0000000..34460a0
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_eq.h
@@ -0,0 +1,543 @@
+///////////////////////////////////////////////////////////
+// ihacres_eq.h //
+// //
+// Copyright (C) 2006 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// 2006-08-27 //
+// modified: 2008-01-28 //
+//-------------------------------------------------------//
+//
+// References:
+// Jakeman, A.J. / Hornberger, G.M (1993).
+// How Much Complexity Is Warranted in a
+// Rainfall-Runoff Model?
+// Water Resources Research, (29), NO. 8 (2637-2649)
+// Kokkonen, T. S. et al. (2003).
+// Predicting daily flows in ungauged catchments:
+// model regionalization from catchment descriptors
+// at the Coweeta Hydrologic Laboratory, North Carolina
+// Hydrological Processes (17), 2219-2238
+// Croke, B. F. W., W. S. Merritt, et al. (2004).
+// A dynamic model for predicting hydrologic response
+// to land cover changes in gauged and
+// ungauged catchments.
+// Journal Of Hydrology 291(1-2): 115-131.
+// Croke, B. F. W., Andrews, F., Jakeman, A. J., Cuddy, S., Luddy, A.:
+// (2005). Redesign of the IHACRES rainfall-runoff model
+///////////////////////////////////////////////////////////
+
+//*******************************************************//
+// NOTES //
+//*******************************************************//
+// This class provides functions of the rainfall-runoff
+// model IHACRES. On the one hand the class can be used as
+// a provider of functions using the standard constructor
+// or the class can be instantiated and then performs the
+// calculations automatically.
+//
+// Every function working with fields can be provided with
+// arrays (pointer) or vector. You find for both solutions
+// the appropriate function.
+//*******************************************************//
+
+//*******************************************************//
+// ToDo //
+//-------------------------------------------------------//
+// - Difference eRain-streamflow_obs
+// - Tau(q) and Tau(s)
+// - Tau-values for different storages
+// - if TMP_data_exist = false ???
+// - hourly data (not only daily)
+//
+// - SNOW MODULE
+// - snow module on/off
+// - snow module integration in CalcExcessRain (add bool variable)
+// - implementation of an instanteneous store
+// - implement more efficiency criterions
+//*******************************************************//
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__ihacres_eq_H
+#define HEADER_INCLUDED__ihacres_eq_H
+//---------------------------------------------------------
+
+#include <saga_api/saga_api.h> // CSG_Table
+
+#include <vector> // used for storing date string values in array
+ // and double arrays (streamflow, pcp, tmp ...)
+#include <string>
+
+using namespace std;
+
+#include "snow_module.h"
+#include "model_tools.h"
+
+typedef std::vector<std::string> date_array;
+typedef vector<double> vector_d;
+//---------------------------------------------------------
+
+//---------------------------------------------------------
+// A CLASS TO DEAL WITH PARAMETERS OF THE
+// LINEAR STORAGE MODULE
+//---------------------------------------------------------
+class C_IHAC_LinearParms
+{
+public:
+ C_IHAC_LinearParms() {
+ _ZeroPointers();
+ }
+ C_IHAC_LinearParms(int size, int nStorages) {
+ _ZeroPointers();
+ this->nStorages = nStorages;
+ if (nStorages == 1)
+ {
+ a = new double[size];
+ b = new double[size];
+ }
+ if (nStorages == 2)
+ {
+ aq = new double[size];
+ as = new double[size];
+ bq = new double[size];
+ bs = new double[size];
+ }
+ }
+ ~C_IHAC_LinearParms(void) {
+ if (nStorages == 1)
+ {
+ if (a) delete[] a;
+ if (b) delete[] b;
+ }
+ if (nStorages == 2)
+ {
+ if (aq) delete[] aq;
+ if (as) delete[] as;
+ if (bq) delete[] bq;
+ if (bs) delete[] bs;
+ }
+ }
+
+ // linear module parameters
+ int nStorages;
+ double* a;
+ double* b;
+ double* aq;
+ double* as;
+ double* bq;
+ double* bs;
+
+private:
+ void _ZeroPointers() {
+ a = NULL;
+ b = NULL;
+ aq = NULL;
+ as = NULL;
+ bq = NULL;
+ bs = NULL;
+ }
+};
+//---------------------------------------------------------
+
+//---------------------------------------------------------
+// A CLASS TO DEAL WITH PARAMETERS OF THE
+// NON-LINEAR RAINFALL-LOSSES MODULE
+//---------------------------------------------------------
+class C_IHAC_NonLinearParms
+{
+public:
+ C_IHAC_NonLinearParms() {
+ mp_tw = NULL;
+ mp_f = NULL;
+ mp_c = NULL;
+ mp_l = NULL;
+ mp_p = NULL;
+ mp_eR_flow_dif = NULL;
+ };
+ C_IHAC_NonLinearParms(int size) {
+ mp_tw = new double[size];
+ mp_f = new double[size];
+ mp_c = new double[size];
+ mp_l = new double[size];
+ mp_p = new double[size];
+ mp_eR_flow_dif = new double[size];
+ };
+ ~C_IHAC_NonLinearParms(void) {
+ if (mp_tw) delete[] mp_tw;
+ if (mp_f) delete[] mp_f;
+ if (mp_c) delete[] mp_c;
+ if (mp_l) delete[] mp_l;
+ if (mp_p) delete[] mp_p;
+ if (mp_eR_flow_dif) delete[] mp_eR_flow_dif;
+ };
+ // non-linear module parms
+ double* mp_tw;
+ double* mp_f;
+ double* mp_c;
+ double* mp_l;
+ double* mp_p;
+ double* mp_eR_flow_dif;
+};
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// CLASS Cihacres_eq
+//
+///////////////////////////////////////////////////////////////////////
+class Cihacres_eq
+{
+public:
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CONSTRUCTORS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ // default
+ Cihacres_eq();
+
+ // two storages
+ // using vector<double> as input
+ // if no temperature data are available
+ Cihacres_eq (date_array date,
+ vector_d streamflow_obs,
+ vector_d precipitation,
+ double Tw, double f, double c,
+ double l, double p,
+ double aq, double as, double bq, double bs);
+ // two storages
+ // using vector<double> as input
+ // if temperature data are available
+ Cihacres_eq (date_array date,
+ vector_d streamflow_obs,
+ vector_d precipitation,
+ vector_d temperature,
+ double Tw, double f, double c,
+ double l, double p,
+ double aq, double as, double bq, double bs,
+ double area, bool TMP_data_exist,
+ int IHAC_vers,
+ int storconf,
+ bool bSnowModule,
+ CSnowModule *SnowMod,
+ //double T_Rain,
+ //double T_Melt,
+ //double DD_FAC,
+ int delay);
+
+ // two storages
+ // using double arrays as input
+ // if no temperature data are available
+ Cihacres_eq (int size, // array size
+ date_array date,
+ double *streamflow_obs,
+ double *precipitation,
+ double Tw, double f, double c,
+ double aq, double as, double bq, double bs);
+ // two storages
+ // if temperature data are available
+ // using double arrays as input
+ Cihacres_eq (int size, // array size
+ date_array date,
+ double *streamflow_obs,
+ double *precipitation,
+ double *temperature,
+ double Tw, double f, double c,
+ double aq, double as, double bq, double bs);
+
+ // end constructors ///////////////////////////////////////////////
+
+ // destructor
+ ~Cihacres_eq(void);
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // PUBLIC MEMEBER VARIABLES
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ // Variables
+ int sizeAll; // incoming data array size (number of records in input data)
+
+ CSnowModule *m_pSnowMod; // class Snow Module
+
+ double* m_pMeltRate;
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // PUBLIC MEMBER FUNCTIONS
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ //--------------------------------------------------------
+
+ void RunNonLinearModule (bool TMP_data_exist, bool bSnowModule, double T_Rain);
+
+ // simulate streamflow (single storage)
+ void SimStreamflowSingle (vector_d &excessRain, double initVal,
+ vector_d &streamflow_sim, int delay,
+ double a, double b);
+
+ void SimStreamflowSingle (double *excessRain, double initVal,
+ double *streamflow_sim, int delay,
+ double a, double b, int size);
+
+ // simulate streamflow with two parallel storages
+ void SimStreamflow2Parallel (vector_d &excessRain,
+ vector_d &streamflow_sim,
+ double initVal, // first observed streamflow value
+ double aq, double as, double bq, double bs,
+ double &vq, double &vs,
+ int IHAC_vers,
+ int delay);
+
+ void SimStreamflow2Parallel (double *excessRain,
+ double *streamflow_sim,
+ double initVal, // first observed streamflow value
+ double aq, double as, double bq, double bs,
+ double &vq, double &vs,
+ int IHAC_vers, int size,
+ int delay);
+
+ void SimStreamflow2Parallel (double *excessRain,
+ double *streamflow_sim,
+ double initVal, // first observed streamflow value
+ C_IHAC_LinearParms* linparms, int index,
+ double &vq, double &vs, int size, int delay);
+
+ double Calc_Parm_BS (double aq, double as, double bq);
+
+ // calculate time of decay for quick or slow component (aq or bq)
+ double Calc_TimeOfDecay (double a);
+
+ //--------------------------------------------------------
+
+ // calculating the time constant, or inversely the rate at which
+ // the catchment wetness declines in the absence of rainfall
+ void CalcWetnessTimeConst (vector_d &temperature,
+ vector_d &Tw,
+ double TwConst,
+ double f);
+
+ void CalcWetnessTimeConst (double *temperature,
+ double *Tw,
+ double TwConst,
+ double f,
+ int size);
+
+ void CalcWetnessTimeConst (double* temperature, double* Tw,
+ C_IHAC_NonLinearParms* nonlinparms, int index,
+ int size);
+
+ // For ihacres_climate_scen
+ void CalcWetnessTimeConst_scen(double* temperature, double* Tw,
+ C_IHAC_NonLinearParms* nonlinparms, int index,
+ int size);
+
+ // modified version after Croke et al. (2005)
+ void CalcWetnessTimeConst_Redesign(vector_d &temperature,
+ vector_d &Tw,
+ double TwConst,
+ double f);
+
+ // modified version after Croke et al. (2005)
+ void CalcWetnessTimeConst_Redesign(double *temperature,
+ double *Tw,
+ double TwConst,
+ double f,
+ int size);
+
+ void CalcWetnessTimeConst_Redesign(double *temperature, double *Tw,
+ C_IHAC_NonLinearParms* nonlinparms, int index,
+ int size);
+
+ // calculating the catchment wetness index,
+ // or antecedent precipitation index
+ void CalcWetnessIndex (vector_d &Tw,
+ vector_d &precipitation, vector_d &temperature,
+ vector_d &WetnessIndex, double WI_init,
+ double c, bool bSnowModule, double T_Rain);
+
+ void CalcWetnessIndex (double *Tw,
+ double *precipitation, double *temperature,
+ double *WetnessIndex, double WI_init,
+ double c, bool bSnowModule, double T_Rain,
+ int size);
+
+ // modified version after Croke et al. (2005)
+ void CalcWetnessIndex_Redesign(vector_d &Tw,
+ vector_d &precipitation,
+ vector_d &WetnessIndex,
+ bool bSnowModule,double T_Rain);
+
+ // modified version after Croke et al. (2005)
+ void CalcWetnessIndex_Redesign(double *Tw,
+ double *precipitation,
+ double *WetnessIndex, double WI_init,
+ bool bSnowModule,double T_Rain,
+ int size);
+
+ // calculate the effecive or excess rainfall and
+ // calculate total effective rainfall over the period in [mm]
+ double CalcExcessRain (vector_d &precipitation,
+ vector_d &temperature,
+ vector_d &WetnessIndex,
+ vector_d &excessRain, double eR_init,
+ double &sum_eRainGTpcp,
+ bool bSnowModule,
+ CSnowModule* pSnowModule);
+
+ double CalcExcessRain (double *precipitation,
+ double *temperature,
+ double *WetnessIndex,
+ double *excessRain, double eR_init,
+ double &sum_eRainGTpcp,
+ int size,
+ bool bSnowModule, double T_Rain, double T_Melt, double* MeltRate);
+
+ // modified version after Croke et al. (2005)
+ double CalcExcessRain_Redesign (vector_d &precipitation,
+ vector_d &temperature,
+ vector_d &WetnessIndex,
+ vector_d &excessRain, double eR_init,
+ double &sum_eRainGTpcp,
+ double c, // mass balance parameter
+ double l, // soil moisture index threshold
+ double p, // power on soil moisture
+ bool bSnowModule, CSnowModule* m_pSnowMod);
+
+ // modified version after Croke et al. (2005)
+ double CalcExcessRain_Redesign (double *precipitation,
+ double *temperature,
+ double *WetnessIndex,
+ double *excessRain, double eR_init,
+ double &sum_eRainGTpcp,
+ int size,
+ double c, // mass balance parameter
+ double l, // soil moisture index threshold
+ double p, // power on soil moisture
+ bool bSnowModule, double T_Rain, double T_Melt, double* MeltRate);
+ //--------------------------------------------------------
+
+
+ //--------------------------------------------------------
+ void AssignFirstLastRec (CSG_Table &pTable,
+ int &first, int &last,
+ CSG_String date1,CSG_String date2,
+ int dateField);
+
+ int Assign_nStorages (int storconf);
+
+ double SumVector (vector_d &input);
+ double SumVector (double *input, int size);
+
+ double _Assign_NSE_temp (int obj_func,
+ double NSE,
+ double NSE_highflow,
+ double NSE_lowflow);
+
+ //--------------------------------------------------------
+ // Get Functions
+ //--------------------------------------------------------
+ double get_vq(); // fraction of quick flow
+ double get_vs(); // fraction of slow flow
+ double get_sum_streamflowMM_obs(int size); // sum of observed streamflow in [mm]
+ double get_sum_precipitation(int size);
+ double get_NSE();
+
+ vector_d get_streamflow_sim();
+ vector_d get_excessRain();
+ vector_d get_WetnessIndex();
+ vector_d get_Tw();
+
+private:
+
+ ///////////////////////////////////////////////////////////////////
+ // Private Member Variables
+ ///////////////////////////////////////////////////////////////////
+
+ // incoming arrays / vectors
+ date_array date; // Vector containing date values
+ vector_d streamflow_obs; // Vector containing observed streamflow data
+ vector_d precipitation; // Vector containing measured precipitation
+ vector_d temperature; // Vector containing measured temperature
+ vector_d streamflowMM_obs; // Streamflow time series in [mm]
+
+ //
+ double sum_eRainGTpcp; // sum of excess rainfall that is greater
+ // than precipitation in one simulation
+
+ // Vectors (arrays)
+ vector_d streamflow_sim; // Vector containing simulated streamflow data
+ vector_d excessRain; // Vector containing estimated excess or effective rainfall
+ vector_d WetnessIndex; // catchment wetness index
+ vector_d Tw;
+
+ // parameters
+ bool TMP_data_exist; // if temperature data are available (TMP_data_exist = true)
+ double RainRunoffCoef; // Rainfall-Runoff coefficient
+ double NSE; // Nash-Sutcliffe Efficiency
+
+ double sum_streamflow_obs;
+ double sum_streamflow_sim;
+ double sum_eRainMM; // sum of estimated effective rainfall [mm]
+
+ // non-linear IHACRES module parameters
+ double c;
+ double f;
+ double TwConst; // Tw is approximately the time constant, or inversely,
+ // the rate at which the catchment wetness declines
+ // in the absence of rainfall.
+ // Additional parameters for Croke et al. (2005) Redesign version
+ double l; // soil moisture index threshold
+ double p; // power on soil moisture
+
+ // linear IHACRES module parameters
+ double a;
+ double b;
+
+ double aq;
+ double as;
+ double bq;
+ double bs;
+
+ double vq; // fraction of quick flow
+ double vs; // fraction of slow flow
+
+ int delay; // The delay after the start of rainfall,
+ // before the discharge starts to rise.
+
+ double area; // area of the watershed in [km2]
+
+ int IHAC_version; // Different versions of IHACRES exist, corresponding
+ // to the version...
+
+ bool bSnowModule; // if true, snow module is active
+
+ /*
+ // snow module parameters
+ vector_d SnowStorage;
+ vector_d MeltRate;
+ double T_Rain;
+ double T_Melt;
+ double DD_FAC;
+ */
+ ///////////////////////////////////////////////////////////////////
+ // Private Member Functions
+ ///////////////////////////////////////////////////////////////////
+
+ // initialize Vectors
+ void _InitVectorsStart (int size);
+
+ // Resize all vectors *.resize(0)
+ void _ZeroAllVectors ();
+
+}; // end class ihacres_eq
+
+//---------------------------------------------------------
+#endif /* #ifndef HEADER_INCLUDED__ihacres_eq_H */
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_v1.cpp b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_v1.cpp
new file mode 100644
index 0000000..aa84d6d
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_v1.cpp
@@ -0,0 +1,797 @@
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ihacres_v1 //
+// //
+//-------------------------------------------------------//
+// //
+// ihacres_v1.cpp //
+// //
+// Copyright (C) 2006 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// //
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// //
+// 2006-08-31 //
+//-------------------------------------------------------//
+//
+// References:
+// Jakeman, A.J. / Hornberger, G.M (1993).
+// How Much Complexity Is Warranted in a
+// Rainfall-Runoff Model?
+// Water Resources Research, (29), NO. 8 (2637-2649)
+// Kokkonen, T. S. et al. (2003).
+// Predicting daily flows in ungauged catchments:
+// model regionalization from catchment descriptors
+// at the Coweeta Hydrologic Laboratory, North Carolina
+// Hydrological Processes (17), 2219-2238
+// Croke, B. F. W., W. S. Merritt, et al. (2004).
+// A dynamic model for predicting hydrologic response
+// to land cover changes in gauged and
+// ungauged catchments.
+// Journal Of Hydrology 291(1-2): 115-131.
+//-------------------------------------------------------//
+
+//---------------------------------------------------------
+#include <iostream> // used for textfile output (test only)
+#include <fstream> // used for textfile output (test only)
+
+#include "ihacres_v1.h"
+//#include "ihacres_cal.h"
+#include "model_tools.h"
+//---------------------------------------------------------
+
+// constructor
+Cihacres_v1::Cihacres_v1(void)
+{
+ //-----------------------------------------------------
+ // 1. Info...
+ Set_Name(_TL("IHACRES Version 1.0"));
+
+ Set_Author(SG_T("copyrights (c) 2008 Stefan Liersch"));
+
+ Set_Description(_TW("The Rainfall-Runoff Model IHACRES \n \n \n"
+ "Reference: \n \n"
+ "Jakeman, A.J. / Hornberger, G.M. (1993). \n"
+ "How Much Complexity Is Warranted in a Rainfall-Runoff Model? \n"
+ "Water Resources Research, (29), NO. 8 (2637-2649) \n \n"
+ "Croke, B. F. W. et al.(2004).\n"
+ "A dynamic model for predicting hydrologic response "
+ "to land cover changes in gauged and "
+ "ungauged catchments. \n"
+ "Journal Of Hydrology 291(1-2): 115-131."
+ ));
+
+ ///////////////////////////////////////////////////////////////////
+ // FIRST MODULE DIALOG
+ CreateDialog1();
+ ///////////////////////////////////////////////////////////////////
+}
+
+//---------------------------------------------------------
+// destructor
+Cihacres_v1::~Cihacres_v1(void)
+{}
+
+//---------------------------------------------------------
+
+bool Cihacres_v1::On_Execute(void)
+{
+ ///////////////////////////////////////////////////////////////////
+ //
+ // VARIABLES
+ //
+ ///////////////////////////////////////////////////////////////////
+ int j,k; //counter
+ CSG_Table *pTable, *pTable_out, *pTable_parms, *pTable_settings;
+
+ bool bTMP; // true, if temperature data are used to
+ // to refine wetness index estimation.
+ bool writeAllTimeSeries;
+ int storconf; // storage configuration
+ // 0 = single, 1 = two parallel, 2 = two in series
+
+ // Assign Parameters from first Module Dialog
+ //---------------------------------------------------------
+ pTable = Parameters("TABLE") ->asTable();
+ // Field numbers
+ dateField = Parameters("DATE_Field") ->asInt();
+ dischargeField = Parameters("DISCHARGE_Field") ->asInt();
+ pcpField = Parameters("PCP_Field") ->asInt();
+ tmpField = Parameters("TMP_Field") ->asInt();
+
+ bTMP = Parameters("USE_TMP") ->asBool();
+ c = Parameters("CFAC") ->asDouble();
+ TwConst = Parameters("TwFAC") ->asDouble();
+ m_area = Parameters("AREA") ->asDouble();
+ storconf = Parameters("STORAGE") ->asInt();
+ IHAC_version = Parameters("IHACVERS") ->asInt();
+ bSnowModule = Parameters("SNOW_MODULE") ->asBool();
+ writeAllTimeSeries = Parameters("WRITEALL_TS") ->asBool();
+ first = last = 0;
+ //---------------------------------------------------------
+
+ ///////////////////////////////////////////////////////////////////
+ // Create Second Dialog and assign linear module parameters
+ if ( CreateDialog2(bTMP, storconf, IHAC_version, pTable, dateField, dischargeField) ) {
+ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////
+ // searching the first and the last record of the time range
+ ihacres->AssignFirstLastRec(*pTable, first, last, date1, date2, dateField);
+ ///////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////
+ // INITIALIZE VECTORS
+ sizeAll = last - first + 1;
+ // global array variables
+ date.resize(sizeAll);
+ m_Q_obs_m3s.resize(sizeAll);
+ m_Q_obs_mmday.resize(sizeAll);
+ precipitation.resize(sizeAll);
+ if (bTMP) temperature.resize(sizeAll);
+
+ for (j = 0, k = first; j < sizeAll, k < last + 1; j++, k++)
+ {
+ date[j].append(SG_STR_SGTOMB(pTable->Get_Record(k)->asString(dateField)));
+ m_Q_obs_m3s[j] = pTable->Get_Record(k)->asDouble(dischargeField);
+ precipitation[j] = pTable->Get_Record(k)->asDouble(pcpField);
+ if (bTMP) temperature[j] = pTable->Get_Record(k)->asDouble(tmpField);
+ }
+
+ if (bSnowModule && bTMP)
+ {
+ m_pSnowModule = new CSnowModule(temperature, precipitation, T_Rain, T_Melt, DD_FAC);
+ if (!bSnowModule) m_pSnowModule = NULL;
+ //m_pSnowModule->MeltRate = new double[sizeAll];
+ //m_pSnowModule->SnowStorage = new double[sizeAll];
+ }
+
+ //---------------------------------------------------------
+ // Convert streamflow from m3/s to mm/day
+ ///////////////////////////////////////////////////////////////
+
+
+ ///////////////////////////////////////////////////////////////
+ //
+ // INSTANTIATE CLASS IHACRES
+ //
+ ///////////////////////////////////////////////////////////////
+
+ // different constructors are available for class ihacres_eq,
+ // depending on availability of temperature data,
+ // storage characteristics, and data storage properties (vector / arrays)
+
+ switch(storconf)
+ {
+ case 0: // single storage
+ ihacres = new Cihacres_eq(date,
+ m_Q_obs_m3s,
+ precipitation,
+ temperature,
+ TwConst, f, c, l, p,
+ a, 0, b, 0,
+ m_area,
+ bTMP,
+ IHAC_version,
+ storconf,
+ bSnowModule,
+ m_pSnowModule,
+ delay);
+ break;
+ case 1: // two storages in parallel
+ // if temperature data available
+ // and using vectors to store time series data
+ // and 2 storages in parallel
+ ihacres = new Cihacres_eq(date,
+ m_Q_obs_m3s,
+ precipitation,
+ temperature,
+ TwConst, f, c, l, p,
+ aq, as, bq, bs,
+ m_area,
+ bTMP,
+ IHAC_version,
+ storconf,
+ bSnowModule,
+ m_pSnowModule,
+ delay);
+ break;
+ } // end switch
+
+ //---------------------------------------------------------
+ // create output tables and add them to SAGA workspace
+ //---------------------------------------------------------
+ pTable_out = SG_Create_Table();
+ CreateTableSim(pTable_out, date, m_Q_obs_m3s, ihacres->get_streamflow_sim());//ihacres->streamflow_sim);
+ // add tables to SAGA Workspace
+ pTable_out->Set_Name(SG_T("IHACRES_Sim"));
+ Parameters("TABLEout")->Set_Value(pTable_out);
+
+ pTable_settings = SG_Create_Table();
+ if (bSnowModule)
+ {
+ CreateTableSettings(pTable_settings, TwConst, c, f, aq, as, bq, bs,
+ ihacres->get_vq(), ihacres->get_vs(),
+ bSnowModule, m_pSnowModule->Get_T_Rain(), m_pSnowModule->Get_T_Melt(), m_pSnowModule->Get_DD_FAC(),
+ delay,
+ model_tools::CalcRunoffCoeff(m_Q_obs_mmday,precipitation), ihacres->get_NSE(),
+ m_area);
+ } else {
+ CreateTableSettings(pTable_settings, TwConst, c, f, aq, as, bq, bs,
+ ihacres->get_vq(), ihacres->get_vs(),
+ bSnowModule, 0, 0, 0,
+ delay,
+ model_tools::CalcRunoffCoeff(m_Q_obs_mmday,precipitation), ihacres->get_NSE(),
+ m_area);
+ }
+ pTable_settings->Set_Name(SG_T("IHACRES_Settings"));
+ Parameters("TABLEsettings")->Set_Value(pTable_settings);
+
+ if (writeAllTimeSeries)
+ {
+ pTable_parms = SG_Create_Table();
+ CreateTableParms(pTable_parms, date, m_Q_obs_m3s, precipitation, temperature,
+ ihacres->get_streamflow_sim(), ihacres->get_excessRain(),
+ ihacres->get_WetnessIndex(), ihacres->get_Tw());
+ pTable_parms->Set_Name(SG_T("IHACRES_Parms"));
+ Parameters("TABLEparms")->Set_Value(pTable_parms);
+ }
+
+ ///////////////////////////////////////////////////////////////
+ // DELETE AND RESIZE
+ ///////////////////////////////////////////////////////////////
+ delete ihacres;
+ date.resize(0);
+ m_Q_obs_m3s.resize(0);
+ m_Q_obs_mmday.resize(0);
+ precipitation.resize(0);
+ if (bTMP) temperature.resize(0);
+ if (bSnowModule) delete m_pSnowModule;
+ ///////////////////////////////////////////////////////////////
+
+ //---------------------------------------------------------
+ return( true ); // bool Cihacres_cal::On_Execute(void)
+ } else {
+ return(false);
+ }
+} // end function On_Execute()
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// PRIVATE FUNCTIONS
+//
+///////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////
+//
+// CREATE OUTPUT TABLES
+//
+///////////////////////////////////////////////////////////////////////
+
+void Cihacres_v1::CreateTableSim(CSG_Table *pTable, date_array date, vector_d strfl_obs, vector_d strfl_sim)
+{
+ int i = 0; // used in function Get_Record(i)
+ CSG_Table_Record *pRecord;
+
+ // creating the column titles
+ pTable->Add_Field("Date", SG_DATATYPE_String);
+ pTable->Add_Field("Flow OBS", SG_DATATYPE_Double);
+ pTable->Add_Field("Flow SIM", SG_DATATYPE_Double);
+
+ for (unsigned int j = 0; j < date.size(); j++)
+ {
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(i);
+
+ // writing the data into the rows
+ pRecord->Set_Value(0,SG_STR_MBTOSG(date[j].c_str()));
+ pRecord->Set_Value(1,strfl_obs[j]);
+ pRecord->Set_Value(2,model_tools::mmday_to_m3s(strfl_sim[j],m_area));
+ i++;
+ }
+}
+
+void Cihacres_v1::CreateTableParms(CSG_Table *pTable, date_array date, vector_d strfl_obs, vector_d precipitation, vector_d temperature,
+ vector_d strfl_sim, vector_d excessRain, vector_d wi, vector_d Tw)
+{
+ int i = 0; // used in function Get_Record(i)
+ CSG_Table_Record *pRecord;
+
+ // creating the column titles
+ pTable->Add_Field("Date", SG_DATATYPE_String);
+ pTable->Add_Field("Flow OBS", SG_DATATYPE_Double);
+ pTable->Add_Field("Flow SIM", SG_DATATYPE_Double);
+ pTable->Add_Field("TMP", SG_DATATYPE_Double);
+ pTable->Add_Field("PCP", SG_DATATYPE_Double);
+ pTable->Add_Field("ExcessRain", SG_DATATYPE_Double);
+ pTable->Add_Field("WetnessIndex", SG_DATATYPE_Double);
+ pTable->Add_Field("Tau", SG_DATATYPE_Double);
+
+ for (unsigned int j = 0; j < date.size(); j++)
+ {
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(i);
+
+ // writing the data into the rows
+ pRecord->Set_Value(0,SG_STR_MBTOSG(date[j].c_str()));
+ pRecord->Set_Value(1,strfl_obs[j]);
+ pRecord->Set_Value(2,model_tools::mmday_to_m3s(strfl_sim[j], m_area));
+ pRecord->Set_Value(3,temperature[j]);
+ pRecord->Set_Value(4,precipitation[j]);
+ pRecord->Set_Value(5,excessRain[j]);
+ pRecord->Set_Value(6,wi[j]);
+ pRecord->Set_Value(7,Tw[j]);
+ i++;
+ }
+}
+
+void Cihacres_v1::CreateTableSettings(CSG_Table *pTable, double Tw, double c, double f,
+ double aq, double as, double bq, double bs,
+ double vq , double vs,
+ bool bSnowModule, double T_Rain, double T_Melt, double DD_FAC,
+ int delay,
+ double RRCoef, double NSE,
+ double m_area)
+{
+ int count = 1;
+ CSG_Table_Record *pRecord;
+
+ // creating the column titles
+ pTable->Add_Field("Parameters", SG_DATATYPE_String);
+ pTable->Add_Field("Settings", SG_DATATYPE_Double);
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(0);
+ pRecord->Set_Value(0,SG_T("Tau"));
+ pRecord->Set_Value(1,Tw);
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(1);
+ pRecord->Set_Value(0,SG_T("c"));
+ pRecord->Set_Value(1,c);
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(2);
+ pRecord->Set_Value(0,SG_T("f"));
+ pRecord->Set_Value(1,f);
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(3);
+ pRecord->Set_Value(0,SG_T("a(q)"));
+ pRecord->Set_Value(1,aq);
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(4);
+ pRecord->Set_Value(0,SG_T("a(s)"));
+ pRecord->Set_Value(1,as);
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(5);
+ pRecord->Set_Value(0,SG_T("b(q)"));
+ pRecord->Set_Value(1,bq);
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(6);
+ pRecord->Set_Value(0,SG_T("b(s)"));
+ pRecord->Set_Value(1,bs);
+ //pRecord->Set_Value(1,vs * (1 + as));
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(7);
+ pRecord->Set_Value(0,SG_T("v(q)"));
+ pRecord->Set_Value(1,vq);
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(8);
+ pRecord->Set_Value(0,SG_T("v(s)"));
+ pRecord->Set_Value(1,vs);
+
+ pTable->Add_Record();
+ pRecord= pTable->Get_Record(9);
+ pRecord->Set_Value(0,SG_T("T(q)"));
+ pRecord->Set_Value(1,ihacres->Calc_TimeOfDecay(aq));
+
+ pTable->Add_Record();
+ pRecord= pTable->Get_Record(10);
+ pRecord->Set_Value(0,SG_T("T(s)"));
+ pRecord->Set_Value(1,ihacres->Calc_TimeOfDecay(as));
+
+ if (bSnowModule)
+ {
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(10+count);
+ pRecord->Set_Value(0,SG_T("T_Rain"));
+ pRecord->Set_Value(1,T_Rain);
+ count++;
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(10+count);
+ pRecord->Set_Value(0,SG_T("T_Melt"));
+ pRecord->Set_Value(1,T_Melt);
+ count++;
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(10+count);
+ pRecord->Set_Value(0,SG_T("DD_Fac"));
+ pRecord->Set_Value(1,DD_FAC);
+ count++;
+ }
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(10+count);
+ pRecord->Set_Value(0,SG_T("RR-Delay"));
+ pRecord->Set_Value(1,delay);
+ count++;
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(10+count);
+ pRecord->Set_Value(0,SG_T("RRCoef"));
+ pRecord->Set_Value(1,RRCoef);
+ count++;
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(10+count);
+ pRecord->Set_Value(0,SG_T("NSE"));
+ pRecord->Set_Value(1,NSE);
+ count++;
+
+ pTable->Add_Record();
+ pRecord = pTable->Get_Record(10+count);
+ pRecord->Set_Value(0,SG_T("Area"));
+ pRecord->Set_Value(1,m_area);
+ count++;
+}
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// DIALOGS
+//
+///////////////////////////////////////////////////////////////////////
+
+void Cihacres_v1::CreateDialog1()
+{
+ CSG_Parameter *pNode;
+ CSG_String s;
+
+ pNode = Parameters.Add_Table(
+ NULL , "TABLE" , _TL("Table"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "DATE_Field" , _TL("Date Column"),
+ SG_T("Select the column containing the Date")
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "DISCHARGE_Field" , _TL("Streamflow Column"),
+ SG_T("Select the Column containing Discharge Values")
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "PCP_Field" , _TL("Precipitation Column"),
+ SG_T("Select the Column containing precipitation Values")
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "TMP_Field" , _TL("Temperature Column"),
+ SG_T("Select the Column containing Temperature Values")
+ );
+
+ Parameters.Add_Value(
+ pNode, "USE_TMP", _TL("Using temperature data?"),
+ _TL("If checked, then temperature data are used."),
+ PARAMETER_TYPE_Bool, true
+ );
+
+ pNode = Parameters.Add_Value(
+ NULL, "AREA", _TL("Area of the Watershed in [km2]"),
+ _TL("Area of the Watershed in [km2] used for unit conversion"),
+ PARAMETER_TYPE_Double,
+ 100.0, 0.00001, true, 0.0, false
+ );
+
+ s.Printf(SG_T("Node2"), 2);
+ pNode = Parameters.Add_Node(NULL,s,SG_T("Non-Linear Module"),_TL(""));
+
+ Parameters.Add_Value(
+ pNode, "CFAC", _TL("Parameter (c)"),
+ _TL("Parameter (c) to fit streamflow volume"),
+ PARAMETER_TYPE_Double,
+ 0.001, 0.0, true, 1.0, true
+ );
+ Parameters.Add_Value(
+ pNode, "TwFAC", _TL("(Tw) wetness decline time constant"),
+ _TW("Tw is approximately the time constant, or inversely,"
+ "the rate at which the catchment wetness declines in the absence of rainfall"),
+ PARAMETER_TYPE_Double,
+ 1.0, 0.01, true, 150.0, true
+ );
+
+ s.Printf(SG_T("Node3"), 3);
+ pNode = Parameters.Add_Node(NULL,s,SG_T("Storage Configuration"),_TL(""));
+
+ Parameters.Add_Choice(
+ pNode , "STORAGE" , _TL("Storage"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("Single Storage"), // 0
+ _TL("Two Parallel Storages"), // 1
+ _TL("Two Storages in Series !!! not yet implemented !!!") // 2
+ )
+ );
+
+ s.Printf(SG_T("Node4"), 4);
+ pNode = Parameters.Add_Node(NULL,s,SG_T("IHACRES Version"),_TL(""));
+
+ Parameters.Add_Choice(
+ pNode , "IHACVERS" , _TL("IHACRES Version"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("Jakeman & Hornberger (1993)"), // 0
+ _TL("Croke et al. (2005)") // 1
+
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode, "SNOW_MODULE", _TL("Using the snow-melt module?"),
+ _TL("If checked, snow-melt module is used."),
+ PARAMETER_TYPE_Bool, false
+ );
+
+ Parameters.Add_Value(
+ NULL, "WRITEALL_TS", _TL("Write all calculated Time Series in a table?"),
+ _TL("If checked, then a second output table with all Time Series data is created."),
+ PARAMETER_TYPE_Bool, true
+ );
+
+ Parameters.Add_Table_Output(
+ NULL , "TABLEout" , _TL("Table"),
+ _TL("")
+ );
+ Parameters.Add_Table_Output(
+ NULL , "TABLEparms" , _TL("Table"),
+ _TL("")
+ );
+ Parameters.Add_Table_Output(
+ NULL , "TABLEsettings", _TL("Table"),
+ _TL("")
+ );
+}
+//---------------------------------------------------------------------
+// DIALOG 2
+//---------------------------------------------------------------------
+
+bool Cihacres_v1::CreateDialog2(bool bTMP, int storconf, int IHAC_version,
+ CSG_Table *pTable,
+ int dateField, int dischargeField)
+{
+ CSG_String s;
+ CSG_Parameters P; // used to add Parameters in the second dialog
+ CSG_Parameter *pNode, *pNode1;
+
+ // Dialog design
+ P.Set_Name(_TL("IHACRES Model Parameters (Calibration)"));
+
+ s.Printf(SG_T("Node1"), 1);
+ pNode = P.Add_Node(NULL,s,SG_T("Time Range"),_TL(""));
+
+ s.Printf(SG_T("FDAY") , 1-1);
+ P.Add_String(pNode,s,_TL("First Day"),_TL(""),
+ pTable->Get_Record(0)->asString(dateField));
+
+ s.Printf(SG_T("LDAY") , 1-2);
+ P.Add_String(pNode,s,_TL("Last Day"),_TL(""),
+ pTable->Get_Record(pTable->Get_Record_Count()-1)->asString(dateField));
+
+
+ if (bTMP) // if observed temperature data are used
+ {
+ s.Printf(SG_T("Node2"), 2);
+ pNode = P.Add_Node(NULL,s,SG_T("Non-Linear Module"),_TL(""));
+
+ s.Printf(SG_T("Node2-1"), 2-1);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Temperature Modulation Factor"),_TL(""));
+
+ P.Add_Value(
+ pNode1 , "TFac" , _TL("Temperature Modulation Factor (f)"),
+ _TL("Temperature Modulation Factor f"),
+ PARAMETER_TYPE_Double,
+ 1.0, 0.0001, true, 10.0, true
+ );
+ } // End if (bTMP)
+
+ switch(IHAC_version)
+ {
+ case 0: // Jakeman & Hornberger (1993)
+ break;
+ case 1: // Croke et al. (2005)
+ s.Printf(SG_T("Node4"), 4);
+ pNode = P.Add_Node(NULL,s,SG_T("Soil Moisture Power Eq."),_TL(""));
+
+ s.Printf(SG_T("Node4-1"), 4-1);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Parameter l"),_TL(""));
+
+ P.Add_Value(
+ pNode1,"L",_TL("Soil moisture index (l)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 5.0, true
+ );
+
+ s.Printf(SG_T("Node4-2"), 4-2);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Parameter p"),_TL(""));
+
+ P.Add_Value(
+ pNode1,"P",_TL("Power on soil (p)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 5.0, true
+ );
+ break;
+ } // end switch (IHAC_version)
+
+ switch(storconf)
+ {
+ case 0: // single storage
+ s.Printf(SG_T("Node3"), 3);
+ pNode = P.Add_Node(NULL,s,SG_T("Linear Module"),_TL(""));
+
+ s.Printf(SG_T("Node3-1"), 3-1);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Parameter (a)"),_TL(""));
+
+ P.Add_Value(
+ pNode1, "AFAC", _TL("(a)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.8, -0.99, true, -0.01, true
+ );
+
+ s.Printf(SG_T("Node3-2"), 3-2);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Parameter (b)"),_TL(""));
+
+ P.Add_Value(
+ pNode1, "BFAC", _TL("(b)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.2, 0.001, true, 1.0, true
+ );
+ break;
+
+ case 1: // two parallel storages
+ s.Printf(SG_T("Node3"), 3);
+ pNode = P.Add_Node(NULL,s,SG_T("Linear Module"),_TL(""));
+
+ // Parameter a
+ s.Printf(SG_T("Node3-1"), 3-1);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Parameter (a)"),_TL(""));
+
+ P.Add_Value(
+ pNode1, "AQ", _TL("a(q)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.7, -0.99, true, -0.01, true
+ );
+ P.Add_Value(
+ pNode1, "AS", _TL("a(s)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ -0.9, -0.99, true, -0.01, true
+ );
+
+ // Parameter b
+ s.Printf(SG_T("Node3-2"), 3-2);
+ pNode1 = P.Add_Node(pNode,s,SG_T("Parameter (b)"),_TL(""));
+
+ P.Add_Value(
+ pNode1, "BQ", _TL("b(q)"),
+ _TL(""),
+ PARAMETER_TYPE_Double,
+ 0.0, 0.0, true, 1.0, true
+ );
+ break;
+
+ case 2: // two storages in series
+ break;
+ } // end switch (storconf)
+
+ if (bSnowModule)
+ {
+ s.Printf(SG_T("Node5"), 5);
+ pNode1 = P.Add_Node(NULL,s,SG_T("Snow Module Parameters"),_TL(""));
+
+ P.Add_Value(
+ pNode1, "T_RAIN", _TL("Temperature Threshold for Rainfall"),
+ _TL("Below this threshold precipitation will fall as snow"),
+ PARAMETER_TYPE_Double,
+ -1.0, -10.0, true, 10.0, true
+ );
+ P.Add_Value(
+ pNode1, "T_MELT", _TL("Temperature Threshold for Melting"),
+ _TL("Above this threshold snow will start to melt"),
+ PARAMETER_TYPE_Double,
+ 1.0, -5.0, true, 10.0, true
+ );
+ P.Add_Value(
+ pNode1, "DD_FAC", _TL("Day-Degree Factor"),
+ _TL("Day-Degree Factor depends on catchment characteristics"),
+ PARAMETER_TYPE_Double,
+ 0.7, 0.7, true, 9.2, true
+ );
+ }
+ s.Printf(SG_T("Node6"), 6);
+ pNode1 = P.Add_Node(NULL,s,SG_T("Time Delay after Start of Rainfall (INTEGER)"),_TL(""));
+
+ P.Add_Value(
+ pNode1, "DELAY", _TL("Time Delay (Rain-Runoff)"),
+ _TL("The delay after the start of rainfall, before the discharge starts to rise."),
+ PARAMETER_TYPE_Int,
+ 1, 0, true, 100, true
+ );
+
+ // End of second dialog design
+
+ if( SG_UI_Dlg_Parameters(&P, _TL("Choose Time Range")) )
+ {
+ ///////////////////////////////////////////////////////////////
+ //
+ // ASSIGN DATA FROM SECOND DIALOG
+ //
+ ///////////////////////////////////////////////////////////////
+ date1 = P(CSG_String::Format(SG_T("FDAY"),dateField).c_str())
+ ->asString();
+ date2 = P(CSG_String::Format(SG_T("LDAY"),dischargeField).c_str())
+ ->asString();
+ // if observed temperature data are used
+ if (bTMP) f = P("TFac") ->asDouble();
+
+ switch(IHAC_version)
+ {
+ case 0: break;
+ case 1:
+ l = P("L") ->asDouble();
+ p = P("P") ->asDouble();
+
+ break;
+ }
+
+ if (bSnowModule)
+ {
+ T_Rain = P("T_RAIN") ->asDouble();
+ T_Melt = P("T_MELT") ->asDouble();
+ DD_FAC = P("DD_FAC") ->asDouble();
+ }
+ switch (storconf)
+ {
+ case 0: // single storage
+ a = P("AFAC") ->asDouble();
+ b = P("BFAC") ->asDouble();
+ delay = P("DELAY") ->asInt();
+ break;
+ case 1: // two parallel storages
+ aq = P("AQ") ->asDouble();
+ as = P("AS") ->asDouble();
+ bq = P("BQ") ->asDouble();
+ //bs = P("BS") ->asDouble();
+ bs = ihacres->Calc_Parm_BS(aq,as,bq);
+ delay = P("DELAY") ->asInt();
+ break;
+ case 2: // two storages in series
+ break;
+ } // end switch (storconf)
+ return(true);
+ } else {
+ return(false);
+ }
+}
\ No newline at end of file
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_v1.h b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_v1.h
new file mode 100644
index 0000000..33e3550
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/ihacres_v1.h
@@ -0,0 +1,160 @@
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// IHACRES //
+// //
+//-------------------------------------------------------//
+// //
+// ihacres_v1.h //
+// //
+// Copyright (C) 2006 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// //
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// //
+// 2006-08-31 //
+// //
+///////////////////////////////////////////////////////////
+
+
+//*******************************************************//
+// ToDo //
+//-------------------------------------------------------//
+// - stürzt ab, wenn im zweiten Dialog auf Cancel gedrückt wird
+//
+// - add NSE_highflow to output table
+// - wenn SingleStore, dann wird IHACRES_Sim output table nicht korrekt geschrieben
+// (Spalte Streamflow sim)
+// - implement 2 or n storages in series
+// - number of simulations for linear module
+// - choosing the number of Top simulations from non-linear module calibration
+// - Gültigkeitsbereiche auf Sinn prüfen
+// - WriteTable1Storage
+// - Streamflow simulation function using n, m values
+// - if (bTMP) = false ???
+//*******************************************************//
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__ihacres_v1_H
+#define HEADER_INCLUDED__ihacres_v1_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+#include "ihacres_eq.h"
+
+#include <vector> // used for storing date string values in array
+using namespace std;
+
+typedef std::vector<std::string> date_array;
+typedef vector<double> vector_d;
+//---------------------------------------------------------
+
+class Cihacres_v1 : public CSG_Module
+{
+public:
+
+ // constructor
+ Cihacres_v1(void);
+
+ // destructor
+ virtual ~Cihacres_v1(void);
+
+protected:
+
+ // execute module
+ virtual bool On_Execute (void);
+
+private:
+
+ //--------------------------------------------------------
+ // Private Member Variables
+ //--------------------------------------------------------
+ int sizeAll; // number of selected records
+ date_array date;
+ vector_d m_Q_obs_m3s;
+ vector_d m_Q_obs_mmday;
+ vector_d precipitation;
+ vector_d temperature;
+
+ // Field numbers
+ int dateField; // table field numbers
+ int dischargeField;
+ int pcpField;
+ int tmpField;
+
+ int first; // number of the record (index) of first date
+ int last; // number of the record (index) of last date
+
+ CSG_String date1, date2; // first and last date of selected period
+ double m_area; // area of the watershed in [km2]
+
+ // Non-Linear Module Parameters
+ double TwConst; // Tw is approximately the time constant, or inversely,
+ // the rate at which the catchment wetness declines
+ // in the absence of rainfall.
+ double f; // temperature modulation factor which
+ double c; // Parameter c is chosen so that the volume
+ // of excess rainfall is equal to the total
+ // streamflow over the calibration period
+ double l; // Croke et al. (2005)
+ double p; // Croke et al. (2005)
+
+ // Linear Module Parameters
+ double a; // linear module (single storage)
+ double b;
+ double aq; // linear module (two storages)
+ double as;
+ double bq;
+ double bs;
+
+ int delay; // The delay after the start of rainfall,
+ // before the discharge starts to rise.
+
+ int IHAC_version; // Different versions of IHACRES exist, corresponding
+ // to the version...
+
+ bool bSnowModule;
+
+ // snow module parameters
+ CSnowModule *m_pSnowModule;
+ double *m_pMeltRate;
+ double T_Rain;
+ double T_Melt;
+ double DD_FAC;
+
+ //vector_d SnowStorage;
+ //vector_d MeltRate;
+ //CSnowModule_alt *m_pSnowModule;
+
+
+ //--------------------------------------------------------
+ // Private Member Functions
+ //--------------------------------------------------------
+
+ void CreateTableSim (CSG_Table *pTable, date_array date, vector_d strfl_obs, vector_d strfl_sim);
+ void CreateTableParms (CSG_Table *pTable, date_array date, vector_d strfl_obs, vector_d precipitation, vector_d temperature,
+ vector_d strfl_sim, vector_d excessRain, vector_d wi, vector_d Tw);
+ void CreateTableSettings (CSG_Table *pTable, double Tw, double c, double f,
+ double aq, double as, double bq, double bs,
+ double vq, double vs,
+ bool bSnowModule, double T_Rain, double T_Melt, double DD_FAC,
+ int delay,
+ double RRCoef, double NSE,
+ double area);
+
+ void CreateDialog1 ();
+ bool CreateDialog2 (bool bTMP, int storconf, int IHAC_version,
+ CSG_Table *pTable,
+ int dateField, int dischargeField);
+
+ // Class ihacres_eq
+ Cihacres_eq *ihacres;
+
+};
+#endif /* #ifndef HEADER_INCLUDED__ihacres_v1_H */
\ No newline at end of file
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/model_tools.cpp b/src/modules_contrib/contrib_s_liersch/ihacres/model_tools.cpp
new file mode 100644
index 0000000..695165c
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/model_tools.cpp
@@ -0,0 +1,339 @@
+#include "model_tools.h"
+#include <math.h>
+#include <stdlib.h> // random numbers
+//-------------------------------------------------------------------
+
+///////////////////////////////////////////////////////////////////////
+//
+// OBJECTIVE FUNCTIONS
+//
+///////////////////////////////////////////////////////////////////////
+
+//---------------------------------------------------------------------
+// Calculate Nash-Sutcliff efficiency
+//---------------------------------------------------------------------
+double model_tools::CalcEfficiency(double *obs, double *sim, int nvals)
+{
+ int i;
+
+ double sum_obsminsim_2 = 0.0;
+ double sum_obsminmean_2 = 0.0;
+ double mean_obs = 0.0;
+ //double sum_obs = 0.0; // sum of observed discharge
+
+ // calculate mean of observed time series
+ for (i = 0; i < nvals; i++)
+ mean_obs += obs[i] / nvals;
+
+ for (i = 0; i < nvals; i++)
+ {
+ sum_obsminsim_2 += pow(obs[i] - sim[i], 2.0);
+ sum_obsminmean_2 += pow(obs[i] - mean_obs, 2.0);
+ }
+
+ return (1 - sum_obsminsim_2 / sum_obsminmean_2);
+}
+//-------------------------------------------------------------------
+
+double model_tools::CalcEfficiency(vector_d &obs, vector_d &sim)
+{
+ int i;
+
+ int nvals = obs.size();
+ double sum_obsminsim_2 = 0.0;
+ double sum_obsminmean_2 = 0.0;
+ double mean_obs = 0.0;
+ //double sum_obs = 0.0; // sum of observed discharge
+
+ // calculate mean of observed time series
+ for (i = 0; i < nvals; i++)
+ mean_obs += obs[i] / nvals;
+
+ for (i = 0; i < nvals; i++)
+ {
+ sum_obsminsim_2 += pow(obs[i] - sim[i], 2.0);
+ sum_obsminmean_2 += pow(obs[i] - mean_obs, 2.0);
+ }
+
+ return (1 - sum_obsminsim_2 / sum_obsminmean_2);
+}
+//-------------------------------------------------------------------
+// Calculate Nash-Sutcliff efficiency adapted to high flow
+// Reference:
+// Liu and De Smedt, 2004. WetSpa Extension,
+// A GIS-based Hydrologic Model for Flood Prediction and Watershed Management
+// Documentation and User Manual. Brussels. Vrije Universiteit Brussel.
+
+double model_tools::Calc_NSE_HighFlow(double *obs, double *sim, int nvals)
+{
+ int i;
+
+ double mean_obs = 0.0;
+ double sum_numerator = 0.0;
+ double sum_denominator = 0.0;
+
+ // calculate mean of observed time series
+ for (i = 0; i < nvals; i++)
+ mean_obs += obs[i] / nvals;
+
+ for (i = 0; i < nvals; i++)
+ {
+ sum_numerator += ( (obs[i] + mean_obs) * pow(sim[i] - obs[i], 2.0));
+ sum_denominator += ( (obs[i] + mean_obs) * pow(obs[i] - mean_obs, 2.0));
+ }
+
+ return ( 1 - sum_numerator / sum_denominator );
+}
+//-------------------------------------------------------------------
+
+//-------------------------------------------------------------------
+// Calculate Nash-Sutcliff efficiency adapted to high flow
+// Reference:
+// Liu and De Smedt, 2004. WetSpa Extension,
+// A GIS-based Hydrologic Model for Flood Prediction and Watershed Management
+// Documentation and User Manual. Brussels. Vrije Universiteit Brussel.
+
+double model_tools::Calc_NSE_LowFlow(double *obs, double *sim, int nvals)
+{
+ int i;
+
+ double mean_obs = 0.0;
+ double sum_log_obsminsim_2 = 0.0;
+ double sum_log_obsminmean_2 = 0.0;
+
+ // calculate mean of observed time series
+ for (i = 0; i < nvals; i++)
+ mean_obs += obs[i] / nvals;
+
+ for (i = 0; i < nvals; i++)
+ {
+ sum_log_obsminsim_2 += pow( (log(obs[i])-log(sim[i])),2 );
+ sum_log_obsminmean_2 += pow( (log(obs[i])-log(mean_obs)),2 );
+ }
+
+ return( 1 - sum_log_obsminsim_2 / sum_log_obsminmean_2);
+}
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+// Calculate PBIAS
+//---------------------------------------------------------------------
+double model_tools::Calc_PBIAS(double* obs, double* sim, int nvals)
+{
+ double sim_min_obs = 0.0;
+ double sum_obs = 0.0;
+
+ for (int i = 0; i < nvals; i++)
+ {
+ sim_min_obs += sim[i] - obs[i];
+ sum_obs += obs[i];
+ }
+
+ return(sim_min_obs * 100 / sum_obs);
+}
+//---------------------------------------------------------------------
+
+
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// RUNOFF COEFFICIENT
+//
+///////////////////////////////////////////////////////////////////////
+
+//---------------------------------------------------------------------
+// Calculate Runoff Coefficient
+//---------------------------------------------------------------------
+double model_tools::CalcRunoffCoeff(vector_d &streamflow, vector_d &precipitation)
+{
+ // calculate runoff coefficient as stated in:
+ // Kokkonen, T. S. et al. (2003).
+ double sum_flow = 0;
+ double sum_pcp = 0;
+
+ for (unsigned int i = 0; i < streamflow.size(); i++)
+ {
+ sum_flow += streamflow[i];
+ sum_pcp += precipitation[i];
+ }
+ return (sum_flow / sum_pcp * 100);
+}
+//---------------------------------------------------------------------
+double model_tools::CalcRunoffCoeff(double *streamflow, double *precipitation,
+ int nvals)
+{
+ // calculate runoff coefficient as stated in:
+ // Kokkonen, T. S. et al. (2003).
+ double sum_flow = 0;
+ double sum_pcp = 0;
+
+ for (int i = 0; i < nvals; i++)
+ {
+ sum_flow += streamflow[i];
+ sum_pcp += precipitation[i];
+ }
+ return (sum_flow / sum_pcp * 100);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// UNIT CONVERSION
+//
+///////////////////////////////////////////////////////////////////////
+
+double model_tools::m3s_to_mmday(double val, double area)
+{
+ return(val * 86.4 / area);
+}
+//---------------------------------------------------------------------
+double *model_tools::m3s_to_mmday(double *m3s, double *mmday, int nvals, double area)
+{
+ for (int i = 0; i < nvals; i++)
+ mmday[i] = m3s[i] * 86.4 / area;
+ return(mmday);
+}
+//---------------------------------------------------------------------
+vector_d model_tools::m3s_to_mmday(vector_d &m3s, vector_d &mmday, double area)
+{
+ for (unsigned int i = 0; i < m3s.size(); i++)
+ mmday[i] = m3s[i] * 86.4 / area;
+ return(mmday);
+}
+//---------------------------------------------------------------------
+
+double model_tools::mmday_to_m3s(double val, double area)
+{
+ return(val * area / 86.4);
+}
+//---------------------------------------------------------------------
+double *model_tools::mmday_to_m3s(double *mmday, double *m3s, int nvals, double area)
+{
+ for (int i = 0; i < nvals; i++)
+ m3s[i] = mmday[i] * area / 86.4;
+ return(m3s);
+}
+//---------------------------------------------------------------------
+vector_d model_tools::mmday_to_m3s(vector_d &mmday, vector_d &m3s, double area)
+{
+ for (unsigned int i = 0; i < m3s.size(); i++)
+ m3s[i] = mmday[i] * area / 86.4;
+ return(m3s);
+}
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// MISC
+//
+///////////////////////////////////////////////////////////////////////
+
+//---------------------------------------------------------------------
+// Create a random number
+//---------------------------------------------------------------------
+double model_tools::Random_double(double lb, double ub)
+{
+ // lb = lower bound, ub = upper bound
+ double random;
+
+ random = rand()/(1.+RAND_MAX);
+ random = lb + (ub - lb) * random;
+
+ return(random);
+}
+//-------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+// Leap year function
+//---------------------------------------------------------------------
+bool model_tools::LeapYear(int year)
+{
+ if ( (year % 4 == 0) &&
+ (year % 100 != 0) ||
+ (year % 400 == 0) )
+ return(true);
+ else
+ return(false);
+}
+//-------------------------------------------------------------------
+
+
+//---------------------------------------------------------------------
+// Find indices of lowest values
+//---------------------------------------------------------------------
+void model_tools::FindLowestIndices(double *array, int nvals, int *TopIndex, int top)
+{
+ double min_temp = 99999999.0;
+ double x = -99999999.0;
+ int index = 0;
+
+ for (int k = 0; k < top; k++)
+ {
+ for (int j = 0; j < nvals; j++)
+ {
+ if (array[j] < min_temp && array[j] > x)
+ {
+ min_temp = array[j];
+ index = j;
+ }
+ }
+ TopIndex[k] = index;
+ x = min_temp;
+ min_temp = 99999999.0;
+ }
+}
+
+//---------------------------------------------------------------------
+// Find indices of highest values
+//---------------------------------------------------------------------
+void model_tools::FindHighestIndices(double *array, int nvals, int *TopIndex, int top, double min)
+{
+ double max_temp = -99999999.0;
+ double x = 99999999.0;
+ int index = 0;
+ bool exist = false;
+
+ for (int k = 0; k < top; k++)
+ {
+ for (int j = 0; j < nvals; j++)
+ {
+ if (array[j] > max_temp && array[j] < x && array[j] > min)
+ {
+ max_temp = array[j];
+ index = j;
+ exist = true;
+ }
+ }
+ if (exist)
+ {
+ TopIndex[k] = index;
+ } else {
+ TopIndex[k] = -1;
+ }
+ exist = false;
+ x = max_temp;
+ max_temp = -99999999.0;
+ }
+}
+//---------------------------------------------------------------------
+
+
+//---------------------------------------------------------------------
+// summarize arrays
+//---------------------------------------------------------------------
+double model_tools::SumArray(double* array, unsigned int size)
+{
+ double sum = 0.0;
+ for (unsigned int i = 0; i < size; i++) {
+ sum += array[i];
+ }
+ return(sum);
+}
+//---------------------------------------------------------------------
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/model_tools.h b/src/modules_contrib/contrib_s_liersch/ihacres/model_tools.h
new file mode 100644
index 0000000..a645b27
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/model_tools.h
@@ -0,0 +1,189 @@
+///////////////////////////////////////////////////////////
+// model_tools.h //
+// //
+// Copyright (C) 2007 by //
+// Stefan Liersch //
+//-------------------------------------------------------//
+// e-mail: stefan.liersch at ufz.de //
+// stefan.liersch at gmail.com //
+// 2008-01-24 //
+//-------------------------------------------------------//
+
+#ifndef HEADER_INCLUDED__model_tools_H
+#define HEADER_INCLUDED__model_tools_H
+
+#include <vector>
+typedef std::vector<double> vector_d;
+
+namespace model_tools
+{
+ ///////////////////////////////////////////////////////////////////////
+ //
+ // OBJECTIVE FUNCTIONS
+ //
+ ///////////////////////////////////////////////////////////////////////
+
+ //---------------------------------------------------------------------
+ // Calculate Nash-Sutcliff efficiency
+ //---------------------------------------------------------------------
+ double CalcEfficiency(double *obs, double *sim, int nvals);
+
+ double CalcEfficiency(vector_d &obs, vector_d &sim);
+
+ // Calculate Nash-Sutcliff efficiency adapted to high flow
+ // Reference:
+ // Liu and De Smedt, 2004. WetSpa Extension,
+ // A GIS-based Hydrologic Model for Flood Prediction and Watershed Management
+ // Documentation and User Manual. Brussels. Vrije Universiteit Brussel.
+ double Calc_NSE_HighFlow(double *obs, double *sim, int nvals);
+ double Calc_NSE_LowFlow (double *obs, double *sim, int nvals);
+ //---------------------------------------------------------------------
+
+ //---------------------------------------------------------------------
+ // PBIAS
+ //---------------------------------------------------------------------
+ double Calc_PBIAS(double* obs, double* sim, int nvals);
+ //---------------------------------------------------------------------
+
+
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ // RUNOFF COEFFICIENT
+ //
+ ///////////////////////////////////////////////////////////////////////
+
+ //---------------------------------------------------------------------
+ // Calculate rainfall-runoff coefficient
+ double CalcRunoffCoeff (double *streamflow,
+ double *precipitation, int nvals);
+
+ double CalcRunoffCoeff (vector_d &streamflow,
+ vector_d &precipitation);
+ //---------------------------------------------------------------------
+
+
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ // UNIT CONVERSION FUNCTIONS
+ //
+ ///////////////////////////////////////////////////////////////////////
+
+ //---------------------------------------------------------------------
+ double m3s_to_mmday(double val, double area);
+ double* m3s_to_mmday(double *m3s, double *mmday, int nvals, double area);
+ vector_d m3s_to_mmday(vector_d &m3s, vector_d &mmday, double area);
+
+ double mmday_to_m3s(double val, double area);
+ double* mmday_to_m3s(double *mmday, double *m3s, int nvals, double area);
+ vector_d mmday_to_m3s(vector_d &mmday, vector_d &m3s, double area);
+ //---------------------------------------------------------------------
+
+
+
+ ///////////////////////////////////////////////////////////////////////
+ //
+ // MISC
+ //
+ ///////////////////////////////////////////////////////////////////////
+
+ //---------------------------------------------------------------------
+ // Produce a random number within the given lower and upper bound
+ // Don't forget to initialize the random function before calling
+ // this function with: srand((unsigned) time(NULL)); // using time.h
+ // include 'stdlib.h' and 'time.h' in the calling program
+ double Random_double(double lb, double ub);
+ //---------------------------------------------------------------------
+
+ //---------------------------------------------------------------------
+ // Returns true if the year is a leap year
+ bool LeapYear(int year);
+ //---------------------------------------------------------------------
+
+ //---------------------------------------------------------------------
+ // This function receives an array of doubles and
+ // returns the indices of the lowest values.
+ // array = array of doubles
+ // nvals = number of values in array
+ // TopIndex = array of indices = return values
+ // top = number of lowest values which indices will be stored in TopIndex
+ void FindLowestIndices(double* array, int nvals, int* TopIndex, int top);
+ //---------------------------------------------------------------------
+
+ //---------------------------------------------------------------------
+ // This function receives an array of doubles and
+ // returns the indices of the highest values.
+ // array = array of doubles
+ // nvals = number of values in array
+ // TopIndex = array of indices = return values
+ // top = number of highest values which indices will be stored in TopIndex
+ // min = minimum
+ void FindHighestIndices(double* array, int nvals, int* TopIndex, int top, double min);
+ //---------------------------------------------------------------------
+
+
+ //---------------------------------------------------------------------
+ // summarize arrays
+ //---------------------------------------------------------------------
+ double SumArray(double* array, unsigned int size);
+};
+
+
+
+
+
+///////////////////////////////////////////////////////////////////////
+//
+// dynamic array template class
+//
+///////////////////////////////////////////////////////////////////////
+// http://www.codeguru.com/forum/showthread.php?s=&threadid=231046
+template <typename T>
+class dynamic_array
+{
+public:
+ dynamic_array(){};
+ dynamic_array(int rows, int cols)
+ {
+ for(int i=0; i<rows; ++i)
+ {
+ data_.push_back(std::vector<T>(cols));
+ }
+ }
+
+ // other ctors ....
+
+ inline std::vector<T> & operator[](int i) { return data_[i]; }
+
+ inline const std::vector<T> & operator[] (int i) const { return data_[i]; }
+
+ // other accessors, like at() ...
+
+ void resize(int rows, int cols)
+ {
+ data_.resize(rows);
+ for(int i = 0; i < rows; ++i)
+ data_[i].resize(cols);
+ }
+
+ // other member functions, like reserve()....
+
+private:
+ std::vector<std::vector<T> > data_;
+};
+
+//---------------------------------------------------------------------
+// An example to use the template class
+//---------------------------------------------------------------------
+//int main()
+//{
+// dynamic_array<int> a(3, 3);
+// a[1][1] = 2;
+// int x = a[1][1];
+// return 0;
+//}
+///////////////////////////////////////////////////////////////////////
+
+
+#endif /* HEADER_INCLUDED__model_tools_H */
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/snow_module.cpp b/src/modules_contrib/contrib_s_liersch/ihacres/snow_module.cpp
new file mode 100644
index 0000000..9b0dfe0
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/snow_module.cpp
@@ -0,0 +1,326 @@
+////////////////////////////////////////////////////////////////
+// File:
+// snow_module.cpp
+//
+// A class to calculate a time series of
+// snow melt and snow storage.
+//
+// Author:
+// Stefan Liersch: stefan.liersch at gmail.com, stefan.liersch at ufz.de
+//
+// Date: 2007-10-05
+// last modified: 2007-10-05
+//
+//--------------------------------------------------------------
+// DESCRIPTION
+//--------------------------------------------------------------
+// This class provides functions to calculate snow melt processes,
+// based on the simple degree-day method.
+
+// INPUT:
+// - Daily temperature and precipitation time series
+// This could be double* pointers or double vectors.
+// In both cases the output (snow storage and melt rate) will be double* !!!
+// - T_Rain : temperature threshold, T < T_Rain precip = snow (range: -10 to +10�C)
+// - T_Melt : temperature threshold, T > T_Melt = Snow storage starts melting (range: -5 to +10�C)
+// - DD_FAC : day-degree factor (range: 0.7 to 9.2)
+
+// OUTPUT:
+// - double* m_pSnowStorage[i]
+// - double* m_pMeltRate[i]
+
+//--------------------------------------------------------------
+// REFERENCES
+//--------------------------------------------------------------
+// - The Encyclopedia of Water
+// http://www.wileywater.com/Contributor/Sample_3.htm
+// - Chang, A. T. C., J. L. Foster, P. Gloersen, W. J. Campbell, E. G. Josberger, A. Rango and Z. F. Danes (1987)
+// Estimating snowpack parameters in the Colorado River basin.
+// In: Proc. Large Scale Effects of Seasonal Snow Cover,
+// IAHS Publ. No. 166, 343-353.
+// - Singh, P. and Singh, V.P. (2001)
+// Snow and Glacier Hydrology.
+// Kluwer Academic Publishers, Dordrecht, The Netherlands, p. 221
+//--------------------------------------------------------------
+// ToDo
+//--------------------------------------------------------------
+// - implementation for vector instead of double*
+//--------------------------------------------------------------
+
+//--------------------------------------------------------------
+#include <iostream>
+#include "snow_module.h"
+//--------------------------------------------------------------
+
+//--------------------------------------------------------------
+#define max(a, b) (((a) > (b)) ? (a) : (b))
+//--------------------------------------------------------------
+
+//--------------------------------------------------------------
+// CONSTRUCTORS
+//--------------------------------------------------------------
+
+CSnowModule::CSnowModule(int size)
+{
+ InitParms(size);
+}
+//--------------------------------------------------------------
+// double* INPUT
+//
+CSnowModule::CSnowModule(double *temperature, double *precipitation, int size,
+ double T_Rain, double T_Melt, double DD_FAC)
+{
+ m_T_Rain = T_Rain;
+ m_T_Melt = T_Melt;
+ m_DD_FAC = DD_FAC;
+ m_size = size;
+ InitParms(m_size);
+
+ // perform snow storage and snow melt calculations
+ Calc_SnowModule(temperature, precipitation, m_size, T_Rain, T_Melt, DD_FAC);
+}
+//--------------------------------------------------------------
+// vector INPUT
+//
+CSnowModule::CSnowModule(vector_d temperature, vector_d precipitation,
+ double T_Rain, double T_Melt, double DD_FAC)
+{
+ m_T_Rain = T_Rain;
+ m_T_Melt = T_Melt;
+ m_DD_FAC = DD_FAC;
+ m_size = temperature.size();
+ InitParms(m_size);
+
+ // perform snow storage and snow melt calculations
+ Calc_SnowModule(temperature, precipitation, T_Rain, T_Melt, DD_FAC);
+}
+
+//--------------------------------------------------------------
+// DESTRUCTOR
+//--------------------------------------------------------------
+CSnowModule::~CSnowModule()
+{
+ if (m_pSnowStorage) delete[] m_pSnowStorage;
+ if (m_pMeltRate) delete[] m_pMeltRate;
+}
+
+//--------------------------------------------------------------
+//
+// PUBLIC FUNCTIONS
+//
+//--------------------------------------------------------------
+void CSnowModule::InitParms(int size)
+{
+ m_size = size;
+ m_pSnowStorage = new double[m_size];
+ m_pMeltRate = new double[m_size];
+ _ZeroPointers();
+}
+//--------------------------------------------------------------
+double *CSnowModule::Get_SnowStorage(double *snow_storage, int size)
+{
+ for (int i = 0; i < size; i++)
+ snow_storage[i] = m_pSnowStorage[i];
+ return(snow_storage);
+}
+//--------------------------------------------------------------
+double *CSnowModule::Get_MeltRate(double *melt_rate, int size)
+{
+ for (int i = 0; i < size; i++)
+ melt_rate[i] = m_pMeltRate[i];
+ return(melt_rate);
+}
+//--------------------------------------------------------------
+//
+// SET FUNCTIONS
+//
+//--------------------------------------------------------------
+bool CSnowModule::Set_T_Rain(double value)
+{
+ if (value >= -10.0 && value <= 10.0)
+ {
+ m_T_Rain = value;
+ return(true);
+ } else {
+ return(false);
+ }
+}
+//--------------------------------------------------------------
+bool CSnowModule::Set_T_Melt(double value)
+{
+ if (value >= -5.0 && value <= 10.0)
+ {
+ m_T_Melt = value;
+ return(true);
+ } else {
+ return(false);
+ }
+}
+//--------------------------------------------------------------
+bool CSnowModule::Set_DD_FAC(double value)
+{
+ if (value >= 0.7 && value <= 9.2)
+ {
+ m_DD_FAC = value;
+ return(true);
+ } else {
+ return(false);
+ }
+}
+
+//--------------------------------------------------------------
+//
+// CALCULATE Snow storage and melt rate
+//
+//--------------------------------------------------------------
+
+//--------------------------------------------------------------
+// double* INPUT
+//--------------------------------------------------------------
+bool CSnowModule::Calc_SnowModule(double *temperature, double *precipitation, unsigned int size,
+ double T_Rain, double T_Melt, double DD_FAC)
+{
+ // still missing!!!
+ // what happens with precipitation at the same day as
+ // snowmelt is calculated?
+ // is it correct to handle this in excess rainfall function only?
+
+ if (size != m_size) return(false);
+
+ _ZeroPointers();
+ m_T_Rain = T_Rain;
+ m_T_Melt = T_Melt;
+ m_DD_FAC = DD_FAC;
+
+ double T_diff;
+
+ for (unsigned int i = 1; i < size; i++)
+ {
+ // calculate snow accumulation
+ if (temperature[i] < T_Rain)
+ {
+ m_pSnowStorage[i] = m_pSnowStorage[i-1] + precipitation[i];
+ m_pMeltRate[i] = 0.0;
+ }
+
+ // calculate snowmelt
+ if (temperature[i] > T_Melt)
+ {
+ T_diff = temperature[i] - T_Melt;
+ m_pMeltRate[i] = DD_FAC * max(0.0,T_diff);
+ if (m_pMeltRate[i] > m_pSnowStorage[i-1])
+ {
+ m_pMeltRate[i] = m_pSnowStorage[i-1];
+ m_pSnowStorage[i] = 0.0;
+ }
+ m_pSnowStorage[i] = m_pSnowStorage[i-1] - m_pMeltRate[i];
+ }
+
+ // if temperature between T_Rain and T_Melt
+ if ((temperature[i] > T_Rain) && (temperature[i] < T_Melt))
+ {
+ /*
+ T_diff = temperature[i] - T_Melt;
+ m_pMeltRate[i] = (DD_FAC * max(0.0, T_diff)) / 2;
+ */
+ m_pMeltRate[i] = 0.0;
+ if (precipitation[i] > 0.0) m_pMeltRate[i] = precipitation[i] / 2;
+ if (m_pMeltRate[i] > m_pSnowStorage[i-1])
+ {
+ m_pMeltRate[i] = m_pSnowStorage[i-1];
+ m_pSnowStorage[i] = 0.0;
+ }
+ m_pSnowStorage[i] = m_pSnowStorage[i-1] - m_pMeltRate[i];
+ }
+
+ if (m_pSnowStorage[i] < 0.0) m_pSnowStorage[i] = 0.0;
+ }
+ return(true);
+}
+
+//--------------------------------------------------------------
+// vector INPUT
+//--------------------------------------------------------------
+bool CSnowModule::Calc_SnowModule(vector_d temperature, vector_d precipitation,
+ double T_Rain, double T_Melt, double DD_FAC)
+{
+ // still missing!!!
+ // what happens with precipitation at the same day as
+ // snowmelt is calculated?
+ // is it correct to handle this in excess rainfall function only?
+
+ if (temperature.size() != m_size || precipitation.size() != m_size)
+ return(false);
+
+ int size = m_size;
+
+ _ZeroPointers();
+ m_T_Rain = T_Rain;
+ m_T_Melt = T_Melt;
+ m_DD_FAC = DD_FAC;
+
+ double T_diff;
+
+ for (int i = 1; i < size; i++)
+ {
+ // calculate snow accumulation
+ if (temperature[i] < T_Rain)
+ {
+ m_pSnowStorage[i] = m_pSnowStorage[i-1] + precipitation[i];
+ m_pMeltRate[i] = 0.0;
+ }
+
+ // calculate snowmelt
+ if (temperature[i] > T_Melt)
+ {
+ T_diff = temperature[i] - T_Melt;
+ m_pMeltRate[i] = DD_FAC * max(0.0,T_diff);
+ if (m_pMeltRate[i] > m_pSnowStorage[i-1])
+ {
+ m_pMeltRate[i] = m_pSnowStorage[i-1];
+ m_pSnowStorage[i] = 0.0;
+ }
+ m_pSnowStorage[i] = m_pSnowStorage[i-1] - m_pMeltRate[i];
+ }
+
+ // if temperature between T_Rain and T_Melt
+ if ((temperature[i] > T_Rain) && (temperature[i] < T_Melt))
+ {
+ /*
+ T_diff = temperature[i] - T_Melt;
+ m_pMeltRate[i] = (DD_FAC * max(0.0, T_diff)) / 2;
+ */
+ m_pMeltRate[i] = 0.0;
+ if (precipitation[i] > 0.0) m_pMeltRate[i] = precipitation[i] / 2;
+ if (m_pMeltRate[i] > m_pSnowStorage[i-1])
+ {
+ m_pMeltRate[i] = m_pSnowStorage[i-1];
+ m_pSnowStorage[i] = 0.0;
+ }
+ m_pSnowStorage[i] = m_pSnowStorage[i-1] - m_pMeltRate[i];
+ }
+
+ if (m_pSnowStorage[i] < 0.0) m_pSnowStorage[i] = 0.0;
+ }
+ return(true);
+}
+
+//--------------------------------------------------------------
+//
+// PRIVATE FUNCTIONS
+//
+//--------------------------------------------------------------
+
+void CSnowModule::_ZeroPointers()
+{
+ // This is important, because only on days where snow
+ // accumulats or melts a value is assigned to the pointers
+ if (m_pSnowStorage != NULL && m_pMeltRate != NULL && m_size > 0)
+ {
+ for (unsigned int i = 0; i < m_size; i++)
+ {
+ m_pSnowStorage[i] = 0.0;
+ m_pMeltRate[i] = 0.0;
+ }
+ }
+}
diff --git a/src/modules_contrib/contrib_s_liersch/ihacres/snow_module.h b/src/modules_contrib/contrib_s_liersch/ihacres/snow_module.h
new file mode 100644
index 0000000..d98fca1
--- /dev/null
+++ b/src/modules_contrib/contrib_s_liersch/ihacres/snow_module.h
@@ -0,0 +1,129 @@
+////////////////////////////////////////////////////////////////
+// File:
+// snow_module.h
+//
+// A class to calculate a time series of
+// snow melt and snow storage.
+//
+// Author:
+// Stefan Liersch: stefan.liersch at gmail.com, stefan.liersch at ufz.de
+//
+// Date: 2007-10-05
+// last modified: 2007-10-05
+//
+//--------------------------------------------------------------
+// DESCRIPTION
+//--------------------------------------------------------------
+// This class provides functions to calculate snow melt processes,
+// based on the simple degree-day method.
+
+// INPUT:
+// - Daily temperature and precipitation time series
+// This could be double* pointers or double vectors.
+// In both cases the output (snow storage and melt rate) will be double* !!!
+// - T_Rain : temperature threshold, T < T_Rain precip = snow (range: -10 to +10�C)
+// - T_Melt : temperature threshold, T > T_Melt = Snow storage starts melting (range: -5 to +10�C)
+// - DD_FAC : day-degree factor (range: 0.7 to 9.2)
+
+// OUTPUT:
+// - double* m_pSnowStorage[i]
+// - double* m_pMeltRate[i]
+
+//--------------------------------------------------------------
+// REFERENCES
+//--------------------------------------------------------------
+// - The Encyclopedia of Water
+// http://www.wileywater.com/Contributor/Sample_3.htm
+// - Chang, A. T. C., J. L. Foster, P. Gloersen, W. J. Campbell, E. G. Josberger, A. Rango and Z. F. Danes (1987)
+// Estimating snowpack parameters in the Colorado River basin.
+// In: Proc. Large Scale Effects of Seasonal Snow Cover,
+// IAHS Publ. No. 166, 343-353.
+// - Singh, P. and Singh, V.P. (2001)
+// Snow and Glacier Hydrology.
+// Kluwer Academic Publishers, Dordrecht, The Netherlands, p. 221
+//--------------------------------------------------------------
+// ToDo
+//--------------------------------------------------------------
+// - implementation for vector instead of double*
+//--------------------------------------------------------------
+
+#ifndef HEADER_INCLUDED__snow_module_H
+#define HEADER_INCLUDED__snow_module_H
+
+#include <vector> // used for storing date string values in array
+
+typedef std::vector<double> vector_d;
+//--------------------------------------------------------------
+
+class CSnowParms
+{
+public:
+ CSnowParms() {
+ T_Rain = 0.0;
+ T_Melt = 0.0;
+ DD_FAC = 0.0;
+ }
+ double T_Rain;
+ double T_Melt;
+ double DD_FAC;
+};
+
+//--------------------------------------------------------------
+
+class CSnowModule
+{
+public:
+ CSnowModule(int size);
+ CSnowModule(double *temperature, double *precipitation, int size,
+ double T_Rain, double T_Melt, double DD_FAC);
+
+ // using double vectors as input instead of double*
+ CSnowModule(vector_d temperature, vector_d precipitation,
+ double T_Rain, double T_Melt, double DD_FAC);
+
+ ~CSnowModule();
+
+ //----------------------------------------------
+ // PUBLIC FUNCTIONS
+ //----------------------------------------------
+ void InitParms(int size);
+ double Get_SnowStorage(unsigned int i) { return( i < m_size ? m_pSnowStorage[i] : -9999); }
+ double* Get_SnowStorage(double *snow_storage, int size);
+ double Get_MeltRate(unsigned int i) { return( i < m_size ? m_pMeltRate[i] : -9999); }
+ double* Get_MeltRate(double *melt_rate, int size);
+ double Get_T_Rain() { return(m_T_Rain); }
+ double Get_T_Melt() { return(m_T_Melt); }
+ double Get_DD_FAC() { return(m_DD_FAC); }
+
+ bool Set_T_Rain(double value);
+ bool Set_T_Melt(double value);
+ bool Set_DD_FAC(double value);
+
+ bool Calc_SnowModule(double *temperature, double *precipitation, unsigned int size,// pointer size (temperature, precip)
+ double T_Rain, double T_Melt, double DD_FAC);
+
+ //----------------------------------------------
+
+private:
+ void _ZeroPointers();
+ // variables
+ double* m_pSnowStorage;
+ double* m_pMeltRate;
+ unsigned int m_size; // number of values in arrays, time steps
+ double m_T_Rain;
+ double m_T_Melt;
+ double m_DD_FAC;
+
+//--------------------------------------------------------------
+//
+// FUNCTIONS FOR VECTORS
+//
+//--------------------------------------------------------------
+public:
+ bool Calc_SnowModule(vector_d temperature, vector_d precipitation,
+ double T_Rain, double T_Melt, double DD_FAC);
+
+
+};
+
+#endif /* HEADER_INCLUDED__snow_module_H */
diff --git a/src/modules_geostatistics/Makefile.in b/src/modules_geostatistics/Makefile.in
index 16b9cb5..d62fbec 100644
--- a/src/modules_geostatistics/Makefile.in
+++ b/src/modules_geostatistics/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_geostatistics/geostatistics/Makefile.am b/src/modules_geostatistics/geostatistics/Makefile.am
index ecfbeed..9031ede 100644
--- a/src/modules_geostatistics/geostatistics/Makefile.am
+++ b/src/modules_geostatistics/geostatistics/Makefile.am
@@ -1 +1 @@
-SUBDIRS = geostatistics_points geostatistics_kriging geostatistics_grid
+SUBDIRS = geostatistics_points geostatistics_kriging geostatistics_grid geostatistics_regression
diff --git a/src/modules_geostatistics/geostatistics/Makefile.in b/src/modules_geostatistics/geostatistics/Makefile.in
index c1050ef..514cdeb 100644
--- a/src/modules_geostatistics/geostatistics/Makefile.in
+++ b/src/modules_geostatistics/geostatistics/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -202,7 +203,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = geostatistics_points geostatistics_kriging geostatistics_grid
+SUBDIRS = geostatistics_points geostatistics_kriging geostatistics_grid geostatistics_regression
all: all-recursive
.SUFFIXES:
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Directional_Statistics.cpp b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Directional_Statistics.cpp
new file mode 100644
index 0000000..b9afb97
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Directional_Statistics.cpp
@@ -0,0 +1,260 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Grid //
+// //
+//-------------------------------------------------------//
+// //
+// GSGrid_Directional_Statistics.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "GSGrid_Directional_Statistics.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGSGrid_Directional_Statistics::CGSGrid_Directional_Statistics(void)
+{
+ Set_Name (_TL("Directional Statistics for Single Grid"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ "Calculates for each cell statistical properties (arithmetic mean, minimum, maximum, "
+ "variance, standard deviation) of all cells lying in given direction based on the input grid. "
+ ));
+
+
+ Parameters.Add_Grid(NULL, "GRID" , _TL("Grid") , _TL(""), PARAMETER_INPUT);
+
+ Parameters.Add_Grid(NULL, "MEAN" , _TL("Arithmetic Mean") , _TL(""), PARAMETER_OUTPUT_OPTIONAL);
+ Parameters.Add_Grid(NULL, "DIFMEAN" , _TL("Difference from Arithmetic Mean") , _TL(""), PARAMETER_OUTPUT_OPTIONAL);
+ Parameters.Add_Grid(NULL, "MIN" , _TL("Minimum") , _TL(""), PARAMETER_OUTPUT_OPTIONAL);
+ Parameters.Add_Grid(NULL, "MAX" , _TL("Maximum") , _TL(""), PARAMETER_OUTPUT_OPTIONAL);
+ Parameters.Add_Grid(NULL, "RANGE" , _TL("Range") , _TL(""), PARAMETER_OUTPUT_OPTIONAL);
+ Parameters.Add_Grid(NULL, "VAR" , _TL("Variance") , _TL(""), PARAMETER_OUTPUT_OPTIONAL);
+ Parameters.Add_Grid(NULL, "STDDEV" , _TL("Standard Deviation") , _TL(""), PARAMETER_OUTPUT_OPTIONAL);
+ Parameters.Add_Grid(NULL, "STDDEVLO" , _TL("Mean less Standard Deviation") , _TL(""), PARAMETER_OUTPUT_OPTIONAL);
+ Parameters.Add_Grid(NULL, "STDDEVHI" , _TL("Mean plus Standard Deviation") , _TL(""), PARAMETER_OUTPUT_OPTIONAL);
+ Parameters.Add_Grid(NULL, "DEVMEAN" , _TL("Deviation from Arithmetic Mean") , _TL(""), PARAMETER_OUTPUT_OPTIONAL);
+ Parameters.Add_Grid(NULL, "PERCENT" , _TL("Percentile") , _TL(""), PARAMETER_OUTPUT_OPTIONAL);
+
+ Parameters.Add_Value(
+ NULL, "DIRECTION" , _TL("Direction [Degree]"),
+ _TL(""),
+ PARAMETER_TYPE_Double
+ );
+
+ Parameters.Add_Value(
+ NULL, "TOLERANCE" , _TL("Tolerance [Degree]"),
+ _TL(""),
+ PARAMETER_TYPE_Double, 0.0, 0.0, true, 45.0, true
+ );
+
+ Parameters.Add_Value(
+ NULL, "MAXDISTANCE" , _TL("Maximum Distance [Cells]"),
+ _TL("Maximum distance parameter is ignored if set to zero (default)."),
+ PARAMETER_TYPE_Int, 0.0, 0.0, true
+ );
+
+ Parameters.Add_Parameters(
+ NULL, "WEIGHTING" , _TL("Weighting"),
+ _TL("")
+ )->asParameters()->Assign(m_Cells.Get_Weighting().Get_Parameters());
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGSGrid_Directional_Statistics::On_Execute(void)
+{
+ int Radius;
+ double Direction, Tolerance;
+
+ //-----------------------------------------------------
+ m_pGrid = Parameters("GRID") ->asGrid();
+
+ m_pMean = Parameters("MEAN") ->asGrid();
+ m_pDifMean = Parameters("DIFMEAN") ->asGrid();
+ m_pMin = Parameters("MIN") ->asGrid();
+ m_pMax = Parameters("MAX") ->asGrid();
+ m_pRange = Parameters("RANGE") ->asGrid();
+ m_pVar = Parameters("VAR") ->asGrid();
+ m_pStdDev = Parameters("STDDEV") ->asGrid();
+ m_pStdDevLo = Parameters("STDDEVLO") ->asGrid();
+ m_pStdDevHi = Parameters("STDDEVHI") ->asGrid();
+ m_pDevMean = Parameters("DEVMEAN") ->asGrid();
+ m_pPercent = Parameters("PERCENT") ->asGrid();
+
+ //-----------------------------------------------------
+ if( !m_pGrid || (!m_pMean && !m_pDifMean && !m_pMin && !m_pMax && !m_pRange && !m_pVar && !m_pStdDev && !m_pStdDevLo && !m_pStdDevHi && !m_pPercent) )
+ {
+ Message_Dlg(_TL("no target grids specified"));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Direction = Parameters("DIRECTION") ->asDouble() * M_DEG_TO_RAD;
+ Tolerance = Parameters("TOLERANCE") ->asDouble() * M_DEG_TO_RAD;
+
+ Radius = Parameters("MAXDISTANCE") ->asInt();
+
+ if( Radius <= 0 )
+ {
+ Radius = 1 + (int)SG_Get_Length(Get_NX(), Get_NY());
+ }
+
+ m_Cells.Get_Weighting().Set_Parameters(Parameters("WEIGHTING")->asParameters());
+
+ if( !m_Cells.Set_Sector(Radius, Direction, Tolerance) )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
+ {
+ Get_Statistics(x, y);
+ }
+ }
+
+ //-----------------------------------------------------
+ m_Cells.Destroy();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGSGrid_Directional_Statistics::Get_Statistics(int x, int y)
+{
+ if( m_pGrid->is_InGrid(x, y) )
+ {
+ int i, ix, iy, nLower;
+ double z, iz, id, iw;
+
+ CSG_Simple_Statistics Statistics;
+
+ for(i=0, nLower=0, z=m_pGrid->asDouble(x, y); i<m_Cells.Get_Count(); i++)
+ {
+ if( m_Cells.Get_Values(i, ix = x, iy = y, id, iw, true) && id > 0.0 && m_pGrid->is_InGrid(ix, iy) )
+ {
+ Statistics.Add_Value(iz = m_pGrid->asDouble(ix, iy), iw);
+
+ if( z > iz )
+ {
+ nLower++;
+ }
+ }
+ }
+
+ //-------------------------------------------------
+ if( Statistics.Get_Weights() > 0.0 )
+ {
+ if( m_pMean ) m_pMean ->Set_Value(x, y, Statistics.Get_Mean());
+ if( m_pDifMean ) m_pDifMean ->Set_Value(x, y, m_pGrid->asDouble(x, y) - Statistics.Get_Mean());
+ if( m_pMin ) m_pMin ->Set_Value(x, y, Statistics.Get_Minimum());
+ if( m_pMax ) m_pMax ->Set_Value(x, y, Statistics.Get_Maximum());
+ if( m_pRange ) m_pRange ->Set_Value(x, y, Statistics.Get_Range());
+ if( m_pVar ) m_pVar ->Set_Value(x, y, Statistics.Get_Variance());
+ if( m_pStdDev ) m_pStdDev ->Set_Value(x, y, Statistics.Get_StdDev());
+ if( m_pStdDevLo ) m_pStdDevLo ->Set_Value(x, y, Statistics.Get_Mean() - Statistics.Get_StdDev());
+ if( m_pStdDevHi ) m_pStdDevHi ->Set_Value(x, y, Statistics.Get_Mean() + Statistics.Get_StdDev());
+ if( m_pDevMean ) m_pDevMean ->Set_Value(x, y, Statistics.Get_StdDev() > 0.0 ? ((z - Statistics.Get_Mean()) / Statistics.Get_StdDev()) : 0.0);
+ if( m_pPercent ) m_pPercent ->Set_Value(x, y, 100.0 * nLower / (double)Statistics.Get_Count());
+
+ return( true );
+ }
+ }
+
+ //-----------------------------------------------------
+ if( m_pMean ) m_pMean ->Set_NoData(x, y);
+ if( m_pDifMean ) m_pDifMean ->Set_NoData(x, y);
+ if( m_pMin ) m_pMin ->Set_NoData(x, y);
+ if( m_pMax ) m_pMax ->Set_NoData(x, y);
+ if( m_pRange ) m_pRange ->Set_NoData(x, y);
+ if( m_pVar ) m_pVar ->Set_NoData(x, y);
+ if( m_pStdDev ) m_pStdDev ->Set_NoData(x, y);
+ if( m_pStdDevLo ) m_pStdDevLo ->Set_NoData(x, y);
+ if( m_pStdDevHi ) m_pStdDevHi ->Set_NoData(x, y);
+ if( m_pDevMean ) m_pDevMean ->Set_NoData(x, y);
+ if( m_pPercent ) m_pPercent ->Set_NoData(x, y);
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Directional_Statistics.h b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Directional_Statistics.h
new file mode 100644
index 0000000..0f9cbc8
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Directional_Statistics.h
@@ -0,0 +1,110 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Grid //
+// //
+//-------------------------------------------------------//
+// //
+// GSGrid_Directional_Statistics.h //
+// //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__GSGrid_Directional_Statistics_H
+#define HEADER_INCLUDED__GSGrid_Directional_Statistics_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGSGrid_Directional_Statistics : public CSG_Module_Grid
+{
+public:
+ CGSGrid_Directional_Statistics(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ CSG_Grid_Cell_Addressor m_Cells;
+
+ CSG_Grid *m_pGrid, *m_pMean, *m_pDifMean, *m_pMin, *m_pMax, *m_pRange, *m_pVar, *m_pStdDev, *m_pStdDevLo, *m_pStdDevHi, *m_pDevMean, *m_pPercent;
+
+
+ bool Get_Statistics (int x, int y);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__GSGrid_Directional_Statistics_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Residuals.cpp b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Residuals.cpp
index 5bfb5f8..ab2ff5e 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Residuals.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Residuals.cpp
@@ -1,240 +1,230 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// Geostatistics_Grid //
-// //
-//-------------------------------------------------------//
-// //
-// GSGrid_Residuals.cpp //
-// //
-// Copyright (C) 2003 by //
-// Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "GSGrid_Residuals.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CGSGrid_Residuals::CGSGrid_Residuals(void)
-{
- //-----------------------------------------------------
- // 1. Info...
-
- Set_Name (_TL("Residual Analysis (Grid)"));
-
- Set_Author (SG_T("(c) 2003 by O.Conrad"));
-
- Set_Description (_TW("Relations of each grid cell to its neighborhood. "
- "Wilson & Gallant (2000) used this type of calculation in terrain analysis.\n"
- "\n"
- "Reference:\n"
- "- Wilson, J.P., Gallant, J.C., (Eds.), 2000: "
- "'Terrain analysis - principles and applications', "
- "New York, John Wiley & Sons, Inc.\n"
- ));
-
-
- //-----------------------------------------------------
- // 2. Parameters...
-
- Parameters.Add_Grid( NULL, "INPUT" , _TL("Grid") , _TL(""), PARAMETER_INPUT);
-
- Parameters.Add_Grid( NULL, "MEAN" , _TL("Mean Value") , _TL(""), PARAMETER_OUTPUT);
- Parameters.Add_Grid( NULL, "DIFF" , _TL("Difference from Mean Value") , _TL(""), PARAMETER_OUTPUT);
- Parameters.Add_Grid( NULL, "STDDEV" , _TL("Standard Deviation") , _TL(""), PARAMETER_OUTPUT);
- Parameters.Add_Grid( NULL, "RANGE" , _TL("Value Range") , _TL(""), PARAMETER_OUTPUT);
- Parameters.Add_Grid( NULL, "MIN" , _TL("Minimum Value") , _TL(""), PARAMETER_OUTPUT);
- Parameters.Add_Grid( NULL, "MAX" , _TL("Maximum Value") , _TL(""), PARAMETER_OUTPUT);
- Parameters.Add_Grid( NULL, "DEVMEAN" , _TL("Deviation from Mean Value") , _TL(""), PARAMETER_OUTPUT);
- Parameters.Add_Grid( NULL, "PERCENTILE" , _TL("Percentile") , _TL(""), PARAMETER_OUTPUT);
-
- Parameters.Add_Value( NULL, "RADIUS" , _TL("Radius (Cells)") , _TL(""), PARAMETER_TYPE_Int, 7, 1, true);
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CGSGrid_Residuals::On_Execute(void)
-{
- pInput = Parameters("INPUT") ->asGrid();
-
- pMean = Parameters("MEAN") ->asGrid();
- pDiff = Parameters("DIFF") ->asGrid();
- pStdDev = Parameters("STDDEV") ->asGrid();
- pRange = Parameters("RANGE") ->asGrid();
- pMin = Parameters("MIN") ->asGrid();
- pMax = Parameters("MAX") ->asGrid();
- pDevMean = Parameters("DEVMEAN") ->asGrid();
- pPercentile = Parameters("PERCENTILE") ->asGrid();
-
- DataObject_Set_Colors(pDiff , 100, SG_COLORS_RED_GREY_BLUE, true);
- DataObject_Set_Colors(pStdDev , 100, SG_COLORS_RED_GREY_BLUE, true);
- DataObject_Set_Colors(pRange , 100, SG_COLORS_RED_GREY_BLUE, true);
- DataObject_Set_Colors(pMin , 100, SG_COLORS_RED_GREY_BLUE, true);
- DataObject_Set_Colors(pMax , 100, SG_COLORS_RED_GREY_BLUE, true);
- DataObject_Set_Colors(pDevMean , 100, SG_COLORS_RED_GREY_BLUE, true);
- DataObject_Set_Colors(pPercentile , 100, SG_COLORS_RED_GREY_BLUE, true);
-
- //-----------------------------------------------------
- m_Radius.Create(Parameters("RADIUS")->asInt() + 1);
-
- Values = (double *)malloc(m_Radius.Get_nPoints() * sizeof(double));
-
- //-----------------------------------------------------
- for(int y=0; y<Get_NY() && Set_Progress(y); y++)
- {
- for(int x=0; x<Get_NX(); x++)
- {
- Get_Value(x, y);
- }
- }
-
- //-----------------------------------------------------
- m_Radius.Destroy();
-
- free(Values);
-
- return( true );
-}
-
-//---------------------------------------------------------
-int CGSGrid_Residuals::Get_Value(int x, int y)
-{
- int iPoint, ix, iy, nPoints, nLower;
- double Value, zValue, zMin, zMax, Mean, StdDev;
-
- //-----------------------------------------------------
- nPoints = 0;
-
- if( pInput->is_InGrid(x, y) )
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Grid //
+// //
+//-------------------------------------------------------//
+// //
+// GSGrid_Residuals.cpp //
+// //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "GSGrid_Residuals.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGSGrid_Residuals::CGSGrid_Residuals(void)
+{
+ //-----------------------------------------------------
+ // 1. Info...
+
+ Set_Name (_TL("Residual Analysis (Grid)"));
+
+ Set_Author (SG_T("O.Conrad (c) 2003"));
+
+ Set_Description (_TW("Relations of each grid cell to its neighborhood. "
+ "Wilson & Gallant (2000) used this type of calculation in terrain analysis.\n"
+ "\n"
+ "Reference:\n"
+ "- Wilson, J.P., Gallant, J.C., [Eds.] (2000): "
+ "'Terrain analysis - principles and applications', "
+ "New York, John Wiley & Sons, Inc.\n"
+ ));
+
+
+ //-----------------------------------------------------
+ // 2. Parameters...
+
+ Parameters.Add_Grid( NULL, "GRID" , _TL("Grid") , _TL(""), PARAMETER_INPUT);
+
+ Parameters.Add_Grid( NULL, "MEAN" , _TL("Mean Value") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "DIFF" , _TL("Difference from Mean Value") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "STDDEV" , _TL("Standard Deviation") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "RANGE" , _TL("Value Range") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "MIN" , _TL("Minimum Value") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "MAX" , _TL("Maximum Value") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "DEVMEAN" , _TL("Deviation from Mean Value") , _TL(""), PARAMETER_OUTPUT);
+ Parameters.Add_Grid( NULL, "PERCENT" , _TL("Percentile") , _TL(""), PARAMETER_OUTPUT);
+
+ Parameters.Add_Value( NULL, "RADIUS" , _TL("Radius (Cells)") , _TL(""), PARAMETER_TYPE_Int, 7, 1, true);
+
+ Parameters.Add_Parameters(
+ NULL, "WEIGHTING" , _TL("Weighting"),
+ _TL("")
+ )->asParameters()->Assign(m_Cells.Get_Weighting().Get_Parameters());
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGSGrid_Residuals::On_Execute(void)
+{
+ m_pGrid = Parameters("GRID") ->asGrid();
+
+ m_pMean = Parameters("MEAN") ->asGrid();
+ m_pDiff = Parameters("DIFF") ->asGrid();
+ m_pStdDev = Parameters("STDDEV") ->asGrid();
+ m_pRange = Parameters("RANGE") ->asGrid();
+ m_pMin = Parameters("MIN") ->asGrid();
+ m_pMax = Parameters("MAX") ->asGrid();
+ m_pDevMean = Parameters("DEVMEAN") ->asGrid();
+ m_pPercent = Parameters("PERCENT") ->asGrid();
+
+ DataObject_Set_Colors(m_pDiff , 100, SG_COLORS_RED_GREY_BLUE, true);
+ DataObject_Set_Colors(m_pStdDev , 100, SG_COLORS_RED_GREY_BLUE, true);
+ DataObject_Set_Colors(m_pRange , 100, SG_COLORS_RED_GREY_BLUE, true);
+ DataObject_Set_Colors(m_pMin , 100, SG_COLORS_RED_GREY_BLUE, true);
+ DataObject_Set_Colors(m_pMax , 100, SG_COLORS_RED_GREY_BLUE, true);
+ DataObject_Set_Colors(m_pDevMean, 100, SG_COLORS_RED_GREY_BLUE, true);
+ DataObject_Set_Colors(m_pPercent, 100, SG_COLORS_RED_GREY_BLUE, true);
+
+ //-----------------------------------------------------
+ m_Cells.Get_Weighting().Set_Parameters(Parameters("WEIGHTING")->asParameters());
+
+ if( !m_Cells.Set_Radius(Parameters("RADIUS")->asInt()) )
{
- nLower = 0;
- Mean = 0.0;
- zValue = pInput->asDouble(x, y);
-
- for(iPoint=0; iPoint<m_Radius.Get_nPoints(); iPoint++)
- {
- m_Radius.Get_Point(iPoint, x, y, ix, iy);
-
- if( pInput->is_InGrid(ix, iy) )
- {
- Mean += (Values[nPoints++] = Value = pInput->asDouble(ix, iy));
-
- if( nPoints <= 1 )
- {
- zMin = zMax = Value;
- }
- else if( zMin > Value )
- {
- zMin = Value;
- }
- else if( zMax < Value )
- {
- zMax = Value;
- }
-
- if( Value < zValue )
- {
- nLower++;
- }
- }
- }
- }
-
- //-----------------------------------------------------
- if( nPoints <= 1 )
- {
- pMean ->Set_NoData(x, y);
- pDiff ->Set_NoData(x, y);
- pStdDev ->Set_NoData(x, y);
- pRange ->Set_NoData(x, y);
- pMin ->Set_NoData(x, y);
- pMax ->Set_NoData(x, y);
- pDevMean ->Set_NoData(x, y);
- pPercentile ->Set_NoData(x, y);
- }
- else
- {
- Mean /= (double)nPoints;
-
- StdDev = 0.0;
-
- for(iPoint=0; iPoint<nPoints; iPoint++)
- {
- Value = Values[iPoint] - Mean;
-
- StdDev += Value * Value;
- }
-
- StdDev /= (double)(nPoints - 1.0);
-
- pMean ->Set_Value(x, y, Mean);
- pDiff ->Set_Value(x, y, zValue - Mean);
- pStdDev ->Set_Value(x, y, StdDev);
- pRange ->Set_Value(x, y, zMax - zMin);
- pMin ->Set_Value(x, y, zMin);
- pMax ->Set_Value(x, y, zMax);
- pDevMean ->Set_Value(x, y, (zValue - Mean) / StdDev);
- pPercentile ->Set_Value(x, y, 100.0 * (double)nLower / (double)(nPoints - 1.0));
+ return( false );
}
- return( nPoints );
-}
+ //-----------------------------------------------------
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
+ {
+ Get_Statistics(x, y);
+ }
+ }
+
+ //-----------------------------------------------------
+ m_Cells.Destroy();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGSGrid_Residuals::Get_Statistics(int x, int y)
+{
+ if( m_pGrid->is_InGrid(x, y) )
+ {
+ int i, ix, iy, nLower;
+ double z, iz, id, iw;
+
+ CSG_Simple_Statistics Statistics;
+
+ for(i=0, nLower=0, z=m_pGrid->asDouble(x, y); i<m_Cells.Get_Count(); i++)
+ {
+ if( m_Cells.Get_Values(i, ix = x, iy = y, id, iw, true) && id > 0.0 && m_pGrid->is_InGrid(ix, iy) )
+ {
+ Statistics.Add_Value(iz = m_pGrid->asDouble(ix, iy), iw);
+
+ if( z > iz )
+ {
+ nLower++;
+ }
+ }
+ }
+
+ //-------------------------------------------------
+ if( Statistics.Get_Weights() > 0.0 )
+ {
+ m_pMean ->Set_Value(x, y, Statistics.Get_Mean());
+ m_pDiff ->Set_Value(x, y, z - Statistics.Get_Mean());
+ m_pStdDev ->Set_Value(x, y, Statistics.Get_StdDev());
+ m_pRange ->Set_Value(x, y, Statistics.Get_Range());
+ m_pMin ->Set_Value(x, y, Statistics.Get_Minimum());
+ m_pMax ->Set_Value(x, y, Statistics.Get_Maximum());
+ m_pDevMean ->Set_Value(x, y, Statistics.Get_StdDev() > 0.0 ? ((z - Statistics.Get_Mean()) / Statistics.Get_StdDev()) : 0.0);
+ m_pPercent ->Set_Value(x, y, 100.0 * nLower / (double)Statistics.Get_Count());
+
+ return( true );
+ }
+ }
+
+ //-----------------------------------------------------
+ m_pMean ->Set_NoData(x, y);
+ m_pDiff ->Set_NoData(x, y);
+ m_pStdDev ->Set_NoData(x, y);
+ m_pRange ->Set_NoData(x, y);
+ m_pMin ->Set_NoData(x, y);
+ m_pMax ->Set_NoData(x, y);
+ m_pDevMean ->Set_NoData(x, y);
+ m_pPercent ->Set_NoData(x, y);
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Residuals.h b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Residuals.h
index 0ee86be..28b2d71 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Residuals.h
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Residuals.h
@@ -84,8 +84,6 @@ class CGSGrid_Residuals : public CSG_Module_Grid
public:
CGSGrid_Residuals(void);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Neighborhoods" )); }
-
protected:
@@ -94,14 +92,12 @@ protected:
private:
- double *Values;
-
- CSG_Grid_Radius m_Radius;
+ CSG_Grid_Cell_Addressor m_Cells;
- CSG_Grid *pInput, *pMean, *pDiff, *pStdDev, *pRange, *pMin, *pMax, *pDevMean, *pPercentile;
+ CSG_Grid *m_pGrid, *m_pMean, *m_pDiff, *m_pStdDev, *m_pRange, *m_pMin, *m_pMax, *m_pDevMean, *m_pPercent;
- int Get_Value (int x, int y);
+ bool Get_Statistics (int x, int y);
};
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Variance.h b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Variance.h
index 0db980e..25e3c5b 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Variance.h
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Variance.h
@@ -85,8 +85,6 @@ public:
CGSGrid_Variance(void);
virtual ~CGSGrid_Variance(void);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Neighborhoods") ); }
-
protected:
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Variance_Radius.h b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Variance_Radius.h
index 07c320f..093279a 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Variance_Radius.h
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Variance_Radius.h
@@ -85,8 +85,6 @@ public:
CGSGrid_Variance_Radius(void);
virtual ~CGSGrid_Variance_Radius(void);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Neighborhoods") ); }
-
protected:
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Zonal_Statistics.cpp b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Zonal_Statistics.cpp
index 310cb9f..feb0466 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Zonal_Statistics.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Zonal_Statistics.cpp
@@ -1,427 +1,561 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// Geostatistics_Grid //
-// //
-//-------------------------------------------------------//
-// //
-// GSGrid_Zonal_Statistics.cpp //
-// //
-// Copyright (C) 2005 by //
-// Volker Wichmann //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: reklovw at web.de //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "GSGrid_Zonal_Statistics.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// Construction/Destruction //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CGSGrid_Zonal_Statistics::CGSGrid_Zonal_Statistics(void)
-{
- //-----------------------------------------------------
- // Place information about your module here...
-
- Set_Name (_TL("{STATZONAL_NAME} Zonal Grid Statistics"));
-
- Set_Author (_TL("Copyrights (c) 2005 by Volker Wichmann"));
-
- Set_Description (_TW("{STATZONAL_DESC} "
- "The module can be used to create a contingency table of unique condition units (UCUs). These "
- "units are delineated from a zonal grid (e.g. sub catchments) and optional categorial grids (e.g. "
- "landcover, soil, ...). It is possible to calculate simple statistics (min, max, mean, standard "
- "deviation and sum) for each UCU from optional grids with continious data (e.g. slope). The number "
- "of input grids is only limited by available memory. The module has four different modes of "
- "application: (1) only a zonal grid is used as input. This results in a simple contingency table with "
- "the number of grid cells in each zone. (2) a zonal grid and additional categorial grids are used as "
- "input. This results in a contingency table with the number of cells in each UCU. (3) a zonal grid "
- "and additional grids with continuous data are used as input. This results in a contingency table "
- "with the number of cells in each zone and some simple statistics for each zone. The statistics are "
- "calculated for each continuous grid. (4) a zonal grid, additional categorial grids and additional "
- "grids with continuous data are used as input. This results in a contingency table with the number "
- "of cells in each UCU and the corresponding statistics for each continuous grid.\n"
- "\n"
- "Depending on the mode of application, the output table contains information about the category "
- "combination of each UCU, the number of cells in each UCU and the statistics for each UCU. A "
- "typical output table may look like this:\n"
- "<table border=\"1\">"
- "<tr><td>ID Zone</td><td>ID 1stCat</td><td>ID 2ndCat</td><td>Count UCU</td><td>MIN 1stCont</td><td>MAX 1stCont</td><td>MEAN 1stCont</td><td>STDDEV 1stCont</td><td>SUM 1stCont</td></tr>"
- "<tr><td>0 </td><td>2 </td><td>6 </td><td>6 </td><td>708.5 </td><td>862.0 </td><td>734.5 </td><td>62.5 </td><td>4406.8 </td></tr>"
- "<tr><td>0 </td><td>3 </td><td>4 </td><td>106 </td><td>829.1 </td><td>910.1 </td><td>848.8 </td><td>28.5 </td><td>89969.0 </td></tr>"
- "</table>"
- ));
-
-
- Parameters.Add_Grid(
- NULL, "ZONES" , _TL("Zone Grid"),
- _TL("Grid defining the zones to analyse. This grid also acts as a mask. Coding: no-data / categorial values."),
- PARAMETER_INPUT
- );
-
- Parameters.Add_Grid_List(
- NULL, "CATLIST" , _TL("Categorial Grids"),
- _TL("Grids used to delineate the UCUs. Coding: no-data / categorial values."),
- PARAMETER_INPUT_OPTIONAL
- );
-
- Parameters.Add_Grid_List(
- NULL, "STATLIST" , _TL("Grids to analyse"),
- _TL("Grids with continuous data, statistics are calculated for each grid. Coding: no-data / continuous values."),
- PARAMETER_INPUT_OPTIONAL
- );
-
- Parameters.Add_Table(
- NULL, "OUTTAB" , _TL("Result Table"),
- _TL("Summary table."),
- PARAMETER_OUTPUT
- );
-}
-
-//---------------------------------------------------------
-CGSGrid_Zonal_Statistics::~CGSGrid_Zonal_Statistics(void)
-{}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CGSGrid_Zonal_Statistics::On_Execute(void)
-{
- int x, y, nCatGrids, nStatGrids, iGrid, zoneID, catID, NDcount, catLevel, NDcountStat;
- double statID;
-
- CSG_Grid *pZones, *pGrid;
- CSG_Parameter_Grid_List *pCatList;
- CSG_Parameter_Grid_List *pStatList;
-
- CList_Conti *newZone, *startList, *runList, *newSub, *parent, *runSub, *subList;
- CList_Stat *runStats;
- CSG_Table *pOutTab;
- CSG_Table_Record *pRecord;
-
-
- pZones = Parameters("ZONES") ->asGrid();
- pCatList = Parameters("CATLIST") ->asGridList();
- pStatList = Parameters("STATLIST") ->asGridList();
- pOutTab = Parameters("OUTTAB") ->asTable();
-
- nCatGrids = pCatList ->Get_Count();
- nStatGrids = pStatList ->Get_Count();
-
- NDcount = 0; // NoData Counter (ZoneGrid)
- NDcountStat = 0; // NoData Counter (StatGrids)
-
- if (pOutTab != NULL)
- pOutTab->Destroy();
-
- newZone = new CList_Conti(); // create first list entry (dummy)
- startList = newZone;
-
- for(y=0; y<Get_NY() && Set_Progress(y); y++)
- {
- for(x=0; x<Get_NX(); x++)
- {
- runList = startList;
- zoneID = pZones->asInt(x, y); // get zone ID
-
- while( runList->next != NULL && runList->cat < zoneID ) // search for last entry in list or insert point
- {
- runList = runList->next;
- }
-
- if( runList->dummy == true )
- {
- runList->cat = zoneID; // first list entry, write and
- runList->dummy = false; // setup
- }
- else if( runList->cat == zoneID )
- runList = runList; // zoneID found
- else if( runList->next == NULL && runList->cat < zoneID ) // append zoneID
- {
- newZone = new CList_Conti();
- newZone->previous = runList;
- runList->next = newZone;
-
- newZone->cat = zoneID; // ... and write info
- newZone->dummy = false;
- runList = newZone;
- }
- else // insert new entry
- {
- newZone = new CList_Conti();
-
- newZone->next = runList;
- if( runList->previous != NULL )
- {
- newZone->previous = runList->previous;
- runList->previous->next = newZone;
- }
- runList->previous = newZone;
-
- if( runList == startList )
- startList = newZone; // if new entry is first element, update startList pointer
-
- newZone->cat = zoneID; // ... and write info
- newZone->dummy = false;
- runList = newZone;
- }
-
-
- for(iGrid=0; iGrid<nCatGrids; iGrid++) // collect categories
- {
- parent = runList;
- if( runList->sub == NULL ) // no sub class found
- {
- newSub = new CList_Conti();
- runList->sub = newSub;
- }
-
- runList = runList->sub;
-
- pGrid = pCatList->asGrid(iGrid);
- if( !pGrid->is_NoData(x, y) )
- catID = pGrid->asInt(x, y);
- else
- catID = (int)pGrid->Get_NoData_Value();
-
-
- while( runList->next != NULL && runList->cat < catID ) // search for last entry in list or insert point
- {
- runList = runList->next;
- }
-
- if( runList->dummy == true )
- {
- runList->cat = catID; // first list entry, write and
- runList->dummy = false; // setup
- runList->parent = parent;
- }
- else if( runList->cat == catID )
- runList = runList; // zoneID found, all infos already written
- else if( runList->next == NULL && runList->cat < catID) // append zoneID
- {
- newSub = new CList_Conti();
- newSub->cat = catID; // ... and write info
- newSub->previous = runList;
- newSub->parent = parent;
- newSub->dummy = false;
- runList->next = newSub;
- runList = newSub;
- }
- else // insert new entry
- {
- newSub = new CList_Conti();
- newSub->cat = catID; // ... and write info
- newSub->next = runList;
- newSub->parent = parent;
- newSub->dummy = false;
- if( runList->previous != NULL )
- {
- newSub->previous = runList->previous;
- runList->previous->next = newSub;
- }
- else
- parent->sub = newSub;
-
- runList->previous = newSub;
- runList = newSub;
- }
- }
-
-
- for(iGrid=0; iGrid<nStatGrids; iGrid++) // collect statistics for StatGrids
- {
- if( iGrid == 0 )
- {
- if( runList->stats == NULL )
- runList->stats = new CList_Stat();
-
- runStats = runList->stats;
- }
- else
- {
- if( runStats->next == NULL )
- runStats->next = new CList_Stat();
-
- runStats = runStats->next;
- }
- if( !pStatList->asGrid(iGrid)->is_NoData(x, y) )
- {
- statID = pStatList->asGrid(iGrid)->asDouble(x, y);
-
- if( runStats->dummy == true )
- {
- runStats->min = statID;
- runStats->max = statID;
- runStats->dummy = false;
- }
- if( runStats->min > statID )
- runStats->min = statID;
- if( runStats->max < statID )
- runStats->max = statID;
-
- runStats->sum += statID;
- runStats->dev += pow(statID, 2);
- }
- else
- NDcountStat += 1;
- }
-
-
- runList->count += 1; // sum up unique condition area
- }
- }
-
-
- // Create fields in output table (1st = Zone, 2nd = Catgrid1, 3rd = Catgrid 2, ...)
- pOutTab->Add_Field(CSG_String::Format(SG_T("%s"),pZones->Get_Name()).BeforeFirst(SG_Char('.')), SG_DATATYPE_Int);
- for(iGrid=0; iGrid<nCatGrids; iGrid++)
- {
- pOutTab->Add_Field(CSG_String::Format(SG_T("%s"),pCatList->asGrid(iGrid)->Get_Name()).BeforeFirst(SG_Char('.')), SG_DATATYPE_Int);
- }
- pOutTab->Add_Field("Count", SG_DATATYPE_Int);
- for(iGrid=0; iGrid<nStatGrids; iGrid++)
- {
- pOutTab->Add_Field(CSG_String::Format(SG_T("%s_MIN") , CSG_String::Format(SG_T("%s"),pStatList->asGrid(iGrid)->Get_Name()).BeforeFirst(SG_Char('.')).c_str()), SG_DATATYPE_Double);
- pOutTab->Add_Field(CSG_String::Format(SG_T("%s_MAX") , CSG_String::Format(SG_T("%s"),pStatList->asGrid(iGrid)->Get_Name()).BeforeFirst(SG_Char('.')).c_str()), SG_DATATYPE_Double);
- pOutTab->Add_Field(CSG_String::Format(SG_T("%s_MEAN") , CSG_String::Format(SG_T("%s"),pStatList->asGrid(iGrid)->Get_Name()).BeforeFirst(SG_Char('.')).c_str()), SG_DATATYPE_Double);
- pOutTab->Add_Field(CSG_String::Format(SG_T("%s_STDDEV"), CSG_String::Format(SG_T("%s"),pStatList->asGrid(iGrid)->Get_Name()).BeforeFirst(SG_Char('.')).c_str()), SG_DATATYPE_Double);
- pOutTab->Add_Field(CSG_String::Format(SG_T("%s_SUM") , CSG_String::Format(SG_T("%s"),pStatList->asGrid(iGrid)->Get_Name()).BeforeFirst(SG_Char('.')).c_str()), SG_DATATYPE_Double);
- }
-
- while( startList != NULL ) // scan zone layer list and write cat values in table
- {
- runList = startList;
- while( runList->sub != NULL ) // fall down to lowest layer
- runList = runList->sub;
-
- subList = runList; // use pointer to scan horizontal
-
- while( subList != NULL ) // move forward and read all categories of this layer (including the parent layers)
- {
- runSub = subList;
- catLevel = nCatGrids;
- pRecord = pOutTab->Add_Record(); // create new record in table
- pRecord->Set_Value((catLevel+1), runSub->count); // read/write field count
-
- for(iGrid=0; iGrid<nStatGrids; iGrid++) // read/write statistics
- {
- if( iGrid == 0 )
- runStats = runSub->stats;
- else
- runStats = runStats->next;
-
- pRecord->Set_Value(catLevel+2+iGrid*5, runStats->min);
- pRecord->Set_Value(catLevel+3+iGrid*5, runStats->max);
- pRecord->Set_Value(catLevel+4+iGrid*5, runStats->sum/runSub->count);
- pRecord->Set_Value(catLevel+5+iGrid*5, sqrt((runStats->dev - runSub->count*pow(runStats->sum/runSub->count, 2)) / (runSub->count - 1))); // sample
- //pRecord->Set_Value(catLevel+5+iGrid*5, sqrt((runStats->dev - pow(runStats->sum/runSub->count, 2)) / runSub->count)); // population
- pRecord->Set_Value(catLevel+6+iGrid*5, runStats->sum);
- }
-
- while( runSub != NULL ) // read/write categories
- {
- pRecord->Set_Value(catLevel, runSub->cat);
- runSub = runSub->parent;
- catLevel -= 1;
- }
- subList = subList->next;
- }
-
- while( runList->parent != NULL && runList->parent->next == NULL ) // move up to next 'Caterory with -> next'
- runList = runList->parent;
-
- if( runList->parent != NULL ) // if not upper layer (zones)
- {
- runList = runList->parent; // move to parent of next 'Caterory with -> next'
- if( runList->next != NULL && runList->parent != NULL )
- runList->parent->sub = runList->next; // redirect pointer to category which is next 'Categora with -> next' next
- else if (runList->parent == NULL && runList->next != NULL )
- startList = runList->next; // when upper layer (zones) is reached, move to next zone
- else
- startList = NULL; // reading finished
-
- if( runList->parent == NULL )
- startList = runList->next; // ?? when upper layer is reached, move to next zone
- else
- runList->sub = runList->sub->next; // on sub layers redirect pointer to ->next
- }
- else
- {
- if( nCatGrids == 0 )
- startList = NULL;
- else
- startList = runList->next; // ?? upper layer is reached, move to next zone
- }
-
-
- runList->next = NULL;
- delete (runList); // delete disconneted part of the list
-
- }
-
-
- if( NDcountStat > 0 )
- {
- Message_Add(CSG_String::Format(SG_T("\n\n\n%s: %d %s\n\n\n"), _TL("WARNING"), NDcountStat, _TL("no-data value(s) in statistic grid(s)!")));
- }
-
- return (true);
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Grid //
+// //
+//-------------------------------------------------------//
+// //
+// GSGrid_Zonal_Statistics.cpp //
+// //
+// Copyright (C) 2005-9 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: reklovw at web.de //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "GSGrid_Zonal_Statistics.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// Construction/Destruction //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGSGrid_Zonal_Statistics::CGSGrid_Zonal_Statistics(void)
+{
+ //-----------------------------------------------------
+ // Place information about your module here...
+
+ Set_Name (_TL("{STATZONAL_NAME} Zonal Grid Statistics"));
+
+ Set_Author (_TL("Copyrights (c) 2005 by Volker Wichmann"));
+
+ Set_Description (_TW("{STATZONAL_DESC} "
+ "The module calculates zonal statistics and reports these in a table. "
+ "The module can be used to create a contingency table of unique condition units (UCUs). These "
+ "units are delineated from a zonal grid (e.g. sub catchments) and optional categorial grids (e.g. "
+ "landcover, soil, ...). It is possible to calculate simple statistics (min, max, mean, standard "
+ "deviation and sum) for each UCU from optional grids with continious data (e.g. slope; aspect must be "
+ "handled specially, please use the \"Aspect\" input parameter for such a grid). The number "
+ "of input grids is only limited by available memory. The module has four different modes of "
+ "application: (1) only a zonal grid is used as input. This results in a simple contingency table with "
+ "the number of grid cells in each zone. (2) a zonal grid and additional categorial grids are used as "
+ "input. This results in a contingency table with the number of cells in each UCU. (3) a zonal grid "
+ "and additional grids with continuous data are used as input. This results in a contingency table "
+ "with the number of cells in each zone and some simple statistics for each zone. The statistics are "
+ "calculated for each continuous grid. (4) a zonal grid, additional categorial grids and additional "
+ "grids with continuous data are used as input. This results in a contingency table with the number "
+ "of cells in each UCU and the corresponding statistics for each continuous grid.\n"
+ "\n"
+ "Depending on the mode of application, the output table contains information about the category "
+ "combination of each UCU, the number of cells in each UCU and the statistics for each UCU. A "
+ "typical output table may look like this:\n"
+ "<table border=\"1\">"
+ "<tr><td>ID Zone</td><td>ID 1stCat</td><td>ID 2ndCat</td><td>Count UCU</td><td>MIN 1stCont</td><td>MAX 1stCont</td><td>MEAN 1stCont</td><td>STDDEV 1stCont</td><td>SUM 1stCont</td></tr>"
+ "<tr><td>0 </td><td>2 </td><td>6 </td><td>6 </td><td>708.5 </td><td>862.0 </td><td>734.5 </td><td>62.5 </td><td>4406.8 </td></tr>"
+ "<tr><td>0 </td><td>3 </td><td>4 </td><td>106 </td><td>829.1 </td><td>910.1 </td><td>848.8 </td><td>28.5 </td><td>89969.0 </td></tr>"
+ "</table>"
+ ));
+
+
+ Parameters.Add_Grid(
+ NULL, "ZONES" , _TL("Zone Grid"),
+ _TL("Grid defining the zones to analyse. This grid also acts as a mask. Coding: no-data / categorial values."),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid_List(
+ NULL, "CATLIST" , _TL("Categorial Grids"),
+ _TL("Grids used to delineate the UCUs. Coding: no-data / categorial values."),
+ PARAMETER_INPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid_List(
+ NULL, "STATLIST" , _TL("Grids to analyse"),
+ _TL("Grids with continuous data, statistics are calculated for each grid. Coding: no-data / continuous values."),
+ PARAMETER_INPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid(
+ NULL, "ASPECT" , _TL("Aspect"),
+ _TL("Aspect grid, in radians."),
+ PARAMETER_INPUT_OPTIONAL
+ );
+
+ Parameters.Add_Table(
+ NULL, "OUTTAB" , _TL("Zonal Statistics"),
+ _TL("Summary table."),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Value(
+ NULL, "SHORTNAMES" , _TL("Short Field Names"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, true
+ );
+}
+
+//---------------------------------------------------------
+CGSGrid_Zonal_Statistics::~CGSGrid_Zonal_Statistics(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGSGrid_Zonal_Statistics::On_Execute(void)
+{
+ bool bShortNames;
+ int x, y, nCatGrids, nStatGrids, iGrid, zoneID, catID, NDcount, catLevel, NDcountStat;
+ double statID;
+
+ CSG_Grid *pZones, *pGrid, *pAspect;
+ CSG_Parameter_Grid_List *pCatList;
+ CSG_Parameter_Grid_List *pStatList;
+
+ CList_Conti *newZone, *startList, *runList, *newSub, *parent, *runSub, *subList;
+ CList_Stat *runStats;
+ CSG_Table *pOutTab;
+ CSG_Table_Record *pRecord;
+ CSG_String fieldName, tmpName;
+
+
+ pZones = Parameters("ZONES") ->asGrid();
+ pCatList = Parameters("CATLIST") ->asGridList();
+ pStatList = Parameters("STATLIST") ->asGridList();
+ pAspect = Parameters("ASPECT") ->asGrid();
+ pOutTab = Parameters("OUTTAB") ->asTable();
+ bShortNames = Parameters("SHORTNAMES") ->asBool();
+
+ nCatGrids = pCatList ->Get_Count();
+ nStatGrids = pStatList ->Get_Count();
+
+ NDcount = 0; // NoData Counter (ZoneGrid)
+ NDcountStat = 0; // NoData Counter (StatGrids)
+
+ if (pOutTab != NULL)
+ pOutTab->Destroy();
+
+ newZone = new CList_Conti(); // create first list entry (dummy)
+ startList = newZone;
+
+ for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ runList = startList;
+ zoneID = pZones->asInt(x, y); // get zone ID
+
+ while( runList->next != NULL && runList->cat < zoneID ) // search for last entry in list or insert point
+ {
+ runList = runList->next;
+ }
+
+ if( runList->dummy == true )
+ {
+ runList->cat = zoneID; // first list entry, write and
+ runList->dummy = false; // setup
+ }
+ else if( runList->cat == zoneID )
+ runList = runList; // zoneID found
+ else if( runList->next == NULL && runList->cat < zoneID ) // append zoneID
+ {
+ newZone = new CList_Conti();
+ newZone->previous = runList;
+ runList->next = newZone;
+
+ newZone->cat = zoneID; // ... and write info
+ newZone->dummy = false;
+ runList = newZone;
+ }
+ else // insert new entry
+ {
+ newZone = new CList_Conti();
+
+ newZone->next = runList;
+ if( runList->previous != NULL )
+ {
+ newZone->previous = runList->previous;
+ runList->previous->next = newZone;
+ }
+ runList->previous = newZone;
+
+ if( runList == startList )
+ startList = newZone; // if new entry is first element, update startList pointer
+
+ newZone->cat = zoneID; // ... and write info
+ newZone->dummy = false;
+ runList = newZone;
+ }
+
+
+ for(iGrid=0; iGrid<nCatGrids; iGrid++) // collect categories
+ {
+ parent = runList;
+ if( runList->sub == NULL ) // no sub class found
+ {
+ newSub = new CList_Conti();
+ runList->sub = newSub;
+ }
+
+ runList = runList->sub;
+
+ pGrid = pCatList->asGrid(iGrid);
+ if( !pGrid->is_NoData(x, y) )
+ catID = pGrid->asInt(x, y);
+ else
+ catID = (int)pGrid->Get_NoData_Value();
+
+
+ while( runList->next != NULL && runList->cat < catID ) // search for last entry in list or insert point
+ {
+ runList = runList->next;
+ }
+
+ if( runList->dummy == true )
+ {
+ runList->cat = catID; // first list entry, write and
+ runList->dummy = false; // setup
+ runList->parent = parent;
+ }
+ else if( runList->cat == catID )
+ runList = runList; // zoneID found, all infos already written
+ else if( runList->next == NULL && runList->cat < catID) // append zoneID
+ {
+ newSub = new CList_Conti();
+ newSub->cat = catID; // ... and write info
+ newSub->previous = runList;
+ newSub->parent = parent;
+ newSub->dummy = false;
+ runList->next = newSub;
+ runList = newSub;
+ }
+ else // insert new entry
+ {
+ newSub = new CList_Conti();
+ newSub->cat = catID; // ... and write info
+ newSub->next = runList;
+ newSub->parent = parent;
+ newSub->dummy = false;
+ if( runList->previous != NULL )
+ {
+ newSub->previous = runList->previous;
+ runList->previous->next = newSub;
+ }
+ else
+ parent->sub = newSub;
+
+ runList->previous = newSub;
+ runList = newSub;
+ }
+ }
+
+
+ for(iGrid=0; iGrid<nStatGrids; iGrid++) // collect statistics for StatGrids
+ {
+ if( iGrid == 0 )
+ {
+ if( runList->stats == NULL )
+ runList->stats = new CList_Stat();
+
+ runStats = runList->stats;
+ }
+ else
+ {
+ if( runStats->next == NULL )
+ runStats->next = new CList_Stat();
+
+ runStats = runStats->next;
+ }
+ if( !pStatList->asGrid(iGrid)->is_NoData(x, y) )
+ {
+ statID = pStatList->asGrid(iGrid)->asDouble(x, y);
+
+ if( runStats->dummy == true )
+ {
+ runStats->min = statID;
+ runStats->max = statID;
+ runStats->dummy = false;
+ }
+ if( runStats->min > statID )
+ runStats->min = statID;
+ if( runStats->max < statID )
+ runStats->max = statID;
+
+ runStats->sum += statID;
+ runStats->dev += pow(statID, 2);
+ }
+ else
+ NDcountStat += 1;
+ }
+
+ if( pAspect != NULL )
+ {
+ for( int i=0; i<2; i++ )
+ {
+ if( nStatGrids == 0 && i == 0 )
+ {
+ if( runList->stats == NULL )
+ runList->stats = new CList_Stat();
+
+ runStats = runList->stats;
+ }
+ else
+ {
+ if( runStats->next == NULL )
+ runStats->next = new CList_Stat();
+
+ runStats = runStats->next;
+ }
+ if( !pAspect->is_NoData(x, y) )
+ {
+ statID = pAspect->asDouble(x, y);
+
+ if( i == 0 )
+ {
+ if( runStats->dummy == true )
+ {
+ runStats->min = statID;
+ runStats->max = statID;
+ runStats->dummy = false;
+ }
+ if( runStats->min > statID )
+ runStats->min = statID;
+ if( runStats->max < statID )
+ runStats->max = statID;
+
+ statID = sin(statID);
+ }
+ else
+ statID = cos(statID);
+
+ runStats->sum += statID;
+ }
+ else
+ NDcountStat += 1;
+ }
+ }
+
+ runList->count += 1; // sum up unique condition area
+ }
+ }
+
+
+ // Create fields in output table (1st = Zone, 2nd = Catgrid1, 3rd = Catgrid 2, ...)
+ fieldName = CSG_String::Format(SG_T("%s"),pZones->Get_Name()).BeforeFirst(SG_Char('.'));
+ if (bShortNames && fieldName.Length() > 10)
+ fieldName.Remove(10, fieldName.Length()-10);
+ pOutTab->Add_Field(fieldName, SG_DATATYPE_Int);
+
+ for(iGrid=0; iGrid<nCatGrids; iGrid++)
+ {
+ fieldName = CSG_String::Format(SG_T("%s"),pCatList->asGrid(iGrid)->Get_Name()).BeforeFirst(SG_Char('.'));
+ if (bShortNames && fieldName.Length() > 10)
+ fieldName.Remove(10, fieldName.Length()-10);
+ pOutTab->Add_Field(fieldName, SG_DATATYPE_Int);
+ }
+
+ pOutTab->Add_Field("Count", SG_DATATYPE_Int);
+
+ for( iGrid=0; iGrid<nStatGrids; iGrid++ )
+ {
+ tmpName = CSG_String::Format(SG_T("%s"),pStatList->asGrid(iGrid)->Get_Name()).BeforeFirst(SG_Char('.'));
+ fieldName = tmpName;
+ if (bShortNames && fieldName.Length()+3 > 10)
+ fieldName.Remove(7, fieldName.Length()-7);
+ pOutTab->Add_Field(CSG_String::Format(SG_T("%sMIN") , fieldName.c_str()), SG_DATATYPE_Double);
+ pOutTab->Add_Field(CSG_String::Format(SG_T("%sMAX") , fieldName.c_str()), SG_DATATYPE_Double);
+ fieldName = tmpName;
+ if (bShortNames && fieldName.Length()+4 > 10)
+ fieldName.Remove(6, fieldName.Length()-6);
+ pOutTab->Add_Field(CSG_String::Format(SG_T("%sMEAN") , fieldName.c_str()), SG_DATATYPE_Double);
+ fieldName = tmpName;
+ if (bShortNames && fieldName.Length()+6 > 10)
+ fieldName.Remove(4, fieldName.Length()-4);
+ pOutTab->Add_Field(CSG_String::Format(SG_T("%sSTDDEV"), fieldName.c_str()), SG_DATATYPE_Double);
+ fieldName = tmpName;
+ if (bShortNames && fieldName.Length()+3 > 10)
+ fieldName.Remove(7, fieldName.Length()-7);
+ pOutTab->Add_Field(CSG_String::Format(SG_T("%sSUM") , fieldName.c_str()), SG_DATATYPE_Double);
+ }
+
+ if( pAspect != NULL )
+ {
+ tmpName = CSG_String::Format(SG_T("%s"),pAspect->Get_Name()).BeforeFirst(SG_Char('.'));
+ fieldName = tmpName;
+ if (bShortNames && fieldName.Length()+3 > 10)
+ fieldName.Remove(7, fieldName.Length()-7);
+ pOutTab->Add_Field(CSG_String::Format(SG_T("%sMIN") , fieldName.c_str()), SG_DATATYPE_Double);
+ pOutTab->Add_Field(CSG_String::Format(SG_T("%sMAX") , fieldName.c_str()), SG_DATATYPE_Double);
+ fieldName = tmpName;
+ if (bShortNames && fieldName.Length()+4 > 10)
+ fieldName.Remove(6, fieldName.Length()-6);
+ pOutTab->Add_Field(CSG_String::Format(SG_T("%sMEAN") , fieldName.c_str()), SG_DATATYPE_Double);
+ }
+
+ while( startList != NULL ) // scan zone layer list and write cat values in table
+ {
+ runList = startList;
+ while( runList->sub != NULL ) // fall down to lowest layer
+ runList = runList->sub;
+
+ subList = runList; // use pointer to scan horizontal
+
+ while( subList != NULL ) // move forward and read all categories of this layer (including the parent layers)
+ {
+ runSub = subList;
+ catLevel = nCatGrids;
+ pRecord = pOutTab->Add_Record(); // create new record in table
+ pRecord->Set_Value((catLevel+1), runSub->count); // read/write field count
+
+ for(iGrid=0; iGrid<nStatGrids; iGrid++) // read/write statistics
+ {
+ if( iGrid == 0 )
+ runStats = runSub->stats;
+ else
+ runStats = runStats->next;
+
+ pRecord->Set_Value(catLevel+2+iGrid*5, runStats->min);
+ pRecord->Set_Value(catLevel+3+iGrid*5, runStats->max);
+ pRecord->Set_Value(catLevel+4+iGrid*5, runStats->sum/runSub->count);
+ pRecord->Set_Value(catLevel+5+iGrid*5, sqrt((runStats->dev - runSub->count*pow(runStats->sum/runSub->count, 2)) / (runSub->count - 1))); // sample
+ //pRecord->Set_Value(catLevel+5+iGrid*5, sqrt((runStats->dev - pow(runStats->sum/runSub->count, 2)) / runSub->count)); // population
+ pRecord->Set_Value(catLevel+6+iGrid*5, runStats->sum);
+ }
+
+ if( pAspect != NULL )
+ {
+ iGrid = nStatGrids * 5;
+
+ if( runSub->cat == pAspect->Get_NoData_Value() )
+ {
+ for( int i=2; i<5; i++ )
+ pRecord->Set_Value(catLevel+i+iGrid, 0.0);
+ }
+ else
+ {
+ double min, max, sumYcomp, sumXcomp, val, valYcomp, valXcomp;
+
+ if( nStatGrids == 0 )
+ runStats = runSub->stats;
+ else
+ runStats = runStats->next;
+ min = runStats->min;
+ max = runStats->max;
+ sumXcomp = runStats->sum;
+
+ runStats = runStats->next;
+ sumYcomp = runStats->sum;
+
+ pRecord ->Set_Value(catLevel+2+iGrid, min*M_RAD_TO_DEG);
+ pRecord ->Set_Value(catLevel+3+iGrid, max*M_RAD_TO_DEG);
+ valXcomp = sumXcomp / runSub->count;
+ valYcomp = sumYcomp / runSub->count;
+ val = valXcomp ? fmod(M_PI_270 + atan2(valYcomp, valXcomp), M_PI_360) : (valYcomp > 0 ? M_PI_270 : (valYcomp < 0 ? M_PI_090 : -1));
+ val = fmod(M_PI_360 - val, M_PI_360);
+ pRecord ->Set_Value(catLevel+4+iGrid, val*M_RAD_TO_DEG);
+ }
+ }
+
+ while( runSub != NULL ) // read/write categories
+ {
+ pRecord->Set_Value(catLevel, runSub->cat);
+ runSub = runSub->parent;
+ catLevel -= 1;
+ }
+ subList = subList->next;
+ }
+
+ while( runList->parent != NULL && runList->parent->next == NULL ) // move up to next 'Caterory with -> next'
+ runList = runList->parent;
+
+ if( runList->parent != NULL ) // if not upper layer (zones)
+ {
+ runList = runList->parent; // move to parent of next 'Caterory with -> next'
+ if( runList->next != NULL && runList->parent != NULL )
+ runList->parent->sub = runList->next; // redirect pointer to category which is next 'Categora with -> next' next
+ else if (runList->parent == NULL && runList->next != NULL )
+ startList = runList->next; // when upper layer (zones) is reached, move to next zone
+ else
+ startList = NULL; // reading finished
+
+ if( runList->parent == NULL )
+ startList = runList->next; // ?? when upper layer is reached, move to next zone
+ else
+ runList->sub = runList->sub->next; // on sub layers redirect pointer to ->next
+ }
+ else
+ {
+ if( nCatGrids == 0 )
+ startList = NULL;
+ else
+ startList = runList->next; // ?? upper layer is reached, move to next zone
+ }
+
+
+ runList->next = NULL;
+ delete (runList); // delete disconneted part of the list
+
+ }
+
+
+ if( NDcountStat > 0 )
+ {
+ Message_Add(CSG_String::Format(SG_T("\n\n\n%s: %d %s\n\n\n"), _TL("WARNING"), NDcountStat, _TL("NoData value(s) in statistic grid(s)!")));
+ }
+
+ return (true);
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Zonal_Statistics.h b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Zonal_Statistics.h
index f11d8c7..6ec8a09 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Zonal_Statistics.h
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/GSGrid_Zonal_Statistics.h
@@ -12,7 +12,7 @@
// //
// GSGrid_Zonal_Statistics.h //
// //
-// Copyright (C) 2005 by //
+// Copyright (C) 2005-9 by //
// Volker Wichmann //
// //
//-------------------------------------------------------//
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/MLB_Interface.cpp b/src/modules_geostatistics/geostatistics/geostatistics_grid/MLB_Interface.cpp
index f27d68a..37b3710 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_grid/MLB_Interface.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/MLB_Interface.cpp
@@ -74,16 +74,16 @@ const SG_Char * Get_Info(int i)
return( _TL("Geostatistics - Grids") );
case MLB_INFO_Author:
- return( _TL("Olaf Conrad, Volker Wichmann (c) 2002-5" ));
+ return( _TL("O.Conrad, V.Wichmann (c) 2002-10" ));
case MLB_INFO_Description:
- return( _TL("Tools for (geo)statistical analyses of grids.") );
+ return( _TL("Tools for (geo)statistical analyses.") );
case MLB_INFO_Version:
return( SG_T("1.0") );
case MLB_INFO_Menu_Path:
- return( _TL("Geostatistics|Grid") );
+ return( _TL("Geostatistics|Grids") );
}
}
@@ -91,13 +91,13 @@ const SG_Char * Get_Info(int i)
//---------------------------------------------------------
// 3. Include the headers of your modules here...
+#include "fast_representativeness.h"
#include "GSGrid_Residuals.h"
#include "GSGrid_Variance.h"
#include "GSGrid_Variance_Radius.h"
-#include "GSGrid_Regression.h"
-#include "GSGrid_Regression_Multiple.h"
#include "GSGrid_Statistics.h"
#include "GSGrid_Zonal_Statistics.h"
+#include "GSGrid_Directional_Statistics.h"
//---------------------------------------------------------
@@ -105,49 +105,18 @@ const SG_Char * Get_Info(int i)
CSG_Module * Create_Module(int i)
{
- // Don't forget to continuously enumerate the case switches
- // when adding new modules! Also bear in mind that the
- // enumeration always has to start with [case 0:] and
- // that [default:] must return NULL!...
-
- CSG_Module *pModule;
-
switch( i )
{
- case 0:
- pModule = new CGSGrid_Residuals;
- break;
-
- case 1:
- pModule = new CGSGrid_Variance;
- break;
-
- case 2:
- pModule = new CGSGrid_Variance_Radius;
- break;
-
- case 3:
- pModule = new CGSGrid_Regression;
- break;
-
- case 4:
- pModule = new CGSGrid_Regression_Multiple;
- break;
-
- case 5:
- pModule = new CGSGrid_Statistics;
- break;
-
- case 6:
- pModule = new CGSGrid_Zonal_Statistics;
- break;
-
- default:
- pModule = NULL;
- break;
+ case 0: return( new CFast_Representativeness );
+ case 1: return( new CGSGrid_Residuals );
+ case 2: return( new CGSGrid_Variance );
+ case 3: return( new CGSGrid_Variance_Radius );
+ case 4: return( new CGSGrid_Statistics );
+ case 5: return( new CGSGrid_Zonal_Statistics );
+ case 6: return( new CGSGrid_Directional_Statistics );
}
- return( pModule );
+ return( NULL );
}
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile.am b/src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile.am
index 010296b..1a4d303 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile.am
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:24 tschorr Exp $
+# $Id: Makefile.am,v 1.11 2010/07/08 14:11:51 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,19 +10,19 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgeostatistics_grid.la
libgeostatistics_grid_la_SOURCES =\
-GSGrid_Regression.cpp\
-GSGrid_Regression_Multiple.cpp\
+fast_representativeness.cpp\
+GSGrid_Directional_Statistics.cpp\
GSGrid_Residuals.cpp\
GSGrid_Statistics.cpp\
GSGrid_Variance.cpp\
GSGrid_Variance_Radius.cpp\
GSGrid_Zonal_Statistics.cpp\
MLB_Interface.cpp\
-GSGrid_Regression.h\
-GSGrid_Regression_Multiple.h\
+fast_representativeness.h\
+GSGrid_Directional_Statistics.h\
GSGrid_Residuals.h\
GSGrid_Statistics.h\
GSGrid_Variance.h\
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile.in b/src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile.in
index 2650092..90463a0 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile.in
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -69,14 +68,14 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)"
LTLIBRARIES = $(pkglib_LTLIBRARIES)
libgeostatistics_grid_la_DEPENDENCIES = \
$(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
-am_libgeostatistics_grid_la_OBJECTS = GSGrid_Regression.lo \
- GSGrid_Regression_Multiple.lo GSGrid_Residuals.lo \
+am_libgeostatistics_grid_la_OBJECTS = fast_representativeness.lo \
+ GSGrid_Directional_Statistics.lo GSGrid_Residuals.lo \
GSGrid_Statistics.lo GSGrid_Variance.lo \
GSGrid_Variance_Radius.lo GSGrid_Zonal_Statistics.lo \
MLB_Interface.lo
libgeostatistics_grid_la_OBJECTS = \
$(am_libgeostatistics_grid_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -122,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -131,6 +131,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -221,26 +222,26 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:24 tschorr Exp $
+# $Id: Makefile.am,v 1.11 2010/07/08 14:11:51 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgeostatistics_grid.la
libgeostatistics_grid_la_SOURCES = \
-GSGrid_Regression.cpp\
-GSGrid_Regression_Multiple.cpp\
+fast_representativeness.cpp\
+GSGrid_Directional_Statistics.cpp\
GSGrid_Residuals.cpp\
GSGrid_Statistics.cpp\
GSGrid_Variance.cpp\
GSGrid_Variance_Radius.cpp\
GSGrid_Zonal_Statistics.cpp\
MLB_Interface.cpp\
-GSGrid_Regression.h\
-GSGrid_Regression_Multiple.h\
+fast_representativeness.h\
+GSGrid_Directional_Statistics.h\
GSGrid_Residuals.h\
GSGrid_Statistics.h\
GSGrid_Variance.h\
@@ -323,14 +324,14 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GSGrid_Regression.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GSGrid_Regression_Multiple.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GSGrid_Directional_Statistics.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GSGrid_Residuals.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GSGrid_Statistics.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GSGrid_Variance.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GSGrid_Variance_Radius.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GSGrid_Zonal_Statistics.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/fast_representativeness.Plo at am__quote@
.cpp.o:
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/fast_representativeness.cpp b/src/modules_geostatistics/geostatistics/geostatistics_grid/fast_representativeness.cpp
new file mode 100644
index 0000000..68081f5
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/fast_representativeness.cpp
@@ -0,0 +1,601 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library //
+// imagery_segmentation //
+// //
+//-------------------------------------------------------//
+// //
+// fast_representativeness.cpp //
+// //
+// Copyright (C) 2009 //
+// Andre Ringeler //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: aringel at saga-gis.org //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "fast_representativeness.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define eps 1.0e-6
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CFast_Representativeness::CFast_Representativeness(void)
+{
+ Set_Name (_TL("Fast Representativeness"));
+
+ Set_Author (SG_T("A.Ringeler (c) 2009"));
+
+ Set_Description (_TW(
+ "A fast representativeness algorithm. Resulting seeds might be used with 'Fast Region Growing'.\n"
+ "\n"
+ "References:\n"
+ "Boehner, J., Selige, T., Ringeler, A. (2006): Image segmentation using representativeness analysis and region growing. "
+ "In: Boehner, J., McCloy, K.R., Strobl, J. [Eds.]: SAGA Analysis and Modelling Applications. "
+ "Goettinger Geographische Abhandlungen, Vol.115, "
+ "<a href=\"http://downloads.sourceforge.net/saga-gis/gga115_03.pdf\">pdf</a>\n"
+ ));
+
+ Parameters.Add_Grid( NULL, "INPUT" , _TL("Input"),
+ _TL("Input for module calculations."),
+ PARAMETER_INPUT, true, SG_DATATYPE_Float
+ );
+
+ Parameters.Add_Grid( NULL, "RESULT" , _TL("Output"),
+ _TL("Output of module calculations."),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid( NULL, "RESULT_LOD", _TL("Output Lod"),
+ _TL("Output of module calculations."),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid( NULL, "SEEDS" , _TL("Output Seeds"),
+ _TL("Output of module calculations."),
+ PARAMETER_OUTPUT, true, SG_DATATYPE_Char
+ );
+
+ Parameters.Add_Value( NULL, "LOD" , _TL("Level of Generalisation"),
+ _TL(""),
+ PARAMETER_TYPE_Double, 16, 1
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CFast_Representativeness::On_Execute(void)
+{
+ double Lod;
+ CSG_Grid *Lod_Grid, *Seeds_Grid;
+
+
+ pOrgInput = Parameters("INPUT")->asGrid();
+
+ pOutput = Parameters("RESULT")->asGrid();
+
+ Lod_Grid = Parameters("RESULT_LOD")->asGrid();
+
+ Seeds_Grid = Parameters("SEEDS")->asGrid();
+ Seeds_Grid ->Set_NoData_Value(0);
+ Seeds_Grid ->Assign(0.0);
+
+ Process_Set_Text(_TL("Init Fast Representativeness"));
+
+ FastRep_Initialize();
+
+ Process_Set_Text(_TL("Fast Representativeness"));
+
+ FastRep_Execute();
+
+ Process_Set_Text(_TL("Clear Fast Representativeness"));
+
+ FastRep_Finalize();
+
+ Lod = Parameters("LOD")->asDouble();
+
+
+ CSG_Grid * GenLevel = (CSG_Grid *) new CSG_Grid( SG_DATATYPE_Float,
+ (int)(pOrgInput->Get_NX()/Lod+1),
+ (int)(pOrgInput->Get_NY()/Lod+1),
+ pOrgInput->Get_Cellsize()*Lod,
+ pOrgInput->Get_XMin(),
+ pOrgInput->Get_YMin()
+ ) ;
+
+ CSG_Grid * GenLevelRep = (CSG_Grid *) new CSG_Grid( SG_DATATYPE_Float,
+ (int)(pOrgInput->Get_NX()/Lod+1),
+ (int)(pOrgInput->Get_NY()/Lod+1),
+ pOrgInput->Get_Cellsize()*Lod,
+ pOrgInput->Get_XMin(),
+ pOrgInput->Get_YMin()
+ ) ;
+
+ GenLevel->Assign(pOrgInput);
+
+
+
+
+ pOrgInput = GenLevel;
+ pOutput = GenLevelRep;
+
+ Process_Set_Text(_TL("Init Generalisation"));
+
+ FastRep_Initialize();
+
+ Process_Set_Text(_TL("Generalisation"));
+
+ FastRep_Execute();
+
+ Process_Set_Text(_TL("Clear Generalisation"));
+
+ FastRep_Finalize();
+
+ smooth_rep(pOutput,GenLevel );
+
+ Lod_Grid->Assign(GenLevel);
+
+ Find_Local_Maxima_Minima(Lod_Grid, Seeds_Grid);
+
+ return( true );
+}
+
+//---------------------------------------------------------
+// Repraesentanz stuff
+//---------------------------------------------------------
+
+//---------------------------------------------------------
+void CFast_Representativeness::FastRep_Local_Sum(CSG_Grid *pInput, CSG_Grid **pOutput)
+{
+ *pOutput = (CSG_Grid *) new CSG_Grid(SG_DATATYPE_Float,
+ pInput->Get_NX()/2,
+ pInput->Get_NY()/2,
+ pInput->Get_Cellsize()*2,
+ pInput->Get_Cellsize()*2);
+
+ for (int y = 0; y < pInput->Get_NY() - 1; y += 2)
+ for (int x = 0; x < pInput->Get_NX() - 1; x += 2)
+ {
+ float val;
+
+ if( pInput->is_NoData(x,y) || pInput->is_NoData(x + 1, y) || pInput->is_NoData(x, y + 1) || pInput->is_NoData(x + 1, y + 1))
+ {
+ (*pOutput)->Set_NoData(x/2, y/2);
+ }
+ else
+ {
+ val = pInput->asFloat(x, y)
+ + pInput->asFloat(x + 1, y)
+ + pInput->asFloat(x, y + 1)
+ + pInput->asFloat(x + 1, y + 1);
+
+ (*pOutput)->Set_Value(x/2, y/2, val);
+ }
+ }
+}
+
+//---------------------------------------------------------
+void CFast_Representativeness::FastRep_Execute(void)
+{
+ int x, y;
+ for (y = 0; y < pOutput->Get_NY()&&Set_Progress(y,pOutput->Get_NY()); y++)
+ {
+ for (x = 0; x < pOutput->Get_NX(); x++)
+ {
+ if( ! pOrgInput->is_NoData(x,y ))
+ pOutput->Set_Value(x, y, FastRep_Get_Laenge(x, y));
+ }
+ }
+}
+
+//---------------------------------------------------------
+void CFast_Representativeness::FastRep_Initialize(void)
+{
+
+ double logNx2,logNy2;
+ int pow2y, pow2x;
+ int x,y;
+ int i;
+ int size;
+
+ logNx2 = log((double)pOrgInput->Get_NX())/log(2.0f);
+
+ pow2x = (int) logNx2;
+
+ if (fabs(logNx2 - pow2x) > eps)
+ pow2x++;
+
+ logNy2 = log((double)pOrgInput->Get_NY())/log(2.0f);
+
+ pow2y = (int) logNy2;
+
+ if (fabs(logNy2 - pow2y) > eps)
+ pow2y++;
+
+ Pow2Grid = (CSG_Grid *) new CSG_Grid(SG_DATATYPE_Double, 1 << pow2x, 1 << pow2y);
+
+ for ( y = 0; y < Pow2Grid->Get_NY(); y++)
+ {
+ Set_Progress(y, Pow2Grid->Get_NY());
+
+ for ( x = 0; x < Pow2Grid->Get_NX(); x++)
+ {
+ if (y<pOrgInput->Get_NY() && x < pOrgInput->Get_NX())
+ Pow2Grid->Set_Value(x, y, pOrgInput->asFloat(x, y));
+ else
+ {
+ if(x >= pOrgInput->Get_NX()&&y<pOrgInput->Get_NY())
+ Pow2Grid->Set_Value(x, y,pOrgInput->asFloat(2*pOrgInput->Get_NX()-x-1, y));
+
+ if(y >= pOrgInput->Get_NY()&& x<pOrgInput->Get_NX())
+ Pow2Grid->Set_Value(x, y, pOrgInput->asFloat(x, 2* pOrgInput->Get_NY()-y-1));
+
+ if(y >= pOrgInput->Get_NY()&& x >= pOrgInput->Get_NX())
+ {
+ Pow2Grid->Set_Value(x, y, pOrgInput->asFloat(2*pOrgInput->Get_NX()-x-1, 2* pOrgInput->Get_NY()-y-1));
+ }
+ }
+ }
+ }
+
+ Pow2Grid->Normalise();
+
+ pOutput->Assign_NoData();
+
+ size = (int)(log((double)Pow2Grid->Get_NX())/log(2.0)) - 1;
+
+ m_deep = size;
+
+ Sum[0] = Pow2Grid;
+
+ for ( i = 0; i < size - 1; i++)
+ {
+ FastRep_Local_Sum(Sum[i], &Sum[i + 1]);
+ }
+
+ QSum[0] = (CSG_Grid *)new CSG_Grid(Pow2Grid, SG_DATATYPE_Double); // datas
+ QSum[0]->Assign(Pow2Grid);
+
+ for ( i = 0; i < Pow2Grid->Get_NCells() ; i++)
+ {
+ if (!QSum[0]->is_NoData(i))
+ QSum[0]->Set_Value(i,QSum[0]->asDouble(i)*Pow2Grid->asDouble(i));
+ }
+
+ for (i = 0; i < size - 1; i++)
+ {
+ Set_Progress(i,size - 1);
+ FastRep_Local_Sum(QSum[i], &QSum[i + 1]);
+ }
+
+ V =(double *) malloc((m_deep + 12) * sizeof(double));
+ Z =(int *) malloc((m_deep + 12) * sizeof(int));
+ g =(double *) malloc((m_deep + 12) * sizeof(double));
+ m =(double *) malloc((m_deep + 12) * sizeof(double));
+
+ maxRadius = 12;
+
+ rLength =(int *)malloc((maxRadius + 12) * sizeof(int));
+
+ for (i = 0; i < m_deep; i++)
+ {
+ g[i] = 1.0 / (Get_Cellsize() * (1 <<(i)));
+ }
+
+ FastRep_Init_Radius();
+}
+
+//---------------------------------------------------------
+void CFast_Representativeness::FastRep_Finalize(void)
+{
+ free(V);
+ free(Z);
+ free(rLength);
+ free(g);
+ free(m);
+ free(x_diff);
+ free(y_diff);
+ delete Pow2Grid;
+int i;
+ for (i = 0; i < m_deep ; i++)
+ delete QSum[i];
+
+ for (i = 1; i < m_deep ; i++)
+ delete Sum[i];
+}
+
+//---------------------------------------------------------
+void CFast_Representativeness::FastRep_Init_Radius(void)
+{
+ int k, maxZ;
+
+ long i, j, iijj, rr, r1r1, z;
+
+ maxZ = z = 0;
+ rLength[0] = 0;
+
+ x_diff = y_diff = NULL;
+
+ for (k = 1; k <= maxRadius; k++)
+ {
+ rr = k*k;
+ r1r1 =(k - 1) * (k - 1);
+
+ for (i=-k; i <= k; i++)
+ {
+ for (j=-k; j <= k; j++)
+ {
+ iijj = i*i + j*j;
+
+ if (iijj <= rr && iijj >= r1r1)
+ {
+ if (maxZ <= z)
+ {
+ maxZ += 1000;
+ x_diff =(int *)realloc(x_diff, maxZ*sizeof(int));
+ y_diff =(int *)realloc(y_diff, maxZ*sizeof(int));
+ }
+
+ x_diff[z] = j;
+ y_diff[z] = i;
+
+ z++;
+ }
+ }
+ }
+ rLength[k] = z;
+ }
+}
+
+
+//---------------------------------------------------------
+double CFast_Representativeness::FastRep_Get_Laenge(int x, int y)
+{
+ int Count;
+
+ double d;
+
+ V[0] = FastRep_Get_Variance(x, y, 1, 0, Count);
+ Z[0] = Count;
+int ideep;
+ for (ideep = 1; ideep < m_deep; ideep++)
+ {
+ V[ideep] = V[ideep - 1] + FastRep_Get_Variance(x, y, 4, ideep - 1, Count);
+ Z[ideep] = Z[ideep - 1] + Count;
+ }
+
+ for (ideep = 0; ideep < m_deep; ideep++)
+ {
+ V[ideep] =sqrt(V[ideep]/ (double)(Z[ideep]+1));
+ }
+
+ d = FastRep_Get_Steigung();
+
+ if ( d == 0.0 )
+ return ( pOutput->Get_NoData_Value());
+ else
+ return ( V[m_deep - 1] / d / 2.0 );
+
+}
+
+//---------------------------------------------------------
+double CFast_Representativeness::FastRep_Get_Variance(int x, int y, int iRadius, int deep, int &Count)
+{
+ int i, ix, iy;
+
+ double Variance;
+
+ double q = 0;
+ double s = 0;
+ int lnr = 0;
+
+ Variance = 0;
+
+ int size = (1 << deep) * (1 << deep);
+
+ double z = Sum[0]->asDouble(x, y);
+
+ for (i = rLength[iRadius - 1], Count = 0; i < rLength[iRadius]; i++)
+ {
+ ix = x/ (1 << deep) + x_diff[i];
+ if (ix < 0)
+ continue;
+ else if (ix >= Sum[deep]->Get_NX())
+ continue;
+
+ iy = y/ (1 << deep) + y_diff[i];
+ if (iy < 0)
+ continue;
+ else if (iy >= Sum[deep]->Get_NY())
+ continue;
+
+ if( !QSum[deep]->is_NoData(ix, iy))
+ {
+ Count += size;
+ lnr += size;
+
+ q += QSum[deep]->asDouble(ix, iy);
+ s += Sum[deep]->asDouble(ix, iy);
+ }
+ }
+
+ Variance = q + z* (-s - s +lnr*z);
+
+ if ( Variance < 0.0 ) Variance = 0.0;
+
+ return ( Variance );
+}
+
+//---------------------------------------------------------
+double CFast_Representativeness::FastRep_Get_Steigung()
+{
+ int i;
+ double summe_mg, summe_g;
+
+ m[0] = V[0] / Get_Cellsize();
+
+ for (i = 1; i < m_deep; i++)
+ {
+ m[i] =( V[i] - V[i-1] ) / ( Get_Cellsize()* (1 << (i) ) );
+ }
+
+ summe_mg = summe_g = 0;
+
+ for (i = 0; i < m_deep; i++)
+ {
+ summe_mg += m[i] * g[i];
+ summe_g += g[i];
+ }
+
+ return ( summe_mg / summe_g );
+}
+
+//---------------------------------------------------------
+void CFast_Representativeness::smooth_rep(CSG_Grid * in, CSG_Grid * out)
+{
+ int x,y;
+ int i,j;
+ int xpos, ypos;
+ double val;
+ int count;
+
+ for (y = 0; y < in->Get_NY(); y++)
+ for (x = 0; x < in->Get_NX(); x++)
+ {
+ val = 0.0;
+ count = 0;
+ for (i=-3; i<= 3; i++)
+ for (j=-3; j<= 3; j++)
+ {
+ xpos = x + j;
+ ypos = y + i;
+
+ if( in->is_InGrid(xpos,ypos))
+ {
+ val += in->asDouble(xpos , ypos);
+ count ++;
+ }
+ }
+
+ out ->Set_Value(x,y, val/(double) count );
+ }
+
+}
+
+//---------------------------------------------------------
+void CFast_Representativeness::Find_Local_Maxima_Minima(CSG_Grid * in, CSG_Grid * out)
+{
+ int x,y;
+ int i,j;
+ int xpos, ypos;
+
+ double max, min;
+
+ bool ismax ,ismin;
+ bool hasmax;
+
+ for (y = 2; y < in->Get_NY()-2; y++)
+ for (x = 2; x < in->Get_NX()-2; x++)
+ {
+ ismax = true;
+ ismin = true;
+ hasmax =false;
+
+ max =min = in->asDouble(x , y);
+
+ for (i=-2; i<= 2; i++)
+ for (j=-2; j<= 2; j++)
+ {
+ xpos = x + j;
+ ypos = y + i;
+
+ if (max < in->asDouble(xpos , ypos))
+ ismax= false;
+
+ if (min > in->asDouble(xpos , ypos))
+ ismin= false;
+
+ if(out ->asInt(xpos, ypos))
+ hasmax=true;
+ }
+
+ if (hasmax)
+
+ {
+ ismin = ismax =false;
+ }
+
+ if( ismax||ismin )
+ {
+ out ->Set_Value(x,y, 1);
+ }
+ else
+ {
+ out ->Set_NoData(x,y);
+ }
+ }
+}
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_grid/fast_representativeness.h b/src/modules_geostatistics/geostatistics/geostatistics_grid/fast_representativeness.h
new file mode 100644
index 0000000..f9abb99
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_grid/fast_representativeness.h
@@ -0,0 +1,111 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library //
+// imagery_segmentation //
+// //
+//-------------------------------------------------------//
+// //
+// fast_representativeness.h //
+// //
+// Copyright (C) 2009 //
+// Andre Ringeler //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: aringel at saga-gis.org //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Fast_Representativeness_H
+#define HEADER_INCLUDED__Fast_Representativeness_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CFast_Representativeness : public CSG_Module_Grid
+{
+public:
+ CFast_Representativeness(void);
+
+
+protected:
+
+ virtual bool On_Execute(void);
+
+
+private:
+
+ void FastRep_Local_Sum(CSG_Grid *pInput, CSG_Grid **pOutput);
+ void FastRep_Execute(void);
+ void FastRep_Initialize(void);
+ void FastRep_Init_Radius(void);
+ void FastRep_Finalize(void);
+ double FastRep_Get_Laenge(int x, int y);
+ double FastRep_Get_Variance(int x, int y, int iRadius, int deep, int &Count);
+ double FastRep_Get_Steigung();
+ void smooth_rep(CSG_Grid * in, CSG_Grid * out);
+ void Find_Local_Maxima_Minima(CSG_Grid * in, CSG_Grid * out);
+ CSG_Grid *pOrgInput, *Pow2Grid, *pOutput;
+
+ int *Z, *x_diff, *y_diff, *rLength;
+
+ CSG_Grid *Sum[16];
+ CSG_Grid *QSum[16];
+
+ double *V, *m, *g;
+ int m_deep;
+ int maxRadius;
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Fast_Representativeness_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/MLB_Interface.cpp b/src/modules_geostatistics/geostatistics/geostatistics_kriging/MLB_Interface.cpp
index f9d1c4b..b26c898 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/MLB_Interface.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/MLB_Interface.cpp
@@ -74,7 +74,7 @@ const SG_Char * Get_Info(int i)
return( _TL("Geostatistics - Kriging") );
case MLB_INFO_Author:
- return( SG_T("(c) 2003-08 by O.Conrad") );
+ return( SG_T("O.Conrad (c) 2003-10") );
case MLB_INFO_Description:
return( _TL("Kriging - geostatistical procedures for the gridding of irregular distributed point data." ));
@@ -83,7 +83,7 @@ const SG_Char * Get_Info(int i)
return( SG_T("1.0") );
case MLB_INFO_Menu_Path:
- return( _TL("Geostatistics" ));
+ return( _TL("Geostatistics|Kriging" ));
}
}
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile.am b/src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile.am
index d51b0bc..ef123cb 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile.am
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile.am
@@ -11,7 +11,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = $(DEP_LFLG)
+AM_LDFLAGS = $(DEP_LFLG) -avoid-version
pkglib_LTLIBRARIES = libgeostatistics_kriging.la
libgeostatistics_kriging_la_SOURCES =\
_kriging_base.cpp\
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile.in b/src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile.in
index 8079beb..1885ba9 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile.in
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/Makefile.in
@@ -42,7 +42,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -79,7 +78,7 @@ am_libgeostatistics_kriging_la_OBJECTS = _kriging_base.lo \
MLB_Interface.lo semivariogram.lo variogram_dialog.lo
libgeostatistics_kriging_la_OBJECTS = \
$(am_libgeostatistics_kriging_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -125,6 +124,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -134,6 +134,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -230,7 +231,7 @@ top_srcdir = @top_srcdir@
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = $(DEP_LFLG)
+AM_LDFLAGS = $(DEP_LFLG) -avoid-version
pkglib_LTLIBRARIES = libgeostatistics_kriging.la
libgeostatistics_kriging_la_SOURCES = \
_kriging_base.cpp\
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_base.cpp b/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_base.cpp
index 500d862..030596e 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_base.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_base.cpp
@@ -408,12 +408,15 @@ bool C_Kriging_Base::_Get_Points(void)
{
pShape = m_pShapes->Get_Shape(iShape);
- for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ if( !pShape->is_NoData(m_zField) )
{
- for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
{
- pPoint = pPoints->Add_Shape(pShape, SHAPE_COPY_ATTR);
- pPoint->Add_Point(pShape->Get_Point(iPoint, iPart));
+ for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ pPoint = pPoints->Add_Shape(pShape, SHAPE_COPY_ATTR);
+ pPoint->Add_Point(pShape->Get_Point(iPoint, iPart));
+ }
}
}
}
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_base.h b/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_base.h
index 6723cc0..07a2def 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_base.h
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_base.h
@@ -78,7 +78,7 @@ public:
C_Kriging_Base(void);
virtual ~C_Kriging_Base(void);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Kriging") ); }
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Without Variogram Fit") ); }
protected:
@@ -92,7 +92,7 @@ protected:
double m_Block;
- CSG_Points_3D m_Points;
+ CSG_Points_Z m_Points;
CSG_Vector m_G;
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_ordinary_global.cpp b/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_ordinary_global.cpp
index 8694c40..c0c0e81 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_ordinary_global.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_ordinary_global.cpp
@@ -169,15 +169,18 @@ bool C_Kriging_Ordinary_Global::Get_Weights(void)
{
CSG_Shape *pShape = m_pShapes->Get_Shape(iShape);
- for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ if( !pShape->is_NoData(m_zField) )
{
- for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
{
- m_Points.Add(
- pShape->Get_Point(iPoint, iPart).x,
- pShape->Get_Point(iPoint, iPart).y,
- pShape->asDouble(m_zField)
- );
+ for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ m_Points.Add(
+ pShape->Get_Point(iPoint, iPart).x,
+ pShape->Get_Point(iPoint, iPart).y,
+ pShape->asDouble(m_zField)
+ );
+ }
}
}
}
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_universal_global.cpp b/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_universal_global.cpp
index d635b8c..3efc3ca 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_universal_global.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/_kriging_universal_global.cpp
@@ -201,15 +201,28 @@ bool C_Kriging_Universal_Global::Get_Weights(void)
{
CSG_Shape *pShape = m_pShapes->Get_Shape(iShape);
- for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ if( !pShape->is_NoData(m_zField) )
{
- for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
{
- m_Points.Add(
- pShape->Get_Point(iPoint, iPart).x,
- pShape->Get_Point(iPoint, iPart).y,
- pShape->asDouble(m_zField)
- );
+ for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ bool bAdd;
+ CSG_Point p(pShape->Get_Point(iPoint, iPart));
+
+ for(j=0, bAdd=true; j<nGrids && bAdd; j++)
+ {
+ if( !m_pGrids->asGrid(j)->is_InGrid_byPos(p) )
+ {
+ bAdd = false;
+ }
+ }
+
+ if( bAdd )
+ {
+ m_Points.Add(p.Get_X(), p.Get_Y(), pShape->asDouble(m_zField));
+ }
+ }
}
}
}
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_base.cpp b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_base.cpp
index 56c9ecb..be383f6 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_base.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_base.cpp
@@ -88,36 +88,27 @@ CKriging_Base::CKriging_Base(void)
);
//-----------------------------------------------------
- Parameters.Add_Grid_Output(
- NULL , "GRID" , _TL("Grid"),
- _TL("")
- );
-
- Parameters.Add_Grid_Output(
- NULL , "VARIANCE" , _TL("Variance"),
- _TL("")
- );
-
- Parameters.Add_Value(
- NULL , "BVARIANCE" , _TL("Create Variance Grid"),
- _TL(""),
- PARAMETER_TYPE_Bool , true
- );
-
Parameters.Add_Choice(
NULL , "TARGET" , _TL("Target Grid"),
_TL(""),
-
- CSG_String::Format(SG_T("%s|%s|%s|"),
+ CSG_String::Format(SG_T("%s|%s|"),
_TL("user defined"),
- _TL("grid system"),
_TL("grid")
), 0
);
+ Parameters.Add_Choice(
+ NULL , "TQUALITY" , _TL("Type of Quality Measure"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("standard deviation"),
+ _TL("variance")
+ ), 0
+ );
+
//-----------------------------------------------------
pNode = Parameters.Add_Node(
- NULL , "VARIOGRAM" , _TL("Semi-Variogram"),
+ NULL , "VARIOGRAM" , _TL("Variogram"),
_TL("")
);
@@ -140,83 +131,67 @@ CKriging_Base::CKriging_Base(void)
);
//-----------------------------------------------------
- Parameters.Add_Value(
+ pNode = Parameters.Add_Value(
NULL , "BLOCK" , _TL("Block Kriging"),
_TL(""),
PARAMETER_TYPE_Bool , false
);
Parameters.Add_Value(
- NULL , "DBLOCK" , _TL("Block Size"),
+ pNode , "DBLOCK" , _TL("Block Size"),
_TL(""),
PARAMETER_TYPE_Double , 100.0, 0.0, true
);
+ ///////////////////////////////////////////////////////
//-----------------------------------------------------
- pParameters = Add_Parameters(SG_T("USER") , _TL("User defined grid") , _TL(""));
+ pParameters = Add_Parameters(SG_T("FORMULA"), _TL("Formula"), _TL(""));
- pParameters->Add_Value(
- NULL , "CELL_SIZE" , _TL("Grid Size"),
+ pParameters->Add_String(
+ NULL , "STRING" , _TL("Formula String"),
_TL(""),
- PARAMETER_TYPE_Double, 100.0, 0.0, true
- );
-
- pParameters->Add_Range(
- pNode , "X_EXTENT" , _TL("X-Extent"),
- _TL("")
- );
-
- pParameters->Add_Range(
- pNode , "Y_EXTENT" , _TL("Y-Extent"),
- _TL("")
- );
-
- //-----------------------------------------------------
- pParameters = Add_Parameters(SG_T("SYSTEM") , _TL("Choose Grid System") , _TL(""));
-
- pParameters->Add_Grid_System(
- NULL , "SYSTEM" , _TL("Grid System"),
- _TL("")
+ SG_T("a + b * x")
);
+ ///////////////////////////////////////////////////////
//-----------------------------------------------------
- pParameters = Add_Parameters(SG_T("GRID") , _TL("Choose Grid") , _TL(""));
+ pParameters = Add_Parameters("USER", _TL("User Defined Grid") , _TL(""));
- pNode = pParameters->Add_Grid_System(
- NULL , "SYSTEM" , _TL("Grid System"),
- _TL("")
- );
-
- pParameters->Add_Grid(
- pNode , "GRID" , _TL("Grid"),
+ pParameters->Add_Value(
+ NULL , "BVARIANCE" , _TL("Create Quality Grid"),
_TL(""),
- PARAMETER_OUTPUT, false
+ PARAMETER_TYPE_Bool, true
);
- pParameters->Add_Grid(
- pNode , "VARIANCE" , _TL("Variance"),
- _TL(""),
- PARAMETER_OUTPUT_OPTIONAL, false
- );
+ m_Grid_Target.Add_Parameters_User(pParameters);
//-----------------------------------------------------
- pParameters = Add_Parameters(SG_T("FORMULA"), _TL("Formula"), _TL(""));
+ pParameters = Add_Parameters("GRID", _TL("Choose Grid") , _TL(""));
- pParameters->Add_String(
- NULL , "STRING" , _TL("Formula String"),
- _TL(""),
- SG_T("a + b * x")
- );
+ m_Grid_Target.Add_Parameters_Grid(pParameters);
+
+ //-----------------------------------------------------
+ m_Grid_Target.Add_Grid_Parameter(SG_T("VARIANCE"), _TL("Quality Measure"), true);
+ ///////////////////////////////////////////////////////
//-----------------------------------------------------
m_Variances.Add_Field(SG_T("DISTANCE") , SG_DATATYPE_Double);
m_Variances.Add_Field(SG_T("VAR_CUM") , SG_DATATYPE_Double);
m_Variances.Add_Field(SG_T("VAR_CLS") , SG_DATATYPE_Double);
}
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
-CKriging_Base::~CKriging_Base(void)
-{}
+int CKriging_Base::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ return( m_Grid_Target.On_User_Changed(pParameters, pParameter) ? 1 : 0 );
+}
///////////////////////////////////////////////////////////
@@ -278,6 +253,7 @@ bool CKriging_Base::_Initialise(void)
//-----------------------------------------------------
m_Block = Parameters("DBLOCK") ->asDouble() / 2.0;
m_bBlock = Parameters("BLOCK") ->asBool() && m_Block > 0.0;
+ m_bStdDev = Parameters("TQUALITY")->asInt() == 0;
//-----------------------------------------------------
m_pPoints = Parameters("POINTS") ->asShapes();
@@ -297,85 +273,47 @@ bool CKriging_Base::_Initialise(void)
//---------------------------------------------------------
bool CKriging_Base::_Initialise_Grids(void)
{
- TSG_Rect r;
- CSG_Parameters *P;
-
//-----------------------------------------------------
m_pGrid = NULL;
m_pVariance = NULL;
- //-----------------------------------------------------
switch( Parameters("TARGET")->asInt() )
{
case 0: // user defined...
- r = m_pPoints->Get_Extent();
- P = Get_Parameters("USER");
-
- P->Get_Parameter("X_EXTENT")->asRange()->Set_LoVal(r.xMin);
- P->Get_Parameter("Y_EXTENT")->asRange()->Set_LoVal(r.yMin);
- P->Get_Parameter("X_EXTENT")->asRange()->Set_HiVal(r.xMax);
- P->Get_Parameter("Y_EXTENT")->asRange()->Set_HiVal(r.yMax);
-
- if( Dlg_Parameters("USER") )
+ if( m_Grid_Target.Init_User(m_pPoints->Get_Extent()) && Dlg_Parameters("USER") )
{
- r.xMin = P->Get_Parameter("X_EXTENT")->asRange()->Get_LoVal();
- r.yMin = P->Get_Parameter("Y_EXTENT")->asRange()->Get_LoVal();
- r.xMax = P->Get_Parameter("X_EXTENT")->asRange()->Get_HiVal();
- r.yMax = P->Get_Parameter("Y_EXTENT")->asRange()->Get_HiVal();
-
- double d = P->Get_Parameter("CELL_SIZE")->asDouble();
- int nx = 1 + (int)((r.xMax - r.xMin) / d);
- int ny = 1 + (int)((r.yMax - r.yMin) / d);
+ m_pGrid = m_Grid_Target.Get_User();
- if( nx > 1 && ny > 1 )
+ if( Get_Parameters("USER")->Get_Parameter("BVARIANCE")->asBool() )
{
- m_pGrid = SG_Create_Grid(SG_DATATYPE_Float, nx, ny, d, r.xMin, r.yMin);
+ m_pVariance = m_Grid_Target.Get_User(SG_T("VARIANCE"));
}
}
break;
- case 1: // grid system...
- if( Dlg_Parameters("SYSTEM") )
- {
- m_pGrid = SG_Create_Grid(*Get_Parameters("SYSTEM")->Get_Parameter("SYSTEM")->asGrid_System(), SG_DATATYPE_Float);
- }
- break;
-
- case 2: // grid...
+ case 1: // grid...
if( Dlg_Parameters("GRID") )
{
- m_pGrid = Get_Parameters("GRID")->Get_Parameter("GRID") ->asGrid();
- m_pVariance = Get_Parameters("GRID")->Get_Parameter("VARIANCE") ->asGrid();
+ m_pGrid = m_Grid_Target.Get_Grid();
+ m_pVariance = m_Grid_Target.Get_Grid(SG_T("VARIANCE"));
}
break;
}
- //-----------------------------------------------------
- if( m_pGrid )
+ if( !m_pGrid )
{
- if( !m_pVariance && Parameters("BVARIANCE")->asBool() )
- {
- m_pVariance = SG_Create_Grid(m_pGrid, SG_DATATYPE_Float);
- }
-
- m_pGrid->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_pPoints->Get_Name(), Get_Name()));
- Parameters("GRID")->Set_Value(m_pGrid);
-
- if( m_pVariance )
- {
- m_pVariance->Set_Name(CSG_String::Format(SG_T("%s (%s - %s)"), m_pPoints->Get_Name(), Get_Name(), _TL("Variance")));
- Parameters("VARIANCE")->Set_Value(m_pVariance);
- }
+ return( false );
+ }
- if( Parameters("TARGET")->asInt() == 2 )
- {
- Get_Parameters("GRID")->Get_Parameter("VARIANCE")->Set_Value(m_pVariance);
- }
+ //-----------------------------------------------------
+ m_pGrid->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_pPoints->Get_Name(), Get_Name()));
- return( true );
+ if( m_pVariance )
+ {
+ m_pVariance->Set_Name(CSG_String::Format(SG_T("%s (%s - %s)"), m_pPoints->Get_Name(), Get_Name(), m_bStdDev ? _TL("Standard Deviation") : _TL("Variance")));
}
- return( false );
+ return( true );
}
//---------------------------------------------------------
@@ -416,7 +354,7 @@ bool CKriging_Base::_Interpolate(void)
if( m_pVariance )
{
- m_pVariance->Set_Value(ix, iy, v);
+ m_pVariance->Set_Value(ix, iy, m_bStdDev ? sqrt(v) : v);
}
}
else
@@ -486,24 +424,32 @@ bool CKriging_Base::_Get_Variances(void)
for(i=0, n=0; i<m_pPoints->Get_Count()-nSkip && Set_Progress(n, SG_Get_Square(m_pPoints->Get_Count()/nSkip)/2); i+=nSkip)
{
pPoint = m_pPoints->Get_Shape(i);
- Pt_i = pPoint->Get_Point(0);
- z = pPoint->asDouble(m_zField);
- for(j=i+nSkip; j<m_pPoints->Get_Count(); j+=nSkip, n++)
+ if( !pPoint->is_NoData(m_zField) )
{
- pPoint = m_pPoints->Get_Shape(j);
- Pt_j = pPoint->Get_Point(0);
- dx = Pt_j.x - Pt_i.x;
- dy = Pt_j.y - Pt_i.y;
- d = sqrt(dx*dx + dy*dy);
- k = (int)(d / lagDistance);
-
- if( k < nDistances )
+ Pt_i = pPoint->Get_Point(0);
+ z = pPoint->asDouble(m_zField);
+
+ for(j=i+nSkip; j<m_pPoints->Get_Count(); j+=nSkip, n++)
{
- d = pPoint->asDouble(m_zField) - z;
+ pPoint = m_pPoints->Get_Shape(j);
- Count [k] ++;
- Variance[k] += d * d;
+ if( !pPoint->is_NoData(m_zField) )
+ {
+ Pt_j = pPoint->Get_Point(0);
+ dx = Pt_j.x - Pt_i.x;
+ dy = Pt_j.y - Pt_i.y;
+ d = sqrt(dx*dx + dy*dy);
+ k = (int)(d / lagDistance);
+
+ if( k < nDistances )
+ {
+ d = pPoint->asDouble(m_zField) - z;
+
+ Count [k] ++;
+ Variance[k] += d * d;
+ }
+ }
}
}
}
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_base.h b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_base.h
index 5f90041..b882844 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_base.h
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_base.h
@@ -83,60 +83,61 @@ class geostatistics_kriging_EXPORT CKriging_Base : public CSG_Module
{
public:
CKriging_Base(void);
- virtual ~CKriging_Base(void);
-
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Kriging with Variogram Fit") ); }
protected:
- bool m_bBlock;
+ bool m_bBlock;
+
+ int m_zField;
- int m_zField;
+ double m_Block;
- double m_Block;
+ CSG_Points_Z m_Points;
- CSG_Points_3D m_Points;
+ CSG_Vector m_G;
- CSG_Vector m_G;
+ CSG_Matrix m_W;
- CSG_Matrix m_W;
+ CSG_PRQuadTree m_Search;
- CSG_PRQuadTree m_Search;
+ CSG_Shapes *m_pPoints;
- CSG_Shapes *m_pPoints;
+ virtual bool On_Execute (void);
- virtual bool On_Execute (void);
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
- virtual bool On_Initialise (void) { return( true ); }
+ virtual bool On_Initialise (void) { return( true ); }
- virtual bool Get_Value (double x, double y, double &z, double &Variance) = 0;
+ virtual bool Get_Value (double x, double y, double &z, double &Variance) = 0;
- double Get_Weight (double d) { return( m_Variogram.Get_Value(d) ); }
- double Get_Weight (double dx, double dy) { return( m_Variogram.Get_Value(sqrt(dx*dx + dy*dy)) ); }
+ double Get_Weight (double d) { return( m_Variogram.Get_Value(d) ); }
+ double Get_Weight (double dx, double dy) { return( m_Variogram.Get_Value(sqrt(dx*dx + dy*dy)) ); }
private:
- CSG_Table m_Variances;
+ bool m_bStdDev;
- CSG_Trend m_Variogram;
+ CSG_Parameters_Grid_Target m_Grid_Target;
- CSG_Grid *m_pGrid, *m_pVariance;
+ CSG_Table m_Variances;
+ CSG_Trend m_Variogram;
- bool _Initialise (void);
- bool _Initialise_Grids (void);
- bool _Finalise (void);
+ CSG_Grid *m_pGrid, *m_pVariance;
- bool _Interpolate (void);
- bool _Get_Variances (void);
+ bool _Initialise (void);
+ bool _Initialise_Grids (void);
+ bool _Finalise (void);
-};
+ bool _Interpolate (void);
-#endif // #ifndef HEADER_INCLUDED__kriging_base_H
+ bool _Get_Variances (void);
+
+};
///////////////////////////////////////////////////////////
@@ -146,3 +147,4 @@ private:
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__kriging_base_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_ordinary_global.cpp b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_ordinary_global.cpp
index 7a7024b..255a08c 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_ordinary_global.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_ordinary_global.cpp
@@ -169,11 +169,14 @@ bool CKriging_Ordinary_Global::Get_Weights(void)
{
CSG_Shape *pPoint = m_pPoints->Get_Shape(i);
- m_Points.Add(
- pPoint->Get_Point(0).x,
- pPoint->Get_Point(0).y,
- pPoint->asDouble(m_zField)
- );
+ if( !pPoint->is_NoData(m_zField) )
+ {
+ m_Points.Add(
+ pPoint->Get_Point(0).x,
+ pPoint->Get_Point(0).y,
+ pPoint->asDouble(m_zField)
+ );
+ }
}
//-----------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal.cpp b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal.cpp
index d776370..2fd2fec 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal.cpp
@@ -126,7 +126,32 @@ bool CKriging_Universal::On_Initialise(void)
m_Mode = Parameters("MODE") ->asInt();
//-----------------------------------------------------
- if( !m_Search.Create(m_pPoints, m_zField) )
+ m_Search.Create(m_pPoints->Get_Extent());
+
+ for(int iPoint=0; iPoint<m_pPoints->Get_Count() && Set_Progress(iPoint, m_pPoints->Get_Count()); iPoint++)
+ {
+ CSG_Shape *pPoint = m_pPoints->Get_Shape(iPoint);
+
+ if( !pPoint->is_NoData(m_zField) )
+ {
+ bool bAdd = true;
+
+ for(int iGrid=0; iGrid<m_pGrids->Get_Count(); iGrid++)
+ {
+ if( !m_pGrids->asGrid(iGrid)->is_InGrid_byPos(pPoint->Get_Point(0)) )
+ {
+ bAdd = false;
+ }
+ }
+
+ if( bAdd )
+ {
+ m_Search.Add_Point(pPoint->Get_Point(0).x, pPoint->Get_Point(0).y, pPoint->asDouble(m_zField));
+ }
+ }
+ }
+
+ if( !m_Search.is_Okay() )
{
SG_UI_Msg_Add(_TL("could not initialize point search engine"), true);
@@ -143,8 +168,9 @@ bool CKriging_Universal::On_Initialise(void)
}
m_Points.Set_Count (nPoints_Max);
- m_G .Create (nPoints_Max + 1 + m_pGrids->Get_Count());
- m_W .Create (nPoints_Max + 1 + m_pGrids->Get_Count(), nPoints_Max + 1 + m_pGrids->Get_Count());
+ m_G .Create (nPoints_Max + 1 + m_pGrids->Get_Count() + (m_bCoords ? 2 : 0));
+ m_W .Create (nPoints_Max + 1 + m_pGrids->Get_Count() + (m_bCoords ? 2 : 0),
+ nPoints_Max + 1 + m_pGrids->Get_Count() + (m_bCoords ? 2 : 0));
return( true );
}
@@ -159,12 +185,15 @@ bool CKriging_Universal::On_Initialise(void)
//---------------------------------------------------------
bool CKriging_Universal::Get_Value(double x, double y, double &z, double &v)
{
- int i, j, n, nGrids;
+ int i, j, n, nGrids, nCoords;
double Lambda;
//-----------------------------------------------------
- if( (n = Get_Weights(x, y)) > 0 && (nGrids = m_pGrids->Get_Count()) > 0 )
+ if( (n = Get_Weights(x, y)) > 1 )
{
+ nCoords = m_bCoords ? 2 : 0;
+ nGrids = m_pGrids->Get_Count();
+
for(i=0; i<n; i++)
{
if( !m_bBlock )
@@ -191,10 +220,15 @@ bool CKriging_Universal::Get_Value(double x, double y, double &z, double &v)
}
}
+ for(i=0, j=n+1+nGrids; i<nCoords; i++, j++)
+ {
+ m_G[j] = i == 0 ? x : y;
+ }
+
//-------------------------------------------------
for(i=0, z=0.0, v=0.0; i<n; i++)
{
- for(j=0, Lambda=0.0; j<=n+nGrids; j++)
+ for(j=0, Lambda=0.0; j<=n+nGrids+nCoords; j++)
{
Lambda += m_W[i][j] * m_G[j];
}
@@ -220,7 +254,7 @@ bool CKriging_Universal::Get_Value(double x, double y, double &z, double &v)
//---------------------------------------------------------
int CKriging_Universal::Get_Weights(double x, double y)
{
- int i, j, n, iGrid, nGrids = m_pGrids->Get_Count();
+ int i, j, k, n, nGrids, nCoords;
//-----------------------------------------------------
switch( m_Mode )
@@ -232,6 +266,9 @@ int CKriging_Universal::Get_Weights(double x, double y)
//-----------------------------------------------------
if( n >= m_nPoints_Min )
{
+ nCoords = m_bCoords ? 2 : 0;
+ nGrids = m_pGrids->Get_Count();
+
for(i=0; i<n; i++)
{
m_Search.Get_Selected_Point(i, m_Points[i].x, m_Points[i].y, m_Points[i].z);
@@ -251,23 +288,28 @@ int CKriging_Universal::Get_Weights(double x, double y)
);
}
- for(iGrid=0, j=n+1; iGrid<nGrids; iGrid++, j++)
+ for(k=0, j=n+1; k<nGrids; k++, j++)
{
- m_W[i][j] = m_W[j][i] = m_pGrids->asGrid(iGrid)->Get_Value(
+ m_W[i][j] = m_W[j][i] = m_pGrids->asGrid(k)->Get_Value(
m_Points[i].x, m_Points[i].y, m_Interpolation
);
}
+
+ for(k=0, j=n+nGrids+1; k<nCoords; k++, j++)
+ {
+ m_W[i][j] = m_W[j][i] = k == 0 ? m_Points[i].x : m_Points[i].y;
+ }
}
- for(i=n; i<=n+nGrids; i++)
+ for(i=n; i<=n+nGrids+nCoords; i++)
{
- for(j=n; j<=n+nGrids; j++)
+ for(j=n; j<=n+nGrids+nCoords; j++)
{
m_W[i][j] = 0.0;
}
}
- if( m_W.Set_Inverse(true, n + 1 + nGrids) )
+ if( m_W.Set_Inverse(true, n + 1 + nGrids + nCoords) )
{
return( n );
}
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal.h b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal.h
index 42c391c..c31d296 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal.h
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal.h
@@ -99,6 +99,8 @@ private:
double m_Radius;
+ CSG_Grid m_Mask;
+
int Get_Weights (double x, double y);
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal_global.cpp b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal_global.cpp
index fd7139b..d2d2ee0 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal_global.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal_global.cpp
@@ -82,14 +82,19 @@ CKriging_Universal_Global::CKriging_Universal_Global(void)
));
//-----------------------------------------------------
+ CSG_Parameter *pNode = Parameters.Add_Node(
+ NULL , "NODE_UK" , _TL("Universal Kriging"),
+ _TL("")
+ );
+
Parameters.Add_Grid_List(
- NULL , "GRIDS" , _TL("Grids"),
+ pNode , "GRIDS" , _TL("Grids"),
_TL(""),
- PARAMETER_INPUT
+ PARAMETER_INPUT_OPTIONAL, false
);
Parameters.Add_Choice(
- NULL ,"INTERPOL" , _TL("Grid Interpolation"),
+ pNode ,"INTERPOL" , _TL("Grid Interpolation"),
_TL(""),
CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"),
_TL("Nearest Neighbor"),
@@ -99,6 +104,12 @@ CKriging_Universal_Global::CKriging_Universal_Global(void)
_TL("B-Spline Interpolation")
), 4
);
+
+ Parameters.Add_Value(
+ pNode , "COORDS" , _TL("Coordinates"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, false
+ );
}
//---------------------------------------------------------
@@ -117,6 +128,7 @@ bool CKriging_Universal_Global::On_Initialise(void)
{
m_pGrids = Parameters("GRIDS") ->asGridList();
m_Interpolation = Parameters("INTERPOL") ->asInt();
+ m_bCoords = Parameters("COORDS") ->asBool();
return( Get_Weights() );
}
@@ -131,12 +143,15 @@ bool CKriging_Universal_Global::On_Initialise(void)
//---------------------------------------------------------
bool CKriging_Universal_Global::Get_Value(double x, double y, double &z, double &v)
{
- int i, j, n, nGrids;
+ int i, j, n, nGrids, nCoords;
double Lambda;
//-----------------------------------------------------
- if( (n = m_Points.Get_Count()) > 1 && (nGrids = m_pGrids->Get_Count()) > 0 )
+ if( (n = m_Points.Get_Count()) > 1 )
{
+ nCoords = m_bCoords ? 2 : 0;
+ nGrids = m_pGrids->Get_Count();
+
for(i=0; i<n; i++)
{
if( !m_bBlock )
@@ -163,10 +178,15 @@ bool CKriging_Universal_Global::Get_Value(double x, double y, double &z, double
}
}
+ for(i=0, j=n+1+nGrids; i<nCoords; i++, j++)
+ {
+ m_G[j] = i == 0 ? x : y;
+ }
+
//-------------------------------------------------
for(i=0, z=0.0, v=0.0; i<n; i++)
{
- for(j=0, Lambda=0.0; j<=n+nGrids; j++)
+ for(j=0, Lambda=0.0; j<=n+nGrids+nCoords; j++)
{
Lambda += m_W[i][j] * m_G[j];
}
@@ -192,62 +212,79 @@ bool CKriging_Universal_Global::Get_Value(double x, double y, double &z, double
//---------------------------------------------------------
bool CKriging_Universal_Global::Get_Weights(void)
{
- int i, j, n, iGrid, nGrids;
+ int i, j, k, n, nGrids, nCoords;
//-----------------------------------------------------
- if( (nGrids = m_pGrids->Get_Count()) > 0 )
+ nCoords = m_bCoords ? 2 : 0;
+ nGrids = m_pGrids->Get_Count();
+
+ for(i=0; i<m_pPoints->Get_Count(); i++)
{
- for(i=0; i<m_pPoints->Get_Count(); i++)
+ CSG_Shape *pPoint = m_pPoints->Get_Shape(i);
+
+ if( !pPoint->is_NoData(m_zField) )
{
- CSG_Shape *pPoint = m_pPoints->Get_Shape(i);
+ bool bAdd;
+
+ for(j=0, bAdd=true; j<nGrids && bAdd; j++)
+ {
+ if( !m_pGrids->asGrid(j)->is_InGrid_byPos(pPoint->Get_Point(0)) )
+ {
+ bAdd = false;
+ }
+ }
- m_Points.Add(
- pPoint->Get_Point(0).x,
- pPoint->Get_Point(0).y,
- pPoint->asDouble(m_zField)
- );
+ if( bAdd )
+ {
+ m_Points.Add(pPoint->Get_Point(0).x, pPoint->Get_Point(0).y, pPoint->asDouble(m_zField));
+ }
}
+ }
- //-------------------------------------------------
- if( (n = m_Points.Get_Count()) > 1 )
+ //-----------------------------------------------------
+ if( (n = m_Points.Get_Count()) > 1 )
+ {
+ m_G.Create(n + 1 + nGrids + nCoords);
+ m_W.Create(n + 1 + nGrids + nCoords, n + 1 + nGrids + nCoords);
+
+ for(i=0; i<n; i++)
{
- m_G.Create(n + 1 + nGrids);
- m_W.Create(n + 1 + nGrids, n + 1 + nGrids);
+ m_W[i][i] = 0.0; // diagonal...
+ m_W[i][n] = m_W[n][i] = 1.0; // edge...
- for(i=0; i<n; i++)
+ for(j=i+1; j<n; j++)
{
- m_W[i][i] = 0.0; // diagonal...
- m_W[i][n] = m_W[n][i] = 1.0; // edge...
-
- for(j=i+1; j<n; j++)
- {
- m_W[i][j] = m_W[j][i] = Get_Weight(
- m_Points[i].x - m_Points[j].x,
- m_Points[i].y - m_Points[j].y
- );
- }
+ m_W[i][j] = m_W[j][i] = Get_Weight(
+ m_Points[i].x - m_Points[j].x,
+ m_Points[i].y - m_Points[j].y
+ );
+ }
- for(iGrid=0, j=n+1; iGrid<nGrids; iGrid++, j++)
- {
- m_W[i][j] = m_W[j][i] = m_pGrids->asGrid(iGrid)->Get_Value(
- m_Points[i].x, m_Points[i].y, m_Interpolation
- );
- }
+ for(k=0, j=n+1; k<nGrids; k++, j++)
+ {
+ m_W[i][j] = m_W[j][i] = m_pGrids->asGrid(k)->Get_Value(
+ m_Points[i].x, m_Points[i].y, m_Interpolation
+ );
}
- for(i=n; i<=n+nGrids; i++)
+ for(k=0, j=n+nGrids+1; k<nCoords; k++, j++)
{
- for(j=n; j<=n+nGrids; j++)
- {
- m_W[i][j] = 0.0;
- }
+ m_W[i][j] = m_W[j][i] = k == 0 ? m_Points[i].x : m_Points[i].y;
}
+ }
- return( m_W.Set_Inverse() );
+ for(i=n; i<=n+nGrids+nCoords; i++)
+ {
+ for(j=n; j<=n+nGrids+nCoords; j++)
+ {
+ m_W[i][j] = 0.0;
+ }
}
+
+ return( m_W.Set_Inverse() );
}
- return( 0 );
+ return( false );
}
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal_global.h b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal_global.h
index 376dcb8..9dd4d42 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal_global.h
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/kriging_universal_global.h
@@ -88,6 +88,8 @@ public:
protected:
+ bool m_bCoords;
+
int m_Interpolation;
CSG_Parameter_Grid_List *m_pGrids;
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/semivariogram.cpp b/src/modules_geostatistics/geostatistics/geostatistics_kriging/semivariogram.cpp
index df7bf32..196479b 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/semivariogram.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/semivariogram.cpp
@@ -91,9 +91,9 @@ CSemiVariogram::CSemiVariogram(void)
CSG_Parameter *pNode;
//-----------------------------------------------------
- Set_Name (_TL("Semivariogram (Dialog))"));
+ Set_Name (_TL("Variogram (Dialog))"));
- Set_Author (SG_T("(c) 2009 by O.Conrad"));
+ Set_Author (SG_T("O.Conrad (c) 2009"));
Set_Description(
_TL("")
@@ -241,7 +241,7 @@ bool CSemiVariogram::Get_Variances(CSG_Table *pTable, CSG_Shapes *pPoints, int A
if( maxDistance <= 0.0 )
{
- maxDistance = SG_Get_Length(pPoints->Get_Extent().Get_XRange(), pPoints->Get_Extent().Get_XRange());
+ maxDistance = SG_Get_Length(pPoints->Get_Extent().Get_XRange(), pPoints->Get_Extent().Get_YRange());
}
lagDistance = maxDistance / nDistances;
@@ -296,7 +296,7 @@ bool CSemiVariogram::Get_Variances(CSG_Table *pTable, CSG_Shapes *pPoints, int A
{
if( Count[i] > 0 )
{
- n += Count[i];
+ n += (int)Count[i];
z += Variance[i];
pRecord = pTable->Add_Record();
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/semivariogram.h b/src/modules_geostatistics/geostatistics/geostatistics_kriging/semivariogram.h
index b66550a..bdbf103 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/semivariogram.h
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/semivariogram.h
@@ -76,7 +76,7 @@ class CSemiVariogram : public CSG_Module
public:
CSemiVariogram(void);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Points") ); }
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("A:Geostatistics|Points") ); }
protected:
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_kriging/variogram_dialog.cpp b/src/modules_geostatistics/geostatistics/geostatistics_kriging/variogram_dialog.cpp
index 7c49a8c..59812d1 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_kriging/variogram_dialog.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_kriging/variogram_dialog.cpp
@@ -288,7 +288,7 @@ void CVariogram_Dialog::Fit_Function(void)
s += m_pDiagram->m_pVariogram->Get_Formula(SG_TREND_STRING_Function).c_str();
s += wxString::Format(wxT("\n%s: %.*f") , _TL("Fitting range") , SG_Get_Significant_Decimals(m_pDistance->Get_Value()), m_pDistance->Get_Value());
s += wxString::Format(wxT("\n%s: %d") , _TL("Samples in range") , m_pDiagram->m_pVariogram->Get_Data_Count());
- s += wxString::Format(wxT("\n%s: %.2f%") , _TL("R2") , m_pDiagram->m_pVariogram->Get_R2() * 100.0);
+ s += wxString::Format(wxT("\n%s: %.2f%%") , _TL("R2") , m_pDiagram->m_pVariogram->Get_R2() * 100.0);
}
m_pParameters->SetValue(s);
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Distances.cpp b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Distances.cpp
new file mode 100644
index 0000000..4b5ba80
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Distances.cpp
@@ -0,0 +1,163 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Points //
+// //
+//-------------------------------------------------------//
+// //
+// GSPoints_Distances.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "GSPoints_Distances.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGSPoints_Distances::CGSPoints_Distances(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name (_TL("Minimum Distance Analysis"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description(
+ _TL("")
+ );
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Shapes(
+ NULL , "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Table(
+ NULL , "TABLE" , _TL("Minimum Distance Analysis"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define SET_VALUE(s, v) { pRecord = pTable->Add_Record(); pRecord->Set_Value(0, s); pRecord->Set_Value(1, v); }
+
+//---------------------------------------------------------
+bool CGSPoints_Distances::On_Execute(void)
+{
+ //-----------------------------------------------------
+ CSG_Shapes *pPoints = Parameters("POINTS") ->asShapes();
+ CSG_Table *pTable = Parameters("TABLE") ->asTable();
+
+ //-----------------------------------------------------
+ CSG_PRQuadTree QT(pPoints, 0);
+ CSG_Simple_Statistics s;
+
+ double x, y, z;
+
+ for(int iPoint=0; iPoint<pPoints->Get_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++)
+ {
+ TSG_Point p = pPoints->Get_Shape(iPoint)->Get_Point(0);
+
+ if( QT.Select_Nearest_Points(p.x, p.y, 2) && QT.Get_Selected_Point(1, x, y, z) && (x != p.x || y != p.y) )
+ {
+ s.Add_Value(SG_Get_Distance(x, y, p.x, p.y));
+ }
+ }
+
+ //-----------------------------------------------------
+ if( s.Get_Count() > 0 )
+ {
+ CSG_Table_Record *pRecord;
+
+ pTable->Destroy();
+ pTable->Set_Name(CSG_String::Format(SG_T("%s [%s]"), _TL("Minimum Distance Analysis"), pPoints->Get_Name()));
+
+ pTable->Add_Field(SG_T("NAME") , SG_DATATYPE_String);
+ pTable->Add_Field(SG_T("VALUE") , SG_DATATYPE_Double);
+
+ SET_VALUE(_TL("Mean Average") , s.Get_Mean());
+ SET_VALUE(_TL("Minimum") , s.Get_Minimum());
+ SET_VALUE(_TL("Maximum") , s.Get_Maximum());
+ SET_VALUE(_TL("Standard Deviation") , s.Get_StdDev());
+ SET_VALUE(_TL("Duplicates") , pPoints->Get_Count() - s.Get_Count());
+
+ DataObject_Update(pTable, SG_UI_DATAOBJECT_SHOW);
+
+ return( true );
+ }
+
+ Message_Dlg(_TL("not enough observations"));
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Distances.h b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Distances.h
new file mode 100644
index 0000000..8b33caf
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Distances.h
@@ -0,0 +1,97 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Points //
+// //
+//-------------------------------------------------------//
+// //
+// GSPoints_Distances.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__GSPoints_Distances_H
+#define HEADER_INCLUDED__GSPoints_Distances_H
+
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGSPoints_Distances : public CSG_Module
+{
+public:
+ CGSPoints_Distances(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__GSPoints_Distances_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Semi_Variances.cpp b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Semi_Variances.cpp
index 533dafd..d709e73 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Semi_Variances.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Semi_Variances.cpp
@@ -70,18 +70,13 @@
//---------------------------------------------------------
enum
{
- DIF_FIELD_DISTANCE = 0,
- DIF_FIELD_DIFFERENCE
-};
-
-//---------------------------------------------------------
-enum
-{
- VAR_FIELD_DISTANCE = 0,
- VAR_FIELD_VARIANCE,
- VAR_FIELD_STDDEV,
- VAR_FIELD_CLASSVAR,
- VAR_FIELD_COUNT
+ FIELD_CLASSNR = 0,
+ FIELD_DISTANCE,
+ FIELD_COUNT,
+ FIELD_VARIANCE,
+ FIELD_VARCUMUL,
+ FIELD_COVARIANCE,
+ FIELD_COVARCUMUL
};
@@ -97,9 +92,9 @@ CGSPoints_Semi_Variances::CGSPoints_Semi_Variances(void)
CSG_Parameter *pNode;
//-----------------------------------------------------
- Set_Name (_TL("Semivariogram"));
+ Set_Name (_TL("Variogram"));
- Set_Author (SG_T("(c) 2003 by O.Conrad"));
+ Set_Author (SG_T("O.Conrad (c) 2003"));
Set_Description(
_TL("")
@@ -119,21 +114,21 @@ CGSPoints_Semi_Variances::CGSPoints_Semi_Variances(void)
//-----------------------------------------------------
Parameters.Add_Table(
- NULL , "RESULT" , _TL("Semi-Variances"),
+ NULL , "RESULT" , _TL("Sample Variogram"),
_TL(""),
PARAMETER_OUTPUT
);
Parameters.Add_Value(
- NULL , "DISTLAG" , _TL("Distance Increment"),
+ NULL , "DISTCOUNT" , _TL("Initial Number of Distance Classes"),
_TL(""),
- PARAMETER_TYPE_Double , 10.0, 0.0, true
+ PARAMETER_TYPE_Int , 100, 1, true
);
Parameters.Add_Value(
NULL , "DISTMAX" , _TL("Maximum Distance"),
_TL(""),
- PARAMETER_TYPE_Double , -1.0
+ PARAMETER_TYPE_Double , 0.0, 0.0, true
);
Parameters.Add_Value(
@@ -143,10 +138,6 @@ CGSPoints_Semi_Variances::CGSPoints_Semi_Variances(void)
);
}
-//---------------------------------------------------------
-CGSPoints_Semi_Variances::~CGSPoints_Semi_Variances(void)
-{}
-
///////////////////////////////////////////////////////////
// //
@@ -157,151 +148,102 @@ CGSPoints_Semi_Variances::~CGSPoints_Semi_Variances(void)
//---------------------------------------------------------
bool CGSPoints_Semi_Variances::On_Execute(void)
{
- CSG_Shapes *pShapes;
- CSG_Table *pTable, Table_Differences;
-
- //-----------------------------------------------------
- pShapes = Parameters("POINTS")->asShapes();
-
- Get_Differences(
- pShapes,
- &Table_Differences,
- Parameters("FIELD") ->asInt(),
- Parameters("NSKIP") ->asInt(),
- Parameters("DISTMAX") ->asDouble()
- );
-
- //-----------------------------------------------------
- pTable = Parameters("RESULT")->asTable();
-
- Get_Variances(
- pTable,
- &Table_Differences,
- Parameters("DISTLAG") ->asDouble()
- );
-
- //-----------------------------------------------------
- pTable->Set_Name(CSG_String::Format(SG_T("%s [%s]: %s"),
- pShapes->Get_Name(),
- pShapes->Get_Field_Name(Parameters("FIELD")->asInt()),
- _TL("Semi-Variances")
- ));
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CGSPoints_Semi_Variances::Get_Differences(CSG_Shapes *pShapes, CSG_Table *pTable, int zField, int nSkip, double maxDist)
-{
- int iPoint, jPoint;
- double d, dx, dy, z;
- CSG_Shape *pPoint;
- CSG_Table_Record *pRecord;
+ int i, j, k, n, nDistances, nSkip, Attribute;
+ double zi, zj, zMean, v, c, maxDistance, lagDistance;
TSG_Point Pt_i, Pt_j;
+ CSG_Vector Count, Variance, Covariance;
+ CSG_Table_Record *pRecord;
+ CSG_Table *pTable;
+ CSG_Shape *pPoint;
+ CSG_Shapes *pPoints;
//-----------------------------------------------------
- pTable->Destroy();
- pTable->Add_Field(_TL("Distance") , SG_DATATYPE_Double); // DIF_FIELD_DISTANCE
- pTable->Add_Field(_TL("Difference") , SG_DATATYPE_Double); // DIF_FIELD_DIFFERENCE
-
- //-----------------------------------------------------
- for(iPoint=0; iPoint<pShapes->Get_Count()-nSkip && Set_Progress(iPoint, pShapes->Get_Count()-nSkip); iPoint+=nSkip)
+ pPoints = Parameters("POINTS") ->asShapes();
+ pTable = Parameters("RESULT") ->asTable();
+ Attribute = Parameters("FIELD") ->asInt();
+ nSkip = Parameters("NSKIP") ->asInt();
+ maxDistance = Parameters("DISTMAX") ->asDouble();
+ nDistances = Parameters("DISTCOUNT") ->asInt();
+
+ if( maxDistance <= 0.0 )
{
- pPoint = pShapes->Get_Shape(iPoint);
- Pt_i = pPoint->Get_Point(0);
- z = pPoint->asDouble(zField);
-
- for(jPoint=iPoint+nSkip; jPoint<pShapes->Get_Count(); jPoint+=nSkip)
- {
- pPoint = pShapes->Get_Shape(jPoint);
- Pt_j = pPoint->Get_Point(0);
- dx = Pt_j.x - Pt_i.x;
- dy = Pt_j.y - Pt_i.y;
-
- if( (d = sqrt(dx*dx + dy*dy)) < maxDist || maxDist < 0.0 )
- {
- pRecord = pTable->Add_Record();
- pRecord->Set_Value(DIF_FIELD_DISTANCE , d);
- pRecord->Set_Value(DIF_FIELD_DIFFERENCE , pPoint->asDouble(zField) - z);
- }
- }
+ maxDistance = SG_Get_Length(pPoints->Get_Extent().Get_XRange(), pPoints->Get_Extent().Get_YRange());
}
-}
+ lagDistance = maxDistance / nDistances;
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
+ zMean = pPoints->Get_Mean(Attribute);
-//---------------------------------------------------------
-void CGSPoints_Semi_Variances::Get_Variances(CSG_Table *pTab_Var, CSG_Table *pTab_Dif, double Dist_Step)
-{
- int iDif, nVar, nVarS;
- double iDist, dz, zVar, zVarS, Dist;
- CSG_Table_Record *pRec_Dif, *pRec_Var;
+ Count .Create(nDistances);
+ Variance .Create(nDistances);
+ Covariance .Create(nDistances);
//-----------------------------------------------------
- if( Process_Get_Okay(false) )
+ for(i=0, n=0; i<pPoints->Get_Count() && Set_Progress(n, SG_Get_Square(pPoints->Get_Count()/nSkip)/2); i+=nSkip)
{
- pTab_Var->Destroy();
- pTab_Var->Add_Field(_TL("Distance") , SG_DATATYPE_Double); // VAR_FIELD_DISTANCE
- pTab_Var->Add_Field(_TL("Variance") , SG_DATATYPE_Double); // VAR_FIELD_VARIANCE
- pTab_Var->Add_Field(_TL("Std.Deviation") , SG_DATATYPE_Double); // VAR_FIELD_STDDEV
- pTab_Var->Add_Field(_TL("Class Variance") , SG_DATATYPE_Double); // VAR_FIELD_CLASSVAR
- pTab_Var->Add_Field(_TL("Class Count") , SG_DATATYPE_Int); // VAR_FIELD_COUNT
-
- pTab_Dif->Set_Index(DIF_FIELD_DISTANCE, TABLE_INDEX_Ascending);
-
- //-----------------------------------------------------
- iDist = 0.0;
- zVar = 0.0;
- nVar = 0;
- zVarS = 0.0;
- nVarS = 0;
-
- //-----------------------------------------------------
- for(iDif=0; iDif<pTab_Dif->Get_Record_Count() && Set_Progress(iDif, pTab_Dif->Get_Record_Count()); iDif++)
+ pPoint = pPoints->Get_Shape(i);
+
+ if( !pPoint->is_NoData(Attribute) )
{
- pRec_Dif = pTab_Dif->Get_Record_byIndex(iDif);
+ Pt_i = pPoint->Get_Point(0);
+ zi = pPoint->asDouble(Attribute);
- if( (Dist = pRec_Dif->asDouble(DIF_FIELD_DISTANCE)) > iDist )
+ for(j=i+nSkip; j<pPoints->Get_Count(); j+=nSkip, n++)
{
- if( nVar > 0 )
+ pPoint = pPoints->Get_Shape(j);
+
+ if( !pPoint->is_NoData(Attribute) )
{
- zVarS += zVar;
- nVarS += nVar;
-
- pRec_Var = pTab_Var->Add_Record();
- pRec_Var->Set_Value(VAR_FIELD_DISTANCE , iDist);
- pRec_Var->Set_Value(VAR_FIELD_VARIANCE , 0.5 * zVarS / (double)nVarS);
- pRec_Var->Set_Value(VAR_FIELD_STDDEV , sqrt(0.5 * zVarS / (double)nVarS));
- pRec_Var->Set_Value(VAR_FIELD_CLASSVAR , 0.5 * zVar / (double)nVar);
- pRec_Var->Set_Value(VAR_FIELD_COUNT , nVar);
- }
+ Pt_j = pPoint->Get_Point(0);
+ k = (int)(SG_Get_Distance(Pt_i, Pt_j) / lagDistance);
- zVar = 0.0;
- nVar = 0;
+ if( k < nDistances )
+ {
+ zj = pPoint->asDouble(Attribute);
- do iDist += Dist_Step; while( Dist > iDist );
- }
+ v = SG_Get_Square(zi - zj);
+ c = (zi - zMean) * (zj - zMean);
- dz = pRec_Dif->asDouble(DIF_FIELD_DIFFERENCE);
- zVar += dz*dz;
- nVar++;
+ Count [k] ++;
+ Variance [k] += v;
+ Covariance[k] += c;
+ }
+ }
+ }
}
+ }
- //-----------------------------------------------------
- pTab_Dif->Set_Index(DIF_FIELD_DISTANCE, TABLE_INDEX_None);
+ //-----------------------------------------------------
+ pTable->Destroy();
+ pTable->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pPoints->Get_Name(), _TL("Variogram"), pPoints->Get_Field_Name(Attribute)));
+ pTable->Add_Field(_TL("Class") , SG_DATATYPE_Int); // FIELD_CLASSNR
+ pTable->Add_Field(_TL("Distance") , SG_DATATYPE_Double); // FIELD_DISTANCE
+ pTable->Add_Field(_TL("Count") , SG_DATATYPE_Int); // FIELD_COUNT
+ pTable->Add_Field(_TL("Variance") , SG_DATATYPE_Double); // FIELD_VARIANCE
+ pTable->Add_Field(_TL("Cum.Var.") , SG_DATATYPE_Double); // FIELD_VARCUMUL
+ pTable->Add_Field(_TL("Covariance") , SG_DATATYPE_Double); // FIELD_COVARIANCE
+ pTable->Add_Field(_TL("Cum.Covar.") , SG_DATATYPE_Double); // FIELD_COVARCUMUL
+
+ for(i=0, v=0.0, c=0.0, n=0; i<nDistances; i++)
+ {
+ if( Count[i] > 0 )
+ {
+ n += (int)Count[i];
+ v += Variance [i];
+ c += Covariance[i];
+
+ pRecord = pTable->Add_Record();
+ pRecord->Set_Value(FIELD_CLASSNR , (i + 1));
+ pRecord->Set_Value(FIELD_DISTANCE , (i + 1) * lagDistance);
+ pRecord->Set_Value(FIELD_COUNT , Count[i]);
+ pRecord->Set_Value(FIELD_VARIANCE , 0.5 * Variance [i] / Count[i]);
+ pRecord->Set_Value(FIELD_VARCUMUL , 0.5 * v / n);
+ pRecord->Set_Value(FIELD_COVARIANCE , 1.0 * Covariance[i] / Count[i]);
+ pRecord->Set_Value(FIELD_COVARCUMUL , 1.0 * c / n);
+ }
}
+
+ return( true );
}
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Semi_Variances.h b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Semi_Variances.h
index 0caa2ab..1a4edbc 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Semi_Variances.h
+++ b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Semi_Variances.h
@@ -62,6 +62,12 @@
#define HEADER_INCLUDED__GSPoints_Semi_Variances_H
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
#include "MLB_Interface.h"
@@ -77,19 +83,20 @@ class CGSPoints_Semi_Variances : public CSG_Module
{
public:
CGSPoints_Semi_Variances(void);
- virtual ~CGSPoints_Semi_Variances(void);
protected:
virtual bool On_Execute (void);
+};
-private:
-
- void Get_Differences (CSG_Shapes *pShapes, CSG_Table *pTable, int zField, int nSkip, double maxDist);
- void Get_Variances (CSG_Table *pTab_Var, CSG_Table *pTab_Dif, double Dist_Step);
-};
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+//---------------------------------------------------------
#endif // #ifndef HEADER_INCLUDED__GSPoints_Semi_Variances_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Variogram_Cloud.cpp b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Variogram_Cloud.cpp
new file mode 100644
index 0000000..e32bb34
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Variogram_Cloud.cpp
@@ -0,0 +1,220 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Points //
+// //
+//-------------------------------------------------------//
+// //
+// GSPoints_Variogram_Cloud.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "GSPoints_Variogram_Cloud.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+enum
+{
+ DIF_FIELD_DISTANCE = 0,
+ DIF_FIELD_DIRECTION,
+ DIF_FIELD_DIFFERENCE,
+ DIF_FIELD_VARIANCE,
+ DIF_FIELD_SEMIVARIANCE,
+ DIF_FIELD_COVARIANCE
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGSPoints_Variogram_Cloud::CGSPoints_Variogram_Cloud(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name (_TL("Variogram Cloud"));
+
+ Set_Author (SG_T("O.Conrad (c) 2003"));
+
+ Set_Description(
+ _TL("")
+ );
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Shapes(
+ NULL , "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "FIELD" , _TL("Attribute"),
+ _TL("")
+ );
+
+ //-----------------------------------------------------
+ Parameters.Add_Table(
+ NULL , "RESULT" , _TL("Variogram Cloud"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Value(
+ NULL , "DISTMAX" , _TL("Maximum Distance"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 0.0, 0.0, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "NSKIP" , _TL("Skip Number"),
+ _TL(""),
+ PARAMETER_TYPE_Int, 1, 1, true
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGSPoints_Variogram_Cloud::On_Execute(void)
+{
+ int nSkip, Attribute;
+ double zi, zj, zMean, d, maxDistance;
+ TSG_Point Pt_i, Pt_j;
+ CSG_Table *pTable;
+ CSG_Shape *pPoint;
+ CSG_Shapes *pPoints;
+
+ //-----------------------------------------------------
+ pPoints = Parameters("POINTS") ->asShapes();
+ pTable = Parameters("RESULT") ->asTable();
+ Attribute = Parameters("FIELD") ->asInt();
+ nSkip = Parameters("NSKIP") ->asInt();
+ maxDistance = Parameters("DISTMAX") ->asDouble();
+
+ if( maxDistance <= 0.0 )
+ {
+ maxDistance = SG_Get_Length(pPoints->Get_Extent().Get_XRange(), pPoints->Get_Extent().Get_YRange());
+ }
+
+ zMean = pPoints->Get_Mean(Attribute);
+
+ //-----------------------------------------------------
+ pTable->Destroy();
+ pTable->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), _TL("Variogram Cloud")));
+ pTable->Add_Field(_TL("Distance") , SG_DATATYPE_Double); // DIF_FIELD_DISTANCE
+ pTable->Add_Field(_TL("Direction") , SG_DATATYPE_Double); // DIF_FIELD_DIRECTION
+ pTable->Add_Field(_TL("Difference") , SG_DATATYPE_Double); // DIF_FIELD_DIFFERENCE
+ pTable->Add_Field(_TL("Variance") , SG_DATATYPE_Double); // DIF_FIELD_VARIANCE
+ pTable->Add_Field(_TL("Semivariance") , SG_DATATYPE_Double); // DIF_FIELD_SEMIVARIANCE
+ pTable->Add_Field(_TL("Covariance") , SG_DATATYPE_Double); // DIF_FIELD_COVARIANCE
+
+ //-----------------------------------------------------
+ for(int i=0; i<pPoints->Get_Count()-nSkip && Set_Progress(i, pPoints->Get_Count()-nSkip); i+=nSkip)
+ {
+ pPoint = pPoints->Get_Shape(i);
+
+ if( !pPoint->is_NoData(Attribute) )
+ {
+ Pt_i = pPoint->Get_Point(0);
+ zi = pPoint->asDouble(Attribute);
+
+ for(int j=i; j<pPoints->Get_Count() && Process_Get_Okay(); j+=nSkip)
+ {
+ pPoint = pPoints->Get_Shape(j);
+
+ if( !pPoint->is_NoData(Attribute) )
+ {
+ Pt_j = pPoint->Get_Point(0);
+
+ if( (d = SG_Get_Distance(Pt_i, Pt_j)) <= maxDistance )
+ {
+ CSG_Table_Record *pRecord = pTable->Add_Record();
+
+ zj = pPoint->asDouble(Attribute);
+
+ pRecord->Set_Value(DIF_FIELD_DISTANCE , d);
+ pRecord->Set_Value(DIF_FIELD_DIRECTION , SG_Get_Angle_Of_Direction(Pt_i, Pt_j) * M_RAD_TO_DEG);
+ pRecord->Set_Value(DIF_FIELD_DIFFERENCE , fabs(d = zi - zj));
+ pRecord->Set_Value(DIF_FIELD_VARIANCE , d = d*d);
+ pRecord->Set_Value(DIF_FIELD_SEMIVARIANCE , 0.5*d);
+ pRecord->Set_Value(DIF_FIELD_COVARIANCE , (zi - zMean) * (zj - zMean));
+ }
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Variogram_Cloud.h b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Variogram_Cloud.h
new file mode 100644
index 0000000..3a72e86
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Variogram_Cloud.h
@@ -0,0 +1,100 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Points //
+// //
+//-------------------------------------------------------//
+// //
+// GSPoints_Variogram_Cloud.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__GSPoints_Variogram_Cloud_H
+#define HEADER_INCLUDED__GSPoints_Variogram_Cloud_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGSPoints_Variogram_Cloud : public CSG_Module
+{
+public:
+ CGSPoints_Variogram_Cloud(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__GSPoints_Variogram_Cloud_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Variogram_Surface.cpp b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Variogram_Surface.cpp
new file mode 100644
index 0000000..1701729
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Variogram_Surface.cpp
@@ -0,0 +1,232 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Points //
+// //
+//-------------------------------------------------------//
+// //
+// GSPoints_Variogram_Surface.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "GSPoints_Variogram_Surface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGSPoints_Variogram_Surface::CGSPoints_Variogram_Surface(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name (_TL("Variogram Surface"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description(
+ _TL("")
+ );
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Shapes(
+ NULL , "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "FIELD" , _TL("Attribute"),
+ _TL("")
+ );
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid_Output(
+ NULL , "COUNT" , _TL("Number of Pairs"),
+ _TL("")
+ );
+
+ Parameters.Add_Grid_Output(
+ NULL , "VARIANCE" , _TL("Variogram Surface"),
+ _TL("")
+ );
+
+ Parameters.Add_Grid_Output(
+ NULL , "COVARIANCE" , _TL("Covariance Surface"),
+ _TL("")
+ );
+
+ Parameters.Add_Value(
+ NULL , "DISTCOUNT" , _TL("Number of Distance Classes"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 10, 1, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "NSKIP" , _TL("Skip Number"),
+ _TL(""),
+ PARAMETER_TYPE_Int, 1, 1, true
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGSPoints_Variogram_Surface::On_Execute(void)
+{
+ int i, j, x, y, n, nx, ny, nSkip, Attribute, nDistances;
+ double zi, zj, zMean, v, c, lagDistance;
+ TSG_Point Pt_i, Pt_j;
+ CSG_Shape *pPoint;
+ CSG_Shapes *pPoints;
+ CSG_Grid *pVariance, *pCovariance, *pCount;
+
+ //-----------------------------------------------------
+ pPoints = Parameters("POINTS") ->asShapes();
+ Attribute = Parameters("FIELD") ->asInt();
+ nSkip = Parameters("NSKIP") ->asInt();
+ nDistances = Parameters("DISTCOUNT") ->asInt();
+
+ lagDistance = pPoints->Get_Extent().Get_XRange() < pPoints->Get_Extent().Get_YRange()
+ ? pPoints->Get_Extent().Get_XRange() / nDistances
+ : pPoints->Get_Extent().Get_YRange() / nDistances;
+
+ nx = 1 + (int)(pPoints->Get_Extent().Get_XRange() / lagDistance);
+ ny = 1 + (int)(pPoints->Get_Extent().Get_YRange() / lagDistance);
+ zMean = pPoints->Get_Mean(Attribute);
+
+ pCount = SG_Create_Grid(SG_DATATYPE_Int , 1 + 2 * nx, 1 + 2 * ny, lagDistance, -nx * lagDistance, -ny * lagDistance);
+ pVariance = SG_Create_Grid(SG_DATATYPE_Float, 1 + 2 * nx, 1 + 2 * ny, lagDistance, -nx * lagDistance, -ny * lagDistance);
+ pCovariance = SG_Create_Grid(SG_DATATYPE_Float, 1 + 2 * nx, 1 + 2 * ny, lagDistance, -nx * lagDistance, -ny * lagDistance);
+
+ pCount ->Set_Name(CSG_String::Format(SG_T("%s [%s]") , pPoints->Get_Name(), _TL("Count")));
+ pVariance ->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pPoints->Get_Name(), _TL("Variogram Surface") , pPoints->Get_Field_Name(Attribute)));
+ pCovariance ->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pPoints->Get_Name(), _TL("Covariance Surface"), pPoints->Get_Field_Name(Attribute)));
+
+ //-----------------------------------------------------
+ for(i=0, n=0; i<pPoints->Get_Count() && Set_Progress(n, SG_Get_Square(pPoints->Get_Count()/nSkip)/2); i+=nSkip)
+ {
+ pPoint = pPoints->Get_Shape(i);
+
+ if( !pPoint->is_NoData(Attribute) )
+ {
+ Pt_i = pPoint->Get_Point(0);
+ zi = pPoint->asDouble(Attribute);
+
+ for(j=i+nSkip; j<pPoints->Get_Count(); j+=nSkip, n++)
+ {
+ pPoint = pPoints->Get_Shape(j);
+
+ if( !pPoint->is_NoData(Attribute) )
+ {
+ Pt_j = pPoint->Get_Point(0);
+
+ zj = pPoint->asDouble(Attribute);
+
+ v = SG_Get_Square(zi - zj);
+ c = (zi - zMean) * (zj - zMean);
+
+ Pt_j.x = (Pt_i.x - Pt_j.x) / lagDistance;
+ Pt_j.y = (Pt_i.y - Pt_j.y) / lagDistance;
+
+ x = (int)(Pt_j.x + (Pt_j.x > 0.0 ? 0.5 : -0.5));
+ y = (int)(Pt_j.y + (Pt_j.y > 0.0 ? 0.5 : -0.5));
+
+ pCount ->Add_Value(nx + x, ny + y, 1);
+ pCount ->Add_Value(nx - x, ny - y, 1);
+ pVariance ->Add_Value(nx + x, ny + y, v);
+ pVariance ->Add_Value(nx - x, ny - y, v);
+ pCovariance->Add_Value(nx + x, ny + y, c);
+ pCovariance->Add_Value(nx - x, ny - y, c);
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ for(i=0; i<pCount->Get_NCells(); i++)
+ {
+ if( pCount->asInt(i) > 0 )
+ {
+ pVariance ->Mul_Value(i, 0.5 / pCount->asInt(i));
+ pCovariance->Mul_Value(i, 1.0 / pCount->asInt(i));
+ }
+ else
+ {
+ pVariance ->Set_NoData(i);
+ pCovariance->Set_NoData(i);
+ }
+ }
+
+ DataObject_Add(pCount);
+ DataObject_Add(pVariance);
+ DataObject_Add(pCovariance);
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Variogram_Surface.h b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Variogram_Surface.h
new file mode 100644
index 0000000..7d2e7d2
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_points/GSPoints_Variogram_Surface.h
@@ -0,0 +1,100 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Points //
+// //
+//-------------------------------------------------------//
+// //
+// GSPoints_Variogram_Surface.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__GSPoints_Variogram_Surface_H
+#define HEADER_INCLUDED__GSPoints_Variogram_Surface_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGSPoints_Variogram_Surface : public CSG_Module
+{
+public:
+ CGSPoints_Variogram_Surface(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__GSPoints_Variogram_Surface_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_points/MLB_Interface.cpp b/src/modules_geostatistics/geostatistics/geostatistics_points/MLB_Interface.cpp
index b0f6236..bc58c5b 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_points/MLB_Interface.cpp
+++ b/src/modules_geostatistics/geostatistics/geostatistics_points/MLB_Interface.cpp
@@ -74,10 +74,10 @@ const SG_Char * Get_Info(int i)
return( _TL("Geostatistics - Points") );
case MLB_INFO_Author:
- return( _TL("Olaf Conrad (c) 2002") );
+ return( _TL("O.Conrad (c) 2002-10") );
case MLB_INFO_Description:
- return( _TL("Geostatistical analyses for point data.") );
+ return( _TL("Spatial and geostatistical analyses of point data.") );
case MLB_INFO_Version:
return( SG_T("1.0") );
@@ -92,6 +92,9 @@ const SG_Char * Get_Info(int i)
// 3. Include the headers of your modules here...
#include "GSPoints_Semi_Variances.h"
+#include "GSPoints_Variogram_Cloud.h"
+#include "GSPoints_Variogram_Surface.h"
+#include "GSPoints_Distances.h"
//---------------------------------------------------------
@@ -99,25 +102,15 @@ const SG_Char * Get_Info(int i)
CSG_Module * Create_Module(int i)
{
- // Don't forget to continuously enumerate the case switches
- // when adding new modules! Also bear in mind that the
- // enumeration always has to start with [case 0:] and
- // that [default:] must return NULL!...
-
- CSG_Module *pModule;
-
switch( i )
{
- case 0:
- pModule = new CGSPoints_Semi_Variances;
- break;
-
- default:
- pModule = NULL;
- break;
+ case 0: return( new CGSPoints_Semi_Variances );
+ case 1: return( new CGSPoints_Variogram_Cloud );
+ case 2: return( new CGSPoints_Variogram_Surface );
+ case 3: return( new CGSPoints_Distances );
}
- return( pModule );
+ return( NULL );
}
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_points/Makefile.am b/src/modules_geostatistics/geostatistics/geostatistics_points/Makefile.am
index 9544cee..fc67016 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_points/Makefile.am
+++ b/src/modules_geostatistics/geostatistics/geostatistics_points/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:25 tschorr Exp $
+# $Id: Makefile.am,v 1.8 2010/07/08 14:11:50 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,12 +10,18 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgeostatistics_points.la
libgeostatistics_points_la_SOURCES =\
+GSPoints_Distances.cpp\
GSPoints_Semi_Variances.cpp\
+GSPoints_Variogram_Cloud.cpp\
+GSPoints_Variogram_Surface.cpp\
MLB_Interface.cpp\
+GSPoints_Distances.h\
GSPoints_Semi_Variances.h\
+GSPoints_Variogram_Cloud.h\
+GSPoints_Variogram_Surface.h\
MLB_Interface.h
libgeostatistics_points_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_points/Makefile.in b/src/modules_geostatistics/geostatistics/geostatistics_points/Makefile.in
index c6b03c5..04c716b 100644
--- a/src/modules_geostatistics/geostatistics/geostatistics_points/Makefile.in
+++ b/src/modules_geostatistics/geostatistics/geostatistics_points/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -69,11 +68,12 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)"
LTLIBRARIES = $(pkglib_LTLIBRARIES)
libgeostatistics_points_la_DEPENDENCIES = \
$(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
-am_libgeostatistics_points_la_OBJECTS = GSPoints_Semi_Variances.lo \
- MLB_Interface.lo
+am_libgeostatistics_points_la_OBJECTS = GSPoints_Distances.lo \
+ GSPoints_Semi_Variances.lo GSPoints_Variogram_Cloud.lo \
+ GSPoints_Variogram_Surface.lo MLB_Interface.lo
libgeostatistics_points_la_OBJECTS = \
$(am_libgeostatistics_points_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +129,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,19 +220,25 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:25 tschorr Exp $
+# $Id: Makefile.am,v 1.8 2010/07/08 14:11:50 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libgeostatistics_points.la
libgeostatistics_points_la_SOURCES = \
+GSPoints_Distances.cpp\
GSPoints_Semi_Variances.cpp\
+GSPoints_Variogram_Cloud.cpp\
+GSPoints_Variogram_Surface.cpp\
MLB_Interface.cpp\
+GSPoints_Distances.h\
GSPoints_Semi_Variances.h\
+GSPoints_Variogram_Cloud.h\
+GSPoints_Variogram_Surface.h\
MLB_Interface.h
libgeostatistics_points_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
@@ -308,7 +316,10 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GSPoints_Distances.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GSPoints_Semi_Variances.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GSPoints_Variogram_Cloud.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/GSPoints_Variogram_Surface.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
.cpp.o:
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/MLB_Interface.cpp b/src/modules_geostatistics/geostatistics/geostatistics_regression/MLB_Interface.cpp
new file mode 100644
index 0000000..d8a7b3b
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/MLB_Interface.cpp
@@ -0,0 +1,132 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// The Module Link Library Interface //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+// 1. Include the appropriate SAGA-API header...
+
+#include "MLB_Interface.h"
+
+
+//---------------------------------------------------------
+// 2. Place general module library informations here...
+
+const SG_Char * Get_Info(int i)
+{
+ switch( i )
+ {
+ case MLB_INFO_Name: default:
+ return( _TL("Geostatistics - Regression") );
+
+ case MLB_INFO_Author:
+ return( _TL("O.Conrad (c) 2010" ));
+
+ case MLB_INFO_Description:
+ return( _TL("Tools for (geo)statistical analyses.") );
+
+ case MLB_INFO_Version:
+ return( SG_T("1.0") );
+
+ case MLB_INFO_Menu_Path:
+ return( _TL("Geostatistics|Regression") );
+ }
+}
+
+
+//---------------------------------------------------------
+// 3. Include the headers of your modules here...
+
+#include "point_grid_regression.h"
+#include "point_multi_grid_regression.h"
+#include "point_trend_surface.h"
+#include "gw_regression.h"
+#include "gw_regression_grid.h"
+#include "gw_multi_regression.h"
+#include "gw_multi_regression_grid.h"
+
+
+//---------------------------------------------------------
+// 4. Allow your modules to be created here...
+
+CSG_Module * Create_Module(int i)
+{
+ switch( i )
+ {
+ case 0: return( new CPoint_Grid_Regression );
+ case 1: return( new CPoint_Multi_Grid_Regression );
+ case 2: return( new CPoint_Trend_Surface );
+ case 3: return( new CGW_Regression );
+ case 4: return( new CGW_Regression_Grid );
+ case 5: return( new CGW_Multi_Regression );
+ case 6: return( new CGW_Multi_Regression_Grid );
+ }
+
+ return( NULL );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+//{{AFX_SAGA
+
+ MLB_INTERFACE
+
+//}}AFX_SAGA
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/MLB_Interface.h b/src/modules_geostatistics/geostatistics/geostatistics_regression/MLB_Interface.h
new file mode 100644
index 0000000..4c2c730
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/MLB_Interface.h
@@ -0,0 +1,82 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.h //
+// //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// Include the SAGA-API here //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__geostatistics_regression_H
+#define HEADER_INCLUDED__geostatistics_regression_H
+
+//---------------------------------------------------------
+#include <saga_api/saga_api.h>
+
+//---------------------------------------------------------
+#ifdef geostatistics_regression_EXPORTS
+ #define geostatistics_regression_EXPORT _SAGA_DLL_EXPORT
+#else
+ #define geostatistics_regression_EXPORT _SAGA_DLL_IMPORT
+#endif
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__geostatistics_regression_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/Makefile.am b/src/modules_geostatistics/geostatistics/geostatistics_regression/Makefile.am
new file mode 100644
index 0000000..dabe386
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/Makefile.am
@@ -0,0 +1,34 @@
+#
+# $Id: Makefile.am,v 1.3 2010/07/08 14:11:48 johanvdw Exp $
+#
+if DEBUG
+DBGFLAGS = -g -DDEBUG
+endif
+if SAGA_UNICODE
+UC_DEFS = -D_SAGA_UNICODE
+endif
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -avoid-version
+pkglib_LTLIBRARIES = libgeostatistics_regression.la
+libgeostatistics_regression_la_SOURCES =\
+gw_multi_regression.cpp\
+gw_multi_regression_grid.cpp\
+gw_regression.cpp\
+gw_regression_grid.cpp\
+MLB_Interface.cpp\
+point_grid_regression.cpp\
+point_multi_grid_regression.cpp\
+point_trend_surface.cpp\
+gw_multi_regression.h\
+gw_multi_regression_grid.h\
+gw_regression.h\
+gw_regression_grid.h\
+MLB_Interface.h\
+point_grid_regression.h\
+point_multi_grid_regression.h\
+point_trend_surface.h
+
+libgeostatistics_regression_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/Makefile.in b/src/modules_geostatistics/geostatistics/geostatistics_regression/Makefile.in
new file mode 100644
index 0000000..5bc19c5
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/Makefile.in
@@ -0,0 +1,567 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/modules_geostatistics/geostatistics/geostatistics_regression
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+libgeostatistics_regression_la_DEPENDENCIES = \
+ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+am_libgeostatistics_regression_la_OBJECTS = gw_multi_regression.lo \
+ gw_multi_regression_grid.lo gw_regression.lo \
+ gw_regression_grid.lo MLB_Interface.lo \
+ point_grid_regression.lo point_multi_grid_regression.lo \
+ point_trend_surface.lo
+libgeostatistics_regression_la_OBJECTS = \
+ $(am_libgeostatistics_regression_la_OBJECTS)
+DEFAULT_INCLUDES = -I. at am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libgeostatistics_regression_la_SOURCES)
+DIST_SOURCES = $(libgeostatistics_regression_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+HARU_LIB = @HARU_LIB@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POW_LIB = @POW_LIB@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#
+# $Id: Makefile.am,v 1.3 2010/07/08 14:11:48 johanvdw Exp $
+#
+ at DEBUG_TRUE@DBGFLAGS = -g -DDEBUG
+ at SAGA_UNICODE_TRUE@UC_DEFS = -D_SAGA_UNICODE
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -avoid-version
+pkglib_LTLIBRARIES = libgeostatistics_regression.la
+libgeostatistics_regression_la_SOURCES = \
+gw_multi_regression.cpp\
+gw_multi_regression_grid.cpp\
+gw_regression.cpp\
+gw_regression_grid.cpp\
+MLB_Interface.cpp\
+point_grid_regression.cpp\
+point_multi_grid_regression.cpp\
+point_trend_surface.cpp\
+gw_multi_regression.h\
+gw_multi_regression_grid.h\
+gw_regression.h\
+gw_regression_grid.h\
+MLB_Interface.h\
+point_grid_regression.h\
+point_multi_grid_regression.h\
+point_trend_surface.h
+
+libgeostatistics_regression_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/modules_geostatistics/geostatistics/geostatistics_regression/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/modules_geostatistics/geostatistics/geostatistics_regression/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \
+ }
+
+uninstall-pkglibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \
+ done
+
+clean-pkglibLTLIBRARIES:
+ -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+ @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libgeostatistics_regression.la: $(libgeostatistics_regression_la_OBJECTS) $(libgeostatistics_regression_la_DEPENDENCIES)
+ $(CXXLINK) -rpath $(pkglibdir) $(libgeostatistics_regression_la_OBJECTS) $(libgeostatistics_regression_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gw_multi_regression.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gw_multi_regression_grid.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gw_regression.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gw_regression_grid.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/point_grid_regression.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/point_multi_grid_regression.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/point_trend_surface.Plo at am__quote@
+
+.cpp.o:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+ at am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(pkglibdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+ 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 uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+
+# 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:
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_multi_regression.cpp b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_multi_regression.cpp
new file mode 100644
index 0000000..cec29fa
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_multi_regression.cpp
@@ -0,0 +1,542 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// gw_multi_regression.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "gw_multi_regression.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define SG_ARRAY_DELETE(A) if( A ) { delete[](A); A = NULL; }
+#define SG_ARRAY_FREE(A) if( A ) { SG_Free (A); A = NULL; }
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGW_Multi_Regression::CGW_Multi_Regression(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name (_TL("Geographically Weighted Multiple Regression"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ "Reference:\n"
+ " - Lloyd, C. (2010): Spatial Data Analysis - An Introduction for GIS Users. Oxford, 206p.\n"
+ ));
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Shapes(
+ NULL , "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "DEPENDENT" , _TL("Dependent Variable"),
+ _TL("")
+ );
+
+ Parameters.Add_Parameters(
+ pNode , "PREDICTORS" , _TL("Predictors"),
+ _TL("")
+ );
+
+ //-----------------------------------------------------
+ Parameters.Add_Choice(
+ NULL , "TARGET" , _TL("Target Grids"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("user defined"),
+ _TL("grid")
+ ), 0
+ );
+
+ m_Grid_Target.Add_Parameters_User(Add_Parameters("USER", _TL("User Defined Grid") , _TL("")), false);
+ m_Grid_Target.Add_Parameters_Grid(Add_Parameters("GRID", _TL("Choose Grid") , _TL("")), false);
+
+ m_Grid_Target.Add_Grid_Parameter(SG_T("QUALITY") , _TL("Quality") , false);
+ m_Grid_Target.Add_Grid_Parameter(SG_T("INTERCEPT") , _TL("Intercept"), false);
+
+ //-----------------------------------------------------
+ m_Weighting.Set_Weighting(SG_DISTWGHT_GAUSS);
+
+ Parameters.Add_Parameters(
+ NULL , "WEIGHTING" , _TL("Weighting"),
+ _TL("")
+ )->asParameters()->Assign(m_Weighting.Get_Parameters());
+
+ pNode = Parameters.Add_Choice(
+ NULL , "RANGE" , _TL("Search Range"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("search radius (local)"),
+ _TL("no search radius (global)")
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode , "RADIUS" , _TL("Search Radius"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 100.0
+ );
+
+ Parameters.Add_Choice(
+ pNode , "MODE" , _TL("Search Mode"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("all directions"),
+ _TL("quadrants")
+ )
+ );
+
+ pNode = Parameters.Add_Choice(
+ NULL , "NPOINTS" , _TL("Number of Points"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("maximum number of observations"),
+ _TL("all points")
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode , "MAXPOINTS" , _TL("Maximum Number of Observations"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 10, 2, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "MINPOINTS" , _TL("Minimum Number of Observations"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 4, 2, true
+ );
+
+ //-----------------------------------------------------
+ m_iPredictor = NULL;
+ m_pSlopes = NULL;
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int CGW_Multi_Regression::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ if( m_Grid_Target.On_User_Changed(pParameters, pParameter) )
+ {
+ return( true );
+ }
+
+ if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("POINTS")) )
+ {
+ CSG_Shapes *pPoints = pParameters->Get_Parameter("POINTS") ->asShapes();
+ CSG_Parameters *pAttributes = pParameters->Get_Parameter("PREDICTORS") ->asParameters();
+
+ pAttributes->Destroy();
+ pAttributes->Set_Name(_TL("Predictors"));
+
+ for(int i=0; pPoints && i<pPoints->Get_Field_Count(); i++)
+ {
+ switch( pPoints->Get_Field_Type(i) )
+ {
+ default: // not numeric
+ break;
+
+ case SG_DATATYPE_Byte:
+ case SG_DATATYPE_Char:
+ case SG_DATATYPE_Word:
+ case SG_DATATYPE_Short:
+ case SG_DATATYPE_DWord:
+ case SG_DATATYPE_Int:
+ case SG_DATATYPE_ULong:
+ case SG_DATATYPE_Long:
+ case SG_DATATYPE_Float:
+ case SG_DATATYPE_Double:
+ pAttributes->Add_Value(
+ NULL, SG_Get_String(i, 0), pPoints->Get_Field_Name(i), _TL(""), PARAMETER_TYPE_Bool, false
+ );
+ break;
+ }
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CGW_Multi_Regression::Get_Predictors(void)
+{
+ int i;
+ CSG_Shapes *pPoints = Parameters("POINTS") ->asShapes();
+ CSG_Parameters *pAttributes = Parameters("PREDICTORS") ->asParameters();
+
+ m_nPredictors = 0;
+ m_iPredictor = new int[pPoints->Get_Field_Count()];
+
+ for(i=0; i<pAttributes->Get_Count(); i++)
+ {
+ if( pAttributes->Get_Parameter(i)->asBool() )
+ {
+ m_iPredictor[m_nPredictors++] = CSG_String(pAttributes->Get_Parameter(i)->Get_Identifier()).asInt();
+ }
+ }
+
+ CSG_Parameters *pGrids = Get_Parameters("GRID"), Tmp;
+
+ Tmp.Assign(pGrids);
+
+ pGrids->Create(this, Tmp.Get_Name(), Tmp.Get_Description(), Tmp.Get_Identifier(), false);
+ m_Grid_Target.Add_Grid_Parameter(SG_T("QUALITY") , _TL("Quality") , false);
+ m_Grid_Target.Add_Grid_Parameter(SG_T("INTERCEPT") , _TL("Intercept"), false);
+
+ pGrids->Get_Parameter("QUALITY")->Get_Parent()->asGrid_System()->Assign(*Tmp("QUALITY")->Get_Parent()->asGrid_System());
+ pGrids->Get_Parameter("QUALITY") ->Set_Value(Tmp("QUALITY") ->asGrid());
+ pGrids->Get_Parameter("INTERCEPT")->Set_Value(Tmp("INTERCEPT")->asGrid());
+
+ for(i=0; i<m_nPredictors; i++)
+ {
+ m_Grid_Target.Add_Grid_Parameter(SG_Get_String(i, 0),
+ CSG_String::Format(SG_T("%s [%s]"), _TL("Slope"), pPoints->Get_Field_Name(m_iPredictor[i])), false
+ );
+
+ if( Tmp(SG_Get_String(i, 0)) )
+ {
+ pGrids->Get_Parameter(SG_Get_String(i, 0))->Set_Value(Tmp(SG_Get_String(i, 0))->asGrid());
+ }
+ }
+
+ return( m_nPredictors > 0 );
+}
+
+//---------------------------------------------------------
+void CGW_Multi_Regression::Finalize(void)
+{
+ SG_ARRAY_DELETE(m_iPredictor);
+
+ SG_ARRAY_FREE (m_pSlopes);
+
+ m_Search.Destroy();
+
+ m_y.Destroy();
+ m_z.Destroy();
+ m_w.Destroy();
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGW_Multi_Regression::On_Execute(void)
+{
+ int i;
+
+ //-----------------------------------------------------
+ m_pPoints = Parameters("POINTS") ->asShapes();
+ m_iDependent = Parameters("DEPENDENT") ->asInt();
+ m_Radius = Parameters("RANGE") ->asInt() == 0 ? Parameters("RADIUS") ->asDouble() : 0.0;
+ m_Mode = Parameters("MODE") ->asInt();
+ m_nPoints_Max = Parameters("NPOINTS") ->asInt() == 0 ? Parameters("MAXPOINTS")->asInt() : 0;
+ m_nPoints_Min = Parameters("MINPOINTS") ->asInt();
+
+ m_Weighting.Set_Parameters(Parameters("WEIGHTING")->asParameters());
+
+ //-----------------------------------------------------
+ if( !Get_Predictors() )
+ {
+ Finalize();
+
+ return( false );
+ }
+
+ if( (m_nPoints_Max > 0 || m_Radius > 0.0) && !m_Search.Create(m_pPoints, -1) )
+ {
+ Finalize();
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ m_pQuality = NULL;
+ m_pIntercept = NULL;
+ m_pSlopes = (CSG_Grid **)SG_Calloc(m_nPredictors, sizeof(CSG_Grid *));
+
+ switch( Parameters("TARGET")->asInt() )
+ {
+ case 0: // user defined...
+ if( m_Grid_Target.Init_User(m_pPoints->Get_Extent()) && Dlg_Parameters("USER") )
+ {
+ m_pQuality = m_Grid_Target.Get_User(SG_T("QUALITY" ));
+ m_pIntercept = m_Grid_Target.Get_User(SG_T("INTERCEPT"));
+
+ for(i=0; i<m_nPredictors; i++)
+ {
+ m_pSlopes[i] = m_Grid_Target.Get_User(SG_Get_String(i, 0));
+ }
+ }
+ break;
+
+ case 1: // grid...
+ if( Dlg_Parameters("GRID") )
+ {
+ m_pQuality = m_Grid_Target.Get_Grid(SG_T("QUALITY" ));
+ m_pIntercept = m_Grid_Target.Get_Grid(SG_T("INTERCEPT"));
+
+ for(i=0; i<m_nPredictors; i++)
+ {
+ m_pSlopes[i] = m_Grid_Target.Get_Grid(SG_Get_String(i, 0));
+ }
+ }
+ break;
+ }
+
+ if( m_pQuality == NULL )
+ {
+ Finalize();
+
+ return( false );
+ }
+
+ m_pQuality ->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_pPoints->Get_Name(), _TL("GWR Quality")));
+ m_pIntercept->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_pPoints->Get_Name(), _TL("GWR Intercept")));
+
+ for(i=0; i<m_nPredictors; i++)
+ {
+ m_pSlopes[i]->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_pPoints->Get_Name(), m_pPoints->Get_Field_Name(m_iPredictor[i])));
+ }
+
+ //-----------------------------------------------------
+ int nPoints_Max = m_nPoints_Max > 0 ? m_nPoints_Max : m_pPoints->Get_Count();
+
+ m_y.Create(1 + m_nPredictors, nPoints_Max);
+ m_z.Create(nPoints_Max);
+ m_w.Create(nPoints_Max);
+
+ //-----------------------------------------------------
+ for(int y=0; y<m_pIntercept->Get_NY() && Set_Progress(y, m_pIntercept->Get_NY()); y++)
+ {
+ for(int x=0; x<m_pIntercept->Get_NX(); x++)
+ {
+ if( !Get_Regression(x, y) )
+ {
+ m_pQuality ->Set_NoData(x, y);
+ m_pIntercept->Set_NoData(x, y);
+
+ for(i=0; i<m_nPredictors; i++)
+ {
+ m_pSlopes[i]->Set_NoData(x, y);
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ Finalize();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int CGW_Multi_Regression::Set_Variables(int x, int y)
+{
+ int iPoint, jPoint, nPoints, iPredictor;
+ TSG_Point Point;
+ CSG_Shape *pPoint;
+
+ Point = m_pIntercept->Get_System().Get_Grid_to_World(x, y);
+ nPoints = m_Search.is_Okay() ? m_Search.Select_Nearest_Points(Point.x, Point.y, m_nPoints_Max, m_Radius, m_Mode == 0 ? -1 : 4) : m_pPoints->Get_Count();
+
+ for(iPoint=0, jPoint=0; iPoint<nPoints; iPoint++)
+ {
+ if( m_Search.is_Okay() )
+ {
+ double ix, iy, iz;
+
+ m_Search.Get_Selected_Point(iPoint, ix, iy, iz);
+
+ pPoint = m_pPoints->Get_Shape((int)iz);
+ }
+ else
+ {
+ pPoint = m_pPoints->Get_Shape(iPoint);
+ }
+
+ m_z[iPoint] = pPoint->asDouble(m_iDependent);
+ m_w[iPoint] = m_Weighting.Get_Weight(SG_Get_Distance(Point, pPoint->Get_Point(0)));
+
+ for(iPredictor=0; iPredictor<m_nPredictors; iPredictor++)
+ {
+ if( !pPoint->is_NoData(m_iPredictor[iPredictor]) )
+ {
+ m_y[jPoint][iPredictor] = pPoint->asDouble(m_iPredictor[iPredictor]);
+ }
+ else
+ {
+ iPredictor = m_nPredictors + 1;
+ }
+ }
+
+ if( iPredictor == m_nPredictors )
+ {
+ jPoint++;
+ }
+ }
+
+ return( jPoint );
+}
+
+//---------------------------------------------------------
+bool CGW_Multi_Regression::Get_Regression(int x, int y)
+{
+ int nPoints = Set_Variables(x, y);
+
+ if( nPoints < m_nPoints_Min )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ int i;
+ double zMean, rss, tss;
+ CSG_Vector b, z;
+ CSG_Matrix Y, YtW;
+
+ //-----------------------------------------------------
+ z .Create(nPoints);
+ Y .Create(1 + m_nPredictors, nPoints);
+ YtW.Create(nPoints, 1 + m_nPredictors);
+
+ for(i=0, zMean=0.0; i<nPoints; i++)
+ {
+ Y [i][0] = 1.0;
+ YtW[0][i] = m_w[i];
+
+ for(int j=0; j<m_nPredictors; j++)
+ {
+ Y [i][j + 1] = m_y[i][j];
+ YtW[j + 1][i] = m_y[i][j] * m_w[i];
+ }
+
+ zMean += (z[i] = m_z[i]);
+ }
+
+ //-----------------------------------------------------
+ b = (YtW * Y).Get_Inverse() * (YtW * z);
+
+ zMean /= nPoints;
+
+ for(i=0, rss=0.0, tss=0.0; i<nPoints; i++)
+ {
+ double zr = b[0];
+
+ for(int j=0; j<m_nPredictors; j++)
+ {
+ zr += b[j + 1] * m_y[i][j];
+ }
+
+ rss += m_w[i] * SG_Get_Square(m_z[i] - zr);
+ tss += m_w[i] * SG_Get_Square(m_z[i] - zMean);
+ }
+
+ m_pQuality ->Set_Value(x, y, tss > 0.0 ? (tss - rss) / tss : 0.0);
+ m_pIntercept->Set_Value(x, y, b[0]);
+
+ for(i=0; i<m_nPredictors; i++)
+ {
+ m_pSlopes[i]->Set_Value(x, y, b[i + 1]);
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_multi_regression.h b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_multi_regression.h
new file mode 100644
index 0000000..b6161d4
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_multi_regression.h
@@ -0,0 +1,127 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// gw_multi_regression.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__gw_multi_regression_H
+#define HEADER_INCLUDED__gw_multi_regression_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGW_Multi_Regression : public CSG_Module
+{
+public:
+ CGW_Multi_Regression(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
+
+
+private:
+
+ int m_iDependent, *m_iPredictor, m_nPredictors, m_nPoints_Min, m_nPoints_Max, m_Mode;
+
+ double m_Radius;
+
+ CSG_Parameters_Grid_Target m_Grid_Target;
+
+ CSG_Distance_Weighting m_Weighting;
+
+ CSG_PRQuadTree m_Search;
+
+ CSG_Vector m_z, m_w;
+
+ CSG_Matrix m_y;
+
+ CSG_Shapes *m_pPoints;
+
+ CSG_Grid *m_pQuality, *m_pIntercept, **m_pSlopes;
+
+
+ void Finalize (void);
+
+ bool Get_Predictors (void);
+
+ int Set_Variables (int x, int y);
+
+ bool Get_Regression (int x, int y);
+
+ bool Set_Residuals (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__gw_multi_regression_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_multi_regression_grid.cpp b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_multi_regression_grid.cpp
new file mode 100644
index 0000000..54225f1
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_multi_regression_grid.cpp
@@ -0,0 +1,564 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// gw_multi_regression_grid.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "gw_multi_regression_grid.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define GRID_SET_NODATA(g, x, y) if( g ) { g->Set_NoData(x, y); }
+#define GRID_SET_VALUE(g, x, y, z) if( g ) { g->Set_Value(x, y, z); }
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGW_Multi_Regression_Grid::CGW_Multi_Regression_Grid(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name (_TL("Geographically Weighted Multiple Regression (Points/Grids)"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ "Reference:\n"
+ " - Lloyd, C. (2010): Spatial Data Analysis - An Introduction for GIS Users. Oxford, 206p.\n"
+ ));
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid_List(
+ NULL , "PREDICTORS" , _TL("Predictors"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "REGRESSION" , _TL("Regression"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "QUALITY" , _TL("Coefficient of Determination"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid_List(
+ NULL , "SLOPES" , _TL("Regression Parameters"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL, false
+ );
+
+ Parameters.Add_Value(
+ NULL , "PARAMETERS" , _TL("Output of Regression Parameters"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, false
+ );
+
+ pNode = Parameters.Add_Shapes(
+ NULL , "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "DEPENDENT" , _TL("Dependent Variable"),
+ _TL("")
+ );
+
+ Parameters.Add_Shapes(
+ NULL , "RESIDUALS" , _TL("Residuals"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point
+ );
+
+ //-----------------------------------------------------
+ m_Weighting.Set_Weighting(SG_DISTWGHT_GAUSS);
+
+ Parameters.Add_Parameters(
+ NULL , "WEIGHTING" , _TL("Weighting"),
+ _TL("")
+ )->asParameters()->Assign(m_Weighting.Get_Parameters());
+
+ pNode = Parameters.Add_Choice(
+ NULL , "RANGE" , _TL("Search Range"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("search radius (local)"),
+ _TL("no search radius (global)")
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode , "RADIUS" , _TL("Search Radius"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 100.0
+ );
+
+ Parameters.Add_Choice(
+ pNode , "MODE" , _TL("Search Mode"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("all directions"),
+ _TL("quadrants")
+ )
+ );
+
+ pNode = Parameters.Add_Choice(
+ NULL , "NPOINTS" , _TL("Number of Points"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("maximum number of observations"),
+ _TL("all points")
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode , "MAXPOINTS" , _TL("Maximum Number of Observations"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 10, 2, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "MINPOINTS" , _TL("Minimum Number of Observations"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 4, 2, true
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGW_Multi_Regression_Grid::Initialize(void)
+{
+ bool bAdd;
+ int iPoint, iPredictor, iDependent, Interpolation;
+ double *z;
+ TSG_Point Point;
+ CSG_Shape *pPoint;
+ CSG_Shapes *pPoints;
+
+ //-----------------------------------------------------
+ if( m_pPredictors->Get_Count() < 1 )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ pPoints = Parameters("POINTS") ->asShapes();
+ iDependent = Parameters("DEPENDENT") ->asInt();
+ Interpolation = GRID_INTERPOLATION_BSpline;
+
+ //-----------------------------------------------------
+ m_Points.Create(SHAPE_TYPE_Point);
+ m_Points.Set_Name(pPoints->Get_Name());
+ m_Points.Add_Field(pPoints->Get_Field_Name(iDependent), SG_DATATYPE_Double);
+
+ for(iPredictor=0; iPredictor<m_pPredictors->Get_Count(); iPredictor++)
+ {
+ m_Points.Add_Field(m_pPredictors->asGrid(iPredictor)->Get_Name(), SG_DATATYPE_Double);
+ }
+
+ z = new double[m_pPredictors->Get_Count() + 1];
+
+ //-----------------------------------------------------
+ for(iPoint=0; iPoint<pPoints->Get_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++)
+ {
+ pPoint = pPoints->Get_Shape(iPoint);
+
+ if( !pPoint->is_NoData(iDependent) )
+ {
+ Point = pPoint->Get_Point(0);
+ z[0] = pPoint->asDouble(iDependent);
+
+ for(iPredictor=0, bAdd=true; bAdd && iPredictor<m_pPredictors->Get_Count(); iPredictor++)
+ {
+ if( !m_pPredictors->asGrid(iPredictor)->Get_Value(Point, z[iPredictor + 1], Interpolation) )
+ {
+ bAdd = false;
+ }
+ }
+
+ if( bAdd )
+ {
+ pPoint = m_Points.Add_Shape();
+ pPoint->Add_Point(Point);
+
+ for(iPredictor=0; iPredictor<=m_pPredictors->Get_Count(); iPredictor++)
+ {
+ pPoint->Set_Value(iPredictor, z[iPredictor]);
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ delete[](z);
+
+ return( m_Points.Get_Count() > 1 );
+}
+
+//---------------------------------------------------------
+void CGW_Multi_Regression_Grid::Finalize(void)
+{
+ m_Points.Destroy();
+
+ m_Search.Destroy();
+
+ m_y.Destroy();
+ m_z.Destroy();
+ m_w.Destroy();
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGW_Multi_Regression_Grid::On_Execute(void)
+{
+ int i;
+
+ //-----------------------------------------------------
+ m_pPredictors = Parameters("PREDICTORS") ->asGridList();
+ m_pRegression = Parameters("REGRESSION") ->asGrid();
+ m_pQuality = Parameters("QUALITY") ->asGrid();
+ m_pSlopes = Parameters("SLOPES") ->asGridList();
+ m_Radius = Parameters("RANGE") ->asInt() == 0 ? Parameters("RADIUS") ->asDouble() : 0.0;
+ m_Mode = Parameters("MODE") ->asInt();
+ m_nPoints_Max = Parameters("NPOINTS") ->asInt() == 0 ? Parameters("MAXPOINTS")->asInt() : 0;
+ m_nPoints_Min = Parameters("MINPOINTS") ->asInt();
+
+ m_Weighting.Set_Parameters(Parameters("WEIGHTING")->asParameters());
+
+ //-----------------------------------------------------
+ if( !Initialize() )
+ {
+ Finalize();
+
+ return( false );
+ }
+
+ if( (m_nPoints_Max > 0 || m_Radius > 0.0) && !m_Search.Create(&m_Points, -1) )
+ {
+ Finalize();
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ m_pRegression->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_Points.Get_Name(), _TL("GWR Regression")));
+ m_pQuality ->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_Points.Get_Name(), _TL("GWR Quality")));
+
+ m_pSlopes->Del_Items();
+
+ if( Parameters("PARAMETERS")->asBool() )
+ {
+ CSG_Grid *pGrid;
+
+ m_pSlopes->Add_Item(pGrid = SG_Create_Grid(*Get_System()));
+ pGrid->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_Points.Get_Name(), _TL("Intercept")));
+
+ for(i=0; i<m_pPredictors->Get_Count(); i++)
+ {
+ m_pSlopes->Add_Item(pGrid = SG_Create_Grid(*Get_System()));
+ pGrid->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_Points.Get_Name(), m_pPredictors->asGrid(i)->Get_Name()));
+ }
+ }
+
+ //-----------------------------------------------------
+ int nPoints_Max = m_nPoints_Max > 0 ? m_nPoints_Max : m_Points.Get_Count();
+
+ m_y.Create(1 + m_pPredictors->Get_Count(), nPoints_Max);
+ m_z.Create(nPoints_Max);
+ m_w.Create(nPoints_Max);
+
+ //-----------------------------------------------------
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
+ {
+ bool bNoData = false;
+
+ for(i=0; !bNoData && i<m_pPredictors->Get_Count(); i++)
+ {
+ if( m_pPredictors->asGrid(i)->is_NoData(x, y) )
+ {
+ bNoData = true;
+ }
+ }
+
+ if( bNoData || !Get_Regression(x, y) )
+ {
+ m_pRegression->Set_NoData(x, y);
+ m_pQuality ->Set_NoData(x, y);
+
+ for(i=0; i<m_pSlopes->Get_Count(); i++)
+ {
+ m_pSlopes->asGrid(i)->Set_NoData(x, y);
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ Set_Residuals();
+
+ Finalize();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int CGW_Multi_Regression_Grid::Set_Variables(int x, int y)
+{
+ int nPoints;
+ TSG_Point Point;
+ CSG_Shape *pPoint;
+
+ Point = Get_System()->Get_Grid_to_World(x, y);
+ nPoints = m_Search.is_Okay() ? m_Search.Select_Nearest_Points(Point.x, Point.y, m_nPoints_Max, m_Radius, m_Mode == 0 ? -1 : 4) : m_Points.Get_Count();
+
+ for(int iPoint=0; iPoint<nPoints; iPoint++)
+ {
+ if( m_Search.is_Okay() )
+ {
+ double ix, iy, iz;
+
+ m_Search.Get_Selected_Point(iPoint, ix, iy, iz);
+
+ pPoint = m_Points.Get_Shape((int)iz);
+ }
+ else
+ {
+ pPoint = m_Points.Get_Shape(iPoint);
+ }
+
+ m_z[iPoint] = pPoint->asDouble(0);
+ m_w[iPoint] = m_Weighting.Get_Weight(SG_Get_Distance(Point, pPoint->Get_Point(0)));
+
+ for(int iPredictor=0; iPredictor<m_pPredictors->Get_Count(); iPredictor++)
+ {
+ m_y[iPoint][iPredictor] = pPoint->asDouble(1 + iPredictor);
+ }
+ }
+
+ return( nPoints );
+}
+
+//---------------------------------------------------------
+bool CGW_Multi_Regression_Grid::Get_Regression(int x, int y)
+{
+ int nPoints = Set_Variables(x, y);
+
+ if( nPoints < m_nPoints_Min )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ int i;
+ double zMean, zr, rss, tss;
+ CSG_Vector b, z;
+ CSG_Matrix Y, YtW;
+
+ //-----------------------------------------------------
+ z .Create(nPoints);
+ Y .Create(1 + m_pPredictors->Get_Count(), nPoints);
+ YtW.Create(nPoints, 1 + m_pPredictors->Get_Count());
+
+ for(i=0, zMean=0.0; i<nPoints; i++)
+ {
+ Y [i][0] = 1.0;
+ YtW[0][i] = m_w[i];
+
+ for(int j=0; j<m_pPredictors->Get_Count(); j++)
+ {
+ Y [i][j + 1] = m_y[i][j];
+ YtW[j + 1][i] = m_y[i][j] * m_w[i];
+ }
+
+ zMean += (z[i] = m_z[i]);
+ }
+
+ //-----------------------------------------------------
+ b = (YtW * Y).Get_Inverse() * (YtW * z);
+
+ zMean /= nPoints;
+
+ for(i=0, rss=0.0, tss=0.0; i<nPoints; i++)
+ {
+ zr = b[0];
+
+ for(int j=0; j<m_pPredictors->Get_Count(); j++)
+ {
+ zr += b[j + 1] * m_y[i][j];
+ }
+
+ rss += m_w[i] * SG_Get_Square(m_z[i] - zr);
+ tss += m_w[i] * SG_Get_Square(m_z[i] - zMean);
+ }
+
+ zr = b[0];
+
+ for(i=0; i<m_pPredictors->Get_Count(); i++)
+ {
+ zr += b[i + 1] * m_pPredictors->asGrid(i)->asDouble(x, y);
+ }
+
+ m_pRegression->Set_Value(x, y, zr);
+ m_pQuality ->Set_Value(x, y, tss > 0.0 ? (tss - rss) / tss : 0.0);
+
+ for(i=0; i<m_pSlopes->Get_Count(); i++)
+ {
+ m_pSlopes->asGrid(i)->Set_Value(x, y, b[i]);
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGW_Multi_Regression_Grid::Set_Residuals(void)
+{
+ CSG_Shapes *pResiduals = Parameters("RESIDUALS")->asShapes();
+
+ if( !pResiduals || !m_pRegression )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ pResiduals->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), m_Points.Get_Name(), _TL("Residuals")));
+ pResiduals->Add_Field(m_Points.Get_Field_Name(0), SG_DATATYPE_Double);
+ pResiduals->Add_Field("TREND" , SG_DATATYPE_Double);
+ pResiduals->Add_Field("RESIDUAL", SG_DATATYPE_Double);
+
+ //-------------------------------------------------
+ for(int iShape=0; iShape<m_Points.Get_Count() && Set_Progress(iShape, m_Points.Get_Count()); iShape++)
+ {
+ CSG_Shape *pShape = m_Points.Get_Shape(iShape);
+ double zShape = pShape->asDouble(0);
+
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ double zRegression;
+
+ TSG_Point Point = pShape->Get_Point(iPoint, iPart);
+
+ if( m_pRegression->Get_Value(Point, zRegression) )
+ {
+ CSG_Shape *pResidual = pResiduals->Add_Shape();
+
+ pResidual->Add_Point(Point);
+ pResidual->Set_Value(0, zShape);
+ pResidual->Set_Value(1, zRegression);
+ pResidual->Set_Value(2, zShape - zRegression);
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_multi_regression_grid.h b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_multi_regression_grid.h
new file mode 100644
index 0000000..508fab3
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_multi_regression_grid.h
@@ -0,0 +1,124 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// gw_multi_regression_grid.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__gw_multi_regression_grid_H
+#define HEADER_INCLUDED__gw_multi_regression_grid_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGW_Multi_Regression_Grid : public CSG_Module_Grid
+{
+public:
+ CGW_Multi_Regression_Grid(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ int m_nPoints_Min, m_nPoints_Max, m_Mode;
+
+ double m_Radius;
+
+ CSG_Distance_Weighting m_Weighting;
+
+ CSG_PRQuadTree m_Search;
+
+ CSG_Vector m_z, m_w;
+
+ CSG_Matrix m_y;
+
+ CSG_Shapes m_Points;
+
+ CSG_Grid *m_pRegression, *m_pQuality;
+
+ CSG_Parameter_Grid_List *m_pPredictors, *m_pSlopes;
+
+
+ bool Initialize (void);
+ void Finalize (void);
+
+ int Set_Variables (int x, int y);
+
+ bool Get_Regression (int x, int y);
+
+ bool Set_Residuals (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__gw_multi_regression_grid_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_regression.cpp b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_regression.cpp
new file mode 100644
index 0000000..0e07adb
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_regression.cpp
@@ -0,0 +1,385 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// gw_regression.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "gw_regression.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGW_Regression::CGW_Regression(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name (_TL("Geographically Weighted Regression"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ "Reference:\n"
+ " - Lloyd, C. (2010): Spatial Data Analysis - An Introduction for GIS Users. Oxford, 206p.\n"
+ ));
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Shapes(
+ NULL , "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "DEPENDENT" , _TL("Dependent Variable"),
+ _TL("")
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "PREDICTOR" , _TL("Predictor"),
+ _TL("")
+ );
+
+ //-----------------------------------------------------
+ Parameters.Add_Choice(
+ NULL , "TARGET" , _TL("Target Grids"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("user defined"),
+ _TL("grid")
+ ), 0
+ );
+
+ m_Grid_Target.Add_Parameters_User(Add_Parameters("USER", _TL("User Defined Grid") , _TL("")));
+ m_Grid_Target.Add_Parameters_Grid(Add_Parameters("GRID", _TL("Choose Grid") , _TL("")), false);
+
+ m_Grid_Target.Add_Grid_Parameter(SG_T("QUALITY") , _TL("Quality") , false);
+ m_Grid_Target.Add_Grid_Parameter(SG_T("INTERCEPT") , _TL("Intercept"), false);
+ m_Grid_Target.Add_Grid_Parameter(SG_T("SLOPE") , _TL("Slope") , false);
+
+ //-----------------------------------------------------
+ m_Weighting.Set_Weighting(SG_DISTWGHT_GAUSS);
+
+ Parameters.Add_Parameters(
+ NULL , "WEIGHTING" , _TL("Weighting"),
+ _TL("")
+ )->asParameters()->Assign(m_Weighting.Get_Parameters());
+
+ pNode = Parameters.Add_Choice(
+ NULL , "RANGE" , _TL("Search Range"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("search radius (local)"),
+ _TL("no search radius (global)")
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode , "RADIUS" , _TL("Search Radius"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 100.0
+ );
+
+ Parameters.Add_Choice(
+ pNode , "MODE" , _TL("Search Mode"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("all directions"),
+ _TL("quadrants")
+ )
+ );
+
+ pNode = Parameters.Add_Choice(
+ NULL , "NPOINTS" , _TL("Number of Points"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("maximum number of observations"),
+ _TL("all points")
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode , "MAXPOINTS" , _TL("Maximum Number of Observations"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 10, 2, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "MINPOINTS" , _TL("Minimum Number of Observations"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 4, 2, true
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int CGW_Regression::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ return( m_Grid_Target.On_User_Changed(pParameters, pParameter) ? 1 : 0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGW_Regression::On_Execute(void)
+{
+ //-----------------------------------------------------
+ m_pPoints = Parameters("POINTS") ->asShapes();
+ m_iDependent = Parameters("DEPENDENT") ->asInt();
+ m_iPredictor = Parameters("PREDICTOR") ->asInt();
+ m_Radius = Parameters("RANGE") ->asInt() == 0 ? Parameters("RADIUS") ->asDouble() : 0.0;
+ m_Mode = Parameters("MODE") ->asInt();
+ m_nPoints_Max = Parameters("NPOINTS") ->asInt() == 0 ? Parameters("MAXPOINTS")->asInt() : 0;
+ m_nPoints_Min = Parameters("MINPOINTS") ->asInt();
+
+ m_Weighting.Set_Parameters(Parameters("WEIGHTING")->asParameters());
+
+ //-----------------------------------------------------
+ if( (m_nPoints_Max > 0 || m_Radius > 0.0) && !m_Search.Create(m_pPoints, -1) )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ m_pIntercept = NULL;
+ m_pSlope = NULL;
+ m_pQuality = NULL;
+
+ switch( Parameters("TARGET")->asInt() )
+ {
+ case 0: // user defined...
+ if( m_Grid_Target.Init_User(m_pPoints->Get_Extent()) && Dlg_Parameters("USER") )
+ {
+ m_pIntercept = m_Grid_Target.Get_User(SG_T("INTERCEPT"));
+ m_pSlope = m_Grid_Target.Get_User(SG_T("SLOPE"));
+ m_pQuality = m_Grid_Target.Get_User(SG_T("QUALITY"));
+ }
+ break;
+
+ case 1: // grid...
+ if( Dlg_Parameters("GRID") )
+ {
+ m_pIntercept = m_Grid_Target.Get_Grid(SG_T("INTERCEPT"));
+ m_pSlope = m_Grid_Target.Get_Grid(SG_T("SLOPE"));
+ m_pQuality = m_Grid_Target.Get_Grid(SG_T("QUALITY"));
+ }
+ break;
+ }
+
+ if( m_pIntercept == NULL )
+ {
+ m_Search.Destroy();
+
+ return( false );
+ }
+
+ m_pIntercept->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_pPoints->Get_Name(), _TL("GWR Intercept")));
+ m_pSlope ->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_pPoints->Get_Name(), _TL("GWR Slope")));
+ m_pQuality ->Set_Name(CSG_String::Format(SG_T("%s (%s)"), m_pPoints->Get_Name(), _TL("GWR Quality")));
+
+ //-----------------------------------------------------
+ int nPoints_Max = m_nPoints_Max > 0 ? m_nPoints_Max : m_pPoints->Get_Count();
+
+ m_y.Create(nPoints_Max);
+ m_z.Create(nPoints_Max);
+ m_w.Create(nPoints_Max);
+
+ //-----------------------------------------------------
+ for(int y=0; y<m_pIntercept->Get_NY() && Set_Progress(y, m_pIntercept->Get_NY()); y++)
+ {
+ for(int x=0; x<m_pIntercept->Get_NX(); x++)
+ {
+ if( !Get_Regression(x, y) )
+ {
+ m_pIntercept->Set_NoData(x, y);
+ m_pSlope ->Set_NoData(x, y);
+ m_pQuality ->Set_NoData(x, y);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ m_y.Destroy();
+ m_z.Destroy();
+ m_w.Destroy();
+
+ m_Search.Destroy();
+
+ DataObject_Update(m_pIntercept);
+ DataObject_Update(m_pSlope);
+ DataObject_Update(m_pQuality);
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int CGW_Regression::Set_Variables(int x, int y)
+{
+ int iPoint, jPoint, nPoints;
+ TSG_Point Point;
+ CSG_Shape *pPoint;
+
+ Point = m_pIntercept->Get_System().Get_Grid_to_World(x, y);
+ nPoints = m_Search.is_Okay() ? m_Search.Select_Nearest_Points(Point.x, Point.y, m_nPoints_Max, m_Radius, m_Mode == 0 ? -1 : 4) : m_pPoints->Get_Count();
+
+ for(iPoint=0, jPoint=0; iPoint<nPoints; iPoint++)
+ {
+ if( m_Search.is_Okay() )
+ {
+ double ix, iy, iz;
+
+ m_Search.Get_Selected_Point(iPoint, ix, iy, iz);
+
+ pPoint = m_pPoints->Get_Shape((int)iz);
+ }
+ else
+ {
+ pPoint = m_pPoints->Get_Shape(iPoint);
+ }
+
+ if( !pPoint->is_NoData(m_iDependent) && !pPoint->is_NoData(m_iPredictor) )
+ {
+ m_z[jPoint] = pPoint->asDouble(m_iDependent);
+ m_y[jPoint] = pPoint->asDouble(m_iPredictor);
+ m_w[jPoint] = m_Weighting.Get_Weight(SG_Get_Distance(Point, pPoint->Get_Point(0)));
+
+ jPoint++;
+ }
+ }
+
+ return( jPoint );
+}
+
+//---------------------------------------------------------
+bool CGW_Regression::Get_Regression(int x, int y)
+{
+ int nPoints = Set_Variables(x, y);
+
+ if( nPoints < m_nPoints_Min )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ int i;
+ double zMean, rss, tss;
+ CSG_Vector b, z;
+ CSG_Matrix Y, YtW;
+
+ //-----------------------------------------------------
+ z .Create(nPoints);
+ Y .Create(2, nPoints);
+ YtW.Create(nPoints, 2);
+
+ for(i=0, zMean=0.0; i<nPoints; i++)
+ {
+ Y [i][0] = 1.0;
+ Y [i][1] = m_y[i];
+ YtW[0][i] = m_w[i];
+ YtW[1][i] = m_w[i] * m_y[i];
+
+ zMean += (z[i] = m_z[i]);
+ }
+
+ //-----------------------------------------------------
+ b = (YtW * Y).Get_Inverse() * (YtW * z);
+
+ zMean /= nPoints;
+
+ for(i=0, rss=0.0, tss=0.0; i<nPoints; i++)
+ {
+ rss += m_w[i] * SG_Get_Square(m_z[i] - (b[0] + b[1] * m_y[i]));
+ tss += m_w[i] * SG_Get_Square(m_z[i] - zMean);
+ }
+
+ m_pIntercept->Set_Value(x, y, b[0]);
+ m_pSlope ->Set_Value(x, y, b[1]);
+ m_pQuality ->Set_Value(x, y, (tss - rss) / tss);
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_regression.h b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_regression.h
new file mode 100644
index 0000000..318255a
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_regression.h
@@ -0,0 +1,121 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Grid //
+// //
+//-------------------------------------------------------//
+// //
+// gw_regression.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__GW_Regression_H
+#define HEADER_INCLUDED__GW_Regression_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGW_Regression : public CSG_Module
+{
+public:
+ CGW_Regression(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
+
+
+private:
+
+ int m_iDependent, m_iPredictor, m_nPoints_Min, m_nPoints_Max, m_Mode;
+
+ double m_Radius;
+
+ CSG_Parameters_Grid_Target m_Grid_Target;
+
+ CSG_Distance_Weighting m_Weighting;
+
+ CSG_PRQuadTree m_Search;
+
+ CSG_Vector m_y, m_z, m_w;
+
+ CSG_Shapes *m_pPoints;
+
+ CSG_Grid *m_pIntercept, *m_pSlope, *m_pQuality;
+
+
+ int Set_Variables (int x, int y);
+
+ bool Get_Regression (int x, int y);
+
+ bool Set_Residuals (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__GW_Regression_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_regression_grid.cpp b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_regression_grid.cpp
new file mode 100644
index 0000000..b2065c5
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_regression_grid.cpp
@@ -0,0 +1,430 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// gw_regression_grid.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "gw_regression_grid.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define GRID_INIT(g, s) if( g ) { g->Set_Name(CSG_String::Format(SG_T("%s (%s - %s)"), m_pPoints->Get_Name(), s, m_pPredictor->Get_Name())); }
+#define GRID_SET_NODATA(g, x, y) if( g ) { g->Set_NoData(x, y); }
+#define GRID_SET_VALUE(g, x, y, z) if( g ) { g->Set_Value(x, y, z); }
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGW_Regression_Grid::CGW_Regression_Grid(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name (_TL("Geographically Weighted Regression (Points/Grid)"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ "Reference:\n"
+ " - Lloyd, C. (2010): Spatial Data Analysis - An Introduction for GIS Users. Oxford, 206p.\n"
+ ));
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid(
+ NULL , "PREDICTOR" , _TL("Predictor"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "REGRESSION" , _TL("Regression"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "QUALITY" , _TL("Coefficient of Determination"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid(
+ NULL , "INTERCEPT" , _TL("Intercept"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid(
+ NULL , "SLOPE" , _TL("Slope"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ pNode = Parameters.Add_Shapes(
+ NULL , "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "DEPENDENT" , _TL("Dependent Variable"),
+ _TL("")
+ );
+
+ Parameters.Add_Shapes(
+ NULL , "RESIDUALS" , _TL("Residuals"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point
+ );
+
+ //-----------------------------------------------------
+ m_Weighting.Set_Weighting(SG_DISTWGHT_GAUSS);
+
+ Parameters.Add_Parameters(
+ NULL , "WEIGHTING" , _TL("Weighting"),
+ _TL("")
+ )->asParameters()->Assign(m_Weighting.Get_Parameters());
+
+ pNode = Parameters.Add_Choice(
+ NULL , "RANGE" , _TL("Search Range"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("search radius (local)"),
+ _TL("no search radius (global)")
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode , "RADIUS" , _TL("Search Radius"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 100.0
+ );
+
+ Parameters.Add_Choice(
+ pNode , "MODE" , _TL("Search Mode"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("all directions"),
+ _TL("quadrants")
+ )
+ );
+
+ pNode = Parameters.Add_Choice(
+ NULL , "NPOINTS" , _TL("Number of Points"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("maximum number of observations"),
+ _TL("all points")
+ )
+ );
+
+ Parameters.Add_Value(
+ pNode , "MAXPOINTS" , _TL("Maximum Number of Observations"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 10, 2, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "MINPOINTS" , _TL("Minimum Number of Observations"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 4, 2, true
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGW_Regression_Grid::On_Execute(void)
+{
+ //-----------------------------------------------------
+ m_pPredictor = Parameters("PREDICTOR") ->asGrid();
+ m_pRegression = Parameters("REGRESSION") ->asGrid();
+ m_pQuality = Parameters("QUALITY") ->asGrid();
+ m_pIntercept = Parameters("INTERCEPT") ->asGrid();
+ m_pSlope = Parameters("SLOPE") ->asGrid();
+ m_pPoints = Parameters("POINTS") ->asShapes();
+ m_iDependent = Parameters("DEPENDENT") ->asInt();
+ m_Radius = Parameters("RANGE") ->asInt() == 0 ? Parameters("RADIUS") ->asDouble() : 0.0;
+ m_Mode = Parameters("MODE") ->asInt();
+ m_nPoints_Max = Parameters("NPOINTS") ->asInt() == 0 ? Parameters("MAXPOINTS")->asInt() : 0;
+ m_nPoints_Min = Parameters("MINPOINTS") ->asInt();
+
+ m_Weighting.Set_Parameters(Parameters("WEIGHTING")->asParameters());
+
+ //-----------------------------------------------------
+ if( (m_nPoints_Max > 0 || m_Radius > 0.0) && !m_Search.Create(m_pPoints, -1) )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ GRID_INIT(m_pRegression, _TL("GWR Regression"));
+ GRID_INIT(m_pQuality , _TL("GWR Quality"));
+ GRID_INIT(m_pIntercept , _TL("GWR Intercept"));
+ GRID_INIT(m_pSlope , _TL("GWR Slope"));
+
+ //-----------------------------------------------------
+ int nPoints_Max = m_nPoints_Max > 0 ? m_nPoints_Max : m_pPoints->Get_Count();
+
+ m_y.Create(nPoints_Max);
+ m_z.Create(nPoints_Max);
+ m_w.Create(nPoints_Max);
+
+ //-----------------------------------------------------
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
+ {
+ if( m_pPredictor->is_NoData(x, y) || !Get_Regression(x, y) )
+ {
+ GRID_SET_NODATA(m_pRegression , x, y);
+ GRID_SET_NODATA(m_pIntercept , x, y);
+ GRID_SET_NODATA(m_pSlope , x, y);
+ GRID_SET_NODATA(m_pQuality , x, y);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ Set_Residuals();
+
+ m_y.Destroy();
+ m_z.Destroy();
+ m_w.Destroy();
+
+ m_Search.Destroy();
+
+ DataObject_Update(m_pIntercept);
+ DataObject_Update(m_pSlope);
+ DataObject_Update(m_pQuality);
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int CGW_Regression_Grid::Set_Variables(int x, int y)
+{
+ int iPoint, jPoint, nPoints;
+ double z;
+ TSG_Point Point;
+ CSG_Shape *pPoint;
+
+ Point = Get_System()->Get_Grid_to_World(x, y);
+ nPoints = m_Search.is_Okay() ? m_Search.Select_Nearest_Points(Point.x, Point.y, m_nPoints_Max, m_Radius, m_Mode == 0 ? -1 : 4) : m_pPoints->Get_Count();
+
+ for(iPoint=0, jPoint=0; iPoint<nPoints; iPoint++)
+ {
+ if( m_Search.is_Okay() )
+ {
+ double ix, iy, iz;
+
+ m_Search.Get_Selected_Point(iPoint, ix, iy, iz);
+
+ pPoint = m_pPoints->Get_Shape((int)iz);
+ }
+ else
+ {
+ pPoint = m_pPoints->Get_Shape(iPoint);
+ }
+
+ if( !pPoint->is_NoData(m_iDependent) && m_pPredictor->Get_Value(pPoint->Get_Point(0), z) )
+ {
+ m_w[jPoint] = m_Weighting.Get_Weight(SG_Get_Distance(Point, pPoint->Get_Point(0)));
+ m_z[jPoint] = pPoint->asDouble(m_iDependent);
+ m_y[jPoint] = z;
+
+ jPoint++;
+ }
+ }
+
+ return( jPoint );
+}
+
+//---------------------------------------------------------
+bool CGW_Regression_Grid::Get_Regression(int x, int y)
+{
+ int nPoints = Set_Variables(x, y);
+
+ if( nPoints < m_nPoints_Min )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ int i;
+ double zMean, rss, tss;
+ CSG_Vector b, z;
+ CSG_Matrix Y, YtW;
+
+ //-----------------------------------------------------
+ z .Create(nPoints);
+ Y .Create(2, nPoints);
+ YtW.Create(nPoints, 2);
+
+ for(i=0, zMean=0.0; i<nPoints; i++)
+ {
+ Y [i][0] = 1.0;
+ Y [i][1] = m_y[i];
+ YtW[0][i] = m_w[i];
+ YtW[1][i] = m_w[i] * m_y[i];
+
+ zMean += (z[i] = m_z[i]);
+ }
+
+ //-----------------------------------------------------
+ b = (YtW * Y).Get_Inverse() * (YtW * z);
+
+ zMean /= nPoints;
+
+ for(i=0, rss=0.0, tss=0.0; i<nPoints; i++)
+ {
+ rss += m_w[i] * SG_Get_Square(m_z[i] - (b[0] + b[1] * m_y[i]));
+ tss += m_w[i] * SG_Get_Square(m_z[i] - zMean);
+ }
+
+ GRID_SET_VALUE(m_pRegression, x, y, b[0] + b[1] * m_pPredictor->asDouble(x, y));
+ GRID_SET_VALUE(m_pIntercept , x, y, b[0]);
+ GRID_SET_VALUE(m_pSlope , x, y, b[1]);
+ GRID_SET_VALUE(m_pQuality , x, y, (tss - rss) / tss);
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGW_Regression_Grid::Set_Residuals(void)
+{
+ CSG_Shapes *pResiduals = Parameters("RESIDUALS")->asShapes();
+
+ if( !pResiduals || !m_pPoints || !m_pRegression )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ pResiduals->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), m_pPoints->Get_Name(), _TL("Residuals")));
+ pResiduals->Add_Field(m_pPoints->Get_Field_Name(m_iDependent), SG_DATATYPE_Double);
+ pResiduals->Add_Field("TREND" , SG_DATATYPE_Double);
+ pResiduals->Add_Field("RESIDUAL", SG_DATATYPE_Double);
+
+ //-------------------------------------------------
+ for(int iShape=0; iShape<m_pPoints->Get_Count() && Set_Progress(iShape, m_pPoints->Get_Count()); iShape++)
+ {
+ CSG_Shape *pShape = m_pPoints->Get_Shape(iShape);
+ double zShape = pShape->asDouble(m_iDependent);
+
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ double zRegression;
+
+ TSG_Point Point = pShape->Get_Point(iPoint, iPart);
+
+ if( m_pRegression->Get_Value(Point, zRegression) )
+ {
+ CSG_Shape *pResidual = pResiduals->Add_Shape();
+
+ pResidual->Add_Point(Point);
+ pResidual->Set_Value(0, zShape);
+ pResidual->Set_Value(1, zRegression);
+ pResidual->Set_Value(2, zShape - zRegression);
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_regression_grid.h b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_regression_grid.h
new file mode 100644
index 0000000..a86d8dd
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/gw_regression_grid.h
@@ -0,0 +1,117 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Grid //
+// //
+//-------------------------------------------------------//
+// //
+// gw_regression_grid.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__gw_regression_grid_H
+#define HEADER_INCLUDED__gw_regression_grid_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGW_Regression_Grid : public CSG_Module_Grid
+{
+public:
+ CGW_Regression_Grid(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ int m_iDependent, m_nPoints_Min, m_nPoints_Max, m_Mode;
+
+ double m_Radius;
+
+ CSG_Distance_Weighting m_Weighting;
+
+ CSG_PRQuadTree m_Search;
+
+ CSG_Vector m_y, m_z, m_w;
+
+ CSG_Shapes *m_pPoints;
+
+ CSG_Grid *m_pPredictor, *m_pRegression, *m_pQuality, *m_pIntercept, *m_pSlope;
+
+
+ int Set_Variables (int x, int y);
+
+ bool Get_Regression (int x, int y);
+
+ bool Set_Residuals (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__gw_regression_grid_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/point_grid_regression.cpp b/src/modules_geostatistics/geostatistics/geostatistics_regression/point_grid_regression.cpp
new file mode 100644
index 0000000..8df1d5e
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/point_grid_regression.cpp
@@ -0,0 +1,330 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// point_grid_regression.cpp //
+// //
+// Copyright (C) 2004 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "point_grid_regression.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define GRID_ZFACTOR true
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPoint_Grid_Regression::CPoint_Grid_Regression(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name (_TL("Regression Analysis (Points/Grid)"));
+
+ Set_Author (SG_T("O.Conrad (c) 2004"));
+
+ Set_Description (_TW(
+ "Regression analysis of point attributes with grid values. "
+ "The regression function is used to create a new grid with regression based values. \n"
+ "\n"
+ "Reference:\n"
+ "- Bahrenberg, G., Giese, E., Nipper, J. (1990): "
+ "'Statistische Methoden in der Geographie 1 - Univariate und bivariate Statistik', "
+ "Stuttgart, 233p.\n"
+ ));
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid(
+ NULL , "GRID" , _TL("Grid"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ pNode = Parameters.Add_Shapes(
+ NULL , "SHAPES" , _TL("Shapes"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "ATTRIBUTE" , _TL("Attribute"),
+ _TL("")
+ );
+
+ Parameters.Add_Grid(
+ NULL , "REGRESSION" , _TL("Regression"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Shapes(
+ NULL , "RESIDUAL" , _TL("Residuals"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Choice(
+ NULL ,"INTERPOL" , _TL("Grid Interpolation"),
+ _TL(""),
+
+ CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"),
+ _TL("Nearest Neighbor"),
+ _TL("Bilinear Interpolation"),
+ _TL("Inverse Distance Interpolation"),
+ _TL("Bicubic Spline Interpolation"),
+ _TL("B-Spline Interpolation")
+ ), 4
+ );
+
+ Parameters.Add_Choice(
+ NULL , "METHOD" , _TL("Regression Function"),
+ _TL(""),
+
+ CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"),
+ _TL("Y = a + b * X (linear)"),
+ _TL("Y = a + b / X"),
+ _TL("Y = a / (b - X)"),
+ _TL("Y = a * X^b (power)"),
+ _TL("Y = a e^(b * X) (exponential)"),
+ _TL("Y = a + b * ln(X) (logarithmic)")
+ ), 0
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPoint_Grid_Regression::On_Execute(void)
+{
+ int iAttribute;
+ TSG_Regression_Type Type;
+ CSG_Shapes *pShapes, *pResiduals;
+ CSG_Grid *pGrid, *pRegression;
+
+ //-----------------------------------------------------
+ pGrid = Parameters("GRID") ->asGrid();
+ pRegression = Parameters("REGRESSION") ->asGrid();
+ pShapes = Parameters("SHAPES") ->asShapes();
+ pResiduals = Parameters("RESIDUAL") ->asShapes();
+ iAttribute = Parameters("ATTRIBUTE") ->asInt();
+ m_Interpolation = Parameters("INTERPOL") ->asInt();
+
+ switch( Parameters("METHOD")->asInt() )
+ {
+ default:
+ case 0: Type = REGRESSION_Linear; break; // Y = a + b * X
+ case 1: Type = REGRESSION_Rez_X; break; // Y = a + b / X
+ case 2: Type = REGRESSION_Rez_Y; break; // Y = a / (b - X)
+ case 3: Type = REGRESSION_Pow; break; // Y = a * X^b
+ case 4: Type = REGRESSION_Exp; break; // Y = a e^(b * X)
+ case 5: Type = REGRESSION_Log; break; // Y = a + b * ln(X)
+ }
+
+ //-----------------------------------------------------
+ if( Get_Regression(pGrid, pShapes, pResiduals, iAttribute, Type) )
+ {
+ pRegression->Set_Name(CSG_String::Format(SG_T("%s (%s)"), pShapes->Get_Name(), Get_Name()));
+
+ Set_Regression(pGrid, pRegression);
+
+ Set_Residuals(pResiduals);
+
+ Message_Add(m_Regression.asString());
+
+ m_Regression.Destroy();
+
+ return( true );
+ }
+
+ //-----------------------------------------------------
+ m_Regression.Destroy();
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPoint_Grid_Regression::Get_Regression(CSG_Grid *pGrid, CSG_Shapes *pShapes, CSG_Shapes *pResiduals, int iAttribute, TSG_Regression_Type Type)
+{
+ int iShape, iPart, iPoint;
+ double zShape, zGrid;
+ TSG_Point Point;
+ CSG_Shape *pShape, *pResidual;
+
+ //-----------------------------------------------------
+ if( pResiduals )
+ {
+ pResiduals->Create(SHAPE_TYPE_Point, _TL("Residuals"));
+ pResiduals->Add_Field("ID" , SG_DATATYPE_Int);
+ pResiduals->Add_Field("Y" , SG_DATATYPE_Double);
+ pResiduals->Add_Field("X" , SG_DATATYPE_Double);
+ pResiduals->Add_Field("Y_GUESS" , SG_DATATYPE_Double);
+ pResiduals->Add_Field("Y_RESIDUAL" , SG_DATATYPE_Double);
+ pResiduals->Add_Field("Y_RES_VAR" , SG_DATATYPE_Double);
+ }
+
+ m_Regression.Destroy();
+
+ //-----------------------------------------------------
+ for(iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
+ {
+ pShape = pShapes->Get_Shape(iShape);
+
+ if( !pShape->is_NoData(iAttribute) )
+ {
+ zShape = pShape->asDouble(iAttribute);
+
+ for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ if( pGrid->Get_Value(Point = pShape->Get_Point(iPoint, iPart), zGrid, m_Interpolation, GRID_ZFACTOR) )
+ {
+ m_Regression.Add_Values(zGrid, zShape);
+
+ if( pResiduals )
+ {
+ pResidual = pResiduals->Add_Shape();
+ pResidual->Add_Point(Point);
+ pResidual->Set_Value(0, m_Regression.Get_Count());
+ pResidual->Set_Value(1, zShape);
+ pResidual->Set_Value(2, zGrid);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( m_Regression.Calculate(Type) );
+}
+
+//---------------------------------------------------------
+bool CPoint_Grid_Regression::Set_Regression(CSG_Grid *pGrid, CSG_Grid *pRegression)
+{
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
+ {
+ if( pGrid->is_NoData(x, y) )
+ pRegression->Set_NoData(x, y);
+ else
+ pRegression->Set_Value (x, y, m_Regression.Get_y(pGrid->asDouble(x, y, GRID_ZFACTOR)));
+ }
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CPoint_Grid_Regression::Set_Residuals(CSG_Shapes *pResiduals)
+{
+ int iPoint;
+ double m, b, v, y;
+ CSG_Shape *pPoint;
+
+ if( pResiduals )
+ {
+ m = m_Regression.Get_Coefficient();
+ b = m_Regression.Get_Constant();
+ v = 100.0 / m_Regression.Get_yVariance();
+
+ for(iPoint=0; iPoint<pResiduals->Get_Count() && Set_Progress(iPoint, pResiduals->Get_Count()); iPoint++)
+ {
+ pPoint = pResiduals->Get_Shape(iPoint);
+
+ pPoint->Set_Value(3, y = pPoint->asDouble(2) * m + b);
+ pPoint->Set_Value(4, y = pPoint->asDouble(1) - y);
+ pPoint->Set_Value(5, y * v);
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/point_grid_regression.h b/src/modules_geostatistics/geostatistics/geostatistics_regression/point_grid_regression.h
new file mode 100644
index 0000000..d7701bc
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/point_grid_regression.h
@@ -0,0 +1,107 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Geostatistics_Grid //
+// //
+//-------------------------------------------------------//
+// //
+// point_grid_regression.h //
+// //
+// Copyright (C) 2004 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__point_grid_regression_H
+#define HEADER_INCLUDED__point_grid_regression_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPoint_Grid_Regression : public CSG_Module_Grid
+{
+public:
+ CPoint_Grid_Regression(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ int m_Interpolation;
+
+ CSG_Regression m_Regression;
+
+
+ bool Get_Regression (CSG_Grid *pGrid, CSG_Shapes *pShapes, CSG_Shapes *pResiduals, int iAttribute, TSG_Regression_Type Type);
+ bool Set_Regression (CSG_Grid *pGrid, CSG_Grid *pRegression);
+ bool Set_Residuals (CSG_Shapes *pResiduals);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__point_grid_regression_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/point_multi_grid_regression.cpp b/src/modules_geostatistics/geostatistics/geostatistics_regression/point_multi_grid_regression.cpp
new file mode 100644
index 0000000..600d845
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/point_multi_grid_regression.cpp
@@ -0,0 +1,409 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// point_multi_grid_regression.cpp //
+// //
+// Copyright (C) 2004 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "point_multi_grid_regression.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define GRID_ZFACTOR true
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPoint_Multi_Grid_Regression::CPoint_Multi_Grid_Regression(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name (_TL("Multiple Regression Analysis (Points/Grids)"));
+
+ Set_Author (SG_T("O.Conrad (c) 2004"));
+
+ Set_Description (_TW(
+ "Linear regression analysis of point attributes with multiple grids. "
+ "Details of the regression/correlation analysis will be saved to a table. "
+ "The regression function is used to create a new grid with regression based values. "
+ "The multiple regression analysis uses a forward selection procedure. \n"
+ "\n"
+ "Reference:\n"
+ "- Bahrenberg, G., Giese, E., Nipper, J. (1992): "
+ "'Statistische Methoden in der Geographie 2 - Multivariate Statistik', "
+ "Stuttgart, 415p.\n"
+ ));
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid_List(
+ NULL , "GRIDS" , _TL("Grids"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ pNode = Parameters.Add_Shapes(
+ NULL , "SHAPES" , _TL("Shapes"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "ATTRIBUTE" , _TL("Attribute"),
+ _TL("")
+ );
+
+ Parameters.Add_Table(
+ NULL , "TABLE" , _TL("Details"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Shapes(
+ NULL , "RESIDUAL" , _TL("Residuals"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Grid(
+ NULL , "REGRESSION" , _TL("Regression"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Value(
+ NULL , "COORDS" , _TL("Include Coordinates"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, false
+ );
+
+ Parameters.Add_Choice(
+ NULL ,"INTERPOL" , _TL("Grid Interpolation"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"),
+ _TL("Nearest Neighbor"),
+ _TL("Bilinear Interpolation"),
+ _TL("Inverse Distance Interpolation"),
+ _TL("Bicubic Spline Interpolation"),
+ _TL("B-Spline Interpolation")
+ ), 4
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPoint_Multi_Grid_Regression::On_Execute(void)
+{
+ int iAttribute;
+ CSG_Table *pTable;
+ CSG_Shapes *pShapes, *pResiduals;
+ CSG_Grid *pRegression;
+ CSG_Parameter_Grid_List *pGrids;
+
+ //-----------------------------------------------------
+ pGrids = Parameters("GRIDS") ->asGridList();
+ pRegression = Parameters("REGRESSION") ->asGrid();
+ pTable = Parameters("TABLE") ->asTable();
+ pShapes = Parameters("SHAPES") ->asShapes();
+ pResiduals = Parameters("RESIDUAL") ->asShapes();
+ iAttribute = Parameters("ATTRIBUTE") ->asInt();
+ m_bCoords = Parameters("COORDS") ->asBool();
+ m_Interpolation = Parameters("INTERPOL") ->asInt();
+
+ //-----------------------------------------------------
+ if( Get_Regression(pGrids, pShapes, iAttribute) )
+ {
+ pRegression->Set_Name(CSG_String::Format(SG_T("%s (%s)"), pShapes->Get_Name(), Get_Name()));
+
+ Set_Regression(pGrids, pRegression);
+
+ Set_Residuals(pShapes, iAttribute, pResiduals, pRegression);
+
+ Set_Message();
+
+ if( pTable )
+ {
+ pTable->Assign(m_Regression.Get_Result());
+
+ pTable->Set_Name(_TL("Multiple Regression Analysis"));
+ }
+
+ m_Regression.Destroy();
+
+ return( true );
+ }
+
+ //-----------------------------------------------------
+ m_Regression.Destroy();
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPoint_Multi_Grid_Regression::Get_Regression(CSG_Parameter_Grid_List *pGrids, CSG_Shapes *pShapes, int iAttribute)
+{
+ int iGrid;
+ double zGrid;
+ CSG_Table Table;
+
+ //-----------------------------------------------------
+ Table.Add_Field(pShapes->Get_Name(), SG_DATATYPE_Double);
+
+ for(iGrid=0; iGrid<pGrids->Get_Count(); iGrid++)
+ {
+ Table.Add_Field(pGrids->asGrid(iGrid)->Get_Name(), SG_DATATYPE_Double);
+ }
+
+ if( m_bCoords )
+ {
+ Table.Add_Field(SG_T("X"), SG_DATATYPE_Double);
+ Table.Add_Field(SG_T("Y"), SG_DATATYPE_Double);
+ }
+
+ //-----------------------------------------------------
+ for(int iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
+ {
+ CSG_Shape *pShape = pShapes->Get_Shape(iShape);
+
+ if( !pShape->is_NoData(iAttribute) )
+ {
+ double zShape = pShape->asDouble(iAttribute);
+
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ TSG_Point Point = pShape->Get_Point(iPoint, iPart);
+ CSG_Table_Record *pRecord = Table.Add_Record();
+
+ pRecord->Set_Value(0, zShape);
+
+ for(iGrid=0; iGrid<pGrids->Get_Count() && pRecord; iGrid++)
+ {
+ if( pGrids->asGrid(iGrid)->Get_Value(Point, zGrid, m_Interpolation, GRID_ZFACTOR) )
+ {
+ pRecord->Set_Value(1 + iGrid, zGrid);
+ }
+ else
+ {
+ Table.Del_Record(Table.Get_Record_Count() - 1);
+
+ pRecord = NULL;
+ }
+ }
+
+ if( m_bCoords && pRecord )
+ {
+ pRecord->Set_Value(pGrids->Get_Count() + 1, Point.x);
+ pRecord->Set_Value(pGrids->Get_Count() + 2, Point.y);
+ }
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( m_Regression.Calculate(Table) );
+}
+
+//---------------------------------------------------------
+bool CPoint_Multi_Grid_Regression::Set_Regression(CSG_Parameter_Grid_List *pGrids, CSG_Grid *pRegression)
+{
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
+ {
+ int i, n;
+ double z = m_Regression.Get_RConst();
+
+ for(i=0, n=0; i==n && i<pGrids->Get_Count(); i++)
+ {
+ if( !pGrids->asGrid(i)->is_NoData(x, y) )
+ {
+ z += m_Regression.Get_RCoeff(i) * pGrids->asGrid(i)->asDouble(x, y);
+ n ++;
+ }
+ }
+
+ if( n != pGrids->Get_Count() )
+ {
+ pRegression->Set_NoData(x, y);
+ }
+ else
+ {
+ if( m_bCoords )
+ {
+ z += m_Regression.Get_RCoeff(n + 0) * Get_System()->Get_xGrid_to_World(x);
+ z += m_Regression.Get_RCoeff(n + 1) * Get_System()->Get_yGrid_to_World(y);
+ }
+
+ pRegression->Set_Value (x, y, z);
+ }
+ }
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CPoint_Multi_Grid_Regression::Set_Residuals(CSG_Shapes *pShapes, int iAttribute, CSG_Shapes *pResiduals, CSG_Grid *pRegression)
+{
+ int iPoint, iPart, iShape;
+ double zShape, zGrid;
+ TSG_Point Point;
+ CSG_Shape *pShape, *pResidual;
+
+ //-----------------------------------------------------
+ if( pResiduals )
+ {
+ pResiduals->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Residuals")));
+ pResiduals->Add_Field(pShapes->Get_Field_Name(iAttribute), SG_DATATYPE_Double);
+ pResiduals->Add_Field("TREND" , SG_DATATYPE_Double);
+ pResiduals->Add_Field("RESIDUAL", SG_DATATYPE_Double);
+
+ //-------------------------------------------------
+ for(iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
+ {
+ pShape = pShapes->Get_Shape(iShape);
+
+ if( !pShape->is_NoData(iAttribute) )
+ {
+ zShape = pShape->asDouble(iAttribute);
+
+ for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ Point = pShape->Get_Point(iPoint, iPart);
+
+ if( pRegression->Get_Value(Point, zGrid, m_Interpolation, GRID_ZFACTOR) )
+ {
+ pResidual = pResiduals->Add_Shape();
+ pResidual->Add_Point(Point);
+ pResidual->Set_Value(0, zShape);
+ pResidual->Set_Value(1, zGrid);
+ pResidual->Set_Value(2, zShape - zGrid);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+//---------------------------------------------------------
+void CPoint_Multi_Grid_Regression::Set_Message(void)
+{
+ int i;
+ CSG_String s;
+
+ s += CSG_String::Format(SG_T("\n\n%s:\n Y\t= %f"), _TL("Regression"), m_Regression.Get_RConst());
+
+ for(i=0; i<m_Regression.Get_Count(); i++)
+ {
+ s += CSG_String::Format(SG_T("\n\t %+f\t* [%s]"), m_Regression.Get_RCoeff(i, true), m_Regression.Get_Name(i, true));
+ }
+
+ s += CSG_String::Format(SG_T("\n\n%s:\n"), _TL("Correlation"));
+
+ for(i=0; i<m_Regression.Get_Count(); i++)
+ {
+ s += CSG_String::Format(SG_T("%d: R2 = %f%% [%f%%] -> %s\n"),
+ i + 1,
+ m_Regression.Get_R2 (i, true) * 100.0,
+ m_Regression.Get_R2_Change(i, true) * 100.0,
+ m_Regression.Get_Name (i, true)
+ );
+ }
+
+ Message_Add(s, false);
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/point_multi_grid_regression.h b/src/modules_geostatistics/geostatistics/geostatistics_regression/point_multi_grid_regression.h
new file mode 100644
index 0000000..f4b7d18
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/point_multi_grid_regression.h
@@ -0,0 +1,110 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// point_multi_grid_regression.h //
+// //
+// Copyright (C) 2004 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__point_multi_grid_regression_H
+#define HEADER_INCLUDED__point_multi_grid_regression_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPoint_Multi_Grid_Regression : public CSG_Module_Grid
+{
+public:
+ CPoint_Multi_Grid_Regression(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ bool m_bCoords;
+
+ int m_Interpolation;
+
+ CSG_Regression_Multiple m_Regression;
+
+
+ bool Get_Regression (CSG_Parameter_Grid_List *pGrids, CSG_Shapes *pShapes, int iAttribute);
+ bool Set_Regression (CSG_Parameter_Grid_List *pGrids, CSG_Grid *pRegression);
+ bool Set_Residuals (CSG_Shapes *pShapes, int iAttribute, CSG_Shapes *pResiduals, CSG_Grid *pRegression);
+ void Set_Message (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__point_multi_grid_regression_H
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/point_trend_surface.cpp b/src/modules_geostatistics/geostatistics/geostatistics_regression/point_trend_surface.cpp
new file mode 100644
index 0000000..5c07b38
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/point_trend_surface.cpp
@@ -0,0 +1,405 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// point_trend_surface.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "point_trend_surface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPoint_Trend_Surface::CPoint_Trend_Surface(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name (_TL("Trend Surface"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ "Reference:\n"
+ " - Lloyd, C. (2010): Spatial Data Analysis - An Introduction for GIS Users. Oxford, 206p.\n"
+ ));
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Shapes(
+ NULL , "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Table_Field(
+ pNode , "ATTRIBUTE" , _TL("Attribute"),
+ _TL("")
+ );
+
+ Parameters.Add_Table(
+ NULL , "TABLE" , _TL("Details"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Shapes(
+ NULL , "RESIDUALS" , _TL("Residuals"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Choice(
+ NULL , "TYPE" , _TL("Trend Surface Type"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("first order polynom"),
+ _TL("second order polynom")
+ ), 0
+ );
+
+ //-----------------------------------------------------
+ Parameters.Add_Choice(
+ NULL , "TARGET" , _TL("Trend Surface"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("user defined"),
+ _TL("grid")
+ ), 0
+ );
+
+ m_Grid_Target.Add_Parameters_User(Add_Parameters("USER", _TL("User Defined Grid") , _TL("")));
+ m_Grid_Target.Add_Parameters_Grid(Add_Parameters("GRID", _TL("Choose Grid") , _TL("")));
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int CPoint_Trend_Surface::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ return( m_Grid_Target.On_User_Changed(pParameters, pParameter) ? 1 : 0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPoint_Trend_Surface::On_Execute(void)
+{
+ int iAttribute, Type;
+ CSG_Table *pTable;
+ CSG_Shapes *pPoints, *pResiduals;
+ CSG_Grid *pRegression;
+
+ //-----------------------------------------------------
+ pTable = Parameters("TABLE") ->asTable();
+ pPoints = Parameters("POINTS") ->asShapes();
+ pResiduals = Parameters("RESIDUALS") ->asShapes();
+ iAttribute = Parameters("ATTRIBUTE") ->asInt();
+ Type = Parameters("TYPE") ->asInt();
+
+ //-----------------------------------------------------
+ if( !Get_Regression(pPoints, iAttribute, Type) )
+ {
+ return( false );
+ }
+
+ Set_Message(Type);
+
+ //-----------------------------------------------------
+ pRegression = NULL;
+
+ switch( Parameters("TARGET")->asInt() )
+ {
+ case 0: // user defined...
+ if( m_Grid_Target.Init_User(pPoints->Get_Extent()) && Dlg_Parameters("USER") )
+ {
+ pRegression = m_Grid_Target.Get_User();
+ }
+ break;
+
+ case 1: // grid...
+ if( Dlg_Parameters("GRID") )
+ {
+ pRegression = m_Grid_Target.Get_Grid();
+ }
+ break;
+ }
+
+ if( pRegression == NULL )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ pRegression->Set_Name(CSG_String::Format(SG_T("%s (%s)"), pPoints->Get_Name(), Get_Name()));
+
+ Set_Regression(pRegression, Type);
+
+ Set_Residuals(pPoints, iAttribute, pResiduals, pRegression);
+
+ if( pTable )
+ {
+ pTable->Assign(m_Regression.Get_Result());
+
+ pTable->Set_Name(_TL("Trend Surface Analysis"));
+ }
+
+ m_Regression.Destroy();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPoint_Trend_Surface::Get_Regression(CSG_Shapes *pPoints, int iAttribute, int Type)
+{
+ //-----------------------------------------------------
+ CSG_Table Table;
+
+ Table.Add_Field(pPoints->Get_Name(), SG_DATATYPE_Double);
+
+ Table.Add_Field(SG_T("X"), SG_DATATYPE_Double);
+ Table.Add_Field(SG_T("Y"), SG_DATATYPE_Double);
+
+ if( Type == 1 )
+ {
+ Table.Add_Field(SG_T("XY"), SG_DATATYPE_Double);
+ Table.Add_Field(SG_T("X2"), SG_DATATYPE_Double);
+ Table.Add_Field(SG_T("Y2"), SG_DATATYPE_Double);
+ }
+
+ //-----------------------------------------------------
+ for(int iShape=0; iShape<pPoints->Get_Count() && Set_Progress(iShape, pPoints->Get_Count()); iShape++)
+ {
+ CSG_Shape *pShape = pPoints->Get_Shape(iShape);
+
+ if( !pShape->is_NoData(iAttribute) )
+ {
+ double zShape = pShape->asDouble(iAttribute);
+
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ TSG_Point Point = pShape->Get_Point(iPoint, iPart);
+ CSG_Table_Record *pRecord = Table.Add_Record();
+
+ pRecord->Set_Value(0, zShape);
+
+ pRecord->Set_Value(1, Point.x);
+ pRecord->Set_Value(2, Point.y);
+
+ if( Type == 1 )
+ {
+ pRecord->Set_Value(3, Point.x * Point.y);
+ pRecord->Set_Value(4, Point.x * Point.x);
+ pRecord->Set_Value(5, Point.y * Point.y);
+ }
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( m_Regression.Calculate(Table) );
+}
+
+//---------------------------------------------------------
+bool CPoint_Trend_Surface::Set_Regression(CSG_Grid *pRegression, int Type)
+{
+ int x, y;
+ double z;
+ TSG_Point p;
+
+ for(y=0, p.y=pRegression->Get_YMin(); y<pRegression->Get_NY() && Set_Progress(y, pRegression->Get_NY()); y++, p.y+=pRegression->Get_Cellsize())
+ {
+ for(x=0, p.x=pRegression->Get_XMin(); x<pRegression->Get_NX(); x++, p.x+=pRegression->Get_Cellsize())
+ {
+ z = m_Regression.Get_RConst();
+
+ z += m_Regression.Get_RCoeff(0) * p.x;
+ z += m_Regression.Get_RCoeff(1) * p.y;
+
+ if( Type == 1 )
+ {
+ z += m_Regression.Get_RCoeff(2) * p.x * p.y;
+ z += m_Regression.Get_RCoeff(3) * p.x * p.x;
+ z += m_Regression.Get_RCoeff(4) * p.y * p.y;
+ }
+
+ pRegression->Set_Value (x, y, z);
+ }
+ }
+
+ DataObject_Update(pRegression);
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CPoint_Trend_Surface::Set_Residuals(CSG_Shapes *pPoints, int iAttribute, CSG_Shapes *pResiduals, CSG_Grid *pRegression)
+{
+ int iPoint, iPart, iShape;
+ double zShape, zGrid;
+ TSG_Point Point;
+ CSG_Shape *pShape, *pResidual;
+
+ //-----------------------------------------------------
+ if( pResiduals )
+ {
+ pResiduals->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), _TL("Residuals")));
+ pResiduals->Add_Field(pPoints->Get_Field_Name(iAttribute), SG_DATATYPE_Double);
+ pResiduals->Add_Field("TREND" , SG_DATATYPE_Double);
+ pResiduals->Add_Field("RESIDUAL", SG_DATATYPE_Double);
+
+ //-------------------------------------------------
+ for(iShape=0; iShape<pPoints->Get_Count() && Set_Progress(iShape, pPoints->Get_Count()); iShape++)
+ {
+ pShape = pPoints->Get_Shape(iShape);
+
+ if( !pShape->is_NoData(iAttribute) )
+ {
+ zShape = pShape->asDouble(iAttribute);
+
+ for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ Point = pShape->Get_Point(iPoint, iPart);
+
+ if( pRegression->Get_Value(Point, zGrid) )
+ {
+ pResidual = pResiduals->Add_Shape();
+ pResidual->Add_Point(Point);
+ pResidual->Set_Value(0, zShape);
+ pResidual->Set_Value(1, zGrid);
+ pResidual->Set_Value(2, zShape - zGrid);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+//---------------------------------------------------------
+void CPoint_Trend_Surface::Set_Message(int Type)
+{
+ CSG_String s;
+
+ //-----------------------------------------------------
+ s += CSG_String::Format(SG_T("\n%s:"), _TL("Regression"));
+ s += CSG_String::Format(SG_T("\n Y = %f"), m_Regression.Get_RConst( ));
+ s += CSG_String::Format(SG_T(" %+f*x") , m_Regression.Get_RCoeff(0));
+ s += CSG_String::Format(SG_T(" %+f*y") , m_Regression.Get_RCoeff(1));
+
+ if( Type == 1 )
+ {
+ s += CSG_String::Format(SG_T(" %+f*xy"), m_Regression.Get_RCoeff(2));
+ s += CSG_String::Format(SG_T(" %+f*xx"), m_Regression.Get_RCoeff(3));
+ s += CSG_String::Format(SG_T(" %+f*yy"), m_Regression.Get_RCoeff(4));
+ }
+
+ s += SG_T("\n");
+
+ //-----------------------------------------------------
+ s += CSG_String::Format(SG_T("\n%s:"), _TL("Correlation"));
+
+ s += CSG_String::Format(SG_T("\nR\xc2\xb2 = %2.2f%% [%02.2f%%] -> x"), 100.0 * m_Regression.Get_R2(0), 100.0 * m_Regression.Get_R2_Change(0));
+ s += CSG_String::Format(SG_T("\nR\xc2\xb2 = %2.2f%% [%02.2f%%] -> y"), 100.0 * m_Regression.Get_R2(1), 100.0 * m_Regression.Get_R2_Change(1));
+
+ if( Type == 1 )
+ {
+ s += CSG_String::Format(SG_T("\nR\xc2\xb2 = %2.2f%% [%02.2f%%] -> xy"), 100.0 * m_Regression.Get_R2(2), 100.0 * m_Regression.Get_R2_Change(2));
+ s += CSG_String::Format(SG_T("\nR\xc2\xb2 = %2.2f%% [%02.2f%%] -> xx"), 100.0 * m_Regression.Get_R2(3), 100.0 * m_Regression.Get_R2_Change(3));
+ s += CSG_String::Format(SG_T("\nR\xc2\xb2 = %2.2f%% [%02.2f%%] -> yy"), 100.0 * m_Regression.Get_R2(4), 100.0 * m_Regression.Get_R2_Change(4));
+ }
+
+ s += SG_T("\n");
+
+ //-----------------------------------------------------
+ Message_Add(s, false);
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_geostatistics/geostatistics/geostatistics_regression/point_trend_surface.h b/src/modules_geostatistics/geostatistics/geostatistics_regression/point_trend_surface.h
new file mode 100644
index 0000000..877e156
--- /dev/null
+++ b/src/modules_geostatistics/geostatistics/geostatistics_regression/point_trend_surface.h
@@ -0,0 +1,108 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// geostatistics_regression //
+// //
+//-------------------------------------------------------//
+// //
+// point_trend_surface.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__point_trend_surface_H
+#define HEADER_INCLUDED__point_trend_surface_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPoint_Trend_Surface : public CSG_Module
+{
+public:
+ CPoint_Trend_Surface(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
+
+
+private:
+
+ CSG_Parameters_Grid_Target m_Grid_Target;
+
+ CSG_Regression_Multiple m_Regression;
+
+
+ bool Get_Regression (CSG_Shapes *pPoints, int iAttribute, int Type);
+ bool Set_Regression (CSG_Grid *pRegression, int Type);
+ bool Set_Residuals (CSG_Shapes *pPoints, int iAttribute, CSG_Shapes *pResiduals, CSG_Grid *pRegression);
+ void Set_Message (int Type);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__point_trend_surface_H
diff --git a/src/modules_io/Makefile.am b/src/modules_io/Makefile.am
index cfe0872..f598674 100644
--- a/src/modules_io/Makefile.am
+++ b/src/modules_io/Makefile.am
@@ -1 +1 @@
-SUBDIRS = esri_e00 gps gdal grid shapes table
+SUBDIRS = db esri_e00 gps gdal grid shapes table
diff --git a/src/modules_io/Makefile.in b/src/modules_io/Makefile.in
index ff16ba8..c55d5d9 100644
--- a/src/modules_io/Makefile.in
+++ b/src/modules_io/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -202,7 +203,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = esri_e00 gps gdal grid shapes table
+SUBDIRS = db esri_e00 gps gdal grid shapes table
all: all-recursive
.SUFFIXES:
diff --git a/src/modules_io/db/Makefile.am b/src/modules_io/db/Makefile.am
new file mode 100644
index 0000000..f3c6d7d
--- /dev/null
+++ b/src/modules_io/db/Makefile.am
@@ -0,0 +1 @@
+SUBDIRS = io_odbc
diff --git a/src/modules_io/db/Makefile.in b/src/modules_io/db/Makefile.in
new file mode 100644
index 0000000..8362719
--- /dev/null
+++ b/src/modules_io/db/Makefile.in
@@ -0,0 +1,556 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/modules_io/db
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+ distdir
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+HARU_LIB = @HARU_LIB@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POW_LIB = @POW_LIB@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = io_odbc
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/modules_io/db/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/modules_io/db/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+ install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+ all all-am check check-am clean clean-generic clean-libtool \
+ ctags ctags-recursive distclean distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ 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-recursive \
+ uninstall uninstall-am
+
+
+# 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:
diff --git a/src/modules_io/db/io_odbc/MLB_Interface.cpp b/src/modules_io/db/io_odbc/MLB_Interface.cpp
new file mode 100644
index 0000000..54c09c0
--- /dev/null
+++ b/src/modules_io/db/io_odbc/MLB_Interface.cpp
@@ -0,0 +1,141 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// io_odbc //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.cpp //
+// //
+// Copyright (C) 2004 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// The Module Link Library Interface //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+// 1. Include the appropriate SAGA-API header...
+
+#include "MLB_Interface.h"
+
+
+//---------------------------------------------------------
+// 2. Place general module library informations here...
+
+const SG_Char * Get_Info(int i)
+{
+ switch( i )
+ {
+ case MLB_INFO_Name: default:
+ return( _TL("Import/Export - ODBC/OTL") );
+
+ case MLB_INFO_Author:
+ return( _TL("O.Conrad (c) 2010") );
+
+ case MLB_INFO_Description:
+ return( _TW(
+ "Database access via Open Data Base Connection (ODBC) interface. "
+ "Based on the OTL (Oracle, Odbc and DB2-CLI Template Library), Version 4.0: "
+ "<a target=\"_blank\" href=\"http://otl.sourceforge.net/\">http://otl.sourceforge.net/</a>"
+ ));
+
+ case MLB_INFO_Version:
+ return( _TL("1.0") );
+
+ case MLB_INFO_Menu_Path:
+ return( _TL("Database (ODBC)") );
+ }
+}
+
+
+//---------------------------------------------------------
+// 3. Include the headers of your modules here...
+
+#include "get_connection.h"
+#include "table.h"
+#include "shapes.h"
+#include "pgis_shapes.h"
+
+
+//---------------------------------------------------------
+// 4. Allow your modules to be created here...
+
+CSG_Module * Create_Module(int i)
+{
+ switch( i )
+ {
+ case 0: return( new CGet_Connection );
+ case 1: return( new CDel_Connection );
+ case 2: return( new CTransaction );
+ case 3: return( new CExecute_SQL );
+ case 4: return( new CTable_Info );
+ case 5: return( new CTable_Load );
+ case 6: return( new CTable_Save );
+ case 7: return( new CTable_Drop );
+ case 8: return( new CTable_Query );
+ case 9: return( new CPoints_Load );
+ case 10: return( new CPoints_Save );
+ case 11: return( new CPGIS_Shapes_Load );
+ case 12: return( new CPGIS_Shapes_Save );
+ }
+
+ return( NULL );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+//{{AFX_SAGA
+
+ MLB_INTERFACE
+
+//}}AFX_SAGA
diff --git a/src/modules_io/db/io_odbc/MLB_Interface.h b/src/modules_io/db/io_odbc/MLB_Interface.h
new file mode 100644
index 0000000..fa8bded
--- /dev/null
+++ b/src/modules_io/db/io_odbc/MLB_Interface.h
@@ -0,0 +1,82 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// io_odbc //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.h //
+// //
+// Copyright (C) 2004 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// Include the SAGA-API here //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__io_odbc_H
+#define HEADER_INCLUDED__io_odbc_H
+
+//---------------------------------------------------------
+#include <saga_odbc/saga_odbc.h>
+
+//---------------------------------------------------------
+#ifdef io_odbc_EXPORTS
+ #define io_odbc_EXPORT _SAGA_DLL_EXPORT
+#else
+ #define io_odbc_EXPORT _SAGA_DLL_IMPORT
+#endif
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__io_odbc_H
diff --git a/src/modules_io/db/io_odbc/Makefile.am b/src/modules_io/db/io_odbc/Makefile.am
new file mode 100644
index 0000000..11910d4
--- /dev/null
+++ b/src/modules_io/db/io_odbc/Makefile.am
@@ -0,0 +1,28 @@
+#
+# $Id: Makefile.am,v 1.3 2010/07/08 15:08:36 johanvdw Exp $
+#
+if DEBUG
+DBGFLAGS = -g -DDEBUG
+endif
+if SAGA_UNICODE
+DEP_DEFS = -D_SAGA_UNICODE
+endif
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = $(DEP_LFLG) $(DEP_LIBS) -avoid-version
+pkglib_LTLIBRARIES = libio_odbc.la
+libio_odbc_la_SOURCES =\
+get_connection.cpp\
+MLB_Interface.cpp\
+pgis_shapes.cpp\
+shapes.cpp\
+table.cpp\
+get_connection.h\
+MLB_Interface.h\
+pgis_shapes.h\
+shapes.h\
+table.h
+
+libio_odbc_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(top_srcdir)/src/saga_core/saga_odbc/libsaga_odbc.la
+
diff --git a/src/modules_io/db/io_odbc/Makefile.in b/src/modules_io/db/io_odbc/Makefile.in
new file mode 100644
index 0000000..71db936
--- /dev/null
+++ b/src/modules_io/db/io_odbc/Makefile.in
@@ -0,0 +1,555 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/modules_io/db/io_odbc
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+libio_odbc_la_DEPENDENCIES = \
+ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la \
+ $(top_srcdir)/src/saga_core/saga_odbc/libsaga_odbc.la
+am_libio_odbc_la_OBJECTS = get_connection.lo MLB_Interface.lo \
+ pgis_shapes.lo shapes.lo table.lo
+libio_odbc_la_OBJECTS = $(am_libio_odbc_la_OBJECTS)
+DEFAULT_INCLUDES = -I. at am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libio_odbc_la_SOURCES)
+DIST_SOURCES = $(libio_odbc_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+HARU_LIB = @HARU_LIB@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POW_LIB = @POW_LIB@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#
+# $Id: Makefile.am,v 1.3 2010/07/08 15:08:36 johanvdw Exp $
+#
+ at DEBUG_TRUE@DBGFLAGS = -g -DDEBUG
+ at SAGA_UNICODE_TRUE@DEP_DEFS = -D_SAGA_UNICODE
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = $(DEP_LFLG) $(DEP_LIBS) -avoid-version
+pkglib_LTLIBRARIES = libio_odbc.la
+libio_odbc_la_SOURCES = \
+get_connection.cpp\
+MLB_Interface.cpp\
+pgis_shapes.cpp\
+shapes.cpp\
+table.cpp\
+get_connection.h\
+MLB_Interface.h\
+pgis_shapes.h\
+shapes.h\
+table.h
+
+libio_odbc_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(top_srcdir)/src/saga_core/saga_odbc/libsaga_odbc.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/modules_io/db/io_odbc/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/modules_io/db/io_odbc/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \
+ }
+
+uninstall-pkglibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \
+ done
+
+clean-pkglibLTLIBRARIES:
+ -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+ @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libio_odbc.la: $(libio_odbc_la_OBJECTS) $(libio_odbc_la_DEPENDENCIES)
+ $(CXXLINK) -rpath $(pkglibdir) $(libio_odbc_la_OBJECTS) $(libio_odbc_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/get_connection.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pgis_shapes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/shapes.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/table.Plo at am__quote@
+
+.cpp.o:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+ at am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(pkglibdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+ 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 uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+
+# 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:
diff --git a/src/modules_io/db/io_odbc/get_connection.cpp b/src/modules_io/db/io_odbc/get_connection.cpp
new file mode 100644
index 0000000..e685e3d
--- /dev/null
+++ b/src/modules_io/db/io_odbc/get_connection.cpp
@@ -0,0 +1,452 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// io_odbc //
+// //
+//-------------------------------------------------------//
+// //
+// Get_Connection.cpp //
+// //
+// Copyright (C) 2008 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "get_connection.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CGet_Connection::CGet_Connection(void)
+{
+ Set_Name (_TL("ODBC Connect"));
+
+ Set_Author (SG_T("O.Conrad (c) 2008"));
+
+ Set_Description (_TW(
+ "Connect to ODBC source."
+ ));
+
+ Parameters.Add_Choice(
+ NULL , "SERVERS" , _TL("Server"),
+ _TL(""),
+ _TL("")
+ );
+
+ Parameters.Add_String(
+ NULL , "USERNAME" , _TL("User"),
+ _TL(""),
+ _TL("")
+ );
+
+ Parameters.Add_String(
+ NULL , "PASSWORD" , _TL("Password"),
+ _TL(""),
+ SG_T(""), false, true
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGet_Connection::On_Before_Execution(void)
+{
+ CSG_String Servers;
+
+ if( SG_ODBC_Get_Connection_Manager().Get_Servers(Servers) > 0 )
+ {
+ Parameters("SERVERS")->asChoice()->Set_Items(Servers);
+
+ return( true );
+ }
+
+ Message_Dlg(
+ _TW("No ODBC server available!\n"
+ "Set up an ODBC server first."),
+ _TL("ODBC Database Connection Error")
+ );
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CGet_Connection::On_Execute(void)
+{
+ CSG_String Server, User, Password;
+
+ Server = Parameters("SERVERS") ->asString();
+ User = Parameters("USERNAME") ->asString();
+ Password = Parameters("PASSWORD") ->asString();
+
+ if( SG_ODBC_Get_Connection_Manager().Add_Connection(Server, User, Password) )
+ {
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), Server.c_str(), _TL("ODBC source connected")));
+
+ return( true );
+ }
+
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), Server.c_str(), _TL("could not connect ODBC source")));
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CDel_Connection::CDel_Connection(void)
+{
+ Set_Name (_TL("ODBC Disconnect"));
+
+ Set_Author (SG_T("O.Conrad (c) 2008"));
+
+ Set_Description (_TW(
+ "Disconnect ODBC source."
+ ));
+
+ Parameters.Add_Choice(
+ NULL , "SERVERS" , _TL("Server"),
+ _TL(""),
+ _TL("")
+ );
+
+ Parameters.Add_Choice(
+ NULL , "TRANSACT" , _TL("Transactions"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("rollback"),
+ _TL("commit")
+ ), 1
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CDel_Connection::On_Before_Execution(void)
+{
+ CSG_String Servers;
+
+ if( SG_ODBC_Get_Connection_Manager().Get_Connections(Servers) > 0 )
+ {
+ Parameters("SERVERS")->asChoice()->Set_Items(Servers);
+
+ return( true );
+ }
+
+ Message_Dlg(
+ _TL("No ODBC connection available!"),
+ _TL("ODBC Database Connection Error")
+ );
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CDel_Connection::On_Execute(void)
+{
+ bool bCommit;
+ CSG_String Server;
+
+ Server = Parameters("SERVERS") ->asString();
+ bCommit = Parameters("TRANSACT")->asInt() == 1;
+
+ if( SG_ODBC_Get_Connection_Manager().Del_Connection(Server, bCommit) )
+ {
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), Server.c_str(), _TL("ODBC source connected")));
+
+ return( true );
+ }
+
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), Server.c_str(), _TL("could not connect ODBC source")));
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CTransaction::CTransaction(void)
+{
+ Set_Name (_TL("ODBC Commit/Rollback Transaction"));
+
+ Set_Author (SG_T("O.Conrad (c) 2008"));
+
+ Set_Description (_TW(
+ "Execute a commit or rollback on open transactions with ODBC source."
+ ));
+
+ Parameters.Add_Choice(
+ NULL , "SERVERS" , _TL("Server"),
+ _TL(""),
+ _TL("")
+ );
+
+ Parameters.Add_Choice(
+ NULL , "TRANSACT" , _TL("Transactions"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("rollback"),
+ _TL("commit")
+ ), 1
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CTransaction::On_Before_Execution(void)
+{
+ CSG_String Servers;
+
+ if( SG_ODBC_Get_Connection_Manager().Get_Connections(Servers) > 0 )
+ {
+ Parameters("SERVERS")->asChoice()->Set_Items(Servers);
+
+ return( true );
+ }
+
+ Message_Dlg(
+ _TL("No ODBC connection available!"),
+ _TL("ODBC Database Connection Error")
+ );
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CTransaction::On_Execute(void)
+{
+ CSG_String Server;
+
+ Server = Parameters("SERVERS") ->asString();
+
+ CSG_ODBC_Connection *pConnection = SG_ODBC_Get_Connection_Manager().Get_Connection(Server);
+
+ if( !pConnection )
+ {
+ return( false );
+ }
+
+ if( Parameters("TRANSACT")->asInt() == 1 )
+ {
+ if( pConnection->Commit() )
+ {
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), Server.c_str(), _TL("open transactions committed")));
+
+ return( true );
+ }
+ }
+ else
+ {
+ if( pConnection->Rollback() )
+ {
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), Server.c_str(), _TL("open transactions rollbacked")));
+
+ return( true );
+ }
+ }
+
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), Server.c_str(), _TL("could not commit/rollback transactions.")));
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CExecute_SQL::CExecute_SQL(void)
+{
+ Set_Name (_TL("ODBC Execute SQL"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ "Execute SQL commands on a connected ODBC source. "
+ "Separate different commands with a semicolon (\';\'). "
+ ));
+
+ Parameters.Add_String(
+ NULL , "SQL" , _TL("SQL Statment"),
+ _TL(""),
+ SG_T("CREATE TABLE myTable1 (Col1 VARCHAR(255) PRIMARY KEY, Col2 INTEGER);\n")
+ SG_T("INSERT INTO myTable1 (Col1, Col2) VALUES(\'First Value\', 1);\n")
+ SG_T("DROP TABLE myTable1;\n"),
+ true
+ );
+
+ Parameters.Add_Value(
+ NULL , "COMMIT" , _TL("Commit"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "STOP" , _TL("Stop on Error"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, false
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CExecute_SQL::On_Execute(void)
+{
+ if( !Get_Connection() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ bool bCommit = Parameters("COMMIT") ->asBool ();
+ bool bStop = Parameters("STOP") ->asBool ();
+ CSG_String SQL = Parameters("SQL") ->asString();
+
+ //-----------------------------------------------------
+ if( SQL.Find(SG_T(';')) < 0 )
+ {
+ return( Get_Connection()->Execute(SQL, bCommit) );
+ }
+
+ //-----------------------------------------------------
+ int nSuccess = 0, nErrors = 0;
+
+ SQL += SG_T(';');
+
+ do
+ {
+ CSG_String s = SQL.BeforeFirst(SG_T(';'));
+
+ s.Trim();
+
+ if( s.Length() > 0 )
+ {
+ Message_Add(s);
+
+ if( Get_Connection()->Execute(s, bCommit) )
+ {
+ nSuccess++;
+
+ Message_Add(CSG_String::Format(SG_T("...%s!"), _TL("okay")), false);
+ }
+ else
+ {
+ nErrors++;
+
+ Message_Add(CSG_String::Format(SG_T("...%s!"), _TL("failed")));
+
+ if( bStop )
+ {
+ return( false );
+ }
+ }
+ }
+
+ SQL = SQL.AfterFirst(SG_T(';'));
+ }
+ while( SQL.Length() > 0 );
+
+ return( nErrors == 0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_io/db/io_odbc/get_connection.h b/src/modules_io/db/io_odbc/get_connection.h
new file mode 100644
index 0000000..84d5ade
--- /dev/null
+++ b/src/modules_io/db/io_odbc/get_connection.h
@@ -0,0 +1,168 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// io_odbc //
+// //
+//-------------------------------------------------------//
+// //
+// Get_Connection.h //
+// //
+// Copyright (C) 2008 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Get_Connection_H
+#define HEADER_INCLUDED__Get_Connection_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CGet_Connection : public CSG_Module
+{
+public:
+ CGet_Connection(void);
+
+
+protected:
+
+ virtual bool On_Before_Execution (void);
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CDel_Connection : public CSG_Module
+{
+public:
+ CDel_Connection(void);
+
+
+protected:
+
+ virtual bool On_Before_Execution (void);
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CTransaction : public CSG_ODBC_Module
+{
+public:
+ CTransaction(void);
+
+
+protected:
+
+ virtual bool On_Before_Execution (void);
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CExecute_SQL : public CSG_ODBC_Module
+{
+public:
+ CExecute_SQL(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Get_Connection_H
diff --git a/src/modules_io/db/io_odbc/pgis_shapes.cpp b/src/modules_io/db/io_odbc/pgis_shapes.cpp
new file mode 100644
index 0000000..487592c
--- /dev/null
+++ b/src/modules_io/db/io_odbc/pgis_shapes.cpp
@@ -0,0 +1,549 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// io_odbc //
+// //
+//-------------------------------------------------------//
+// //
+// PGIS_Shapes.cpp //
+// //
+// Copyright (C) 2009 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "pgis_shapes.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPGIS_Shapes_Load::CPGIS_Shapes_Load(void)
+{
+ Set_Name (_TL("PostGIS Shapes Import"));
+
+ Set_Author (SG_T("O.Conrad (c) 2009"));
+
+ Set_Description (_TW(
+ "Imports shapes from a PostGIS database via ODBC."
+ ));
+
+ Parameters.Add_Shapes(
+ NULL , "SHAPES" , _TL("Shapes"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Choice(
+ NULL , "TABLES" , _TL("Tables"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|"),
+ _TL("--- no table available ---")
+ )
+ );
+}
+
+//---------------------------------------------------------
+bool CPGIS_Shapes_Load::On_Before_Execution(void)
+{
+ if( !CSG_ODBC_Module::On_Before_Execution() )
+ {
+ return( false );
+ }
+
+ if( !Get_Connection()->is_PostgreSQL() )
+ {
+ SG_UI_Dlg_Message(_TL("Not a PostgreSQL database!"), _TL("Database Connection Error"));
+
+ return( false );
+ }
+
+ if( !Get_Connection()->Table_Exists(SG_T("spatial_ref_sys")) || !Get_Connection()->Table_Exists(SG_T("geometry_columns")) )
+ {
+ SG_UI_Dlg_Message(_TL("Not a valid PostGIS database!"), _TL("Database Connection Error"));
+
+ return( false );
+ }
+
+ CSG_Table Geo_Tables;
+
+ if( !Get_Connection()->Table_Load(Geo_Tables, SG_T("geometry_columns")) )
+ {
+ return( false );
+ }
+
+ CSG_String s;
+
+ for(int i=0; i<Geo_Tables.Get_Count(); i++)
+ {
+ s += Geo_Tables[i].asString(SG_T("f_table_name")) + CSG_String("|");
+ }
+
+ Parameters("TABLES")->asChoice()->Set_Items(s);
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CPGIS_Shapes_Load::On_Execute(void)
+{
+ TSG_Vertex_Type tVertex;
+ TSG_Shape_Type tShape;
+ CSG_String Select, Geo_Table, Geo_Type, Geo_Field;
+ CSG_Table Geo_Tables;
+ CSG_Shapes *pShapes;
+
+ pShapes = Parameters("SHAPES") ->asShapes();
+ Geo_Table = Parameters("TABLES") ->asString();
+
+ Select.Printf(SG_T("SELECT * FROM geometry_columns WHERE f_table_name = '%s'"), Geo_Table.c_str());
+
+ if( !Get_Connection()->Table_Load(Geo_Tables, SG_T("geometry_columns"), SG_T("*"), CSG_String::Format(SG_T("f_table_name = '%s'"), Geo_Table.c_str()), SG_T("")) )
+ {
+ return( false );
+ }
+
+ if( Geo_Tables.Get_Count() != 1 )
+ {
+ return( false );
+ }
+
+ Geo_Type = Geo_Tables[0].asString(SG_T("type"));
+ Geo_Field = Geo_Tables[0].asString(SG_T("f_geometry_column"));
+
+ //-----------------------------------------------------
+ if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_Point ) ) { tShape = SHAPE_TYPE_Point; tVertex = SG_VERTEX_TYPE_XY; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPoint ) ) { tShape = SHAPE_TYPE_Points; tVertex = SG_VERTEX_TYPE_XY; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_Line ) ) { tShape = SHAPE_TYPE_Line; tVertex = SG_VERTEX_TYPE_XY; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiLine ) ) { tShape = SHAPE_TYPE_Line; tVertex = SG_VERTEX_TYPE_XY; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_Polygon ) ) { tShape = SHAPE_TYPE_Polygon; tVertex = SG_VERTEX_TYPE_XY; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPolygon ) ) { tShape = SHAPE_TYPE_Polygon; tVertex = SG_VERTEX_TYPE_XY; }
+
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_Point_Z ) ) { tShape = SHAPE_TYPE_Point; tVertex = SG_VERTEX_TYPE_XYZ; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPoint_Z ) ) { tShape = SHAPE_TYPE_Points; tVertex = SG_VERTEX_TYPE_XYZ; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_Line_Z ) ) { tShape = SHAPE_TYPE_Line; tVertex = SG_VERTEX_TYPE_XYZ; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiLine_Z ) ) { tShape = SHAPE_TYPE_Line; tVertex = SG_VERTEX_TYPE_XYZ; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_Polygon_Z ) ) { tShape = SHAPE_TYPE_Polygon; tVertex = SG_VERTEX_TYPE_XYZ; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPolygon_Z ) ) { tShape = SHAPE_TYPE_Polygon; tVertex = SG_VERTEX_TYPE_XYZ; }
+
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_Point_M ) ) { tShape = SHAPE_TYPE_Point; tVertex = SG_VERTEX_TYPE_XYZ; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPoint_M ) ) { tShape = SHAPE_TYPE_Points; tVertex = SG_VERTEX_TYPE_XYZ; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_Line_M ) ) { tShape = SHAPE_TYPE_Line; tVertex = SG_VERTEX_TYPE_XYZ; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiLine_M ) ) { tShape = SHAPE_TYPE_Line; tVertex = SG_VERTEX_TYPE_XYZ; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_Polygon_M ) ) { tShape = SHAPE_TYPE_Polygon; tVertex = SG_VERTEX_TYPE_XYZ; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPolygon_M ) ) { tShape = SHAPE_TYPE_Polygon; tVertex = SG_VERTEX_TYPE_XYZ; }
+
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_Point_ZM ) ) { tShape = SHAPE_TYPE_Point; tVertex = SG_VERTEX_TYPE_XYZM; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPoint_ZM ) ) { tShape = SHAPE_TYPE_Points; tVertex = SG_VERTEX_TYPE_XYZM; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_Line_ZM ) ) { tShape = SHAPE_TYPE_Line; tVertex = SG_VERTEX_TYPE_XYZM; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiLine_ZM ) ) { tShape = SHAPE_TYPE_Line; tVertex = SG_VERTEX_TYPE_XYZM; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_Polygon_ZM ) ) { tShape = SHAPE_TYPE_Polygon; tVertex = SG_VERTEX_TYPE_XYZM; }
+ else if( !Geo_Type.CmpNoCase(SG_OGIS_TYPE_STR_MultiPolygon_ZM ) ) { tShape = SHAPE_TYPE_Polygon; tVertex = SG_VERTEX_TYPE_XYZM; }
+
+ else
+ {
+ return( false );
+ }
+
+ if( pShapes->Get_Type() != SHAPE_TYPE_Undefined && pShapes->Get_Type() != tShape )
+ {
+ pShapes = SG_Create_Shapes(tShape, Geo_Table, NULL, tVertex);
+
+ Parameters("SHAPES")->Set_Value(pShapes);
+ }
+ else
+ {
+ pShapes->Create(tShape, Geo_Table, NULL, tVertex);
+ }
+
+ //-----------------------------------------------------
+ if( !Get_Connection()->Table_Load(*pShapes, Geo_Table) )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ if( 1 ) // WKBinary
+ {
+ CSG_Bytes_Array BLOBs;
+
+ Select.Printf(SG_T("AsBinary(%s) AS geom"), Geo_Field.c_str());
+
+ if( !Get_Connection()->Table_Load_BLOBs(BLOBs, Geo_Table, Select, SG_T(""), SG_T("")) )
+ {
+ return( false );
+ }
+
+ if( BLOBs.Get_Count() != pShapes->Get_Count() )
+ {
+ return( false );
+ }
+
+ for(int iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
+ {
+ CSG_Shapes_OGIS_Converter::from_WKBinary(BLOBs[iShape], pShapes->Get_Shape(iShape));
+ }
+ }
+
+ //-----------------------------------------------------
+ else // WKText
+ {
+ CSG_Table Shapes;
+
+ Select.Printf(SG_T("AsText(%s) AS geom"), Geo_Field.c_str());
+
+ if( !Get_Connection()->Table_Load(Shapes, Geo_Table, Select, SG_T(""), SG_T("")) )
+ {
+ return( false );
+ }
+
+ if( Shapes.Get_Count() != pShapes->Get_Count() )
+ {
+ return( false );
+ }
+
+ for(int iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
+ {
+ CSG_Shapes_OGIS_Converter::from_WKText(Shapes[iShape].asString(0), pShapes->Get_Shape(iShape));
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPGIS_Shapes_Save::CPGIS_Shapes_Save(void)
+{
+ Set_Name (_TL("PostGIS Shapes Export"));
+
+ Set_Author (SG_T("O.Conrad (c) 2009"));
+
+ Set_Description (_TW(
+ "Imports shapes from a PostGIS database via ODBC."
+ ));
+
+ Parameters.Add_Shapes(
+ NULL , "SHAPES" , _TL("Shapes"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_String(
+ NULL , "NAME" , _TL("Table Name"),
+ _TL("if empty shapes layers's name is used as table name"),
+ SG_T("")
+ );
+
+ Parameters.Add_Choice(
+ NULL , "SRID" , _TL("Spatial Reference"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|"),
+ _TL("--- not available ---")
+ )
+ );
+
+ Parameters.Add_Parameters(
+ NULL , "FLAGS" , _TL("Constraints"),
+ _TL("")
+ );
+
+ Parameters.Add_Choice(
+ NULL , "EXISTS" , _TL("If table exists..."),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s"),
+ _TL("abort export"),
+ _TL("replace existing table"),
+ _TL("append records, if table structure allows")
+ ), 0
+ );
+}
+
+//---------------------------------------------------------
+int CPGIS_Shapes_Save::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("SHAPES")) )
+ {
+ pParameters->Get_Parameter("NAME")->Set_Value(pParameter->asShapes() ? pParameter->asShapes()->Get_Name() : SG_T(""));
+
+ Set_Constraints(pParameters->Get_Parameter("FLAGS")->asParameters(), pParameter->asShapes());
+ }
+
+ return( 0 );
+}
+
+//---------------------------------------------------------
+bool CPGIS_Shapes_Save::On_Before_Execution(void)
+{
+ if( !CSG_ODBC_Module::On_Before_Execution() )
+ {
+ return( false );
+ }
+
+ if( !Get_Connection()->is_PostgreSQL() )
+ {
+ SG_UI_Dlg_Message(_TL("Not a PostgreSQL database!"), _TL("Database Connection Error"));
+
+ return( false );
+ }
+
+ if( !Get_Connection()->Table_Exists(SG_T("spatial_ref_sys")) || !Get_Connection()->Table_Exists(SG_T("geometry_columns")) )
+ {
+ SG_UI_Dlg_Message(_TL("Not a valid PostGIS database!"), _TL("Database Connection Error"));
+
+ return( false );
+ }
+
+ Parameters("SRID")->asChoice()->Set_Items(SG_Get_Projections().Get_Names());
+
+/* if( Parameters("SRID")->asChoice()->Get_Count() > 1 )
+ return( true );
+
+ CSG_Table SRIDs;
+
+ if( !Get_Connection()->Table_Load(SRIDs, SG_T("spatial_ref_sys")) || SRIDs.Get_Count() == 0 )
+ {
+ return( false );
+ }
+
+ CSG_String s, sID;
+
+ for(int i=0; i<SRIDs.Get_Count(); i++)
+ {
+ sID = SRIDs[i].asString(3);
+
+ s += sID.AfterFirst('\"').BeforeFirst('\"') + SG_T("|");
+ }
+
+ Parameters("SRID")->asChoice()->Set_Items(s);
+/**/
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CPGIS_Shapes_Save::On_Execute(void)
+{
+ int SRID;
+ CSG_Shapes *pShapes;
+ CSG_String SQL, Geo_Table, Geo_Type, Geo_Field, sSRID;
+
+ pShapes = Parameters("SHAPES") ->asShapes();
+ Geo_Table = Parameters("NAME") ->asString(); if( Geo_Table.Length() == 0 ) Geo_Table = pShapes->Get_Name();
+ SRID = Parameters("SRID") ->asInt();
+ SRID = SG_Get_Projections().Get_SRID_byNamesIndex(SRID);
+
+ sSRID.Printf(SG_T("%d"), SRID);
+
+ //-----------------------------------------------------
+ switch( pShapes->Get_Vertex_Type() )
+ {
+ case SG_VERTEX_TYPE_XY:
+ switch( pShapes->Get_Type() )
+ { default: return( false );
+ case SHAPE_TYPE_Point: Geo_Type = SG_OGIS_TYPE_STR_Point; Geo_Field = SG_T("geo_point"); break;
+ case SHAPE_TYPE_Points: Geo_Type = SG_OGIS_TYPE_STR_MultiPoint; Geo_Field = SG_T("geo_points"); break;
+ case SHAPE_TYPE_Line: Geo_Type = SG_OGIS_TYPE_STR_MultiLine; Geo_Field = SG_T("geo_line"); break;
+ case SHAPE_TYPE_Polygon: Geo_Type = SG_OGIS_TYPE_STR_MultiPolygon; Geo_Field = SG_T("geo_polygon"); break;
+ }
+ break;
+
+ case SG_VERTEX_TYPE_XYZ:
+ switch( pShapes->Get_Type() )
+ { default: return( false );
+ case SHAPE_TYPE_Point: Geo_Type = SG_OGIS_TYPE_STR_Point_Z; Geo_Field = SG_T("geo_point_z"); break;
+ case SHAPE_TYPE_Points: Geo_Type = SG_OGIS_TYPE_STR_MultiPoint_Z; Geo_Field = SG_T("geo_points_z"); break;
+ case SHAPE_TYPE_Line: Geo_Type = SG_OGIS_TYPE_STR_MultiLine_Z; Geo_Field = SG_T("geo_line_z"); break;
+ case SHAPE_TYPE_Polygon: Geo_Type = SG_OGIS_TYPE_STR_MultiPolygon_Z; Geo_Field = SG_T("geo_polygon_z"); break;
+ }
+ break;
+
+ case SG_VERTEX_TYPE_XYZM:
+ switch( pShapes->Get_Type() )
+ { default: return( false );
+ case SHAPE_TYPE_Point: Geo_Type = SG_OGIS_TYPE_STR_Point_ZM; Geo_Field = SG_T("geo_point_zm"); break;
+ case SHAPE_TYPE_Points: Geo_Type = SG_OGIS_TYPE_STR_MultiPoint_ZM; Geo_Field = SG_T("geo_points_zm"); break;
+ case SHAPE_TYPE_Line: Geo_Type = SG_OGIS_TYPE_STR_MultiLine_ZM; Geo_Field = SG_T("geo_line_zm"); break;
+ case SHAPE_TYPE_Polygon: Geo_Type = SG_OGIS_TYPE_STR_MultiPolygon_ZM; Geo_Field = SG_T("geo_polygon_zm"); break;
+ }
+ break;
+ }
+
+ //-----------------------------------------------------
+ if( Get_Connection()->Table_Exists(Geo_Table) )
+ {
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("table already exists"), Geo_Table.c_str()));
+
+ switch( Parameters("EXISTS")->asInt() )
+ {
+ case 0: // abort export
+ return( false );
+
+ case 1: // replace existing table
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("trying to drop table"), Geo_Table.c_str()));
+
+ if( !Get_Connection()->Table_Drop(Geo_Table, false) )
+ {
+ Message_Add(CSG_String::Format(SG_T(" ...%s!"), _TL("failed")));
+
+ return( false );
+ }
+
+ break;
+
+ case 2: // append records, if table structure allows
+ break;
+ }
+ }
+
+ //-----------------------------------------------------
+ if( !Get_Connection()->Table_Exists(Geo_Table) && !Get_Connection()->Table_Create(Geo_Table, *pShapes, Get_Constraints(Parameters("FLAGS")->asParameters(), pShapes), false) )
+ {
+ Get_Connection()->Rollback();
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ SQL.Printf(SG_T("SELECT AddGeometryColumn('%s', '%s', %d, '%s', %d)"),
+ Geo_Table.c_str(), // <table_name>
+ Geo_Field.c_str(), // <column_name>
+ SRID, // <srid>
+ Geo_Type.Make_Upper().c_str(), // <type>
+ 2 // <dimension>
+ );
+
+ if( !Get_Connection()->Execute(SQL) )
+ {
+ Get_Connection()->Rollback();
+
+ Message_Add(_TL("could not create geometry field"));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ int iShape, iField, nAdded;
+ CSG_String Insert, Fields, sWKT;
+
+ Fields = Geo_Field;
+
+ for(iField=0; iField<pShapes->Get_Field_Count(); iField++)
+ {
+ Fields += CSG_String(", ") + pShapes->Get_Field_Name(iField);
+ }
+
+ Insert.Printf(SG_T("INSERT INTO %s (%s) VALUES ("), Geo_Table.c_str(), Fields.c_str());
+
+ for(iShape=0, nAdded=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
+ {
+ CSG_Shape *pShape = pShapes->Get_Shape(iShape);
+
+ if( pShape->is_Valid() )
+ {
+ SQL = Insert;
+
+ CSG_Shapes_OGIS_Converter::to_WKText(pShape, sWKT);
+
+ SQL += SG_T("GeomFromText('") + sWKT + SG_T("', ") + sSRID + SG_T(")");
+
+ for(iField=0; iField<pShapes->Get_Field_Count(); iField++)
+ {
+ CSG_String s = pShape->asString(iField);
+
+ if( pShapes->Get_Field_Type(iField) == SG_DATATYPE_String )
+ {
+ s.Replace(SG_T("'"), SG_T("\""));
+ s = SG_T("'") + s + SG_T("'");
+ }
+
+ SQL += SG_T(", ") + s;
+ }
+
+ SQL += SG_T(")");
+
+ if( Get_Connection()->Execute(SQL) )
+ {
+ nAdded++;
+ }
+ else
+ {
+ Message_Add(CSG_String::Format(SG_T("dropped %d. shape"), iShape));
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ if( nAdded == 0 )
+ {
+ Get_Connection()->Rollback();
+
+ Get_Connection()->Table_Drop(Geo_Table);
+
+ return( false );
+ }
+
+ return( Get_Connection()->Commit() );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_io/db/io_odbc/pgis_shapes.h b/src/modules_io/db/io_odbc/pgis_shapes.h
new file mode 100644
index 0000000..7cf6aee
--- /dev/null
+++ b/src/modules_io/db/io_odbc/pgis_shapes.h
@@ -0,0 +1,132 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// io_odbc //
+// //
+//-------------------------------------------------------//
+// //
+// PGIS_Shapes.h //
+// //
+// Copyright (C) 2009 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__PGIS_Shapes_H
+#define HEADER_INCLUDED__PGIS_Shapes_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPGIS_Shapes_Load : public CSG_ODBC_Module
+{
+public:
+ CPGIS_Shapes_Load(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( SG_T("R:PostGIS") ); }
+
+
+protected:
+
+ virtual bool On_Before_Execution (void);
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPGIS_Shapes_Save : public CSG_ODBC_Module
+{
+public:
+ CPGIS_Shapes_Save(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( SG_T("R:PostGIS") ); }
+
+
+protected:
+
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
+
+ virtual bool On_Before_Execution (void);
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__PGIS_Shapes_H
diff --git a/src/modules_io/db/io_odbc/shapes.cpp b/src/modules_io/db/io_odbc/shapes.cpp
new file mode 100644
index 0000000..18603bf
--- /dev/null
+++ b/src/modules_io/db/io_odbc/shapes.cpp
@@ -0,0 +1,168 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// io_odbc //
+// //
+//-------------------------------------------------------//
+// //
+// Shapes.cpp //
+// //
+// Copyright (C) 2009 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "get_connection.h"
+
+#include "shapes.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPoints_Load::CPoints_Load(void)
+{
+ Set_Name (_TL("Points Import"));
+
+ Set_Author (SG_T("O.Conrad (c) 2009"));
+
+ Set_Description (_TW(
+ "Imports points from a database via ODBC."
+ ));
+
+ Parameters.Add_Shapes(
+ NULL , "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_OUTPUT, SHAPE_TYPE_Point
+ );
+
+ Parameters.Add_Choice(
+ NULL , "TABLES" , _TL("Tables"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|"),
+ _TL("--- no table available ---")
+ )
+ );
+}
+
+//---------------------------------------------------------
+bool CPoints_Load::On_Before_Execution(void)
+{
+ if( !CSG_ODBC_Module::On_Before_Execution() )
+ {
+ return( false );
+ }
+
+ CSG_String Table(Parameters("TABLES")->asString());
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CPoints_Load::On_Execute(void)
+{
+ if( Get_Connection()->is_Connected() )
+ {
+ CSG_Parameter_Choice *pTables = Parameters("TABLES") ->asChoice();
+ CSG_Shapes *pShapes = Parameters("POINTS") ->asShapes();
+
+ return( Get_Connection()->Table_Load(*pShapes, pTables->asString()) );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPoints_Save::CPoints_Save(void)
+{
+ Set_Name (_TL("Points Export"));
+
+ Set_Author (SG_T("O.Conrad (c) 2009"));
+
+ Set_Description (_TW(
+ "Exports points to a database via ODBC."
+ ));
+
+ Parameters.Add_Shapes(
+ NULL , "POINTS" , _TL("Points"),
+ _TL(""),
+ PARAMETER_INPUT, SHAPE_TYPE_Point
+ );
+}
+
+//---------------------------------------------------------
+bool CPoints_Save::On_Execute(void)
+{
+ if( Get_Connection()->is_Connected() )
+ {
+ CSG_Shapes *pShapes = Parameters("POINTS") ->asShapes();
+
+ return( Get_Connection()->Table_Save(pShapes->Get_Name(), *pShapes) );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_io/db/io_odbc/shapes.h b/src/modules_io/db/io_odbc/shapes.h
new file mode 100644
index 0000000..6c635c9
--- /dev/null
+++ b/src/modules_io/db/io_odbc/shapes.h
@@ -0,0 +1,124 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// io_odbc //
+// //
+//-------------------------------------------------------//
+// //
+// Shapes.h //
+// //
+// Copyright (C) 2009 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Shapes_H
+#define HEADER_INCLUDED__Shapes_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPoints_Load : public CSG_ODBC_Module
+{
+public:
+ CPoints_Load(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( SG_T("R:Shapes") ); }
+
+
+protected:
+
+ virtual bool On_Before_Execution (void);
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPoints_Save : public CSG_ODBC_Module
+{
+public:
+ CPoints_Save(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( SG_T("R:Shapes") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Shapes_H
diff --git a/src/modules_io/db/io_odbc/table.cpp b/src/modules_io/db/io_odbc/table.cpp
new file mode 100644
index 0000000..2237cb7
--- /dev/null
+++ b/src/modules_io/db/io_odbc/table.cpp
@@ -0,0 +1,462 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// io_odbc //
+// //
+//-------------------------------------------------------//
+// //
+// Table.cpp //
+// //
+// Copyright (C) 2008 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "get_connection.h"
+
+#include "table.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CTable_Info::CTable_Info(void)
+{
+ Set_Name (_TL("Table Field Description"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ "Loads table information from ODBC data source."
+ ));
+
+ Parameters.Add_Table(
+ NULL , "TABLE" , _TL("Field Description"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Choice(
+ NULL , "TABLES" , _TL("Tables"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|"),
+ _TL("--- no table available ---")
+ )
+ );
+}
+
+//---------------------------------------------------------
+bool CTable_Info::On_Before_Execution(void)
+{
+ if( !CSG_ODBC_Module::On_Before_Execution() )
+ {
+ return( false );
+ }
+
+ CSG_String Table(Parameters("TABLES")->asString());
+
+ Parameters("TABLES")->asChoice()->Set_Items(Get_Connection()->Get_Tables());
+ Parameters("TABLES")->Set_Value(Table);
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CTable_Info::On_Execute(void)
+{
+ if( !Get_Connection() )
+ {
+ return( false );
+ }
+
+ CSG_Parameter_Choice *pTables = Parameters("TABLES") ->asChoice();
+ CSG_Table *pTable = Parameters("TABLE") ->asTable();
+
+ pTable->Assign(&Get_Connection()->Get_Field_Desc(pTables->asString()));
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CTable_Load::CTable_Load(void)
+{
+ Set_Name (_TL("Table Import"));
+
+ Set_Author (SG_T("O.Conrad (c) 2008"));
+
+ Set_Description (_TW(
+ "Imports a table from a database via ODBC."
+ ));
+
+ Parameters.Add_Table(
+ NULL , "TABLE" , _TL("Table"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Choice(
+ NULL , "TABLES" , _TL("Tables"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|"),
+ _TL("--- no table available ---")
+ )
+ );
+}
+
+//---------------------------------------------------------
+bool CTable_Load::On_Before_Execution(void)
+{
+ if( !CSG_ODBC_Module::On_Before_Execution() )
+ {
+ return( false );
+ }
+
+ CSG_String Table(Parameters("TABLES")->asString());
+
+ Parameters("TABLES")->asChoice()->Set_Items(Get_Connection()->Get_Tables());
+ Parameters("TABLES")->Set_Value(Table);
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CTable_Load::On_Execute(void)
+{
+ if( !Get_Connection() )
+ {
+ return( false );
+ }
+
+ CSG_Parameter_Choice *pTables = Parameters("TABLES") ->asChoice();
+ CSG_Table *pTable = Parameters("TABLE") ->asTable();
+
+ return( Get_Connection()->Table_Load(*pTable, pTables->asString()) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CTable_Save::CTable_Save(void)
+{
+ Set_Name (_TL("Table Export"));
+
+ Set_Author (SG_T("O.Conrad (c) 2008"));
+
+ Set_Description (_TW(
+ "Exports a table to a database via ODBC."
+ ));
+
+ Parameters.Add_Table(
+ NULL , "TABLE" , _TL("Table"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_String(
+ NULL , "NAME" , _TL("Table Name"),
+ _TL(""),
+ SG_T("")
+ );
+
+ Parameters.Add_Parameters(
+ NULL , "FLAGS" , _TL("Constraints"),
+ _TL("")
+ );
+
+ Parameters.Add_Choice(
+ NULL , "EXISTS" , _TL("If table exists..."),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("abort export"),
+ _TL("replace existing table"),
+ _TL("append records, if table structure allows")
+ ), 0
+ );
+}
+
+//---------------------------------------------------------
+int CTable_Save::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("TABLE")) )
+ {
+ pParameters->Get_Parameter("NAME")->Set_Value(pParameter->asTable() ? pParameter->asTable()->Get_Name() : SG_T(""));
+
+ Set_Constraints(pParameters->Get_Parameter("FLAGS")->asParameters(), pParameter->asTable());
+ }
+
+ return( 0 );
+}
+
+//---------------------------------------------------------
+bool CTable_Save::On_Execute(void)
+{
+ if( !Get_Connection() )
+ {
+ return( false );
+ }
+
+ CSG_Table *pTable = Parameters("TABLE") ->asTable();
+ CSG_String Name = Parameters("NAME") ->asString(); if( Name.Length() == 0 ) Name = pTable->Get_Name();
+
+ //-----------------------------------------------------
+ if( Get_Connection()->Table_Exists(Name) )
+ {
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("table already exists"), Name.c_str()));
+
+ switch( Parameters("EXISTS")->asInt() )
+ {
+ case 0: // abort export
+ return( false );
+
+ case 1: // replace existing table
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("dropping table"), Name.c_str()));
+
+ if( !Get_Connection()->Table_Drop(Name, false) )
+ {
+ Message_Add(CSG_String::Format(SG_T(" ...%s!"), _TL("failed")));
+
+ return( false );
+ }
+
+ return( Get_Connection()->Table_Save(Name, *pTable, Get_Constraints(Parameters("FLAGS")->asParameters(), pTable)) );
+
+ case 2: // append records, if table structure allows
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("appending to existing table"), Name.c_str()));
+
+ if( !Get_Connection()->Table_Insert(Name, *pTable) )
+ {
+ Message_Add(CSG_String::Format(SG_T(" ...%s!"), _TL("failed")));
+
+ return( false );
+ }
+
+ return( true );
+ }
+ }
+ else
+ {
+ return( Get_Connection()->Table_Save(Name, *pTable, Get_Constraints(Parameters("FLAGS")->asParameters(), pTable)) );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CTable_Drop::CTable_Drop(void)
+{
+ Set_Name (_TL("Table Deletion"));
+
+ Set_Author (SG_T("O.Conrad (c) 2008"));
+
+ Set_Description (_TW(
+ "Deletes a table from a database via ODBC."
+ ));
+
+ Parameters.Add_Choice(
+ NULL , "TABLES" , _TL("Tables"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|"),
+ _TL("--- no table available ---")
+ )
+ );
+}
+
+//---------------------------------------------------------
+bool CTable_Drop::On_Before_Execution(void)
+{
+ if( !CSG_ODBC_Module::On_Before_Execution() )
+ {
+ return( false );
+ }
+
+ CSG_String Table(Parameters("TABLES")->asString());
+
+ Parameters("TABLES")->asChoice()->Set_Items(Get_Connection()->Get_Tables());
+
+ if( Parameters("TABLES")->asChoice()->Get_Count() == 0 )
+ {
+ Message_Dlg(_TL("No tables available in database!"));
+
+ return( false );
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CTable_Drop::On_Execute(void)
+{
+ if( !Get_Connection() )
+ {
+ return( false );
+ }
+
+ return( Get_Connection()->Table_Drop(Parameters("TABLES")->asChoice()->asString()) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CTable_Query::CTable_Query(void)
+{
+ CSG_Parameter *pNode;
+
+ Set_Name (_TL("Table from Query"));
+
+ Set_Author (SG_T("O.Conrad (c) 2008"));
+
+ Set_Description (_TW(
+ "Import a SQL table from a database via ODBC."
+ ));
+
+ Parameters.Add_Table(
+ NULL , "TABLE" , _TL("Table from SQL Query"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_String(
+ NULL , "TABLES" , _TL("Tables"),
+ _TL(""),
+ SG_T("")
+ );
+
+ Parameters.Add_String(
+ NULL , "FIELDS" , _TL("Fields"),
+ _TL(""),
+ SG_T("*")
+ );
+
+ Parameters.Add_String(
+ NULL , "WHERE" , _TL("Where"),
+ _TL(""),
+ SG_T("")
+ );
+
+ pNode = Parameters.Add_String(
+ NULL , "GROUP" , _TL("Group by"),
+ _TL(""),
+ SG_T("")
+ );
+
+ Parameters.Add_String(
+ pNode , "HAVING" , _TL("Having"),
+ _TL(""),
+ SG_T("")
+ );
+
+ Parameters.Add_String(
+ NULL , "ORDER" , _TL("Order by"),
+ _TL(""),
+ SG_T("")
+ );
+
+ Parameters.Add_Value(
+ NULL , "DISTINCT" , _TL("Distinct"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, false
+ );
+}
+
+//---------------------------------------------------------
+bool CTable_Query::On_Execute(void)
+{
+ if( !Get_Connection() )
+ {
+ return( false );
+ }
+
+ CSG_Table *pTable = Parameters("TABLE") ->asTable ();
+ CSG_String Tables = Parameters("TABLES") ->asString();
+ CSG_String Fields = Parameters("FIELDS") ->asString();
+ CSG_String Where = Parameters("WHERE") ->asString();
+ CSG_String Group = Parameters("GROUP") ->asString();
+ CSG_String Having = Parameters("HAVING") ->asString();
+ CSG_String Order = Parameters("ORDER") ->asString();
+ bool bDistinct = Parameters("DISTINCT")->asBool ();
+
+ return( Get_Connection()->Table_Load(*pTable, Tables, Fields, Where, Group, Having, Order, bDistinct) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_io/db/io_odbc/table.h b/src/modules_io/db/io_odbc/table.h
new file mode 100644
index 0000000..8a3f449
--- /dev/null
+++ b/src/modules_io/db/io_odbc/table.h
@@ -0,0 +1,192 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// io_odbc //
+// //
+//-------------------------------------------------------//
+// //
+// Table.h //
+// //
+// Copyright (C) 2005 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Table_H
+#define HEADER_INCLUDED__Table_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CTable_Info : public CSG_ODBC_Module
+{
+public:
+ CTable_Info(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( SG_T("R:Tables") ); }
+
+
+protected:
+
+ virtual bool On_Before_Execution (void);
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CTable_Load : public CSG_ODBC_Module
+{
+public:
+ CTable_Load(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( SG_T("R:Tables") ); }
+
+
+protected:
+
+ virtual bool On_Before_Execution (void);
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CTable_Save : public CSG_ODBC_Module
+{
+public:
+ CTable_Save(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( SG_T("R:Tables") ); }
+
+
+protected:
+
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CTable_Drop : public CSG_ODBC_Module
+{
+public:
+ CTable_Drop(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( SG_T("R:Tables") ); }
+
+
+protected:
+
+ virtual bool On_Before_Execution (void);
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CTable_Query : public CSG_ODBC_Module
+{
+public:
+ CTable_Query(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( SG_T("R:Tables") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Table_H
diff --git a/src/modules_io/esri_e00/Makefile.in b/src/modules_io/esri_e00/Makefile.in
index b6d851a..fbbc200 100644
--- a/src/modules_io/esri_e00/Makefile.in
+++ b/src/modules_io/esri_e00/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_io/esri_e00/io_esri_e00/ESRI_E00_Import.cpp b/src/modules_io/esri_e00/io_esri_e00/ESRI_E00_Import.cpp
index 00f37f0..df75d2e 100644
--- a/src/modules_io/esri_e00/io_esri_e00/ESRI_E00_Import.cpp
+++ b/src/modules_io/esri_e00/io_esri_e00/ESRI_E00_Import.cpp
@@ -1,1571 +1,1574 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// Grid_IO //
-// //
-//-------------------------------------------------------//
-// //
-// ESRI_E00.cpp //
-// //
-// Copyright (C) 2003 by //
-// Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "ESRI_E00_Import.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// Import //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CESRI_E00_Import::CESRI_E00_Import(void)
-{
- //-----------------------------------------------------
- // 1. info_Table...
-
- Set_Name (_TL("Import ESRI E00 File"));
-
- Set_Author (SG_T("(c) 2004 by O.Conrad"));
-
- Set_Description (_TW(
- "Import data sets from ESRI's E00 interchange format.\n\n"
-
- "This import filter is based on the E00 format analysis of the GRASS GIS module "
- "\'m.in.e00\' written by Michel J. Wurtz. Go to the "
- "<a target=\"_blank\" href=\"http://grass.itc.it/\">GRASS GIS Hompage</a> "
- "for more information.\n"
-
- "The <a target=\"_blank\" href=\"http://avce00.maptools.org/e00compr/index.html\">\'E00Compr\' library</a> "
- "written by Daniel Morissette has been used for e00 file access, so that "
- "compressed e00 files also can be read.\n")
- );
-
-
- //-----------------------------------------------------
- // 2. Parameters...
-
- Parameters.Add_Grid_Output(
- NULL , "GRID" , _TL("Grid"),
- _TL("")
- );
-
- Parameters.Add_Shapes_Output(
- NULL , "ARCS" , _TL("Arcs"),
- _TL("")
- );
-
- Parameters.Add_Shapes_Output(
- NULL , "SITES" , _TL("Sites"),
- _TL("")
- );
-
- Parameters.Add_Shapes_Output(
- NULL , "LABELS" , _TL("Labels"),
- _TL("")
- );
-
- Parameters.Add_Shapes_Output(
- NULL , "BND" , _TL("Boundary"),
- _TL("")
- );
-
- Parameters.Add_Shapes_Output(
- NULL , "TIC" , _TL("Tick Points"),
- _TL("")
- );
-
- Parameters.Add_Table_Output(
- NULL , "TABLE" , _TL("Table"),
- _TL("")
- );
-
- Parameters.Add_FilePath(
- NULL , "FILE" , _TL("File"),
- _TL(""),
- _TL("ESRI E00 Files|*.e00;*.e0*|All Files|*.*")
- );
-}
-
-//---------------------------------------------------------
-CESRI_E00_Import::~CESRI_E00_Import(void)
-{}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CESRI_E00_Import::On_Execute(void)
-{
- bool bResult;
-
- bResult = false;
- hReadPtr = NULL;
-
- if( Open(Parameters("FILE")->asString()) )
- {
- bResult = Load();
- }
-
- if( hReadPtr )
- {
- E00ReadClose(hReadPtr);
- }
-
- return( bResult );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CESRI_E00_Import::E00GotoLine(int iLine)
-{
- if( hReadPtr )
- {
- E00ReadRewind(hReadPtr);
-
- while( E00ReadNextLine(hReadPtr) && hReadPtr->nInputLineNo != iLine );
-
- return( hReadPtr->nInputLineNo == iLine );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CESRI_E00_Import::Open(const SG_Char *FileName)
-{
- const char *Line;
-
- //-----------------------------------------------------
- if( FileName == NULL || (hReadPtr = E00ReadOpen(CSG_String(FileName).b_str())) == NULL )
- {
- Error_Set(CSG_String::Format(_TL("%s - not found\n"), FileName));
-
- return( false );
- }
-
- //-----------------------------------------------------
- if( (Line = E00ReadNextLine(hReadPtr)) == NULL )
- {
- Error_Set(CSG_String::Format(_TL("\"%s\" is not an Arc-info_Table Export file !\n"), FileName));
-
- return( false );
- }
-
- //-----------------------------------------------------
- if( strncmp(Line, "EXP", 3) )
- {
- Error_Set(CSG_String::Format(_TL("\"%s\" is not an Arc-info_Table Export file !\n"), FileName));
-
- return( false );
- }
-
- //-----------------------------------------------------
- e00_Name = FileName;
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CESRI_E00_Import::Load(void)
-{
- const char *line;
-
- int prec_grd, prec_arc, prec_lab, prec_pal;
-
- long current_line,
- offset_grd = 0,
- offset_arc = 0,
- offset_lab = 0,
- offset_pal = 0;
-
- double scale = 1.0;
-
- TSG_Shape_Type shape_type;
-
- CSG_Grid *pGrid;
-
- CSG_Shapes *pShapes;
-
- //-----------------------------------------------------
- pPAT = NULL;
- pAAT = NULL;
-
- //-----------------------------------------------------
- while( (line = E00ReadNextLine(hReadPtr)) != NULL && strncmp(line, "EOS", 3) )
- {
- current_line = hReadPtr->nInputLineNo;
-
- // GRID SECTION
- if( !strncmp(line, "GRD ", 5) )
- {
- offset_grd = current_line;
- prec_grd = line[5] - '2';
- skip("EOG");
- continue;
- }
-
- // ARC SECTION
- if( !strncmp(line, "ARC ", 5) )
- {
- offset_arc = current_line;
- prec_arc = line[5] - '2';
- skip_arc(prec_arc);
- continue;
- }
-
- // POLYGON TOPOLOGY
- if( !strncmp(line, "PAL ", 5)
- || !strncmp(line, "PFF ", 5) )
- {
- offset_pal = current_line;
- prec_pal = line[5] - '2';
- skip_pal(prec_pal);
- continue;
- }
-
- // CENTROID SECTION
- if( !strncmp(line, "CNT ", 5) )
- {
- skip_dat();
- continue;
- }
-
- // LABEL SECTION
- if( !strncmp(line, "LAB ", 5))
- {
- offset_lab = current_line;
- prec_lab = line[5] - '2';
- skip_lab(prec_lab);
- continue;
- }
-
- // INFO SECTION
- if( !strncmp(line, "IFO ", 5) )
- {
- info_Get_Tables();
- continue;
- }
-
- // PROJECTION INFOS
- if( !strncmp(line, "PRJ ", 5) )
- {
- scale = getproj();
- continue;
- }
-
- // Annotations (text). To be imported ? Does anybody have an idea ?
- if( !strncmp(line, "TXT ", 5) )
- {
- skip_txt(line[5] - '2');
- continue;
- }
-
- // Mask description ? Noting to do with it
- if( !strncmp(line, "MSK ", 5) )
- {
- skip_msk();
- continue;
- }
-
- // TOLERANCE SECTION. Should we really use it ?
- if( !strncmp(line, "TOL ", 5) )
- {
- skip_dat();
- continue;
- }
-
- // UNKNOW KEYWORD SECTION. Don't know what to do with. Does anybody have an idea?
- if( !strncmp(line, "LNK ", 5) )
- {
- skip("END OF LINK DATA");
- continue;
- }
-
- // SPATIAL INDEX SECTION. Noting to do with it
- if( !strncmp(line, "SIN ", 5) )
- {
- skip("EOX");
- continue;
- }
-
- // Line pattern and palette. Shade pattern and palette end same as e00 archive !
- if( !strncmp(line, "CLN ", 5)
- || !strncmp(line, "CSH ", 5) )
- {
- skip("EOS");
- continue;
- }
-
- // Font description ? Noting to do with it
- if( !strncmp(line, "FNT ", 5) )
- {
- skip("EOF");
- continue;
- }
-
- // PLOT SECTION. Why should we import it ?
- if( !strncmp(line, "PLT ", 5) )
- {
- skip("EOP");
- continue;
- }
-
- // LOG SECTION. Nothing to do with it
- if( !strncmp(line, "LOG ", 5) )
- {
- skip("EOL");
- continue;
- }
-
- if( !strncmp(line, "RPL ", 5) // Specific to regions. Contains PAL formated data for each subclass
- || !strncmp(line, "RXP ", 5) // Specific to regions. Seems to link regions IDs to PAL polygons IDs
- || !strncmp(line, "TX6 ", 5) // Other kind of annotations not same termination. Other differences ?
- || !strncmp(line, "TX7 ", 5) ) // Very close from TX6. So same questions and same rules...
- {
- skip("JABBERWOCKY");
- continue;
- }
- }
-
- //-----------------------------------------------------
- switch( pPAT ? (pAAT ? 3 : 2) : (pAAT ? 1 : 0) )
- {
- case 0: default:
- shape_type = offset_arc != 0 ? SHAPE_TYPE_Line : SHAPE_TYPE_Point;
- break;
-
- case 1: // pAAT
- shape_type = SHAPE_TYPE_Line;
- break;
-
- case 2: // pPAT
- shape_type = offset_arc != 0 ? SHAPE_TYPE_Polygon : SHAPE_TYPE_Point;
- break;
-
- case 3: // pAAT && pPAT
- shape_type = offset_pal != 0 || offset_lab != 0 ? SHAPE_TYPE_Polygon : SHAPE_TYPE_Line;
- break;
- }
-
- //-----------------------------------------------------
- // Extracting useful information as noted before...
-
- //-----------------------------------------------------
- if( offset_grd > 0 )
- {
- E00GotoLine(offset_grd);
-
- if( (pGrid = getraster (prec_grd, scale)) != NULL )
- {
- pGrid->Set_Name(e00_Name);
-
- Parameters("GRID")->Set_Value(pGrid);
- }
- }
-
- //-----------------------------------------------------
- if( offset_arc != 0 )
- {
- E00GotoLine(offset_arc);
-
- if( (pShapes = getarcs (prec_arc, scale, shape_type)) != NULL )
- {
- pShapes->Set_Name(e00_Name);
-
- Parameters("ARCS")->Set_Value(pShapes);
- }
- }
-
- //-----------------------------------------------------
- if( offset_lab != 0 && shape_type == SHAPE_TYPE_Point )
- {
- E00GotoLine(offset_lab);
-
- if( (pShapes = getsites (prec_lab, scale)) != NULL )
- {
- pShapes->Set_Name(e00_Name);
-
- Parameters("SITES")->Set_Value(pShapes);
- }
- }
-
- //-----------------------------------------------------
- if( offset_lab != 0 && shape_type != SHAPE_TYPE_Point )
- {
- E00GotoLine(offset_lab);
-
- if( (pShapes = getlabels(prec_lab, scale)) != NULL )
- {
- pShapes->Set_Name(e00_Name);
-
- Parameters("LABELS")->Set_Value(pShapes);
- }
- }
-
- //-----------------------------------------------------
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// Grid //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Grid * CESRI_E00_Import::getraster(int prec, double scale)
-{
- const char *line;
-
- int x, y, ix;
- long rows, cols, depth, p[5];
- float f[5];
- double xres, yres, xmin, ymin, xmax, ymax, nul_val, d[3];
- CSG_Grid *pGrid;
-
- //-----------------------------------------------------
- if( (line = E00ReadNextLine(hReadPtr)) == NULL )
- return( NULL );
-// sscanf(line, "%ld%ld%ld", &cols, &rows, &depth, &nul_val);
- sscanf(line, "%ld%ld%ld%lf", &cols, &rows, &depth, &nul_val);
-
- if( (line = E00ReadNextLine(hReadPtr)) == NULL )
- return( NULL );
- sscanf(line, "%lf%lf", &xres, &yres);
-
- if( (line = E00ReadNextLine(hReadPtr)) == NULL )
- return( NULL );
- sscanf(line, "%lf%lf", &xmin, &ymin);
-
- if( (line = E00ReadNextLine(hReadPtr)) == NULL )
- return( NULL );
- sscanf(line, "%lf%lf", &xmax, &ymax);
-
- xmax = xmax * scale;
- xmin = xmin * scale;
- ymax = ymax * scale;
- ymin = ymin * scale;
- xres = xres * scale;
- yres = yres * scale;
-
- if( depth == 2 && prec )
- {
- depth = 3;
- }
-
- //-----------------------------------------------------
- switch( depth )
- {
- default:
- pGrid = NULL;
- break;
-
- //-----------------------------------------------------
- case 1:
- pGrid = SG_Create_Grid(SG_DATATYPE_Int, cols, rows, xres, xmin, ymin);
- pGrid->Set_NoData_Value(nul_val);
-
- for(y=0; y<rows && line && Set_Progress(y, rows); y++)
- {
- for(x=0; x<cols; x+= 5)
- {
- if( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%ld%ld%ld%ld%ld", p, p+1, p+2, p+3, p+4);
-
- for(ix=0; ix<5 && x+ix<cols; ix++)
- {
- pGrid->Set_Value(x + ix, y, p[ix]);
- }
- }
- }
- }
- break;
-
- //-----------------------------------------------------
- case 2:
- pGrid = SG_Create_Grid(SG_DATATYPE_Float, cols, rows, xres, xmin, ymin);
- pGrid->Set_NoData_Value(nul_val);
-
- for(y=0; y<rows && line && Set_Progress(y, rows); y++)
- {
- for(x=0; x<cols; x+= 5)
- {
- if( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%f%f%f%f%f", f, f+1, f+2, f+3, f+4);
-
- for(ix=0; ix<5 && x+ix<cols; ix++)
- {
- pGrid->Set_Value(x + ix, y, f[ix]);
- }
- }
- }
- }
- break;
-
- //-----------------------------------------------------
- case 3:
- pGrid = SG_Create_Grid(SG_DATATYPE_Double, cols, rows, xres, xmin, ymin);
- pGrid->Set_NoData_Value(nul_val);
-
- for(y=0; y<rows && line && Set_Progress(y, rows); y++)
- {
- for(x=0; x<cols; x+= 3)
- {
- if( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%lf%lf%lf", d, d+1, d+2);
-
- for(ix=0; ix<3 && x+ix<cols; ix++)
- {
- pGrid->Set_Value(x + ix, y, d[ix]);
- }
- }
- }
- }
- break;
- }
-
- //-----------------------------------------------------
- skip("EOG");
-
- return( pGrid );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#define ARC_FNODE 2
-#define ARC_TNODE 3
-#define ARC_LPOL 4
-#define ARC_RPOL 5
-
-//---------------------------------------------------------
-CSG_Shapes * CESRI_E00_Import::getarcs(int prec, double scale, TSG_Shape_Type &shape_type)
-{
- const char *line;
-
- int covnum, cov_id, fnode, tnode, lpol, rpol, nPoints, iPoint;
- double x_buf[2], y_buf[2];
- CSG_Shape *pShape;
- CSG_Shapes *pShapes;
-
- //-----------------------------------------------------
- pShapes = SG_Create_Shapes(shape_type);
- pShapes->Add_Field("ID" , SG_DATATYPE_Int);
- pShapes->Add_Field("ID#" , SG_DATATYPE_Int);
- pShapes->Add_Field("FNODE" , SG_DATATYPE_Int);
- pShapes->Add_Field("TNODE" , SG_DATATYPE_Int);
- pShapes->Add_Field("LPOL" , SG_DATATYPE_Int);
- pShapes->Add_Field("RPOL" , SG_DATATYPE_Int);
-
- Set_Progress(0, 100);
-
- //-----------------------------------------------------
- do
- {
- Process_Set_Text(CSG_String::Format(SG_T("Loaded arcs: %d"), pShapes->Get_Count()));
-
- if( (line = E00ReadNextLine(hReadPtr)) == NULL )
- {
- covnum = -1;
- }
- else
- {
- sscanf(line, "%d %d %d %d %d %d %d", &covnum, &cov_id, &fnode, &tnode, &lpol, &rpol, &nPoints);
- }
-
- if( covnum != -1 )
- {
- pShape = pShapes->Add_Shape();
-
- pShape->Set_Value(0 , covnum);
- pShape->Set_Value(1 , cov_id);
- pShape->Set_Value(ARC_FNODE , fnode);
- pShape->Set_Value(ARC_TNODE , tnode);
- pShape->Set_Value(ARC_LPOL , lpol);
- pShape->Set_Value(ARC_RPOL , rpol);
-
- //---------------------------------------------
- if( prec ) // double precision : 1 coord pair / line
- {
- for(iPoint=0; iPoint<nPoints && line; iPoint++)
- {
- if( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%lf %lf", x_buf, y_buf);
-
- pShape->Add_Point(x_buf[0] * scale, y_buf[0] * scale);
- }
- }
- }
-
- //---------------------------------------------
- else // single precision : 2 x,y pairs / line
- {
- for(iPoint=0; iPoint<nPoints && line; iPoint+=2)
- {
- if( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%lf %lf %lf %lf", x_buf, y_buf, x_buf + 1, y_buf + 1);
-
- pShape->Add_Point(x_buf[0] * scale, y_buf[0] * scale);
-
- if( iPoint + 1 < nPoints )
- {
- pShape->Add_Point(x_buf[1] * scale, y_buf[1] * scale);
- }
- }
- }
- }
- }
- }
- while( covnum != -1 && line && Process_Get_Okay(false) );
-
- //-----------------------------------------------------
- if( pShapes->Get_Count() == 0 )
- {
- delete(pShapes);
-
- shape_type = SHAPE_TYPE_Point;
-
- return( NULL );
- }
-
- if( shape_type == SHAPE_TYPE_Polygon )
- {
- pShapes = Arcs2Polygons(pShapes);
-
- Assign_Attributes(pShapes);
- }
-
- return( pShapes );
-}
-
-//---------------------------------------------------------
-CSG_Shapes * CESRI_E00_Import::Arcs2Polygons(CSG_Shapes *pArcs)
-{
- int iArc, nArcs, id;
- CSG_Shapes *pPolygons;
-
- //-----------------------------------------------------
- Process_Set_Text(_TL("Arcs to polygons"));
-
- pPolygons = SG_Create_Shapes(SHAPE_TYPE_Polygon);
- pPolygons->Add_Field("ID", SG_DATATYPE_Int);
-
- nArcs = pArcs->Get_Count();
-
- //-----------------------------------------------------
- while( (iArc = pArcs->Get_Count() - 1) >= 0 && Set_Progress(nArcs - iArc - 1, nArcs) )
- {
- id = pArcs->Get_Shape(iArc)->asInt(ARC_LPOL);
-
- if( id == pArcs->Get_Shape(iArc)->asInt(ARC_RPOL) )
- {
- pArcs->Del_Shape(iArc);
- }
- else if( id > 1 )
- {
- Arcs2Polygon(pArcs, pPolygons, id);
- }
-
- if( (iArc = pArcs->Get_Count() - 1) >= 0 )
- {
- id = pArcs->Get_Shape(iArc)->asInt(ARC_RPOL);
-
- if( id > 1 )
- {
- Arcs2Polygon(pArcs, pPolygons, id);
- }
- }
- }
-
- //-----------------------------------------------------
- delete( pArcs );
-
- return( pPolygons );
-}
-
-//---------------------------------------------------------
-void CESRI_E00_Import::Arcs2Polygon(CSG_Shapes *pArcs, CSG_Shapes *pPolygons, int id)
-{
- int iShape, iPart, iPoint, iNode;
- CSG_Shape *pArc, *pShape;
- CSG_Shapes Arcs;
-
- //-----------------------------------------------------
- Arcs.Create(SHAPE_TYPE_Line);
- Arcs.Add_Field("FROM_NODE", SG_DATATYPE_Int);
- Arcs.Add_Field("TO___NODE", SG_DATATYPE_Int);
-
- //-----------------------------------------------------
- for(iShape=pArcs->Get_Count()-1; iShape>=0; iShape--)
- {
- pShape = pArcs->Get_Shape(iShape);
-
- if( id == pShape->asInt(ARC_LPOL) )
- {
- pArc = Arcs.Add_Shape();
- pArc->Set_Value(0, pShape->asInt(ARC_FNODE));
- pArc->Set_Value(1, pShape->asInt(ARC_TNODE));
-
- for(iPoint=0; iPoint<pShape->Get_Point_Count(0); iPoint++)
- {
- pArc->Add_Point(pShape->Get_Point(iPoint, 0), 0);
- }
-
- if( pShape->asInt(ARC_RPOL) <= 1 )
- {
- pArcs->Del_Shape(iShape);
- }
- else
- {
- pShape->Set_Value(ARC_LPOL, 1);
- }
- }
- else if( id == pShape->asInt(ARC_RPOL) )
- {
- pArc = Arcs.Add_Shape();
- pArc->Set_Value(1, pShape->asInt(ARC_FNODE));
- pArc->Set_Value(0, pShape->asInt(ARC_TNODE));
-
- for(iPoint=pShape->Get_Point_Count(0)-1; iPoint>=0; iPoint--)
- {
- pArc->Add_Point(pShape->Get_Point(iPoint, 0), 0);
- }
-
- if( pShape->asInt(ARC_LPOL) <= 1 )
- {
- pArcs->Del_Shape(iShape);
- }
- else
- {
- pShape->Set_Value(ARC_RPOL, 1);
- }
- }
- }
-
- //-----------------------------------------------------
- if( Arcs.Get_Count() > 0 )
- {
- iPart = 0;
- pShape = pPolygons->Add_Shape();
- pShape->Set_Value(0, id);
-
- do
- {
- pArc = Arcs.Get_Shape(0);
-
- while( pArc )
- {
- for(iPoint=0; iPoint<pArc->Get_Point_Count(0); iPoint++)
- {
- pShape->Add_Point(pArc->Get_Point(iPoint, 0), iPart);
- }
-
- iNode = pArc->asInt(1);
- Arcs.Del_Shape(pArc);
-
- for(iShape=0, pArc=NULL; iShape<Arcs.Get_Count() && !pArc; iShape++)
- {
- if( iNode == Arcs.Get_Shape(iShape)->asInt(0) )
- {
- pArc = Arcs.Get_Shape(iShape);
- }
- }
- }
-
- iPart++;
- }
- while( Arcs.Get_Count() > 0 );
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Shapes * CESRI_E00_Import::getlabels(int prec, double scale) // shape_type: LINE or AREA
-{
- const char *line;
-
- int num, id; // coverage-# and coverage-ID
- double x, y;
- CSG_Shapes *pShapes;
- CSG_Shape *pShape;
-
- pShapes = SG_Create_Shapes(SHAPE_TYPE_Point);
-
- pShapes->Add_Field("ID#" , SG_DATATYPE_Int);
- pShapes->Add_Field("ID" , SG_DATATYPE_Int);
-
- while( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%d %d %lf %lf", &id, &num, &x, &y);
-
- if( id == -1 )
- {
- break;
- }
- else
- {
- pShape = pShapes->Add_Shape();
-
- pShape->Add_Point(x * scale, y * scale);
-
- pShape->Set_Value(0, num);
- pShape->Set_Value(1, id);
-
- //---------------------------------------------
- E00ReadNextLine(hReadPtr); // 4 values to skip
-
- if( prec )
- {
- E00ReadNextLine(hReadPtr); // on 2nd line when double precision
- }
- }
- }
-
- if( pShapes->Get_Count() <= 0 )
- {
- delete( pShapes );
- pShapes = NULL;
- }
-
- return( pShapes );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Shapes * CESRI_E00_Import::getsites(int prec, double scale)
-{
- const char *line;
-
- int id;
- double x, y;
- CSG_Shape *pShape;
- CSG_Shapes *pShapes;
-
- pShapes = SG_Create_Shapes(SHAPE_TYPE_Point);
- pShapes->Add_Field("ID", SG_DATATYPE_Int);
-
- while( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%d %*d %lf %lf", &id, &x, &y);
-
- if( id == -1 )
- {
- break;
- }
-
- pShape = pShapes->Add_Shape();
-
- pShape->Add_Point(x * scale, y * scale);
- pShape->Set_Value(0, id);
-
- //-------------------------------------------------
- E00ReadNextLine(hReadPtr); // 4 values to skip
-
- if( prec )
- {
- E00ReadNextLine(hReadPtr); // on 2nd line when double precision
- }
- }
-
- if( pShapes->Get_Count() <= 0 )
- {
- delete( pShapes );
- pShapes = NULL;
- }
- else
- {
- Assign_Attributes(pShapes);
- }
-
- return( pShapes );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-double CESRI_E00_Import::getproj(void)
-{
- const char *line;
-
- double scale = 1.0;
-
- while( (line = E00ReadNextLine(hReadPtr)) != NULL && strncmp(line, "EOP", 3) )
- {
- if( !strncmp(line, "Units", 5) )
- {
- sscanf(line + 6, "%lf", &scale);
- }
- }
-
- scale = 1.0 / scale;
-
- return( scale );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// info section //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-struct info_Field
-{
- char Name[18]; // name of item
-
- int Position, // position in data line
- Size, // size for reading
- Type; // type of data
-};
-
-//---------------------------------------------------------
-struct info_Table
-{
- char Name[34],
- AI[4]; // XX if Arc/info file, spaces otherwise
-
- int uFields, // number of usable items in this table
- nFields, // number of items in this table
- ldr; // length of data record
-
- long nRecords, // number of data records
- length; // total length for one data line
-
- struct info_Field *Field; // One per field...
-};
-
-//---------------------------------------------------------
-// [06.06.2006] ESRI E00 Import crash fix, James Flemer
-int CESRI_E00_Import::info_Get_Tables(void)
-{
- const char *line;
-
- char tmp[12], *p;
- int i;
- CSG_String s;
- CSG_Table *pTable;
- struct info_Table info;
-
- //-----------------------------------------------------
- while( (line = E00ReadNextLine(hReadPtr)) != NULL && strncmp(line, "EOI", 3) )
- {
- strncpy(info.Name, line, 32);
- info.Name[32] = 0;
- p = strchr(info.Name, ' ');
- if( p != NULL )
- *p = 0;
- p = strchr(info.Name, '.');
- if( p == 0 )
- p = info.Name;
- else
- p++;
- s = p;
-
- strncpy(info.AI , line + 32, 2); info.AI[2] = 0;
- strncpy(tmp , line + 34, 4); tmp[ 4] = 0; info.uFields = atoi(tmp);
- strncpy(tmp , line + 38, 4); tmp[ 4] = 0; info.nFields = atoi(tmp);
- strncpy(tmp , line + 42, 4); tmp[ 4] = 0; info.ldr = atoi(tmp);
- strncpy(tmp , line + 46, 11); tmp[11] = 0; info.nRecords = atol(tmp);
-
- info.length = 0;
- info.Field = (struct info_Field *)malloc(info.nFields * sizeof(struct info_Field));
-
- //---------------------------------------------
- for(i=0; i<info.nFields; i++)
- {
- if( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%16s", info.Field[i].Name);
- info.Field[i].Size = atoi(&line[16]);
- info.Field[i].Type = atoi(&line[34]);
- }
-
- //---------------------------------------------
- switch( info.Field[i].Type )
- {
- case 60: // float / double
- info.Field[i].Size = info.Field[i].Size == 4 ? 14 : 24;
- break;
-
- case 50: // short / long
- info.Field[i].Size = info.Field[i].Size == 2 ? 6 : 11;
- break;
-
- case 40: // float
- info.Field[i].Size = 14;
- break;
-
- case 10:
- info.Field[i].Size = 8;
- break;
-
- default: // string
- break;
- }
-
- if( i < info.uFields )
- {
- info.length += info.Field[i].Size;
- }
-
- if( i == 0 )
- {
- info.Field[i].Position = 0;
- }
- else
- {
- info.Field[i].Position = info.Field[i-1].Position + info.Field[i-1].Size;
- }
- }
-
- //---------------------------------------------
- pTable = NULL;
-
- if ( !s.CmpNoCase(SG_T("aat")) && pAAT == NULL )
- {
- pTable = pAAT = info_Get_Table(info);
- }
- else if( !s.CmpNoCase(SG_T("pat")) && pPAT == NULL )
- {
- pTable = pPAT = info_Get_Table(info);
- }
- // else if( !s.CmpNoCase("vat") ) // value table (grid)
- // else if( !s.CmpNoCase("bnd") ) // coverage boundaries
- // else if( !s.CmpNoCase("tic") ) // tick marks
- // else if( !s.CmpNoCase("sta") ) // stats on grid
- // else if( !s.CmpNoCase("lut") ) // look-up table
- // else if( !s.CmpNoCase("acode") ) // arc attributes
- // else if( !s.CmpNoCase("pcode") ) // polygon attributes
- // else // non graphic tables
- else // come on, let's get every table we can get...
- {
- pTable = info_Get_Table(info);
- }
-
- //-------------------------------------------------
- free(info.Field);
-
- if( pTable )
- {
- CSG_Table_Record *pRecord;
- CSG_Shape *pShape;
- CSG_Shapes *pBND, *pTIC;
-
- if ( !s.CmpNoCase(SG_T("bnd")) ) // coverage boundaries
- {
- pBND = SG_Create_Shapes(SHAPE_TYPE_Polygon, SG_T("Boundary"));
- pBND->Add_Field("XMIN", SG_DATATYPE_Double);
- pBND->Add_Field("YMIN", SG_DATATYPE_Double);
- pBND->Add_Field("XMAX", SG_DATATYPE_Double);
- pBND->Add_Field("YMAX", SG_DATATYPE_Double);
- pRecord = pTable->Get_Record(0);
- pShape = pBND->Add_Shape();
- pShape->Set_Value(0, pRecord->asDouble(0));
- pShape->Set_Value(1, pRecord->asDouble(1));
- pShape->Set_Value(2, pRecord->asDouble(2));
- pShape->Set_Value(3, pRecord->asDouble(3));
- pShape->Add_Point(pRecord->asDouble(0), pRecord->asDouble(1));
- pShape->Add_Point(pRecord->asDouble(0), pRecord->asDouble(3));
- pShape->Add_Point(pRecord->asDouble(2), pRecord->asDouble(3));
- pShape->Add_Point(pRecord->asDouble(2), pRecord->asDouble(1));
- Parameters("BND")->Set_Value(pBND);
- delete(pTable);
- }
- else if( !s.CmpNoCase(SG_T("tic")) ) // tick marks
- {
- pTIC = SG_Create_Shapes(SHAPE_TYPE_Point, SG_T("Tick Points"));
- pTIC->Add_Field("ID", SG_DATATYPE_Int);
- pTIC->Add_Field("X" , SG_DATATYPE_Double);
- pTIC->Add_Field("Y" , SG_DATATYPE_Double);
- for(i=0; i<pTable->Get_Record_Count(); i++)
- {
- pRecord = pTable->Get_Record(i);
- pShape = pTIC->Add_Shape();
- pShape->Set_Value(0, pRecord->asInt (0));
- pShape->Set_Value(1, pRecord->asDouble(1));
- pShape->Set_Value(2, pRecord->asDouble(2));
- pShape->Add_Point(pRecord->asDouble(1), pRecord->asDouble(2));
- }
- Parameters("TIC")->Set_Value(pTIC);
- delete(pTable);
- }
- else
- {
- Parameters("TABLE")->Set_Value(pTable);
- }
- }
- }
-
- //-----------------------------------------------------
- // 0 if none, 1 if AAT, 2 if PAT, 3 if both
- return( pPAT ? (pAAT ? 3 : 2) : (pAAT ? 1 : 0) );
-}
-
-//---------------------------------------------------------
-CSG_Table * CESRI_E00_Import::info_Get_Table(struct info_Table info)
-{
- char *buffer_record, *buffer_item;
- int iRecord, iField;
- CSG_Table *pTable;
- CSG_Table_Record *pRecord;
-
- //-----------------------------------------------------
- Process_Set_Text(CSG_String(info.Name));
-
- buffer_record = (char *)malloc(info.length + 3);
- buffer_item = (char *)malloc(info.length + 3);
-
- pTable = SG_Create_Table();
- pTable->Set_Name(CSG_String(info.Name));
-
- //-----------------------------------------------------
- for(iField=0; iField<info.uFields; iField++)
- {
- switch( info.Field[iField].Type )
- {
- case 60: // float / double
- pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_Double);
- break;
-
- case 50: // short / long
- pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_Int);
- break;
-
- case 40: // float
- pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_Double);
- break;
-
- case 10: // short
- pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_Int);
- break;
-
- default: // string
- pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_String);
- break;
- }
- }
-
- //-----------------------------------------------------
- for(iRecord=0; iRecord<info.nRecords && Set_Progress(iRecord, info.nRecords); iRecord++)
- {
- info_Get_Record(buffer_record, info.length);
-
- pRecord = pTable->Add_Record();
-
- for(iField=0; iField<info.uFields; iField++)
- {
- strncpy(buffer_item, &buffer_record[info.Field[iField].Position], info.Field[iField].Size);
- buffer_item[info.Field[iField].Size] = 0;
-
- switch( pTable->Get_Field_Type(iField) )
- {
- default:
- pRecord->Set_Value(iField, atof(buffer_item));
- break;
-
- case SG_DATATYPE_Int:
- pRecord->Set_Value(iField, atoi(buffer_item));
- break;
-
- case SG_DATATYPE_String:
- pRecord->Set_Value(iField, CSG_String(buffer_item));
- break;
- }
- }
- }
-
- //-----------------------------------------------------
- free(buffer_record);
- free(buffer_item);
-
- return( pTable );
-}
-
-//---------------------------------------------------------
-void CESRI_E00_Import::info_Skip_Table(struct info_Table info)
-{
- char *buffer_record;
- int iRecord;
-
- buffer_record = (char *)malloc(info.length + 3);
-
- for(iRecord=0; iRecord<info.nRecords; iRecord++)
- {
- info_Get_Record(buffer_record, info.length);
- }
-
- free(buffer_record);
-}
-
-//---------------------------------------------------------
-void CESRI_E00_Import::info_Get_Record(char *buffer, int buffer_length)
-{
- const char *line;
-
- char *p;
- int l;
-
- //-----------------------------------------------------
- p = buffer;
- l = 0;
-
- //-----------------------------------------------------
- if( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- strncpy(buffer, line, buffer_length < 84 ? buffer_length : 84);
-
- while( l < buffer_length )
- {
- if( *p =='\r' || *p == '\n' || *p == 0 )
- {
- while( (l % 80 || p == buffer) && l < buffer_length )
- {
- l++;
- *p++ = ' ';
- }
-
- if( l == buffer_length )
- {
- break;
- }
- else if( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- strncpy(p, line, buffer_length - l < 84 ? buffer_length - l : 84);
-
- if( *p =='\r' || *p == '\n' || *p == 0 ) // if empty line
- {
- l++;
- *p++ = ' ';
- *p = 0;
- }
- }
- }
- else
- {
- l++;
- p++;
- }
- }
-
- *p = 0;
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// Skips //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CESRI_E00_Import::Assign_Attributes(CSG_Shapes *pShapes)
-{
- int iShape, iRecord, iField, oField, id;
- CSG_Table_Record *pRec;
- CSG_Shape *pShape;
-
- if( pShapes && pShapes->Get_Field_Count() > 0 && pPAT && pPAT->Get_Field_Count() > 2 )
- {
- Process_Set_Text(_TL("Assign attributes to shapes..."));
-
- oField = pShapes->Get_Field_Count();
-
- for(iField=0; iField<pPAT->Get_Field_Count(); iField++)
- {
- pShapes->Add_Field(pPAT->Get_Field_Name(iField), pPAT->Get_Field_Type(iField));
- }
-
- for(iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
- {
- pShape = pShapes->Get_Shape(iShape);
- id = pShape->asInt(0);
-
- for(iRecord=0; iRecord<pPAT->Get_Record_Count(); iRecord++)
- {
- pRec = pPAT->Get_Record(iRecord);
-
- if( id == pRec->asInt(2) )
- {
- for(iField=0; iField<pPAT->Get_Field_Count(); iField++)
- {
- switch( pPAT->Get_Field_Type(iField) )
- {
- case SG_DATATYPE_String:
- pShape->Set_Value(oField + iField, pRec->asString(iField));
- break;
-
- default:
- pShape->Set_Value(oField + iField, pRec->asDouble(iField));
- break;
- }
- }
-
- break;
- }
- }
-
- }
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// Skips //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CESRI_E00_Import::skip(char *end)
-{
- const char *line;
-
- int l = strlen(end);
-
- while( (line = E00ReadNextLine(hReadPtr)) != NULL && strncmp(line, end, l) );
-}
-
-//---------------------------------------------------------
-void CESRI_E00_Import::skip_dat(void)
-{
- const char *line;
-
- int i = 0;
-
- while( (line = E00ReadNextLine(hReadPtr)) != NULL && i != -1 )
- {
- sscanf(line, "%d", &i);
- }
-}
-
-//---------------------------------------------------------
-void CESRI_E00_Import::skip_msk(void)
-{
- const char *line;
-
- double xmin, ymin, xmax, ymax, res, sk;
- long xsize, ysize, nskip;
-
- if( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%lf %lf %lf", &xmin, &ymin, &xmax);
-
- if( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%lf %lf %ld %ld", &ymax, &res, &xsize, &ysize);
-
- sk = ((ymax - ymin) / res) * ((xmax - xmin) / res) / 32.0;
- nskip = (long)ceil(sk / 7.0);
-
- while( nskip-- )
- {
- E00ReadNextLine(hReadPtr);
- }
- }
- }
-}
-
-//---------------------------------------------------------
-void CESRI_E00_Import::skip_arc(int prec)
-{
- const char *line;
-
- int i, covnum, nPoints;
-
- while( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%d %*d %*d %*d %*d %*d %d", &covnum, &nPoints);
-
- if( covnum == -1 )
- break;
-
- if( prec == 0 )
- nPoints = (nPoints + 1) / 2; // number of coordinate lines
-
- for(i=0; i<nPoints; i++)
- {
- E00ReadNextLine(hReadPtr);
- }
- }
-}
-
-//---------------------------------------------------------
-void CESRI_E00_Import::skip_lab(int prec)
-{
- const char *line;
-
- long covid;
-
- while( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%ld", &covid);
-
- if( covid == -1 )
- break;
-
- E00ReadNextLine(hReadPtr);
-
- if( prec ) // two lines of coordinates in double precision
- E00ReadNextLine(hReadPtr);
- }
-}
-
-//---------------------------------------------------------
-void CESRI_E00_Import::skip_pal(int prec)
-{
- const char *line;
-
- int i, narcs;
-
- while( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf(line, "%d", &narcs);
-
- if( prec ) // two lines of coordinates in double precision
- E00ReadNextLine(hReadPtr);
-
- if( narcs == -1 )
- break;
-
- for(i=(narcs+1)/2; i; i--)
- E00ReadNextLine(hReadPtr);
- }
-}
-
-//---------------------------------------------------------
-void CESRI_E00_Import::skip_txt(int prec)
-{
- const char *line;
-
- int i, n, nskip;
-
- nskip = prec ? 7 : 5;
-
- while( (line = E00ReadNextLine(hReadPtr)) != NULL )
- {
- sscanf( line, "%d", &n);
-
- if( n == -1 )
- break;
-
- for(i=0; i<nskip; i++)
- E00ReadNextLine(hReadPtr);
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_IO //
+// //
+//-------------------------------------------------------//
+// //
+// ESRI_E00.cpp //
+// //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "ESRI_E00_Import.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// Import //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CESRI_E00_Import::CESRI_E00_Import(void)
+{
+ //-----------------------------------------------------
+ // 1. info_Table...
+
+ Set_Name (_TL("Import ESRI E00 File"));
+
+ Set_Author (SG_T("(c) 2004 by O.Conrad"));
+
+ Set_Description (_TW(
+ "Import data sets from ESRI's E00 interchange format.\n\n"
+
+ "This import filter is based on the E00 format analysis of the GRASS GIS module "
+ "\'m.in.e00\' written by Michel J. Wurtz. Go to the "
+ "<a target=\"_blank\" href=\"http://grass.itc.it/\">GRASS GIS Hompage</a> "
+ "for more information.\n"
+
+ "The <a target=\"_blank\" href=\"http://avce00.maptools.org/e00compr/index.html\">\'E00Compr\' library</a> "
+ "written by Daniel Morissette has been used for e00 file access, so that "
+ "compressed e00 files also can be read.\n")
+ );
+
+
+ //-----------------------------------------------------
+ // 2. Parameters...
+
+ Parameters.Add_Grid_Output(
+ NULL , "GRID" , _TL("Grid"),
+ _TL("")
+ );
+
+ Parameters.Add_Shapes_Output(
+ NULL , "ARCS" , _TL("Arcs"),
+ _TL("")
+ );
+
+ Parameters.Add_Shapes_Output(
+ NULL , "SITES" , _TL("Sites"),
+ _TL("")
+ );
+
+ Parameters.Add_Shapes_Output(
+ NULL , "LABELS" , _TL("Labels"),
+ _TL("")
+ );
+
+ Parameters.Add_Shapes_Output(
+ NULL , "BND" , _TL("Boundary"),
+ _TL("")
+ );
+
+ Parameters.Add_Shapes_Output(
+ NULL , "TIC" , _TL("Tick Points"),
+ _TL("")
+ );
+
+ Parameters.Add_Table_Output(
+ NULL , "TABLE" , _TL("Table"),
+ _TL("")
+ );
+
+ Parameters.Add_FilePath(
+ NULL , "FILE" , _TL("File"),
+ _TL(""),
+ _TL("ESRI E00 Files|*.e00;*.e0*|All Files|*.*")
+ );
+}
+
+//---------------------------------------------------------
+CESRI_E00_Import::~CESRI_E00_Import(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CESRI_E00_Import::On_Execute(void)
+{
+ bool bResult;
+
+ bResult = false;
+ hReadPtr = NULL;
+
+ if( Open(Parameters("FILE")->asString()) )
+ {
+ bResult = Load();
+ }
+
+ if( hReadPtr )
+ {
+ E00ReadClose(hReadPtr);
+ }
+
+ return( bResult );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CESRI_E00_Import::E00GotoLine(int iLine)
+{
+ if( hReadPtr )
+ {
+ E00ReadRewind(hReadPtr);
+
+ while( E00ReadNextLine(hReadPtr) && hReadPtr->nInputLineNo != iLine );
+
+ return( hReadPtr->nInputLineNo == iLine );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CESRI_E00_Import::Open(const SG_Char *FileName)
+{
+ const char *Line;
+
+ //-----------------------------------------------------
+ if( FileName == NULL || (hReadPtr = E00ReadOpen(CSG_String(FileName).b_str())) == NULL )
+ {
+ Error_Set(CSG_String::Format(_TL("%s - not found\n"), FileName));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ if( (Line = E00ReadNextLine(hReadPtr)) == NULL )
+ {
+ Error_Set(CSG_String::Format(_TL("\"%s\" is not an Arc-info_Table Export file !\n"), FileName));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ if( strncmp(Line, "EXP", 3) )
+ {
+ Error_Set(CSG_String::Format(_TL("\"%s\" is not an Arc-info_Table Export file !\n"), FileName));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ e00_Name = FileName;
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CESRI_E00_Import::Load(void)
+{
+ const char *line;
+
+ int prec_grd, prec_arc, prec_lab, prec_pal;
+
+ long current_line,
+ offset_grd = 0,
+ offset_arc = 0,
+ offset_lab = 0,
+ offset_pal = 0;
+
+ double scale = 1.0;
+
+ TSG_Shape_Type shape_type;
+
+ CSG_Grid *pGrid;
+
+ CSG_Shapes *pShapes;
+
+ //-----------------------------------------------------
+ pPAT = NULL;
+ pAAT = NULL;
+
+ //-----------------------------------------------------
+ while( (line = E00ReadNextLine(hReadPtr)) != NULL && strncmp(line, "EOS", 3) )
+ {
+ current_line = hReadPtr->nInputLineNo;
+
+ // GRID SECTION
+ if( !strncmp(line, "GRD ", 5) )
+ {
+ offset_grd = current_line;
+ prec_grd = line[5] - '2';
+ skip("EOG");
+ continue;
+ }
+
+ // ARC SECTION
+ if( !strncmp(line, "ARC ", 5) )
+ {
+ offset_arc = current_line;
+ prec_arc = line[5] - '2';
+ skip_arc(prec_arc);
+ continue;
+ }
+
+ // POLYGON TOPOLOGY
+ if( !strncmp(line, "PAL ", 5)
+ || !strncmp(line, "PFF ", 5) )
+ {
+ offset_pal = current_line;
+ prec_pal = line[5] - '2';
+ skip_pal(prec_pal);
+ continue;
+ }
+
+ // CENTROID SECTION
+ if( !strncmp(line, "CNT ", 5) )
+ {
+ skip_dat();
+ continue;
+ }
+
+ // LABEL SECTION
+ if( !strncmp(line, "LAB ", 5))
+ {
+ offset_lab = current_line;
+ prec_lab = line[5] - '2';
+ skip_lab(prec_lab);
+ continue;
+ }
+
+ // INFO SECTION
+ if( !strncmp(line, "IFO ", 5) )
+ {
+ info_Get_Tables();
+ continue;
+ }
+
+ // PROJECTION INFOS
+ if( !strncmp(line, "PRJ ", 5) )
+ {
+ scale = getproj();
+ continue;
+ }
+
+ // Annotations (text). To be imported ? Does anybody have an idea ?
+ if( !strncmp(line, "TXT ", 5) )
+ {
+ skip_txt(line[5] - '2');
+ continue;
+ }
+
+ // Mask description ? Noting to do with it
+ if( !strncmp(line, "MSK ", 5) )
+ {
+ skip_msk();
+ continue;
+ }
+
+ // TOLERANCE SECTION. Should we really use it ?
+ if( !strncmp(line, "TOL ", 5) )
+ {
+ skip_dat();
+ continue;
+ }
+
+ // UNKNOW KEYWORD SECTION. Don't know what to do with. Does anybody have an idea?
+ if( !strncmp(line, "LNK ", 5) )
+ {
+ skip("END OF LINK DATA");
+ continue;
+ }
+
+ // SPATIAL INDEX SECTION. Noting to do with it
+ if( !strncmp(line, "SIN ", 5) )
+ {
+ skip("EOX");
+ continue;
+ }
+
+ // Line pattern and palette. Shade pattern and palette end same as e00 archive !
+ if( !strncmp(line, "CLN ", 5)
+ || !strncmp(line, "CSH ", 5) )
+ {
+ skip("EOS");
+ continue;
+ }
+
+ // Font description ? Noting to do with it
+ if( !strncmp(line, "FNT ", 5) )
+ {
+ skip("EOF");
+ continue;
+ }
+
+ // PLOT SECTION. Why should we import it ?
+ if( !strncmp(line, "PLT ", 5) )
+ {
+ skip("EOP");
+ continue;
+ }
+
+ // LOG SECTION. Nothing to do with it
+ if( !strncmp(line, "LOG ", 5) )
+ {
+ skip("EOL");
+ continue;
+ }
+
+ if( !strncmp(line, "RPL ", 5) // Specific to regions. Contains PAL formated data for each subclass
+ || !strncmp(line, "RXP ", 5) // Specific to regions. Seems to link regions IDs to PAL polygons IDs
+ || !strncmp(line, "TX6 ", 5) // Other kind of annotations not same termination. Other differences ?
+ || !strncmp(line, "TX7 ", 5) ) // Very close from TX6. So same questions and same rules...
+ {
+ skip("JABBERWOCKY");
+ continue;
+ }
+ }
+
+ //-----------------------------------------------------
+ switch( pPAT ? (pAAT ? 3 : 2) : (pAAT ? 1 : 0) )
+ {
+ case 0: default:
+ shape_type = offset_arc != 0 ? SHAPE_TYPE_Line : SHAPE_TYPE_Point;
+ break;
+
+ case 1: // pAAT
+ shape_type = SHAPE_TYPE_Line;
+ break;
+
+ case 2: // pPAT
+ shape_type = offset_arc != 0 ? SHAPE_TYPE_Polygon : SHAPE_TYPE_Point;
+ break;
+
+ case 3: // pAAT && pPAT
+ shape_type = offset_pal != 0 || offset_lab != 0 ? SHAPE_TYPE_Polygon : SHAPE_TYPE_Line;
+ break;
+ }
+
+ //-----------------------------------------------------
+ // Extracting useful information as noted before...
+
+ //-----------------------------------------------------
+ if( offset_grd > 0 )
+ {
+ E00GotoLine(offset_grd);
+
+ if( (pGrid = getraster (prec_grd, scale)) != NULL )
+ {
+ pGrid->Set_Name(e00_Name);
+
+ Parameters("GRID")->Set_Value(pGrid);
+ }
+ }
+
+ //-----------------------------------------------------
+ if( offset_arc != 0 )
+ {
+ E00GotoLine(offset_arc);
+
+ if( (pShapes = getarcs (prec_arc, scale, shape_type)) != NULL )
+ {
+ pShapes->Set_Name(e00_Name);
+
+ Parameters("ARCS")->Set_Value(pShapes);
+ }
+ }
+
+ //-----------------------------------------------------
+ if( offset_lab != 0 && shape_type == SHAPE_TYPE_Point )
+ {
+ E00GotoLine(offset_lab);
+
+ if( (pShapes = getsites (prec_lab, scale)) != NULL )
+ {
+ pShapes->Set_Name(e00_Name);
+
+ Parameters("SITES")->Set_Value(pShapes);
+ }
+ }
+
+ //-----------------------------------------------------
+ if( offset_lab != 0 && shape_type != SHAPE_TYPE_Point )
+ {
+ E00GotoLine(offset_lab);
+
+ if( (pShapes = getlabels(prec_lab, scale)) != NULL )
+ {
+ pShapes->Set_Name(e00_Name);
+
+ Parameters("LABELS")->Set_Value(pShapes);
+ }
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Grid //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Grid * CESRI_E00_Import::getraster(int prec, double scale)
+{
+ const char *line;
+
+ int x, y, ix;
+ long rows, cols, depth, p[5];
+ float f[5];
+ double xres, yres, xmin, ymin, xmax, ymax, nul_val, d[3];
+ CSG_Grid *pGrid;
+
+ //-----------------------------------------------------
+ if( (line = E00ReadNextLine(hReadPtr)) == NULL )
+ return( NULL );
+// sscanf(line, "%ld%ld%ld", &cols, &rows, &depth, &nul_val);
+ sscanf(line, "%ld%ld%ld%lf", &cols, &rows, &depth, &nul_val);
+
+ if( (line = E00ReadNextLine(hReadPtr)) == NULL )
+ return( NULL );
+ sscanf(line, "%lf%lf", &xres, &yres);
+
+ if( (line = E00ReadNextLine(hReadPtr)) == NULL )
+ return( NULL );
+ sscanf(line, "%lf%lf", &xmin, &ymin);
+
+ if( (line = E00ReadNextLine(hReadPtr)) == NULL )
+ return( NULL );
+ sscanf(line, "%lf%lf", &xmax, &ymax);
+
+ xmax = xmax * scale;
+ xmin = xmin * scale;
+ ymax = ymax * scale;
+ ymin = ymin * scale;
+ xres = xres * scale;
+ yres = yres * scale;
+
+ xmin += xres / 2.0; // SAGA treats xmin/ymin as "pixel-as-point" and not as "pixel-as-area"
+ ymin += yres / 2.0;
+
+ if( depth == 2 && prec )
+ {
+ depth = 3;
+ }
+
+ //-----------------------------------------------------
+ switch( depth )
+ {
+ default:
+ pGrid = NULL;
+ break;
+
+ //-----------------------------------------------------
+ case 1:
+ pGrid = SG_Create_Grid(SG_DATATYPE_Int, cols, rows, xres, xmin, ymin);
+ pGrid->Set_NoData_Value(nul_val);
+
+ for(y=0; y<rows && line && Set_Progress(y, rows); y++)
+ {
+ for(x=0; x<cols; x+= 5)
+ {
+ if( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%ld%ld%ld%ld%ld", p, p+1, p+2, p+3, p+4);
+
+ for(ix=0; ix<5 && x+ix<cols; ix++)
+ {
+ pGrid->Set_Value(x + ix, y, p[ix]);
+ }
+ }
+ }
+ }
+ break;
+
+ //-----------------------------------------------------
+ case 2:
+ pGrid = SG_Create_Grid(SG_DATATYPE_Float, cols, rows, xres, xmin, ymin);
+ pGrid->Set_NoData_Value(nul_val);
+
+ for(y=0; y<rows && line && Set_Progress(y, rows); y++)
+ {
+ for(x=0; x<cols; x+= 5)
+ {
+ if( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%f%f%f%f%f", f, f+1, f+2, f+3, f+4);
+
+ for(ix=0; ix<5 && x+ix<cols; ix++)
+ {
+ pGrid->Set_Value(x + ix, y, f[ix]);
+ }
+ }
+ }
+ }
+ break;
+
+ //-----------------------------------------------------
+ case 3:
+ pGrid = SG_Create_Grid(SG_DATATYPE_Double, cols, rows, xres, xmin, ymin);
+ pGrid->Set_NoData_Value(nul_val);
+
+ for(y=0; y<rows && line && Set_Progress(y, rows); y++)
+ {
+ for(x=0; x<cols; x+= 3)
+ {
+ if( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%lf%lf%lf", d, d+1, d+2);
+
+ for(ix=0; ix<3 && x+ix<cols; ix++)
+ {
+ pGrid->Set_Value(x + ix, y, d[ix]);
+ }
+ }
+ }
+ }
+ break;
+ }
+
+ //-----------------------------------------------------
+ skip("EOG");
+
+ return( pGrid );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define ARC_FNODE 2
+#define ARC_TNODE 3
+#define ARC_LPOL 4
+#define ARC_RPOL 5
+
+//---------------------------------------------------------
+CSG_Shapes * CESRI_E00_Import::getarcs(int prec, double scale, TSG_Shape_Type &shape_type)
+{
+ const char *line;
+
+ int covnum, cov_id, fnode, tnode, lpol, rpol, nPoints, iPoint;
+ double x_buf[2], y_buf[2];
+ CSG_Shape *pShape;
+ CSG_Shapes *pShapes;
+
+ //-----------------------------------------------------
+ pShapes = SG_Create_Shapes(shape_type);
+ pShapes->Add_Field("ID" , SG_DATATYPE_Int);
+ pShapes->Add_Field("ID#" , SG_DATATYPE_Int);
+ pShapes->Add_Field("FNODE" , SG_DATATYPE_Int);
+ pShapes->Add_Field("TNODE" , SG_DATATYPE_Int);
+ pShapes->Add_Field("LPOL" , SG_DATATYPE_Int);
+ pShapes->Add_Field("RPOL" , SG_DATATYPE_Int);
+
+ Set_Progress(0, 100);
+
+ //-----------------------------------------------------
+ do
+ {
+ Process_Set_Text(CSG_String::Format(SG_T("Loaded arcs: %d"), pShapes->Get_Count()));
+
+ if( (line = E00ReadNextLine(hReadPtr)) == NULL )
+ {
+ covnum = -1;
+ }
+ else
+ {
+ sscanf(line, "%d %d %d %d %d %d %d", &covnum, &cov_id, &fnode, &tnode, &lpol, &rpol, &nPoints);
+ }
+
+ if( covnum != -1 )
+ {
+ pShape = pShapes->Add_Shape();
+
+ pShape->Set_Value(0 , covnum);
+ pShape->Set_Value(1 , cov_id);
+ pShape->Set_Value(ARC_FNODE , fnode);
+ pShape->Set_Value(ARC_TNODE , tnode);
+ pShape->Set_Value(ARC_LPOL , lpol);
+ pShape->Set_Value(ARC_RPOL , rpol);
+
+ //---------------------------------------------
+ if( prec ) // double precision : 1 coord pair / line
+ {
+ for(iPoint=0; iPoint<nPoints && line; iPoint++)
+ {
+ if( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%lf %lf", x_buf, y_buf);
+
+ pShape->Add_Point(x_buf[0] * scale, y_buf[0] * scale);
+ }
+ }
+ }
+
+ //---------------------------------------------
+ else // single precision : 2 x,y pairs / line
+ {
+ for(iPoint=0; iPoint<nPoints && line; iPoint+=2)
+ {
+ if( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%lf %lf %lf %lf", x_buf, y_buf, x_buf + 1, y_buf + 1);
+
+ pShape->Add_Point(x_buf[0] * scale, y_buf[0] * scale);
+
+ if( iPoint + 1 < nPoints )
+ {
+ pShape->Add_Point(x_buf[1] * scale, y_buf[1] * scale);
+ }
+ }
+ }
+ }
+ }
+ }
+ while( covnum != -1 && line && Process_Get_Okay(false) );
+
+ //-----------------------------------------------------
+ if( pShapes->Get_Count() == 0 )
+ {
+ delete(pShapes);
+
+ shape_type = SHAPE_TYPE_Point;
+
+ return( NULL );
+ }
+
+ if( shape_type == SHAPE_TYPE_Polygon )
+ {
+ pShapes = Arcs2Polygons(pShapes);
+
+ Assign_Attributes(pShapes);
+ }
+
+ return( pShapes );
+}
+
+//---------------------------------------------------------
+CSG_Shapes * CESRI_E00_Import::Arcs2Polygons(CSG_Shapes *pArcs)
+{
+ int iArc, nArcs, id;
+ CSG_Shapes *pPolygons;
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("Arcs to polygons"));
+
+ pPolygons = SG_Create_Shapes(SHAPE_TYPE_Polygon);
+ pPolygons->Add_Field("ID", SG_DATATYPE_Int);
+
+ nArcs = pArcs->Get_Count();
+
+ //-----------------------------------------------------
+ while( (iArc = pArcs->Get_Count() - 1) >= 0 && Set_Progress(nArcs - iArc - 1, nArcs) )
+ {
+ id = pArcs->Get_Shape(iArc)->asInt(ARC_LPOL);
+
+ if( id == pArcs->Get_Shape(iArc)->asInt(ARC_RPOL) )
+ {
+ pArcs->Del_Shape(iArc);
+ }
+ else if( id > 1 )
+ {
+ Arcs2Polygon(pArcs, pPolygons, id);
+ }
+
+ if( (iArc = pArcs->Get_Count() - 1) >= 0 )
+ {
+ id = pArcs->Get_Shape(iArc)->asInt(ARC_RPOL);
+
+ if( id > 1 )
+ {
+ Arcs2Polygon(pArcs, pPolygons, id);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ delete( pArcs );
+
+ return( pPolygons );
+}
+
+//---------------------------------------------------------
+void CESRI_E00_Import::Arcs2Polygon(CSG_Shapes *pArcs, CSG_Shapes *pPolygons, int id)
+{
+ int iShape, iPart, iPoint, iNode;
+ CSG_Shape *pArc, *pShape;
+ CSG_Shapes Arcs;
+
+ //-----------------------------------------------------
+ Arcs.Create(SHAPE_TYPE_Line);
+ Arcs.Add_Field("FROM_NODE", SG_DATATYPE_Int);
+ Arcs.Add_Field("TO___NODE", SG_DATATYPE_Int);
+
+ //-----------------------------------------------------
+ for(iShape=pArcs->Get_Count()-1; iShape>=0; iShape--)
+ {
+ pShape = pArcs->Get_Shape(iShape);
+
+ if( id == pShape->asInt(ARC_LPOL) )
+ {
+ pArc = Arcs.Add_Shape();
+ pArc->Set_Value(0, pShape->asInt(ARC_FNODE));
+ pArc->Set_Value(1, pShape->asInt(ARC_TNODE));
+
+ for(iPoint=0; iPoint<pShape->Get_Point_Count(0); iPoint++)
+ {
+ pArc->Add_Point(pShape->Get_Point(iPoint, 0), 0);
+ }
+
+ if( pShape->asInt(ARC_RPOL) <= 1 )
+ {
+ pArcs->Del_Shape(iShape);
+ }
+ else
+ {
+ pShape->Set_Value(ARC_LPOL, 1);
+ }
+ }
+ else if( id == pShape->asInt(ARC_RPOL) )
+ {
+ pArc = Arcs.Add_Shape();
+ pArc->Set_Value(1, pShape->asInt(ARC_FNODE));
+ pArc->Set_Value(0, pShape->asInt(ARC_TNODE));
+
+ for(iPoint=pShape->Get_Point_Count(0)-1; iPoint>=0; iPoint--)
+ {
+ pArc->Add_Point(pShape->Get_Point(iPoint, 0), 0);
+ }
+
+ if( pShape->asInt(ARC_LPOL) <= 1 )
+ {
+ pArcs->Del_Shape(iShape);
+ }
+ else
+ {
+ pShape->Set_Value(ARC_RPOL, 1);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ if( Arcs.Get_Count() > 0 )
+ {
+ iPart = 0;
+ pShape = pPolygons->Add_Shape();
+ pShape->Set_Value(0, id);
+
+ do
+ {
+ pArc = Arcs.Get_Shape(0);
+
+ while( pArc )
+ {
+ for(iPoint=0; iPoint<pArc->Get_Point_Count(0); iPoint++)
+ {
+ pShape->Add_Point(pArc->Get_Point(iPoint, 0), iPart);
+ }
+
+ iNode = pArc->asInt(1);
+ Arcs.Del_Shape(pArc);
+
+ for(iShape=0, pArc=NULL; iShape<Arcs.Get_Count() && !pArc; iShape++)
+ {
+ if( iNode == Arcs.Get_Shape(iShape)->asInt(0) )
+ {
+ pArc = Arcs.Get_Shape(iShape);
+ }
+ }
+ }
+
+ iPart++;
+ }
+ while( Arcs.Get_Count() > 0 );
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Shapes * CESRI_E00_Import::getlabels(int prec, double scale) // shape_type: LINE or AREA
+{
+ const char *line;
+
+ int num, id; // coverage-# and coverage-ID
+ double x, y;
+ CSG_Shapes *pShapes;
+ CSG_Shape *pShape;
+
+ pShapes = SG_Create_Shapes(SHAPE_TYPE_Point);
+
+ pShapes->Add_Field("ID#" , SG_DATATYPE_Int);
+ pShapes->Add_Field("ID" , SG_DATATYPE_Int);
+
+ while( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%d %d %lf %lf", &id, &num, &x, &y);
+
+ if( id == -1 )
+ {
+ break;
+ }
+ else
+ {
+ pShape = pShapes->Add_Shape();
+
+ pShape->Add_Point(x * scale, y * scale);
+
+ pShape->Set_Value(0, num);
+ pShape->Set_Value(1, id);
+
+ //---------------------------------------------
+ E00ReadNextLine(hReadPtr); // 4 values to skip
+
+ if( prec )
+ {
+ E00ReadNextLine(hReadPtr); // on 2nd line when double precision
+ }
+ }
+ }
+
+ if( pShapes->Get_Count() <= 0 )
+ {
+ delete( pShapes );
+ pShapes = NULL;
+ }
+
+ return( pShapes );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Shapes * CESRI_E00_Import::getsites(int prec, double scale)
+{
+ const char *line;
+
+ int id;
+ double x, y;
+ CSG_Shape *pShape;
+ CSG_Shapes *pShapes;
+
+ pShapes = SG_Create_Shapes(SHAPE_TYPE_Point);
+ pShapes->Add_Field("ID", SG_DATATYPE_Int);
+
+ while( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%d %*d %lf %lf", &id, &x, &y);
+
+ if( id == -1 )
+ {
+ break;
+ }
+
+ pShape = pShapes->Add_Shape();
+
+ pShape->Add_Point(x * scale, y * scale);
+ pShape->Set_Value(0, id);
+
+ //-------------------------------------------------
+ E00ReadNextLine(hReadPtr); // 4 values to skip
+
+ if( prec )
+ {
+ E00ReadNextLine(hReadPtr); // on 2nd line when double precision
+ }
+ }
+
+ if( pShapes->Get_Count() <= 0 )
+ {
+ delete( pShapes );
+ pShapes = NULL;
+ }
+ else
+ {
+ Assign_Attributes(pShapes);
+ }
+
+ return( pShapes );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+double CESRI_E00_Import::getproj(void)
+{
+ const char *line;
+
+ double scale = 1.0;
+
+ while( (line = E00ReadNextLine(hReadPtr)) != NULL && strncmp(line, "EOP", 3) )
+ {
+ if( !strncmp(line, "Units", 5) )
+ {
+ sscanf(line + 6, "%lf", &scale);
+ }
+ }
+
+ scale = 1.0 / scale;
+
+ return( scale );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// info section //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+struct info_Field
+{
+ char Name[18]; // name of item
+
+ int Position, // position in data line
+ Size, // size for reading
+ Type; // type of data
+};
+
+//---------------------------------------------------------
+struct info_Table
+{
+ char Name[34],
+ AI[4]; // XX if Arc/info file, spaces otherwise
+
+ int uFields, // number of usable items in this table
+ nFields, // number of items in this table
+ ldr; // length of data record
+
+ long nRecords, // number of data records
+ length; // total length for one data line
+
+ struct info_Field *Field; // One per field...
+};
+
+//---------------------------------------------------------
+// [06.06.2006] ESRI E00 Import crash fix, James Flemer
+int CESRI_E00_Import::info_Get_Tables(void)
+{
+ const char *line;
+
+ char tmp[12], *p;
+ int i;
+ CSG_String s;
+ CSG_Table *pTable;
+ struct info_Table info;
+
+ //-----------------------------------------------------
+ while( (line = E00ReadNextLine(hReadPtr)) != NULL && strncmp(line, "EOI", 3) )
+ {
+ strncpy(info.Name, line, 32);
+ info.Name[32] = 0;
+ p = strchr(info.Name, ' ');
+ if( p != NULL )
+ *p = 0;
+ p = strchr(info.Name, '.');
+ if( p == 0 )
+ p = info.Name;
+ else
+ p++;
+ s = p;
+
+ strncpy(info.AI , line + 32, 2); info.AI[2] = 0;
+ strncpy(tmp , line + 34, 4); tmp[ 4] = 0; info.uFields = atoi(tmp);
+ strncpy(tmp , line + 38, 4); tmp[ 4] = 0; info.nFields = atoi(tmp);
+ strncpy(tmp , line + 42, 4); tmp[ 4] = 0; info.ldr = atoi(tmp);
+ strncpy(tmp , line + 46, 11); tmp[11] = 0; info.nRecords = atol(tmp);
+
+ info.length = 0;
+ info.Field = (struct info_Field *)malloc(info.nFields * sizeof(struct info_Field));
+
+ //---------------------------------------------
+ for(i=0; i<info.nFields; i++)
+ {
+ if( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%16s", info.Field[i].Name);
+ info.Field[i].Size = atoi(&line[16]);
+ info.Field[i].Type = atoi(&line[34]);
+ }
+
+ //---------------------------------------------
+ switch( info.Field[i].Type )
+ {
+ case 60: // float / double
+ info.Field[i].Size = info.Field[i].Size == 4 ? 14 : 24;
+ break;
+
+ case 50: // short / long
+ info.Field[i].Size = info.Field[i].Size == 2 ? 6 : 11;
+ break;
+
+ case 40: // float
+ info.Field[i].Size = 14;
+ break;
+
+ case 10:
+ info.Field[i].Size = 8;
+ break;
+
+ default: // string
+ break;
+ }
+
+ if( i < info.uFields )
+ {
+ info.length += info.Field[i].Size;
+ }
+
+ if( i == 0 )
+ {
+ info.Field[i].Position = 0;
+ }
+ else
+ {
+ info.Field[i].Position = info.Field[i-1].Position + info.Field[i-1].Size;
+ }
+ }
+
+ //---------------------------------------------
+ pTable = NULL;
+
+ if ( !s.CmpNoCase(SG_T("aat")) && pAAT == NULL )
+ {
+ pTable = pAAT = info_Get_Table(info);
+ }
+ else if( !s.CmpNoCase(SG_T("pat")) && pPAT == NULL )
+ {
+ pTable = pPAT = info_Get_Table(info);
+ }
+ // else if( !s.CmpNoCase("vat") ) // value table (grid)
+ // else if( !s.CmpNoCase("bnd") ) // coverage boundaries
+ // else if( !s.CmpNoCase("tic") ) // tick marks
+ // else if( !s.CmpNoCase("sta") ) // stats on grid
+ // else if( !s.CmpNoCase("lut") ) // look-up table
+ // else if( !s.CmpNoCase("acode") ) // arc attributes
+ // else if( !s.CmpNoCase("pcode") ) // polygon attributes
+ // else // non graphic tables
+ else // come on, let's get every table we can get...
+ {
+ pTable = info_Get_Table(info);
+ }
+
+ //-------------------------------------------------
+ free(info.Field);
+
+ if( pTable )
+ {
+ CSG_Table_Record *pRecord;
+ CSG_Shape *pShape;
+ CSG_Shapes *pBND, *pTIC;
+
+ if ( !s.CmpNoCase(SG_T("bnd")) ) // coverage boundaries
+ {
+ pBND = SG_Create_Shapes(SHAPE_TYPE_Polygon, SG_T("Boundary"));
+ pBND->Add_Field("XMIN", SG_DATATYPE_Double);
+ pBND->Add_Field("YMIN", SG_DATATYPE_Double);
+ pBND->Add_Field("XMAX", SG_DATATYPE_Double);
+ pBND->Add_Field("YMAX", SG_DATATYPE_Double);
+ pRecord = pTable->Get_Record(0);
+ pShape = pBND->Add_Shape();
+ pShape->Set_Value(0, pRecord->asDouble(0));
+ pShape->Set_Value(1, pRecord->asDouble(1));
+ pShape->Set_Value(2, pRecord->asDouble(2));
+ pShape->Set_Value(3, pRecord->asDouble(3));
+ pShape->Add_Point(pRecord->asDouble(0), pRecord->asDouble(1));
+ pShape->Add_Point(pRecord->asDouble(0), pRecord->asDouble(3));
+ pShape->Add_Point(pRecord->asDouble(2), pRecord->asDouble(3));
+ pShape->Add_Point(pRecord->asDouble(2), pRecord->asDouble(1));
+ Parameters("BND")->Set_Value(pBND);
+ delete(pTable);
+ }
+ else if( !s.CmpNoCase(SG_T("tic")) ) // tick marks
+ {
+ pTIC = SG_Create_Shapes(SHAPE_TYPE_Point, SG_T("Tick Points"));
+ pTIC->Add_Field("ID", SG_DATATYPE_Int);
+ pTIC->Add_Field("X" , SG_DATATYPE_Double);
+ pTIC->Add_Field("Y" , SG_DATATYPE_Double);
+ for(i=0; i<pTable->Get_Record_Count(); i++)
+ {
+ pRecord = pTable->Get_Record(i);
+ pShape = pTIC->Add_Shape();
+ pShape->Set_Value(0, pRecord->asInt (0));
+ pShape->Set_Value(1, pRecord->asDouble(1));
+ pShape->Set_Value(2, pRecord->asDouble(2));
+ pShape->Add_Point(pRecord->asDouble(1), pRecord->asDouble(2));
+ }
+ Parameters("TIC")->Set_Value(pTIC);
+ delete(pTable);
+ }
+ else
+ {
+ Parameters("TABLE")->Set_Value(pTable);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ // 0 if none, 1 if AAT, 2 if PAT, 3 if both
+ return( pPAT ? (pAAT ? 3 : 2) : (pAAT ? 1 : 0) );
+}
+
+//---------------------------------------------------------
+CSG_Table * CESRI_E00_Import::info_Get_Table(struct info_Table info)
+{
+ char *buffer_record, *buffer_item;
+ int iRecord, iField;
+ CSG_Table *pTable;
+ CSG_Table_Record *pRecord;
+
+ //-----------------------------------------------------
+ Process_Set_Text(CSG_String(info.Name));
+
+ buffer_record = (char *)malloc(info.length + 3);
+ buffer_item = (char *)malloc(info.length + 3);
+
+ pTable = SG_Create_Table();
+ pTable->Set_Name(CSG_String(info.Name));
+
+ //-----------------------------------------------------
+ for(iField=0; iField<info.uFields; iField++)
+ {
+ switch( info.Field[iField].Type )
+ {
+ case 60: // float / double
+ pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_Double);
+ break;
+
+ case 50: // short / long
+ pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_Int);
+ break;
+
+ case 40: // float
+ pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_Double);
+ break;
+
+ case 10: // short
+ pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_Int);
+ break;
+
+ default: // string
+ pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_String);
+ break;
+ }
+ }
+
+ //-----------------------------------------------------
+ for(iRecord=0; iRecord<info.nRecords && Set_Progress(iRecord, info.nRecords); iRecord++)
+ {
+ info_Get_Record(buffer_record, info.length);
+
+ pRecord = pTable->Add_Record();
+
+ for(iField=0; iField<info.uFields; iField++)
+ {
+ strncpy(buffer_item, &buffer_record[info.Field[iField].Position], info.Field[iField].Size);
+ buffer_item[info.Field[iField].Size] = 0;
+
+ switch( pTable->Get_Field_Type(iField) )
+ {
+ default:
+ pRecord->Set_Value(iField, atof(buffer_item));
+ break;
+
+ case SG_DATATYPE_Int:
+ pRecord->Set_Value(iField, atoi(buffer_item));
+ break;
+
+ case SG_DATATYPE_String:
+ pRecord->Set_Value(iField, CSG_String(buffer_item));
+ break;
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ free(buffer_record);
+ free(buffer_item);
+
+ return( pTable );
+}
+
+//---------------------------------------------------------
+void CESRI_E00_Import::info_Skip_Table(struct info_Table info)
+{
+ char *buffer_record;
+ int iRecord;
+
+ buffer_record = (char *)malloc(info.length + 3);
+
+ for(iRecord=0; iRecord<info.nRecords; iRecord++)
+ {
+ info_Get_Record(buffer_record, info.length);
+ }
+
+ free(buffer_record);
+}
+
+//---------------------------------------------------------
+void CESRI_E00_Import::info_Get_Record(char *buffer, int buffer_length)
+{
+ const char *line;
+
+ char *p;
+ int l;
+
+ //-----------------------------------------------------
+ p = buffer;
+ l = 0;
+
+ //-----------------------------------------------------
+ if( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ strncpy(buffer, line, buffer_length < 84 ? buffer_length : 84);
+
+ while( l < buffer_length )
+ {
+ if( *p =='\r' || *p == '\n' || *p == 0 )
+ {
+ while( (l % 80 || p == buffer) && l < buffer_length )
+ {
+ l++;
+ *p++ = ' ';
+ }
+
+ if( l == buffer_length )
+ {
+ break;
+ }
+ else if( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ strncpy(p, line, buffer_length - l < 84 ? buffer_length - l : 84);
+
+ if( *p =='\r' || *p == '\n' || *p == 0 ) // if empty line
+ {
+ l++;
+ *p++ = ' ';
+ *p = 0;
+ }
+ }
+ }
+ else
+ {
+ l++;
+ p++;
+ }
+ }
+
+ *p = 0;
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Skips //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CESRI_E00_Import::Assign_Attributes(CSG_Shapes *pShapes)
+{
+ int iShape, iRecord, iField, oField, id;
+ CSG_Table_Record *pRec;
+ CSG_Shape *pShape;
+
+ if( pShapes && pShapes->Get_Field_Count() > 0 && pPAT && pPAT->Get_Field_Count() > 2 )
+ {
+ Process_Set_Text(_TL("Assign attributes to shapes..."));
+
+ oField = pShapes->Get_Field_Count();
+
+ for(iField=0; iField<pPAT->Get_Field_Count(); iField++)
+ {
+ pShapes->Add_Field(pPAT->Get_Field_Name(iField), pPAT->Get_Field_Type(iField));
+ }
+
+ for(iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
+ {
+ pShape = pShapes->Get_Shape(iShape);
+ id = pShape->asInt(0);
+
+ for(iRecord=0; iRecord<pPAT->Get_Record_Count(); iRecord++)
+ {
+ pRec = pPAT->Get_Record(iRecord);
+
+ if( id == pRec->asInt(2) )
+ {
+ for(iField=0; iField<pPAT->Get_Field_Count(); iField++)
+ {
+ switch( pPAT->Get_Field_Type(iField) )
+ {
+ case SG_DATATYPE_String:
+ pShape->Set_Value(oField + iField, pRec->asString(iField));
+ break;
+
+ default:
+ pShape->Set_Value(oField + iField, pRec->asDouble(iField));
+ break;
+ }
+ }
+
+ break;
+ }
+ }
+
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Skips //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CESRI_E00_Import::skip(char *end)
+{
+ const char *line;
+
+ int l = strlen(end);
+
+ while( (line = E00ReadNextLine(hReadPtr)) != NULL && strncmp(line, end, l) );
+}
+
+//---------------------------------------------------------
+void CESRI_E00_Import::skip_dat(void)
+{
+ const char *line;
+
+ int i = 0;
+
+ while( (line = E00ReadNextLine(hReadPtr)) != NULL && i != -1 )
+ {
+ sscanf(line, "%d", &i);
+ }
+}
+
+//---------------------------------------------------------
+void CESRI_E00_Import::skip_msk(void)
+{
+ const char *line;
+
+ double xmin, ymin, xmax, ymax, res, sk;
+ long xsize, ysize, nskip;
+
+ if( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%lf %lf %lf", &xmin, &ymin, &xmax);
+
+ if( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%lf %lf %ld %ld", &ymax, &res, &xsize, &ysize);
+
+ sk = ((ymax - ymin) / res) * ((xmax - xmin) / res) / 32.0;
+ nskip = (long)ceil(sk / 7.0);
+
+ while( nskip-- )
+ {
+ E00ReadNextLine(hReadPtr);
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
+void CESRI_E00_Import::skip_arc(int prec)
+{
+ const char *line;
+
+ int i, covnum, nPoints;
+
+ while( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%d %*d %*d %*d %*d %*d %d", &covnum, &nPoints);
+
+ if( covnum == -1 )
+ break;
+
+ if( prec == 0 )
+ nPoints = (nPoints + 1) / 2; // number of coordinate lines
+
+ for(i=0; i<nPoints; i++)
+ {
+ E00ReadNextLine(hReadPtr);
+ }
+ }
+}
+
+//---------------------------------------------------------
+void CESRI_E00_Import::skip_lab(int prec)
+{
+ const char *line;
+
+ long covid;
+
+ while( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%ld", &covid);
+
+ if( covid == -1 )
+ break;
+
+ E00ReadNextLine(hReadPtr);
+
+ if( prec ) // two lines of coordinates in double precision
+ E00ReadNextLine(hReadPtr);
+ }
+}
+
+//---------------------------------------------------------
+void CESRI_E00_Import::skip_pal(int prec)
+{
+ const char *line;
+
+ int i, narcs;
+
+ while( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf(line, "%d", &narcs);
+
+ if( prec ) // two lines of coordinates in double precision
+ E00ReadNextLine(hReadPtr);
+
+ if( narcs == -1 )
+ break;
+
+ for(i=(narcs+1)/2; i; i--)
+ E00ReadNextLine(hReadPtr);
+ }
+}
+
+//---------------------------------------------------------
+void CESRI_E00_Import::skip_txt(int prec)
+{
+ const char *line;
+
+ int i, n, nskip;
+
+ nskip = prec ? 7 : 5;
+
+ while( (line = E00ReadNextLine(hReadPtr)) != NULL )
+ {
+ sscanf( line, "%d", &n);
+
+ if( n == -1 )
+ break;
+
+ for(i=0; i<nskip; i++)
+ E00ReadNextLine(hReadPtr);
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_io/esri_e00/io_esri_e00/Makefile.am b/src/modules_io/esri_e00/io_esri_e00/Makefile.am
index cafd1d1..1f9e046 100644
--- a/src/modules_io/esri_e00/io_esri_e00/Makefile.am
+++ b/src/modules_io/esri_e00/io_esri_e00/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:25 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:48 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libio_esri_e00.la
libio_esri_e00_la_SOURCES =\
ESRI_E00_Import.cpp\
diff --git a/src/modules_io/esri_e00/io_esri_e00/Makefile.in b/src/modules_io/esri_e00/io_esri_e00/Makefile.in
index f3484fc..8529b66 100644
--- a/src/modules_io/esri_e00/io_esri_e00/Makefile.in
+++ b/src/modules_io/esri_e00/io_esri_e00/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,7 +72,7 @@ am_libio_esri_e00_la_OBJECTS = ESRI_E00_Import.lo MLB_Interface.lo \
cpl_conv.lo cpl_error.lo cpl_vsisimple.lo e00read.lo \
e00write.lo
libio_esri_e00_la_OBJECTS = $(am_libio_esri_e00_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +128,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,14 +219,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:25 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:48 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libio_esri_e00.la
libio_esri_e00_la_SOURCES = \
ESRI_E00_Import.cpp\
diff --git a/src/modules_io/gdal/Makefile.in b/src/modules_io/gdal/Makefile.in
index d11802a..a6a3e7d 100644
--- a/src/modules_io/gdal/Makefile.in
+++ b/src/modules_io/gdal/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_io/gdal/io_gdal/Makefile.am b/src/modules_io/gdal/io_gdal/Makefile.am
index 26d333e..b50b5f9 100644
--- a/src/modules_io/gdal/io_gdal/Makefile.am
+++ b/src/modules_io/gdal/io_gdal/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.1 2008/09/03 13:27:09 oconrad Exp $
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:48 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -11,7 +11,7 @@ DEP_LIBS = `gdal-config --libs`
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core `gdal-config --cflags`
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared $(DEP_LIBS)
+AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS)
pkglib_LTLIBRARIES = libio_gdal.la
libio_gdal_la_SOURCES =\
gdal_driver.cpp\
diff --git a/src/modules_io/gdal/io_gdal/Makefile.in b/src/modules_io/gdal/io_gdal/Makefile.in
index 35ba5fd..770cd2c 100644
--- a/src/modules_io/gdal/io_gdal/Makefile.in
+++ b/src/modules_io/gdal/io_gdal/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,7 +72,7 @@ am_libio_gdal_la_OBJECTS = gdal_driver.lo gdal_export.lo \
gdal_export_geotiff.lo gdal_import.lo MLB_Interface.lo \
ogr_driver.lo ogr_export.lo ogr_import.lo
libio_gdal_la_OBJECTS = $(am_libio_gdal_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +128,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,7 +219,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.1 2008/09/03 13:27:09 oconrad Exp $
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:48 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
@@ -226,7 +227,7 @@ DEP_LIBS = `gdal-config --libs`
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core `gdal-config --cflags`
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared $(DEP_LIBS)
+AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS)
pkglib_LTLIBRARIES = libio_gdal.la
libio_gdal_la_SOURCES = \
gdal_driver.cpp\
diff --git a/src/modules_io/gdal/io_gdal/gdal_driver.cpp b/src/modules_io/gdal/io_gdal/gdal_driver.cpp
index 8b3c02a..12671a0 100644
--- a/src/modules_io/gdal/io_gdal/gdal_driver.cpp
+++ b/src/modules_io/gdal/io_gdal/gdal_driver.cpp
@@ -182,6 +182,9 @@ bool CGDAL_Driver::Set_Transform(GDALDataset *pDataset, CSG_Grid_System *pSystem
CGDAL_System::CGDAL_System(void)
{
m_pDataSet = NULL;
+
+ m_TF_A.Create(2);
+ m_TF_B.Create(2, 2);
}
//---------------------------------------------------------
@@ -189,6 +192,9 @@ CGDAL_System::CGDAL_System(const CSG_String &File_Name, int ioAccess)
{
m_pDataSet = NULL;
+ m_TF_A.Create(2);
+ m_TF_B.Create(2, 2);
+
Create(File_Name, ioAccess);
}
@@ -198,6 +204,11 @@ CGDAL_System::~CGDAL_System(void)
Destroy();
}
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
bool CGDAL_System::Create(const CSG_String &File_Name, int ioAccess)
{
@@ -208,25 +219,42 @@ bool CGDAL_System::Create(const CSG_String &File_Name, int ioAccess)
{
if( (m_pDataSet = (GDALDataset *)GDALOpen(SG_STR_SGTOMB(File_Name), GA_ReadOnly)) != NULL )
{
- if( m_pDataSet->GetGeoTransform(m_Transform) != CE_None )
- {
- m_Transform[0] = 0.0;
- m_Transform[1] = 1.0;
- m_Transform[2] = 0.0;
- m_Transform[3] = 0.0;
- m_Transform[4] = 0.0;
- m_Transform[5] = -1.0;
- }
+ double Transform[6];
m_Access = IO_READ;
m_NX = m_pDataSet->GetRasterXSize();
m_NY = m_pDataSet->GetRasterYSize();
- m_DX = m_Transform[1];
- m_DY = m_Transform[5];
+ if( m_pDataSet->GetGeoTransform(Transform) != CE_None )
+ {
+ m_bTransform = false;
+ m_Cellsize = 1.0;
+ m_xMin = 0.5;
+ m_yMin = 0.5;
+ }
+ else if( Transform[1] == -Transform[5] && Transform[2] == 0.0 && Transform[4] == 0.0 ) // nothing to transform
+ {
+ m_bTransform = false;
+ m_Cellsize = Transform[1]; // pixel width (== pixel height)
+ m_xMin = Transform[0] + m_Cellsize * 0.5; // center (x) of left edge pixels
+ m_yMin = Transform[3] + m_Cellsize * (0.5 - m_NY); // center (y) of lower edge pixels
+ }
+ else
+ {
+ m_bTransform = true;
+ m_Cellsize = 1.0;
+ m_xMin = 0.5;
+ m_yMin = 0.5;
+ }
- to_World(0.5, m_NY - 0.5, m_xMin, m_yMin);
+ m_TF_A[0] = Transform[0];
+ m_TF_A[1] = Transform[3];
+ m_TF_B[0][0] = Transform[1];
+ m_TF_B[0][1] = Transform[2];
+ m_TF_B[1][0] = Transform[4];
+ m_TF_B[1][1] = Transform[5];
+ m_TF_BInv = m_TF_B.Get_Inverse();
return( true );
}
@@ -257,6 +285,11 @@ bool CGDAL_System::Destroy(void)
return( true );
}
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
CSG_Grid * CGDAL_System::Read_Band(int i)
{
@@ -265,7 +298,7 @@ CSG_Grid * CGDAL_System::Read_Band(int i)
if( is_Reading() && (pBand = m_pDataSet->GetRasterBand(i + 1)) != NULL )
{
CSG_Grid *pGrid = SG_Create_Grid(g_GDAL_Driver.Get_Grid_Type(pBand->GetRasterDataType()),
- Get_NX(), Get_NY(), Get_DX(), Get_xMin(), Get_yMin()
+ Get_NX(), Get_NY(), Get_Cellsize(), Get_xMin(), Get_yMin()
);
pGrid->Set_Name (SG_STR_MBTOSG(pBand->GetMetadataItem(GDAL_DMD_LONGNAME)));
@@ -282,13 +315,15 @@ CSG_Grid * CGDAL_System::Read_Band(int i)
for(int y=0; y<Get_NY() && SG_UI_Process_Set_Progress(y, Get_NY()); y++)
{
+ int yy = m_bTransform ? y : Get_NY() - 1 - y;
+
if( pBand->RasterIO(GF_Read, 0, y, Get_NX(), 1, zLine, Get_NX(), 1, GDT_Float64, 0, 0) == CE_None )
{
for(int x=0; x<Get_NX(); x++)
{
- // double NaN = 0.0; NaN = -1.0 / NaN; if( NaN == zLine[x] ) pGrid->Set_NoData(x, System.Get_NY() - 1 - y); else
+ // double NaN = 0.0; NaN = -1.0 / NaN; if( NaN == zLine[x] ) pGrid->Set_NoData(x, yy); else
- pGrid->Set_Value (x, Get_NY() - 1 - y, zMin + zLine[x]);
+ pGrid->Set_Value (x, yy, zMin + zLine[x]);
}
}
}
diff --git a/src/modules_io/gdal/io_gdal/gdal_driver.h b/src/modules_io/gdal/io_gdal/gdal_driver.h
index fb5e320..7b49ba7 100644
--- a/src/modules_io/gdal/io_gdal/gdal_driver.h
+++ b/src/modules_io/gdal/io_gdal/gdal_driver.h
@@ -97,7 +97,7 @@ private:
//---------------------------------------------------------
#define IO_CLOSED 0x00
-#define IO_READ 0x01
+#define IO_READ 0x01
#define IO_WRITE 0x02
#define IO_READWRITE (IO_READ|IO_WRITE)
@@ -112,22 +112,23 @@ public:
bool Create (const CSG_String &File_Name, int ioAccess = IO_READ);
bool Destroy (void);
- bool is_Okay (void) { return( m_pDataSet != NULL ); }
- bool is_Reading (void) { return( m_pDataSet != NULL && m_Access & IO_READ ); }
- bool is_Writing (void) { return( m_pDataSet != NULL && m_Access & IO_WRITE ); }
+ bool is_Okay (void) const { return( m_pDataSet != NULL ); }
+ bool is_Reading (void) const { return( m_pDataSet != NULL && m_Access & IO_READ ); }
+ bool is_Writing (void) const { return( m_pDataSet != NULL && m_Access & IO_WRITE ); }
- int Get_NX (void) { return( m_NX ); }
- int Get_NY (void) { return( m_NY ); }
- double Get_xMin (void) { return( m_xMin ); }
- double Get_yMin (void) { return( m_yMin ); }
- double Get_DX (void) { return( m_DX ); }
- double Get_DY (void) { return( m_DY ); }
- double Get_Transform (int i) { return( m_Transform[i] ); }
+ int Get_NX (void) const { return( m_NX ); }
+ int Get_NY (void) const { return( m_NY ); }
+ double Get_xMin (void) const { return( m_xMin ); }
+ double Get_yMin (void) const { return( m_yMin ); }
+ double Get_Cellsize (void) const { return( m_Cellsize ); }
- GDALDriver * Get_Driver (void) { return( m_pDataSet ? m_pDataSet->GetDriver () : NULL ); }
- const char * Get_Projection (void) { return( m_pDataSet && m_pDataSet->GetProjectionRef() ? m_pDataSet->GetProjectionRef() : NULL ); }
+ bool Needs_Transform (void) const { return( m_bTransform ); }
+ void Get_Transform (CSG_Vector &A, CSG_Matrix &B) const { A = m_TF_A; B = m_TF_B; }
- int Get_Count (void) { return( m_pDataSet ? m_pDataSet->GetRasterCount() : 0 ); }
+ GDALDriver * Get_Driver (void) const { return( m_pDataSet ? m_pDataSet->GetDriver() : NULL ); }
+ const char * Get_Projection (void) const { return( m_pDataSet && m_pDataSet->GetProjectionRef() ? m_pDataSet->GetProjectionRef() : "" ); }
+
+ int Get_Count (void) const { return( m_pDataSet ? m_pDataSet->GetRasterCount() : 0 ); }
CSG_Grid * Read_Band (int i);
GDALDataset * Get_DataSet (void) { return( m_pDataSet ); }
@@ -135,9 +136,15 @@ public:
private:
+ bool m_bTransform;
+
int m_Access, m_NX, m_NY;
- double m_xMin, m_yMin, m_DX, m_DY, m_Transform[6];
+ double m_xMin, m_yMin, m_Cellsize;
+
+ CSG_Vector m_TF_A;
+
+ CSG_Matrix m_TF_B, m_TF_BInv;
GDALDataset *m_pDataSet;
@@ -148,8 +155,8 @@ public:
{
if( m_pDataSet )
{
- xWorld = m_Transform[0] + x * m_Transform[1] + y * m_Transform[2];
- yWorld = m_Transform[3] + y * m_Transform[4] + y * m_Transform[5];
+ xWorld = m_TF_A[0] + x * m_TF_B[0][1] + y * m_TF_B[0][1];
+ yWorld = m_TF_A[1] + x * m_TF_B[1][0] + y * m_TF_B[1][1];
return( true );
}
@@ -157,18 +164,17 @@ public:
return( false );
}
- bool to_Grid (int x, int y, CSG_Grid *pGrid, int &xGrid, int &yGrid)
+ bool from_World (double xWorld, double yWorld, double &x, double &y)
{
- if( m_pDataSet && pGrid )
+ if( m_pDataSet )
{
- double xWorld, yWorld;
-
- to_World(x, y, xWorld, yWorld);
+ xWorld -= m_TF_A[0];
+ yWorld -= m_TF_A[1];
- xGrid = (int)(0.5 + (xWorld - pGrid->Get_XMin()) / pGrid->Get_Cellsize());
- yGrid = (int)(0.5 + (yWorld - pGrid->Get_YMin()) / pGrid->Get_Cellsize());
+ x = xWorld * m_TF_BInv[0][0] + yWorld * m_TF_BInv[0][1];
+ y = xWorld * m_TF_BInv[1][0] + yWorld * m_TF_BInv[1][1];
- return( pGrid->is_InGrid(xGrid, yGrid, false) );
+ return( true );
}
return( false );
diff --git a/src/modules_io/gdal/io_gdal/gdal_export.cpp b/src/modules_io/gdal/io_gdal/gdal_export.cpp
index 7c9aa1a..a4a2b7e 100644
--- a/src/modules_io/gdal/io_gdal/gdal_export.cpp
+++ b/src/modules_io/gdal/io_gdal/gdal_export.cpp
@@ -200,6 +200,11 @@ bool CGDAL_Export::On_Execute(void)
{
g_GDAL_Driver.Set_Transform(pDataset, Get_System());
+ if( pGrids->asGrid(0)->Get_Projection().Get_Type() != SG_PROJ_TYPE_CS_Undefined )
+ {
+ pDataset->SetProjection(SG_STR_SGTOMB(pGrids->asGrid(0)->Get_Projection().Get_WKT()));
+ }
+
zLine = (double *)SG_Malloc(Get_NX() * sizeof(double));
for(n=0; n<pGrids->Get_Count(); n++)
diff --git a/src/modules_io/gdal/io_gdal/gdal_import.cpp b/src/modules_io/gdal/io_gdal/gdal_import.cpp
index d7770c3..ca066f7 100644
--- a/src/modules_io/gdal/io_gdal/gdal_import.cpp
+++ b/src/modules_io/gdal/io_gdal/gdal_import.cpp
@@ -103,8 +103,9 @@ CGDAL_Import::CGDAL_Import(void)
);
Parameters.Add_FilePath(
- NULL, "FILE" , _TL("File"),
- _TL("")
+ NULL, "FILES" , _TL("Files"),
+ _TL(""),
+ NULL, NULL, false, false, true
);
}
@@ -118,31 +119,41 @@ CGDAL_Import::CGDAL_Import(void)
//---------------------------------------------------------
bool CGDAL_Import::On_Execute(void)
{
- CSG_String File_Name;
+ CSG_Strings Files;
CGDAL_System System;
//-----------------------------------------------------
- File_Name = Parameters("FILE") ->asString();
+ if( !Parameters("FILES")->asFilePath()->Get_FilePaths(Files) )
+ {
+ return( false );
+ }
+ //-----------------------------------------------------
m_pGrids = Parameters("GRIDS") ->asGridList();
-
m_pGrids ->Del_Items();
- //-----------------------------------------------------
- if( System.Create(File_Name, IO_READ) == false )
+ for(int i=0; i<Files.Get_Count(); i++)
{
- Message_Add(_TL("could not find suitable import driver"));
- }
- else if( System.Get_Count() <= 0 )
- {
- return( Load_Sub(System, SG_File_Get_Name(File_Name, false)) );
- }
- else
- {
- return( Load(System, SG_File_Get_Name(File_Name, false)) );
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("loading"), Files[i].c_str()));
+
+ if( System.Create(Files[i], IO_READ) == false )
+ {
+ Message_Add(_TL("failed: could not find a suitable import driver"));
+ }
+ else
+ {
+ if( System.Get_Count() <= 0 )
+ {
+ Load_Sub(System, SG_File_Get_Name(Files[i], false));
+ }
+ else
+ {
+ Load(System, SG_File_Get_Name(Files[i], false));
+ }
+ }
}
- return( false );
+ return( m_pGrids->Get_Count() > 0 );
}
@@ -220,68 +231,161 @@ bool CGDAL_Import::Load_Sub(CGDAL_System &System, const CSG_String &Name)
bool CGDAL_Import::Load(CGDAL_System &System, const CSG_String &Name)
{
//-----------------------------------------------------
- if( System.is_Reading() )
+ if( !System.is_Reading() )
{
- Message_Add(CSG_String::Format(
- SG_T("\n%s: %s/%s\n"),
- _TL("Driver"),
- System.Get_Driver()->GetDescription(),
- System.Get_Driver()->GetMetadataItem(GDAL_DMD_LONGNAME)
- ), false);
-
- Message_Add(CSG_String::Format(
- SG_T("%s: x %d, y %d\n%s: %d\n%s x: %.6f, %.6f, %.6f\n%s y: %.6f, %.6f, %.6f"),
- _TL("Cells") , System.Get_NX(), System.Get_NY(),
- _TL("Bands") , System.Get_Count(),
- _TL("Transformation") , System.Get_Transform(0), System.Get_Transform(1), System.Get_Transform(2),
- _TL("Transformation") , System.Get_Transform(3), System.Get_Transform(4), System.Get_Transform(5)
- ), false);
-
- if( System.Get_Projection() != NULL )
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ CSG_Vector A;
+ CSG_Matrix B;
+
+ System.Get_Transform(A, B);
+
+ //-----------------------------------------------------
+ Message_Add(CSG_String::Format(
+ SG_T("\n%s: %s/%s\n"),
+ _TL("Driver"),
+ System.Get_Driver()->GetDescription(),
+ System.Get_Driver()->GetMetadataItem(GDAL_DMD_LONGNAME)
+ ), false);
+
+ Message_Add(CSG_String::Format(
+ SG_T("%s: x %d, y %d\n%s: %d\n%s x' = %.6f + x * %.6f + y * %.6f\n%s y' = %.6f + x * %.6f + y * %.6f"),
+ _TL("Cells") , System.Get_NX(), System.Get_NY(),
+ _TL("Bands") , System.Get_Count(),
+ _TL("Transformation") , A[0], B[0][0], B[0][1],
+ _TL("Transformation") , A[1], B[1][0], B[1][1]
+ ), false);
+
+ //-----------------------------------------------------
+ if( System.Get_Projection() && System.Get_Projection()[0] )
+ {
+ CSG_String s(System.Get_Projection()), t;
+
+ for(int is=0, nt=0; is<(int)s.Length(); is++)
{
- CSG_String s(System.Get_Projection());
-
- s.Replace(SG_T("[") , SG_T("\t"));
- s.Replace(SG_T("]],"), SG_T("\n"));
- s.Replace(SG_T("]]") , SG_T("\n"));
- s.Replace(SG_T("],") , SG_T("\n"));
- s.Replace(SG_T(",") , SG_T("\t"));
-
- Message_Add(CSG_String::Format(
- SG_T("\n%s:\n%s"),
- _TL("Projection"),
- s.c_str()
- ), false);
+ bool bNewLine = false, bPrevious = true;
+
+ switch( s[is] )
+ {
+ case '[': bNewLine = true; nt++; break;
+ case ',': bNewLine = true; break;
+ case ']': nt--; bPrevious = false; break;
+ }
+
+ if( bPrevious )
+ t += s[is];
+
+ if( bNewLine )
+ {
+ t += '\n';
+ for(int it=0; it<nt; it++)
+ t += '\t';
+ }
+
+ if( !bPrevious )
+ t += s[is];
}
- //-------------------------------------------------
- int i, n;
- CSG_Grid *pGrid;
+ Message_Add(CSG_String::Format(SG_T("\n%s:\n%s"), _TL("Projection"), t.c_str()), false);
+ }
+
+ //-----------------------------------------------------
+ int i, n;
+ CSG_Grid *pGrid;
- for(i=0, n=0; i<System.Get_Count(); i++)
+ for(i=0, n=0; i<System.Get_Count(); i++)
+ {
+ if( (pGrid = System.Read_Band(i)) != NULL )
{
- if( (pGrid = System.Read_Band(i)) != NULL )
+ n++;
+
+ if( System.Needs_Transform() )
{
- n++;
+ Set_Transformation(&pGrid, A, B);
+ }
- pGrid->Set_Name(System.Get_Count() > 1
- ? CSG_String::Format(SG_T("%s [%02d]"), Name.c_str(), i + 1).c_str()
- : Name.c_str()
- );
+ pGrid->Set_Name(System.Get_Count() > 1
+ ? CSG_String::Format(SG_T("%s [%02d]"), Name.c_str(), i + 1).c_str()
+ : Name.c_str()
+ );
- m_pGrids->Add_Item(pGrid);
+ pGrid->Get_Projection().Create(System.Get_Projection(), SG_PROJ_FMT_WKT);
+ m_pGrids->Add_Item(pGrid);
- DataObject_Add (pGrid);
- DataObject_Set_Colors (pGrid, CSG_Colors(100, SG_COLORS_BLACK_WHITE, false));
- }
- }
+ DataObject_Add (pGrid);
+ DataObject_Set_Colors (pGrid, CSG_Colors(100, SG_COLORS_BLACK_WHITE, false));
+ }
+ }
+
+ //-----------------------------------------------------
+ return( n > 0 );
+}
- //-------------------------------------------------
- return( n > 0 );
- }
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CGDAL_Import::Set_Transformation(CSG_Grid **ppGrid, const CSG_Vector &A, const CSG_Matrix &B)
+{
//-----------------------------------------------------
- return( false );
+ int x, y;
+ double z;
+ TSG_Rect r;
+ CSG_Vector vImage(2), vWorld(2);
+ CSG_Matrix BInv(B.Get_Inverse());
+ CSG_Grid *pImage, *pWorld;
+
+ //-----------------------------------------------------
+ pImage = *ppGrid;
+
+ //-----------------------------------------------------
+ vImage[0] = pImage->Get_XMin(); vImage[1] = pImage->Get_YMin(); vWorld = B * vImage + A;
+ r.xMin = r.xMax = vWorld[0];
+ r.yMin = r.yMax = vWorld[1];
+
+ vImage[0] = pImage->Get_XMin(); vImage[1] = pImage->Get_YMax(); vWorld = B * vImage + A;
+ if( r.xMin > vWorld[0] ) r.xMin = vWorld[0]; else if( r.xMax < vWorld[0] ) r.xMax = vWorld[0];
+ if( r.yMin > vWorld[1] ) r.yMin = vWorld[1]; else if( r.yMax < vWorld[1] ) r.yMax = vWorld[1];
+
+ vImage[0] = pImage->Get_XMax(); vImage[1] = pImage->Get_YMax(); vWorld = B * vImage + A;
+ if( r.xMin > vWorld[0] ) r.xMin = vWorld[0]; else if( r.xMax < vWorld[0] ) r.xMax = vWorld[0];
+ if( r.yMin > vWorld[1] ) r.yMin = vWorld[1]; else if( r.yMax < vWorld[1] ) r.yMax = vWorld[1];
+
+ vImage[0] = pImage->Get_XMax(); vImage[1] = pImage->Get_YMin(); vWorld = B * vImage + A;
+ if( r.xMin > vWorld[0] ) r.xMin = vWorld[0]; else if( r.xMax < vWorld[0] ) r.xMax = vWorld[0];
+ if( r.yMin > vWorld[1] ) r.yMin = vWorld[1]; else if( r.yMax < vWorld[1] ) r.yMax = vWorld[1];
+
+ z = fabs(B[0][0]) < fabs(B[1][1]) ? fabs(B[0][0]) : fabs(B[1][1]); // guess a suitable cellsize; could be improved...
+ x = 1 + (int)((r.xMax - r.xMin) / z);
+ y = 1 + (int)((r.yMax - r.yMin) / z);
+
+ //-----------------------------------------------------
+ pWorld = *ppGrid = SG_Create_Grid(pImage->Get_Type(), x, y, z, r.xMin, r.yMin);
+
+ for(y=0, vWorld[1]=pWorld->Get_YMin(); y<pWorld->Get_NY() && Set_Progress(y, pWorld->Get_NY()); y++, vWorld[1]+=pWorld->Get_Cellsize())
+ {
+ for(x=0, vWorld[0]=pWorld->Get_XMin(); x<pWorld->Get_NX(); x++, vWorld[0]+=pWorld->Get_Cellsize())
+ {
+ vImage = BInv * (vWorld - A);
+
+ if( pImage->Get_Value(vImage[0], vImage[1], z, GRID_INTERPOLATION_NearestNeighbour, false, true) )
+ {
+ pWorld->Set_Value(x, y, z);
+ }
+ else
+ {
+ pWorld->Set_NoData(x, y);
+ }
+ }
+ }
+
+ delete(pImage);
}
diff --git a/src/modules_io/gdal/io_gdal/gdal_import.h b/src/modules_io/gdal/io_gdal/gdal_import.h
index b2faa41..0bbc714 100644
--- a/src/modules_io/gdal/io_gdal/gdal_import.h
+++ b/src/modules_io/gdal/io_gdal/gdal_import.h
@@ -76,7 +76,7 @@ public:
protected:
- virtual bool On_Execute (void);
+ virtual bool On_Execute (void);
private:
@@ -84,8 +84,10 @@ private:
CSG_Parameter_Grid_List *m_pGrids;
- bool Load_Sub (CGDAL_System &System, const CSG_String &Name);
- bool Load (CGDAL_System &System, const CSG_String &Name);
+ bool Load_Sub (CGDAL_System &System, const CSG_String &Name);
+ bool Load (CGDAL_System &System, const CSG_String &Name);
+
+ void Set_Transformation (CSG_Grid **ppGrid, const CSG_Vector &A, const CSG_Matrix &B);
};
diff --git a/src/modules_io/gdal/io_gdal/ogr_import.cpp b/src/modules_io/gdal/io_gdal/ogr_import.cpp
index f1b2051..ef79084 100644
--- a/src/modules_io/gdal/io_gdal/ogr_import.cpp
+++ b/src/modules_io/gdal/io_gdal/ogr_import.cpp
@@ -106,8 +106,9 @@ COGR_Import::COGR_Import(void)
);
Parameters.Add_FilePath(
- NULL, "FILE" , _TL("File"),
- _TL("")
+ NULL, "FILES" , _TL("Files"),
+ _TL(""),
+ NULL, NULL, false, false, true
);
}
@@ -116,7 +117,6 @@ COGR_Import::~COGR_Import(void)
{}
-
///////////////////////////////////////////////////////////
// //
// //
@@ -126,33 +126,41 @@ COGR_Import::~COGR_Import(void)
//---------------------------------------------------------
bool COGR_Import::On_Execute(void)
{
+ CSG_Strings Files;
COGR_DataSource ds;
//-----------------------------------------------------
- if( !ds.Create(Parameters("FILE")->asString()) )
- {
- Message_Add(_TL("could not open data source"));
-
- return( false );
- }
-
- if( ds.Get_Count() <= 0 )
+ if( !Parameters("FILES")->asFilePath()->Get_FilePaths(Files) )
{
- Message_Add(_TL("no layers in data source"));
-
return( false );
}
//-----------------------------------------------------
Parameters("SHAPES")->asShapesList()->Del_Items();
- for(int iLayer=0; iLayer<ds.Get_Count(); iLayer++)
+ for(int i=0; i<Files.Get_Count(); i++)
{
- CSG_Shapes *pShapes = ds.Read_Shapes(iLayer);
+ Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("loading"), Files[i].c_str()));
- if( pShapes )
+ if( !ds.Create(Files[i]) )
+ {
+ Message_Add(_TL("could not open data source"));
+ }
+ else if( ds.Get_Count() <= 0 )
+ {
+ Message_Add(_TL("no layers in data source"));
+ }
+ else
{
- Parameters("SHAPES")->asShapesList()->Add_Item(pShapes);
+ for(int iLayer=0; iLayer<ds.Get_Count(); iLayer++)
+ {
+ CSG_Shapes *pShapes = ds.Read_Shapes(iLayer);
+
+ if( pShapes )
+ {
+ Parameters("SHAPES")->asShapesList()->Add_Item(pShapes);
+ }
+ }
}
}
diff --git a/src/modules_io/gps/Makefile.in b/src/modules_io/gps/Makefile.in
index a873873..03fd7fe 100644
--- a/src/modules_io/gps/Makefile.in
+++ b/src/modules_io/gps/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_io/gps/io_gps/Makefile.am b/src/modules_io/gps/io_gps/Makefile.am
index ead5905..cb847e3 100644
--- a/src/modules_io/gps/io_gps/Makefile.am
+++ b/src/modules_io/gps/io_gps/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:25 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:51 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libio_gps.la
libio_gps_la_SOURCES =\
GPSBabel.cpp\
diff --git a/src/modules_io/gps/io_gps/Makefile.in b/src/modules_io/gps/io_gps/Makefile.in
index 70a5480..365f228 100644
--- a/src/modules_io/gps/io_gps/Makefile.in
+++ b/src/modules_io/gps/io_gps/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -71,7 +70,7 @@ libio_gps_la_DEPENDENCIES = \
$(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
am_libio_gps_la_OBJECTS = GPSBabel.lo gpx2shp.lo MLB_Interface.lo
libio_gps_la_OBJECTS = $(am_libio_gps_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -117,6 +116,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -126,6 +126,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -216,14 +217,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:25 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:51 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libio_gps.la
libio_gps_la_SOURCES = \
GPSBabel.cpp\
diff --git a/src/modules_io/grid/Makefile.in b/src/modules_io/grid/Makefile.in
index 0338d89..8949dd3 100644
--- a/src/modules_io/grid/Makefile.in
+++ b/src/modules_io/grid/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_io/grid/io_grid/Makefile.am b/src/modules_io/grid/io_grid/Makefile.am
index 5ee551e..f9271df 100644
--- a/src/modules_io/grid/io_grid/Makefile.am
+++ b/src/modules_io/grid/io_grid/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.6 2007/02/13 12:49:25 tschorr Exp $
+# $Id: Makefile.am,v 1.7 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libio_grid.la
libio_grid_la_SOURCES =\
bmp_export.cpp\
diff --git a/src/modules_io/grid/io_grid/Makefile.in b/src/modules_io/grid/io_grid/Makefile.in
index 75de222..c91f3e5 100644
--- a/src/modules_io/grid/io_grid/Makefile.in
+++ b/src/modules_io/grid/io_grid/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,7 +72,7 @@ am_libio_grid_la_OBJECTS = bmp_export.lo erdas_lan.lo esri_arcinfo.lo \
grid_table.lo MLB_Interface.lo mola.lo raw.lo srtm30.lo \
surfer.lo usgs_srtm.lo xyz.lo
libio_grid_la_OBJECTS = $(am_libio_grid_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +128,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,14 +219,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.6 2007/02/13 12:49:25 tschorr Exp $
+# $Id: Makefile.am,v 1.7 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libio_grid.la
libio_grid_la_SOURCES = \
bmp_export.cpp\
diff --git a/src/modules_io/grid/io_grid/esri_arcinfo.cpp b/src/modules_io/grid/io_grid/esri_arcinfo.cpp
index f414e04..2c9ca02 100644
--- a/src/modules_io/grid/io_grid/esri_arcinfo.cpp
+++ b/src/modules_io/grid/io_grid/esri_arcinfo.cpp
@@ -1,616 +1,617 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// Grid_IO //
-// //
-//-------------------------------------------------------//
-// //
-// ESRI_ArcInfo.cpp //
-// //
-// Copyright (C) 2007 by //
-// Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "esri_arcinfo.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#define HDR_NROWS "NROWS"
-#define HDR_NCOLS "NCOLS"
-#define HDR_X_CORNER "XLLCORNER"
-#define HDR_Y_CORNER "YLLCORNER"
-#define HDR_X_CENTER "XLLCENTER"
-#define HDR_Y_CENTER "YLLCENTER"
-#define HDR_CELLSIZE "CELLSIZE"
-#define HDR_NODATA "NODATA_VALUE"
-#define HDR_BYTEORDER "BYTE_ORDER"
-#define HDR_BYTEORDER_HI "MSB_FIRST"
-#define HDR_BYTEORDER_LO "LSB_FIRST"
-
-
-///////////////////////////////////////////////////////////
-// //
-// Import //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CESRI_ArcInfo_Import::CESRI_ArcInfo_Import(void)
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_IO //
+// //
+//-------------------------------------------------------//
+// //
+// ESRI_ArcInfo.cpp //
+// //
+// Copyright (C) 2007 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "esri_arcinfo.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define HDR_NROWS SG_T("NROWS")
+#define HDR_NCOLS SG_T("NCOLS")
+#define HDR_X_CORNER SG_T("XLLCORNER")
+#define HDR_Y_CORNER SG_T("YLLCORNER")
+#define HDR_X_CENTER SG_T("XLLCENTER")
+#define HDR_Y_CENTER SG_T("YLLCENTER")
+#define HDR_CELLSIZE SG_T("CELLSIZE")
+#define HDR_NODATA SG_T("NODATA_VALUE")
+#define HDR_BYTEORDER SG_T("BYTE_ORDER")
+#define HDR_BYTEORDER_HI SG_T("MSB_FIRST")
+#define HDR_BYTEORDER_LO SG_T("LSB_FIRST")
+
+
+///////////////////////////////////////////////////////////
+// //
+// Import //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CESRI_ArcInfo_Import::CESRI_ArcInfo_Import(void)
+{
+ //-----------------------------------------------------
+ // 1. Info...
+
+ Set_Name (_TL("Import ESRI Arc/Info Grid"));
+
+ Set_Author (SG_T("O.Conrad (c) 2007"));
+
+ Set_Description (_TW(
+ "Import grid from ESRI's Arc/Info grid format.")
+ );
+
+
+ //-----------------------------------------------------
+ // 2. Parameters...
+
+ Parameters.Add_Grid_Output(
+ NULL , "GRID" , _TL("Grid"),
+ _TL("")
+ );
+
+ Parameters.Add_FilePath(
+ NULL , "FILE" , _TL("File"),
+ _TL(""),
+
+ CSG_String::Format(
+ SG_T("%s|*.asc;*.flt|%s|*.asc|%s|*.flt|%s|*.*"),
+ _TL("ESRI Arc/Info Grids"),
+ _TL("ESRI Arc/Info ASCII Grids (*.asc)"),
+ _TL("ESRI Arc/Info Binary Grids (*.flt)"),
+ _TL("All Files")
+ )
+ );
+}
+
+//---------------------------------------------------------
+bool CESRI_ArcInfo_Import::On_Execute(void)
+{
+ CSG_File Stream;
+ CSG_String fName;
+ CSG_Grid *pGrid;
+
+ //-----------------------------------------------------
+ pGrid = NULL;
+ fName = Parameters("FILE")->asString();
+
+ //-------------------------------------------------
+ // Binary...
+
+ if( Stream.Open(SG_File_Make_Path(SG_T(""), fName, SG_T("hdr")), SG_FILE_R, false) && (pGrid = Read_Header(Stream)) != NULL )
+ {
+ if( Stream.Open(SG_File_Make_Path(SG_T(""), fName, SG_T("flt")), SG_FILE_R, true) )
+ {
+ float *Line = (float *)SG_Malloc(pGrid->Get_NX() * sizeof(float));
+
+ for(int iy=0, y=pGrid->Get_NY()-1; iy<pGrid->Get_NY() && !Stream.is_EOF() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--)
+ {
+ Stream.Read(Line, sizeof(float), pGrid->Get_NX());
+
+ for(int x=0; x<pGrid->Get_NX(); x++)
+ {
+ pGrid->Set_Value(x, y, Line[x]);
+ }
+ }
+
+ SG_Free(Line);
+ }
+ else
+ {
+ delete(pGrid);
+
+ return( false );
+ }
+ }
+
+ //-------------------------------------------------
+ // ASCII...
+
+ else if( Stream.Open(fName, SG_FILE_R, false) && (pGrid = Read_Header(Stream)) != NULL )
+ {
+ for(int iy=0, y=pGrid->Get_NY()-1; iy<pGrid->Get_NY() && !Stream.is_EOF() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--)
+ {
+ for(int x=0; x<pGrid->Get_NX(); x++)
+ {
+ pGrid->Set_Value(x, y, Read_Value(Stream));
+ }
+ }
+ }
+
+ //-------------------------------------------------
+ else
+ {
+ return( false );
+ }
+
+ pGrid->Set_Name(SG_File_Get_Name(fName, false));
+
+ Parameters("GRID")->Set_Value(pGrid);
+
+ return( true );
+}
+
+//---------------------------------------------------------
+inline bool SG_is_Numeric(int Character)
+{
+ switch( Character )
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ case '-':
+ case '+':
+ case '.':
+ case ',':
+ case 'e':
+ case 'E':
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+double CESRI_ArcInfo_Import::Read_Value(CSG_File &Stream)
+{
+ int c;
+ CSG_String s;
+
+ while( !Stream.is_EOF() && !SG_is_Numeric(c = Stream.Get_Character()) ); // ignore leading white space...
+
+ if( !Stream.is_EOF() && SG_is_Numeric(c) )
+ {
+ do
+ {
+ if( c == ',' )
+ {
+ c = '.';
+ }
+
+ s += c;
+ }
+ while( !Stream.is_EOF() && SG_is_Numeric(c = Stream.Get_Character()) );
+ }
+
+ return( s.asDouble() );
+}
+
+//---------------------------------------------------------
+bool CESRI_ArcInfo_Import::Read_Header_Line(CSG_File &Stream, CSG_String &sLine)
+{
+ int c;
+
+ sLine.Clear();
+
+ while( !Stream.is_EOF() && (c = Stream.Get_Character()) != 0x0A )
+ {
+ if( c != 0x0D )
+ {
+ sLine += c;
+ }
+ }
+
+ sLine.Make_Upper();
+ sLine.Replace(SG_T(","), SG_T("."));
+
+ return( sLine.Length() > 0 );
+}
+
+//---------------------------------------------------------
+bool CESRI_ArcInfo_Import::Read_Header_Value(const CSG_String &sKey, CSG_String &sLine, int &Value)
+{
+ sLine.Make_Upper();
+
+ if( sLine.Contains(sKey) )
+ {
+ CSG_String sValue(sLine.c_str() + sKey.Length());
+
+ return( sValue.asInt(Value) );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CESRI_ArcInfo_Import::Read_Header_Value(const CSG_String &sKey, CSG_String &sLine, double &Value)
+{
+ sLine.Make_Upper();
+
+ if( sLine.Contains(sKey) )
+ {
+ CSG_String sValue(sLine.c_str() + sKey.Length());
+
+ return( sValue.asDouble(Value) );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+CSG_Grid * CESRI_ArcInfo_Import::Read_Header(CSG_File &Stream)
+{
+ bool bCorner_X, bCorner_Y;
+ int NX, NY;
+ double CellSize, xMin, yMin, NoData = -9999.0;
+ CSG_String sLine;
+ CSG_Grid *pGrid;
+
+ //-----------------------------------------------------
+ if( !Stream.is_EOF() )
+ {
+ //-------------------------------------------------
+ Read_Header_Line(Stream, sLine);
+
+ if( !Read_Header_Value(HDR_NCOLS , sLine, NX) )
+ return( NULL );
+
+ //-------------------------------------------------
+ Read_Header_Line(Stream, sLine);
+
+ if( !Read_Header_Value(HDR_NROWS , sLine, NY) )
+ return( NULL );
+
+ //-------------------------------------------------
+ Read_Header_Line(Stream, sLine);
+
+ if( Read_Header_Value(HDR_X_CORNER, sLine, xMin) )
+ bCorner_X = true;
+ else if( Read_Header_Value(HDR_X_CENTER, sLine, xMin) )
+ bCorner_X = false;
+ else
+ return( NULL );
+
+ //-------------------------------------------------
+ Read_Header_Line(Stream, sLine);
+
+ if( Read_Header_Value(HDR_Y_CORNER, sLine, yMin) )
+ bCorner_Y = true;
+ else if( Read_Header_Value(HDR_Y_CENTER, sLine, yMin) )
+ bCorner_Y = false;
+ else
+ return( NULL );
+
+ //-------------------------------------------------
+ Read_Header_Line(Stream, sLine);
+
+ if( !Read_Header_Value(HDR_CELLSIZE, sLine, CellSize) )
+ return( NULL );
+
+ //-------------------------------------------------
+ Read_Header_Line(Stream, sLine);
+
+ if( !Read_Header_Value(HDR_NODATA , sLine, NoData) )
+ // return( NULL );
+ {}
+
+ //-------------------------------------------------
+ if( bCorner_X )
+ xMin += CellSize / 2.0;
+
+ if( bCorner_Y )
+ yMin += CellSize / 2.0;
+
+ //-------------------------------------------------
+ if( (pGrid = SG_Create_Grid(SG_DATATYPE_Float, NX, NY, CellSize, xMin, yMin)) != NULL )
+ {
+ pGrid->Set_NoData_Value(NoData);
+
+ return( pGrid );
+ }
+ }
+
+ return( NULL );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Export //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CESRI_ArcInfo_Export::CESRI_ArcInfo_Export(void)
+{
+ //-----------------------------------------------------
+ // 1. Info...
+
+ Set_Name (_TL("Export ESRI Arc/Info Grid"));
+
+ Set_Author (SG_T("O.Conrad (c) 2007"));
+
+ Set_Description (_TW(
+ "Export grid to ESRI's Arc/Info grid format.")
+ );
+
+
+ //-----------------------------------------------------
+ // 2. Parameters...
+
+ Parameters.Add_Grid(
+ NULL , "GRID" , _TL("Grid"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_FilePath(
+ NULL , "FILE" , _TL("File"),
+ _TL(""),
+
+ CSG_String::Format(
+ SG_T("%s|*.asc;*.flt|%s|*.asc|%s|*.flt|%s|*.*"),
+ _TL("ESRI Arc/Info Grids"),
+ _TL("ESRI Arc/Info ASCII Grids (*.asc)"),
+ _TL("ESRI Arc/Info Binary Grids (*.flt)"),
+ _TL("All Files")
+ ), NULL, true
+ );
+
+ Parameters.Add_Choice(
+ NULL , "FORMAT" , _TL("Format"),
+ _TL(""),
+
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("binary"),
+ _TL("ASCII")
+ ), 1
+ );
+
+ Parameters.Add_Choice(
+ NULL , "GEOREF" , _TL("Geo-Reference"),
+ _TL("The grids geo-reference must be related either to the center or the corner of its lower left grid cell."),
+
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("corner"),
+ _TL("center")
+ ), 0
+ );
+
+ Parameters.Add_Value(
+ NULL , "PREC" , _TL("ASCII Precision"),
+ _TL("Number of decimals when writing floating point values in ASCII format."),
+ PARAMETER_TYPE_Int , 4, -1, true
+ );
+
+ Parameters.Add_Choice(
+ NULL , "DECSEP" , _TL("ASCII Decimal Separator"),
+ _TL("Applies also to the binary format header file."),
+
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("point (.)"),
+ _TL("comma (,)")
+ ), 0
+ );
+
+// Parameters.Add_Choice(
+// NULL , "BYTEORD" , _TL("Binary Byte Order"),
+// _TL("Byte order when writing floating point values in binary format"),
+//
+// CSG_String::Format(SG_T("%s|%s|"),
+// _TL("most significant first"),
+// _TL("least significant first")
+// ), 0
+// );
+}
+
+//---------------------------------------------------------
+bool CESRI_ArcInfo_Export::On_Execute(void)
+{
+ bool bResult, bSwapBytes, bComma;
+ int x, y, iy, Precision;
+ CSG_File Stream;
+ CSG_Grid *pGrid;
+ CSG_String fName;
+
+ //-----------------------------------------------------
+ bResult = false;
+
+ pGrid = Parameters("GRID") ->asGrid();
+ fName = Parameters("FILE") ->asString();
+ Precision = Parameters("PREC") ->asInt();
+ bComma = Parameters("DECSEP") ->asInt() == 1;
+ bSwapBytes = false; // bSwapBytes = Parameters("BYTEORD") ->asInt() == 1;
+
+
+ //-----------------------------------------------------
+ // Binary...
+
+ if( Parameters("FORMAT")->asInt() == 0 )
+ {
+ if( Stream.Open(SG_File_Make_Path(SG_T(""), fName, SG_T("hdr")), SG_FILE_W, false)
+ && Write_Header(Stream, pGrid, bComma)
+ && Stream.Open(SG_File_Make_Path(SG_T(""), fName, SG_T("flt")), SG_FILE_W, true) )
+ {
+ float *Line = (float *)SG_Malloc(pGrid->Get_NX() * sizeof(float));
+
+ for(int iy=0, y=pGrid->Get_NY()-1; iy<pGrid->Get_NY() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--)
+ {
+ for(int x=0; x<pGrid->Get_NX(); x++)
+ {
+ Line[x] = pGrid->asFloat(x, y);
+
+ if( bSwapBytes )
+ {
+ SG_Swap_Bytes(Line + x, sizeof(float));
+ }
+ }
+
+ Stream.Write(Line, sizeof(float), pGrid->Get_NX());
+ }
+
+ SG_Free(Line);
+
+ return( true );
+ }
+ }
+
+
+ //-----------------------------------------------------
+ // ASCII...
+
+ else if( Stream.Open(fName, SG_FILE_W, false) && Write_Header(Stream, pGrid, bComma) )
+ {
+ for(iy=0, y=pGrid->Get_NY()-1; iy<pGrid->Get_NY() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--)
+ {
+ for(x=0; x<pGrid->Get_NX(); x++)
+ {
+ if( x > 0 )
+ {
+ fprintf(Stream.Get_Stream(), " ");
+ }
+
+ fprintf(Stream.Get_Stream(), Write_Value(pGrid->asFloat(x, y), Precision, bComma).b_str());
+ }
+
+ fprintf(Stream.Get_Stream(), "\n");
+ }
+
+ return( true );
+ }
+
+ //-----------------------------------------------------
+ return( false );
+}
+
+//---------------------------------------------------------
+inline CSG_String CESRI_ArcInfo_Export::Write_Value(double Value, int Precision, bool bComma)
{
- //-----------------------------------------------------
- // 1. Info...
-
- Set_Name (_TL("Import ESRI Arc/Info Grid"));
-
- Set_Author (SG_T("(c) 2007 by O.Conrad"));
-
- Set_Description (_TW(
- "Import grid from ESRI's Arc/Info grid format.")
- );
-
-
- //-----------------------------------------------------
- // 2. Parameters...
-
- Parameters.Add_Grid_Output(
- NULL , "GRID" , _TL("Grid"),
- _TL("")
- );
-
- Parameters.Add_FilePath(
- NULL , "FILE" , _TL("File"),
- _TL(""),
-
- CSG_String::Format(
- SG_T("%s|*.asc;*.flt|%s|*.asc|%s|*.flt|%s|*.*"),
- _TL("ESRI Arc/Info Grids"),
- _TL("ESRI Arc/Info ASCII Grids (*.asc)"),
- _TL("ESRI Arc/Info Binary Grids (*.flt)"),
- _TL("All Files")
- )
- );
+ CSG_String s;
+
+ if( Precision < 0 )
+ {
+ s.Printf(SG_T("%f") , Value);
+ }
+ else if( Precision > 0 )
+ {
+ s.Printf(SG_T("%.*f"), Precision, Value);
+ }
+ else
+ {
+ s.Printf(SG_T("%d") , (int)(Value > 0.0 ? Value + 0.5 : Value - 0.5));
+ }
+
+ if( bComma )
+ {
+ s.Replace(SG_T("."), SG_T(","));
+ }
+ else
+ {
+ s.Replace(SG_T(","), SG_T("."));
+ }
+
+ return( s );
}
-
-//---------------------------------------------------------
-CESRI_ArcInfo_Import::~CESRI_ArcInfo_Import(void)
-{}
-
-//---------------------------------------------------------
-bool CESRI_ArcInfo_Import::On_Execute(void)
-{
- bool bResult;
- int x, y, iy;
- float Value, *Line;
- FILE *Stream;
- CSG_String fName;
- CSG_Grid *pGrid;
-
- //-----------------------------------------------------
- bResult = false;
- pGrid = NULL;
-
- if( Parameters("FILE")->asString() )
- {
- //-------------------------------------------------
- // Binary...
-
- if( SG_File_Cmp_Extension(Parameters("FILE")->asString(), SG_T("flt"))
- || SG_File_Cmp_Extension(Parameters("FILE")->asString(), SG_T("hdr")) )
- {
- fName = SG_File_Make_Path(SG_T(""), Parameters("FILE")->asString(), SG_T("hdr"));
-
- if( (Stream = fopen(fName.b_str(), "r")) != NULL && (pGrid = Read_Header(Stream)) != NULL )
- {
- fclose(Stream);
-
- fName = SG_File_Make_Path(SG_T(""), Parameters("FILE")->asString(), SG_T("flt"));
-
- if( (Stream = fopen(fName.b_str(), "rb")) != NULL )
- {
- Line = (float *)SG_Malloc(pGrid->Get_NX() * sizeof(float));
-
- for(iy=0, y=pGrid->Get_NY()-1; iy<pGrid->Get_NY() && !feof(Stream) && Set_Progress(iy, pGrid->Get_NY()); iy++, y--)
- {
- fread(Line, pGrid->Get_NX(), sizeof(float), Stream);
-
- for(x=0; x<pGrid->Get_NX(); x++)
- {
- pGrid->Set_Value(x, y, Line[x]);
- }
- }
-
- SG_Free(Line);
-
- fclose(Stream);
- }
- }
- }
-
-
- //-------------------------------------------------
- // ASCII...
-
- else
- {
- fName = Parameters("FILE")->asString();
-
- if( (Stream = fopen(fName.b_str(), "r")) != NULL )
- {
- if( (pGrid = Read_Header(Stream)) != NULL )
- {
- for(iy=0, y=pGrid->Get_NY()-1; iy<pGrid->Get_NY() && !feof(Stream) && Set_Progress(iy, pGrid->Get_NY()); iy++, y--)
- {
- for(x=0; x<pGrid->Get_NX(); x++)
- {
- fscanf(Stream, "%f", &Value);
-
- pGrid->Set_Value(x, y, Value);
- }
- }
- }
-
- fclose(Stream);
- }
- }
-
- //-------------------------------------------------
- if( pGrid )
- {
- pGrid->Set_Name(SG_File_Get_Name(Parameters("FILE")->asString(), false));
-
- Parameters("GRID")->Set_Value(pGrid);
-
- bResult = true;
- }
- }
-
- return( bResult );
-}
-
-//---------------------------------------------------------
-bool CESRI_ArcInfo_Import::Read_Line(FILE *Stream, CSG_String &sLine)
-{
- if( Stream && !feof(Stream) )
- {
- char c;
-
- sLine.Clear();
-
- while( !feof(Stream) && (c = getc(Stream)) != 0x0A && c != 0x0D )
- {
- sLine.Append(c);
- }
-
- sLine.Make_Upper();
-
- sLine.Replace(SG_T(","), SG_T("."));
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CESRI_ArcInfo_Import::Read_Value(const CSG_String &sKey, CSG_String &sLine, int &Value)
-{
- sLine.Make_Upper();
-
- if( sLine.Contains(sKey) )
- {
- CSG_String sValue(sLine.c_str() + sKey.Length());
-
- return( sValue.asInt(Value) );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CESRI_ArcInfo_Import::Read_Value(const CSG_String &sKey, CSG_String &sLine, double &Value)
-{
- sLine.Make_Upper();
-
- if( sLine.Contains(sKey) )
- {
- CSG_String sValue(sLine.c_str() + sKey.Length());
-
- return( sValue.asDouble(Value) );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-CSG_Grid * CESRI_ArcInfo_Import::Read_Header(FILE *Stream)
-{
- bool bCorner_X, bCorner_Y;
- int NX, NY;
- double CellSize, xMin, yMin, NoData = -9999.0;
- CSG_String sLine;
- CSG_Grid *pGrid;
-
- //-----------------------------------------------------
- if( Stream )
- {
- //-------------------------------------------------
- Read_Line(Stream, sLine);
-
- if( !Read_Value(HDR_NCOLS , sLine, NX) )
- return( NULL );
-
- //-------------------------------------------------
- Read_Line(Stream, sLine);
-
- if( !Read_Value(HDR_NROWS , sLine, NY) )
- return( NULL );
-
- //-------------------------------------------------
- Read_Line(Stream, sLine);
-
- if( Read_Value(HDR_X_CORNER, sLine, xMin) )
- bCorner_X = true;
- else if( Read_Value(HDR_X_CENTER, sLine, xMin) )
- bCorner_X = false;
- else
- return( NULL );
-
- //-------------------------------------------------
- Read_Line(Stream, sLine);
-
- if( Read_Value(HDR_Y_CORNER, sLine, yMin) )
- bCorner_Y = true;
- else if( Read_Value(HDR_Y_CENTER, sLine, yMin) )
- bCorner_Y = false;
- else
- return( NULL );
-
- //-------------------------------------------------
- Read_Line(Stream, sLine);
-
- if( !Read_Value(HDR_CELLSIZE, sLine, CellSize) )
- return( NULL );
-
- //-------------------------------------------------
- Read_Line(Stream, sLine);
-
- if( !Read_Value(HDR_NODATA , sLine, NoData) )
- // return( NULL );
- {}
-
- //-------------------------------------------------
- if( bCorner_X )
- xMin += CellSize / 2.0;
-
- if( bCorner_Y )
- yMin += CellSize / 2.0;
-
- //-------------------------------------------------
- if( (pGrid = SG_Create_Grid(SG_DATATYPE_Float, NX, NY, CellSize, xMin, yMin)) != NULL )
- {
- pGrid->Set_NoData_Value(NoData);
-
- return( pGrid );
- }
- }
-
- return( NULL );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// Export //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CESRI_ArcInfo_Export::CESRI_ArcInfo_Export(void)
-{
- //-----------------------------------------------------
- // 1. Info...
-
- Set_Name (_TL("Export ESRI Arc/Info Grid"));
-
- Set_Author (SG_T("(c) 2001 by O.Conrad"));
-
- Set_Description (_TW(
- "Export grid to ESRI's Arc/Info grid format.")
- );
-
-
- //-----------------------------------------------------
- // 2. Parameters...
-
- Parameters.Add_Grid(
- NULL , "GRID" , _TL("Grid"),
- _TL(""),
- PARAMETER_INPUT
- );
-
- Parameters.Add_FilePath(
- NULL , "FILE" , _TL("File"),
- _TL(""),
-
- CSG_String::Format(
- SG_T("%s|*.asc;*.flt|%s|*.asc|%s|*.flt|%s|*.*"),
- _TL("ESRI Arc/Info Grids"),
- _TL("ESRI Arc/Info ASCII Grids (*.asc)"),
- _TL("ESRI Arc/Info Binary Grids (*.flt)"),
- _TL("All Files")
- ), NULL, true
- );
-
- Parameters.Add_Choice(
- NULL , "FORMAT" , _TL("Format"),
- _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|"),
- _TL("binary"),
- _TL("ASCII")
- ), 1
- );
-
- Parameters.Add_Choice(
- NULL , "GEOREF" , _TL("Geo-Reference"),
- _TL("The grids geo-reference must be related either to the center or the corner of its lower left grid cell."),
-
- CSG_String::Format(SG_T("%s|%s|"),
- _TL("corner"),
- _TL("center")
- ), 0
- );
-
- Parameters.Add_Value(
- NULL , "PREC" , _TL("ASCII Precision"),
- _TL("Number of decimals when writing floating point values in ASCII format."),
- PARAMETER_TYPE_Int , 4, -1, true
- );
-
- Parameters.Add_Choice(
- NULL , "DECSEP" , _TL("ASCII Decimal Separator"),
- _TL("Applies also to the binary format header file."),
-
- CSG_String::Format(SG_T("%s|%s|"),
- _TL("point (.)"),
- _TL("comma (,)")
- ), 0
- );
-
-// Parameters.Add_Choice(
-// NULL , "BYTEORD" , _TL("Binary Byte Order"),
-// _TL("Byte order when writing floating point values in binary format"),
-//
-// CSG_String::Format(SG_T("%s|%s|"),
-// _TL("most significant first"),
-// _TL("least significant first")
-// ), 0
-// );
-}
-
-//---------------------------------------------------------
-CESRI_ArcInfo_Export::~CESRI_ArcInfo_Export(void)
-{}
-
-//---------------------------------------------------------
-bool CESRI_ArcInfo_Export::On_Execute(void)
-{
- bool bResult, bSwapBytes, bComma;
- int x, y, iy, Precision;
- float *Line;
- FILE *Stream;
- CSG_Grid *pGrid;
- CSG_String fName;
-
- //-----------------------------------------------------
- bResult = false;
-
- pGrid = Parameters("GRID") ->asGrid();
- Precision = Parameters("PREC") ->asInt();
- bComma = Parameters("DECSEP") ->asInt() == 1;
- bSwapBytes = false; // bSwapBytes = Parameters("BYTEORD") ->asInt() == 1;
-
-
- //-----------------------------------------------------
- // Binary...
-
- if( Parameters("FORMAT")->asInt() == 0 )
- {
- fName = SG_File_Make_Path(SG_T(""), Parameters("FILE")->asString(), SG_T("hdr"));
-
- if( (Stream = fopen(fName.b_str(), "w")) != NULL )
- {
- if( Write_Header(Stream, pGrid, bComma) )
- {
- fclose(Stream);
-
- fName = SG_File_Make_Path(SG_T(""), Parameters("FILE")->asString(), SG_T("flt"));
-
- if( (Stream = fopen(fName.b_str(), "wb")) != NULL )
- {
- Line = (float *)SG_Malloc(pGrid->Get_NX() * sizeof(float));
-
- for(iy=0, y=pGrid->Get_NY()-1; iy<pGrid->Get_NY() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--)
- {
- for(x=0; x<pGrid->Get_NX(); x++)
- {
- Line[x] = pGrid->asFloat(x, y);
-
- if( bSwapBytes )
- {
- SG_Swap_Bytes(Line + x, sizeof(float));
- }
- }
-
- fwrite(Line, pGrid->Get_NX(), sizeof(float), Stream);
- }
-
- SG_Free(Line);
-
- fclose(Stream);
-
- bResult = true;
- }
- }
- else
- {
- fclose(Stream);
- }
- }
- }
-
-
- //-----------------------------------------------------
- // ASCII...
-
- else
- {
- fName = Parameters("FILE")->asString();
-
- if( (Stream = fopen(fName.b_str(), "w")) != NULL )
- {
- if( Write_Header(Stream, pGrid, bComma) )
- {
- CSG_String s;
-
- for(iy=0, y=pGrid->Get_NY()-1; iy<pGrid->Get_NY() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--)
- {
- for(x=0; x<pGrid->Get_NX(); x++)
- {
- if( Precision < 0 )
- {
- s.Printf(SG_T("%f") , pGrid->asFloat(x, y));
- }
- else if( Precision == 0 )
- {
- s.Printf(SG_T("%d") , (int)(0.5 + pGrid->asFloat(x, y)));
- }
- else
- {
- s.Printf(SG_T("%.*f") , Precision, pGrid->asFloat(x, y));
- }
-
- if( bComma )
- s.Replace(SG_T("."), SG_T(","));
- else
- s.Replace(SG_T(","), SG_T("."));
-
- fprintf(Stream, "%s ", s.b_str());
- }
-
- fprintf(Stream, "\n");
- }
-
- bResult = true;
- }
-
- fclose(Stream);
- }
- }
-
- return( bResult );
-}
-
-//---------------------------------------------------------
-bool CESRI_ArcInfo_Export::Write_Header(FILE *Stream, CSG_Grid *pGrid, bool bComma)
-{
- if( Stream && pGrid && pGrid->is_Valid() )
- {
- CSG_String s;
-
- s += CSG_String::Format(SG_T("%s %d\n") , HDR_NCOLS , pGrid->Get_NX());
- s += CSG_String::Format(SG_T("%s %d\n") , HDR_NROWS , pGrid->Get_NY());
-
- if( Parameters("GEOREF")->asInt() == 0 )
- {
- s += CSG_String::Format(SG_T("%s %f\n") , HDR_X_CORNER , pGrid->Get_XMin() - 0.5 * pGrid->Get_Cellsize());
- s += CSG_String::Format(SG_T("%s %f\n") , HDR_Y_CORNER , pGrid->Get_YMin() - 0.5 * pGrid->Get_Cellsize());
- }
- else
- {
- s += CSG_String::Format(SG_T("%s %f\n") , HDR_X_CENTER , pGrid->Get_XMin());
- s += CSG_String::Format(SG_T("%s %f\n") , HDR_Y_CENTER , pGrid->Get_YMin());
- }
-
- s += CSG_String::Format(SG_T("%s %f\n") , HDR_CELLSIZE , (float)pGrid->Get_Cellsize());
- s += CSG_String::Format(SG_T("%s %f\n") , HDR_NODATA , (float)pGrid->Get_NoData_Value());
-
- if( Parameters("FORMAT")->asInt() == 0 ) // binary
- { if( Parameters("BYTEORD") )
- s += CSG_String::Format(SG_T("%s %s\n") , HDR_BYTEORDER , Parameters("BYTEORD")->asInt() == 1 ? HDR_BYTEORDER_LO : HDR_BYTEORDER_HI);
- }
-
- if( bComma )
- s.Replace(SG_T("."), SG_T(","));
- else
- s.Replace(SG_T(","), SG_T("."));
-
- fprintf(Stream, s.b_str());
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+//---------------------------------------------------------
+bool CESRI_ArcInfo_Export::Write_Header(CSG_File &Stream, CSG_Grid *pGrid, bool bComma)
+{
+ if( Stream.is_Open() && pGrid && pGrid->is_Valid() )
+ {
+ CSG_String s;
+
+ s += CSG_String::Format(SG_T("%s %d\n") , HDR_NCOLS , pGrid->Get_NX());
+ s += CSG_String::Format(SG_T("%s %d\n") , HDR_NROWS , pGrid->Get_NY());
+
+ if( Parameters("GEOREF")->asInt() == 0 )
+ {
+ s += CSG_String::Format(SG_T("%s %s\n") , HDR_X_CORNER , Write_Value(pGrid->Get_XMin() - 0.5 * pGrid->Get_Cellsize(), 10, bComma).c_str());
+ s += CSG_String::Format(SG_T("%s %s\n") , HDR_Y_CORNER , Write_Value(pGrid->Get_YMin() - 0.5 * pGrid->Get_Cellsize(), 10, bComma).c_str());
+ }
+ else
+ {
+ s += CSG_String::Format(SG_T("%s %s\n") , HDR_X_CENTER , Write_Value(pGrid->Get_XMin(), 10, bComma).c_str());
+ s += CSG_String::Format(SG_T("%s %s\n") , HDR_Y_CENTER , Write_Value(pGrid->Get_YMin(), 10, bComma).c_str());
+ }
+
+ s += CSG_String::Format(SG_T("%s %s\n") , HDR_CELLSIZE , Write_Value(pGrid->Get_Cellsize(), -1, bComma).c_str());
+ s += CSG_String::Format(SG_T("%s %s\n") , HDR_NODATA , Write_Value(pGrid->Get_NoData_Value(), Parameters("PREC")->asInt(), bComma).c_str());
+
+ if( Parameters("FORMAT")->asInt() == 0 ) // binary
+ { if( Parameters("BYTEORD") )
+ s += CSG_String::Format(SG_T("%s %s\n") , HDR_BYTEORDER , Parameters("BYTEORD")->asInt() == 1 ? HDR_BYTEORDER_LO : HDR_BYTEORDER_HI);
+ }
+
+ fprintf(Stream.Get_Stream(), s.b_str());
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_io/grid/io_grid/esri_arcinfo.h b/src/modules_io/grid/io_grid/esri_arcinfo.h
index 22a545c..cc87397 100644
--- a/src/modules_io/grid/io_grid/esri_arcinfo.h
+++ b/src/modules_io/grid/io_grid/esri_arcinfo.h
@@ -76,22 +76,23 @@ class CESRI_ArcInfo_Import : public CSG_Module
{
public:
CESRI_ArcInfo_Import(void);
- virtual ~CESRI_ArcInfo_Import(void);
- virtual const SG_Char * Get_MenuPath(void) { return( _TL("R:Import") ); }
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Import") ); }
protected:
- virtual bool On_Execute(void);
+ virtual bool On_Execute (void);
private:
- bool Read_Line (FILE *Stream, CSG_String &sLine);
- bool Read_Value (const CSG_String &sKey, CSG_String &sLine, int &Value);
- bool Read_Value (const CSG_String &sKey, CSG_String &sLine, double &Value);
- CSG_Grid * Read_Header (FILE *Stream);
+ double Read_Value (CSG_File &Stream);
+
+ bool Read_Header_Value (const CSG_String &sKey, CSG_String &sLine, int &Value);
+ bool Read_Header_Value (const CSG_String &sKey, CSG_String &sLine, double &Value);
+ bool Read_Header_Line (CSG_File &Stream, CSG_String &sLine);
+ CSG_Grid * Read_Header (CSG_File &Stream);
};
@@ -107,19 +108,20 @@ class CESRI_ArcInfo_Export : public CSG_Module_Grid
{
public:
CESRI_ArcInfo_Export(void);
- virtual ~CESRI_ArcInfo_Export(void);
- virtual const SG_Char * Get_MenuPath(void) { return( _TL("R:Export") ); }
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Export") ); }
protected:
- virtual bool On_Execute(void);
+ virtual bool On_Execute (void);
private:
- bool Write_Header (FILE *Stream, CSG_Grid *pGrid, bool bComma);
+ CSG_String Write_Value (double Value, int Precision, bool bComma);
+
+ bool Write_Header (CSG_File &Stream, CSG_Grid *pGrid, bool bComma);
};
diff --git a/src/modules_io/grid/io_grid/usgs_srtm.cpp b/src/modules_io/grid/io_grid/usgs_srtm.cpp
index 4c69cfd..f246e16 100644
--- a/src/modules_io/grid/io_grid/usgs_srtm.cpp
+++ b/src/modules_io/grid/io_grid/usgs_srtm.cpp
@@ -77,16 +77,14 @@ CUSGS_SRTM_Import::CUSGS_SRTM_Import(void)
Set_Name (_TL("Import USGS SRTM Grid"));
- Set_Author (SG_T("(c) 2004 by O.Conrad"));
+ Set_Author (SG_T("O.Conrad (c) 2004"));
Set_Description (_TW(
"Import grid from USGS SRTM (Shuttle Radar Topography Mission) data.\n"
"You find data and further information at:\n"
- " <a target=\"_blank\" href=\"ftp://e0srp01u.ecs.nasa.gov/srtm/\">"
- " ftp://e0srp01u.ecs.nasa.gov/srtm/</a>\n"
- " <a target=\"_blank\" href=\"http://seamless.usgs.gov/\">"
- " http://seamless.usgs.gov/</a>\n"
+ " <a target=\"_blank\" href=\"http://dds.cr.usgs.gov/srtm/\">"
+ " http://dds.cr.usgs.gov/srtm/</a>\n"
" <a target=\"_blank\" href=\"http://www.jpl.nasa.gov/srtm/\">"
" http://www.jpl.nasa.gov/srtm/</a>\n"
diff --git a/src/modules_io/grid/io_grid/xyz.cpp b/src/modules_io/grid/io_grid/xyz.cpp
index 5142b15..7035c9a 100644
--- a/src/modules_io/grid/io_grid/xyz.cpp
+++ b/src/modules_io/grid/io_grid/xyz.cpp
@@ -1,363 +1,382 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// Grid_IO //
-// //
-//-------------------------------------------------------//
-// //
-// XYZ.cpp //
-// //
-// Copyright (C) 2003 by //
-// Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "xyz.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CXYZ_Export::CXYZ_Export(void)
-{
- //-----------------------------------------------------
- // 1. Info...
-
- Set_Name (_TL("Export Grid to XYZ"));
-
- Set_Author (SG_T("O. Conrad (c) 2003"));
-
- Set_Description (_TW(
- "Export grid to a table (text format), that contains for each grid cell "
- "the x/y-coordinates and additionally data from selected grids.\n")
- );
-
-
- //-----------------------------------------------------
- // 2. Parameters...
-
- Parameters.Add_Grid_List(
- NULL , "GRIDS" , _TL("Grids"),
- _TL(""),
- PARAMETER_INPUT
- );
-
- Parameters.Add_FilePath(
- NULL , "FILENAME" , _TL("File Name"),
- _TL(""),
- CSG_String::Format(
- SG_T("%s|*.xyz|%s|*.txt|%s|*.*"),
- _TL("XYZ files (*.xyz)"),
- _TL("Text files (*.txt)"),
- _TL("All Files")
- ), NULL, true
- );
-
- Parameters.Add_Value(
- NULL , "CAPTION" , _TL("Write Field Names"),
- _TL(""),
- PARAMETER_TYPE_Bool, true
- );
-}
-
-//---------------------------------------------------------
-bool CXYZ_Export::On_Execute(void)
-{
- int x, y, i;
- TSG_Point p;
- CSG_File Stream;
- CSG_String FileName;
- CSG_Parameter_Grid_List *pGrids;
-
- pGrids = Parameters("GRIDS") ->asGridList();
- FileName = Parameters("FILENAME")->asString();
-
- if( pGrids->Get_Count() > 0 && Stream.Open(FileName, SG_FILE_W, false) )
- {
- if( Parameters("CAPTION")->asBool() )
- {
- Stream.Printf(SG_T("\"X\"\t\"Y\""));
-
- for(i=0; i<pGrids->Get_Count(); i++)
- {
- Stream.Printf(SG_T("\t\"%s\""), pGrids->asGrid(i)->Get_Name());
- }
-
- Stream.Printf(SG_T("\n"));
- }
-
- for(y=0, p.y=Get_YMin(); y<Get_NY() && Set_Progress(y); y++, p.y+=Get_Cellsize())
- {
- for(x=0, p.x=Get_XMin(); x<Get_NX(); x++, p.x+=Get_Cellsize())
- {
- Stream.Printf(SG_T("%f\t%f"), p.x, p.y);
-
- for(i=0; i<pGrids->Get_Count(); i++)
- {
- Stream.Printf(SG_T("\t%f"), pGrids->asGrid(i)->asDouble(x, y));
- }
-
- Stream.Printf(SG_T("\n"));
- }
- }
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CXYZ_Import::CXYZ_Import(void)
-{
- //-----------------------------------------------------
- // 1. Info...
-
- Set_Name (_TL("Import Grid from XYZ"));
-
- Set_Author (SG_T("O. Conrad (c) 2009"));
-
- Set_Description (_TW(
- "Import grid from a table (text format), that contains for each grid cell "
- "the x/y/z-coordinates and additional data from selected grids.\n"
- ));
-
-
- //-----------------------------------------------------
- // 2. Parameters...
-
- Parameters.Add_Grid_Output(
- NULL , "GRID" , _TL("Grid"),
- _TL("")
- );
-
- Parameters.Add_Grid_Output(
- NULL , "COUNT" , _TL("Count"),
- _TL("")
- );
-
- Parameters.Add_FilePath(
- NULL , "FILENAME" , _TL("File Name"),
- _TL(""),
- CSG_String::Format(
- SG_T("%s|*.xyz|%s|*.txt|%s|*.*"),
- _TL("XYZ files (*.xyz)"),
- _TL("Text files (*.txt)"),
- _TL("All Files")
- ), NULL, false
- );
-
- Parameters.Add_Value(
- NULL , "CAPTION" , _TL("Has Field Names"),
- _TL(""),
- PARAMETER_TYPE_Bool, true
- );
-
- Parameters.Add_Value(
- NULL , "CELLSIZE" , _TL("Target Cellsize"),
- _TL(""),
- PARAMETER_TYPE_Double, 1.0, 0.0, true
- );
-
- Parameters.Add_Choice(
- NULL , "SEPARATOR" , _TL("Separator"),
- _TL(""),
- CSG_String::Format(SG_T("%s|%s|,|;|"),
- _TL("space"),
- _TL("tabulator")
- ), 1
- );
-}
-
-//---------------------------------------------------------
-bool CXYZ_Import::On_Execute(void)
-{
- int nx, ny, nValues, fLength;
- double x, y, z, xMin, yMin, xMax, yMax, Cellsize;
- CSG_File Stream;
- CSG_String FileName, sLine;
- CSG_Grid *pGrid, *pCount;
-
- FileName = Parameters("FILENAME")->asString();
- Cellsize = Parameters("CELLSIZE")->asDouble();
-
- switch( Parameters("SEPARATOR")->asInt() )
- {
- case 0: m_Separator = SG_T(' '); break;
- case 1: m_Separator = SG_T('\t'); break;
- case 2: m_Separator = SG_T(','); break;
- case 3: m_Separator = SG_T(';'); break;
- }
-
- if( Cellsize > 0.0 && Stream.Open(FileName, SG_FILE_R, false) )
- {
- if( Parameters("CAPTION")->asBool() )
- {
- Stream.Read_Line(sLine);
- }
-
- fLength = Stream.Length();
- nValues = 0;
-
- while( Read_Values(Stream, x, y, z) && Set_Progress(Stream.Tell(), fLength) )
- {
- if( nValues == 0 )
- {
- xMin = xMax = x;
- yMin = yMax = y;
- }
- else
- {
- if( xMin > x ) xMin = x; else if( xMax < x ) xMax = x;
- if( yMin > y ) yMin = y; else if( yMax < y ) yMax = y;
- }
-
- nValues++;
- }
-
- //-------------------------------------------------
- if( xMin < xMax && yMin < yMax )
- {
- nx = 1 + (int)((xMax - xMin) / Cellsize);
- ny = 1 + (int)((yMax - yMin) / Cellsize);
-
- Parameters("GRID" )->Set_Value(pGrid = SG_Create_Grid(SG_DATATYPE_Float, nx, ny, Cellsize, xMin, yMin));
- Parameters("COUNT")->Set_Value(pCount = SG_Create_Grid(SG_DATATYPE_Byte , nx, ny, Cellsize, xMin, yMin));
-
- if( pGrid && pCount )
- {
- pGrid ->Set_Name(FileName = SG_File_Get_Name(FileName, false));
- pCount ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), FileName.c_str(), _TL("Count")));
-
- Stream.Seek_Start();
-
- if( Parameters("CAPTION")->asBool() )
- {
- Stream.Read_Line(sLine);
- }
-
- while( Read_Values(Stream, x, y, z) && Set_Progress(Stream.Tell(), fLength) )
- {
- if( pGrid->Get_System().Get_World_to_Grid(nx, ny, x, y) )
- {
- pGrid ->Add_Value(nx, ny, z);
- pCount->Add_Value(nx, ny, 1.0);
- }
- }
-
- for(ny=0; ny<pGrid->Get_NY() && Set_Progress(ny, pGrid->Get_NY()); ny++)
- {
- for(nx=0; nx<pGrid->Get_NX(); nx++)
- {
- nValues = pCount->asInt(nx, ny);
-
- if( nValues == 0 )
- {
- pGrid->Set_NoData(nx, ny);
- }
- else if( nValues > 1 )
- {
- pGrid->Mul_Value(nx, ny, 1.0 / nValues);
- }
- }
- }
-
- return( true );
- }
- }
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-inline bool CXYZ_Import::Read_Values(CSG_File &Stream, double &x, double &y, double &z)
-{
- CSG_String sLine;
-
- if( Stream.Read_Line(sLine) )
- {
- if( sLine.asDouble(x) )
- {
- sLine = sLine.AfterFirst(m_Separator);
-
- if( sLine.asDouble(y) )
- {
- sLine = sLine.AfterFirst(m_Separator);
-
- if( sLine.asDouble(z) )
- {
- return( true );
- }
- }
- }
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Grid_IO //
+// //
+//-------------------------------------------------------//
+// //
+// XYZ.cpp //
+// //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "xyz.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CXYZ_Export::CXYZ_Export(void)
+{
+ //-----------------------------------------------------
+ // 1. Info...
+
+ Set_Name (_TL("Export Grid to XYZ"));
+
+ Set_Author (SG_T("O. Conrad (c) 2003"));
+
+ Set_Description (_TW(
+ "Export grid to a table (text format), that contains for each grid cell "
+ "the x/y-coordinates and additionally data from selected grids.\n"
+ "Optionally, it is possible to skip NoData cells from the output. In this "
+ "case, the first input grid will perform like a mask.\n\n")
+ );
+
+
+ //-----------------------------------------------------
+ // 2. Parameters...
+
+ Parameters.Add_Grid_List(
+ NULL , "GRIDS" , _TL("Grids"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_FilePath(
+ NULL , "FILENAME" , _TL("File Name"),
+ _TL(""),
+ CSG_String::Format(
+ SG_T("%s|*.xyz|%s|*.txt|%s|*.*"),
+ _TL("XYZ files (*.xyz)"),
+ _TL("Text files (*.txt)"),
+ _TL("All Files")
+ ), NULL, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "CAPTION" , _TL("Write Field Names"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "EX_NODATA" , _TL("Exclude NoData Cells"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, false
+ );
+}
+
+//---------------------------------------------------------
+bool CXYZ_Export::On_Execute(void)
+{
+ bool bExNoData;
+ int x, y, i;
+ TSG_Point p;
+ CSG_File Stream;
+ CSG_String FileName;
+ CSG_Parameter_Grid_List *pGrids;
+
+ pGrids = Parameters("GRIDS") ->asGridList();
+ FileName = Parameters("FILENAME")->asString();
+ bExNoData = Parameters("EX_NODATA")->asBool();
+
+ if( pGrids->Get_Count() > 0 && Stream.Open(FileName, SG_FILE_W, false) )
+ {
+ if( Parameters("CAPTION")->asBool() )
+ {
+ Stream.Printf(SG_T("\"X\"\t\"Y\""));
+
+ for(i=0; i<pGrids->Get_Count(); i++)
+ {
+ Stream.Printf(SG_T("\t\"%s\""), pGrids->asGrid(i)->Get_Name());
+ }
+
+ Stream.Printf(SG_T("\n"));
+ }
+
+ for(y=0, p.y=Get_YMin(); y<Get_NY() && Set_Progress(y); y++, p.y+=Get_Cellsize())
+ {
+ for(x=0, p.x=Get_XMin(); x<Get_NX(); x++, p.x+=Get_Cellsize())
+ {
+ if( !bExNoData || (bExNoData && !pGrids->asGrid(0)->is_NoData(x, y)) )
+ {
+ Stream.Printf(SG_T("%f\t%f"), p.x, p.y);
+
+ for(i=0; i<pGrids->Get_Count(); i++)
+ {
+ Stream.Printf(SG_T("\t%f"), pGrids->asGrid(i)->asDouble(x, y));
+ }
+
+ Stream.Printf(SG_T("\n"));
+ }
+ }
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CXYZ_Import::CXYZ_Import(void)
+{
+ //-----------------------------------------------------
+ // 1. Info...
+
+ Set_Name (_TL("Import Grid from XYZ"));
+
+ Set_Author (SG_T("O. Conrad (c) 2009"));
+
+ Set_Description (_TW(
+ "Import grid from a table (text format), that contains for each grid cell "
+ "the x/y/z-coordinates and additional data from selected grids.\n"
+ ));
+
+
+ //-----------------------------------------------------
+ // 2. Parameters...
+
+ Parameters.Add_Grid_Output(
+ NULL , "GRID" , _TL("Grid"),
+ _TL("")
+ );
+
+ Parameters.Add_Grid_Output(
+ NULL , "COUNT" , _TL("Count"),
+ _TL("")
+ );
+
+ Parameters.Add_FilePath(
+ NULL , "FILENAME" , _TL("File Name"),
+ _TL(""),
+ CSG_String::Format(
+ SG_T("%s|*.xyz|%s|*.txt|%s|*.*"),
+ _TL("XYZ files (*.xyz)"),
+ _TL("Text files (*.txt)"),
+ _TL("All Files")
+ ), NULL, false
+ );
+
+ Parameters.Add_Value(
+ NULL , "CAPTION" , _TL("Has Field Names"),
+ _TL(""),
+ PARAMETER_TYPE_Bool, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "CELLSIZE" , _TL("Target Cellsize"),
+ _TL(""),
+ PARAMETER_TYPE_Double, 1.0, 0.0, true
+ );
+
+ Parameters.Add_Choice(
+ NULL , "SEPARATOR" , _TL("Separator"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|,|;|"),
+ _TL("space"),
+ _TL("tabulator")
+ ), 1
+ );
+}
+
+//---------------------------------------------------------
+bool CXYZ_Import::On_Execute(void)
+{
+ int nx, ny, nValues, fLength;
+ double x, y, z, xMin, yMin, xMax, yMax, Cellsize;
+ CSG_File Stream;
+ CSG_String FileName, sLine;
+ CSG_Grid *pGrid, *pCount;
+
+ FileName = Parameters("FILENAME")->asString();
+ Cellsize = Parameters("CELLSIZE")->asDouble();
+
+ switch( Parameters("SEPARATOR")->asInt() )
+ {
+ case 0: m_Separator = SG_T(' '); break;
+ case 1: m_Separator = SG_T('\t'); break;
+ case 2: m_Separator = SG_T(','); break;
+ case 3: m_Separator = SG_T(';'); break;
+ }
+
+ if( Cellsize > 0.0 && Stream.Open(FileName, SG_FILE_R, false) )
+ {
+ if( Parameters("CAPTION")->asBool() )
+ {
+ Stream.Read_Line(sLine);
+ }
+
+ fLength = Stream.Length();
+ nValues = 0;
+ xMin = xMax = 0;
+ yMin = yMax = 0;
+
+ while( Read_Values(Stream, x, y, z) && Set_Progress(Stream.Tell(), fLength) )
+ {
+ if( nValues == 0 )
+ {
+ xMin = xMax = x;
+ yMin = yMax = y;
+ }
+ else
+ {
+ if( xMin > x ) xMin = x; else if( xMax < x ) xMax = x;
+ if( yMin > y ) yMin = y; else if( yMax < y ) yMax = y;
+ }
+
+ nValues++;
+ }
+
+ //-------------------------------------------------
+ if( Process_Get_Okay() && xMin < xMax && yMin < yMax )
+ {
+ nx = 1 + (int)((xMax - xMin) / Cellsize);
+ ny = 1 + (int)((yMax - yMin) / Cellsize);
+
+ Parameters("GRID" )->Set_Value(pGrid = SG_Create_Grid(SG_DATATYPE_Float, nx, ny, Cellsize, xMin, yMin));
+ Parameters("COUNT")->Set_Value(pCount = SG_Create_Grid(SG_DATATYPE_Byte , nx, ny, Cellsize, xMin, yMin));
+
+ if( pGrid && pCount )
+ {
+ pGrid ->Set_Name(FileName = SG_File_Get_Name(FileName, false));
+ pCount ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), FileName.c_str(), _TL("Count")));
+
+ Stream.Seek_Start();
+
+ if( Parameters("CAPTION")->asBool() )
+ {
+ Stream.Read_Line(sLine);
+ }
+
+ while( Read_Values(Stream, x, y, z) && Set_Progress(Stream.Tell(), fLength) )
+ {
+ if( pGrid->Get_System().Get_World_to_Grid(nx, ny, x, y) )
+ {
+ pGrid ->Add_Value(nx, ny, z);
+ pCount->Add_Value(nx, ny, 1.0);
+ }
+ }
+
+ for(ny=0; ny<pGrid->Get_NY() && Set_Progress(ny, pGrid->Get_NY()); ny++)
+ {
+ for(nx=0; nx<pGrid->Get_NX(); nx++)
+ {
+ nValues = pCount->asInt(nx, ny);
+
+ if( nValues == 0 )
+ {
+ pGrid->Set_NoData(nx, ny);
+ }
+ else if( nValues > 1 )
+ {
+ pGrid->Mul_Value(nx, ny, 1.0 / nValues);
+ }
+ }
+ }
+
+ return( true );
+ }
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+inline bool CXYZ_Import::Read_Values(CSG_File &Stream, double &x, double &y, double &z)
+{
+ CSG_String sLine;
+
+ if( Stream.Read_Line(sLine) )
+ {
+ sLine.Trim();
+
+ if( sLine.asDouble(x) )
+ {
+ sLine = sLine.AfterFirst(m_Separator);
+
+ sLine.Trim();
+
+ if( sLine.asDouble(y) )
+ {
+ sLine = sLine.AfterFirst(m_Separator);
+
+ if( sLine.asDouble(z) )
+ {
+ return( true );
+ }
+ }
+ }
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_io/grid/io_grid_grib2/Makefile.am b/src/modules_io/grid/io_grid_grib2/Makefile.am
index 7501979..04863c8 100644
--- a/src/modules_io/grid/io_grid_grib2/Makefile.am
+++ b/src/modules_io/grid/io_grid_grib2/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.2 2007/10/23 11:12:17 oconrad Exp $
+# $Id: Makefile.am,v 1.3 2010/07/08 14:11:48 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,8 +10,8 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -DUSE_JPEG2000 -DUSE_PNG
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-#AM_LDFLAGS = -fPIC -shared -lpq -ljasper
-AM_LDFLAGS = -fPIC -shared -ljasper
+#AM_LDFLAGS = -fPIC -shared -avoid-version -lpq -ljasper
+AM_LDFLAGS = -fPIC -shared -avoid-version -ljasper
pkglib_LTLIBRARIES = libio_grid_grib2.la
libio_grid_grib2_la_SOURCES =\
./g2clib-1.0.4/cmplxpack.c\
diff --git a/src/modules_io/grid/io_grid_grib2/Makefile.in b/src/modules_io/grid/io_grid_grib2/Makefile.in
index 63e23e7..6e149d2 100644
--- a/src/modules_io/grid/io_grid_grib2/Makefile.in
+++ b/src/modules_io/grid/io_grid_grib2/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -81,7 +80,7 @@ am_libio_grid_grib2_la_OBJECTS = cmplxpack.lo compack.lo comunpack.lo \
seekgb.lo simpack.lo simunpack.lo specpack.lo specunpack.lo \
grib2_import.lo MLB_Interface.lo
libio_grid_grib2_la_OBJECTS = $(am_libio_grid_grib2_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -127,6 +126,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -136,6 +136,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -226,15 +227,15 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.2 2007/10/23 11:12:17 oconrad Exp $
+# $Id: Makefile.am,v 1.3 2010/07/08 14:11:48 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -DUSE_JPEG2000 -DUSE_PNG
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-#AM_LDFLAGS = -fPIC -shared -lpq -ljasper
-AM_LDFLAGS = -fPIC -shared -ljasper
+#AM_LDFLAGS = -fPIC -shared -avoid-version -lpq -ljasper
+AM_LDFLAGS = -fPIC -shared -avoid-version -ljasper
pkglib_LTLIBRARIES = libio_grid_grib2.la
libio_grid_grib2_la_SOURCES = \
./g2clib-1.0.4/cmplxpack.c\
diff --git a/src/modules_io/grid/io_grid_image/Makefile.am b/src/modules_io/grid/io_grid_image/Makefile.am
index cf2b206..c958c77 100644
--- a/src/modules_io/grid/io_grid_image/Makefile.am
+++ b/src/modules_io/grid/io_grid_image/Makefile.am
@@ -11,7 +11,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = $(DEP_LFLG)
+AM_LDFLAGS = $(DEP_LFLG) -avoid-version
pkglib_LTLIBRARIES = libio_grid_image.la
libio_grid_image_la_SOURCES =\
grid_export.cpp\
diff --git a/src/modules_io/grid/io_grid_image/Makefile.in b/src/modules_io/grid/io_grid_image/Makefile.in
index 026b1db..014845c 100644
--- a/src/modules_io/grid/io_grid_image/Makefile.in
+++ b/src/modules_io/grid/io_grid_image/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -72,7 +71,7 @@ libio_grid_image_la_DEPENDENCIES = \
am_libio_grid_image_la_OBJECTS = grid_export.lo grid_import.lo \
MLB_Interface.lo
libio_grid_image_la_OBJECTS = $(am_libio_grid_image_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -118,6 +117,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -127,6 +127,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -223,7 +224,7 @@ top_srcdir = @top_srcdir@
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = $(DEP_LFLG)
+AM_LDFLAGS = $(DEP_LFLG) -avoid-version
pkglib_LTLIBRARIES = libio_grid_image.la
libio_grid_image_la_SOURCES = \
grid_export.cpp\
diff --git a/src/modules_io/grid/io_grid_image/grid_export.cpp b/src/modules_io/grid/io_grid_image/grid_export.cpp
index 5cc8a7f..9dae85d 100644
--- a/src/modules_io/grid/io_grid_image/grid_export.cpp
+++ b/src/modules_io/grid/io_grid_image/grid_export.cpp
@@ -122,31 +122,30 @@ CGrid_Export::CGrid_Export(void)
Parameters.Add_Choice(
NULL , "COL_PALETTE" , _TL("Color Palette"),
_TL(""),
- CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"),
- _TL("SG_COLORS_DEFAULT"),
- _TL("SG_COLORS_DEFAULT_BRIGHT"),
- _TL("SG_COLORS_BLACK_WHITE"),
- _TL("SG_COLORS_BLACK_RED"),
- _TL("SG_COLORS_BLACK_GREEN"),
- _TL("SG_COLORS_BLACK_BLUE"),
- _TL("SG_COLORS_WHITE_RED"),
- _TL("SG_COLORS_WHITE_GREEN"),
- _TL("SG_COLORS_WHITE_BLUE"),
- _TL("SG_COLORS_YELLOW_RED"),
- _TL("SG_COLORS_YELLOW_GREEN"),
- _TL("SG_COLORS_YELLOW_BLUE"),
- _TL("SG_COLORS_RED_GREEN"),
- _TL("SG_COLORS_RED_BLUE"),
- _TL("SG_COLORS_GREEN_BLUE"),
- _TL("SG_COLORS_RED_GREY_BLUE"),
- _TL("SG_COLORS_RED_GREY_GREEN"),
- _TL("SG_COLORS_GREEN_GREY_BLUE"),
- _TL("SG_COLORS_RED_GREEN_BLUE"),
- _TL("SG_COLORS_RED_BLUE_GREEN"),
- _TL("SG_COLORS_GREEN_RED_BLUE"),
- _TL("SG_COLORS_RAINBOW"),
- _TL("SG_COLORS_NEON"),
- _TL("SG_COLORS_COUNT")
+ CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"),
+ _TL("DEFAULT"),
+ _TL("DEFAULT_BRIGHT"),
+ _TL("BLACK_WHITE"),
+ _TL("BLACK_RED"),
+ _TL("BLACK_GREEN"),
+ _TL("BLACK_BLUE"),
+ _TL("WHITE_RED"),
+ _TL("WHITE_GREEN"),
+ _TL("WHITE_BLUE"),
+ _TL("YELLOW_RED"),
+ _TL("YELLOW_GREEN"),
+ _TL("YELLOW_BLUE"),
+ _TL("RED_GREEN"),
+ _TL("RED_BLUE"),
+ _TL("GREEN_BLUE"),
+ _TL("RED_GREY_BLUE"),
+ _TL("RED_GREY_GREEN"),
+ _TL("GREEN_GREY_BLUE"),
+ _TL("RED_GREEN_BLUE"),
+ _TL("RED_BLUE_GREEN"),
+ _TL("GREEN_RED_BLUE"),
+ _TL("RAINBOW"),
+ _TL("NEON")
), 0
);
@@ -292,6 +291,8 @@ bool CGrid_Export::On_Execute(void)
//-------------------------------------------------
if( img.SaveFile(fName.c_str()) )
{
+ pGrid->Get_Projection().Save(fName, SG_PROJ_FMT_WKT);
+
if( Stream.Open(SG_File_Make_Path(NULL, fName, fExt), SG_FILE_W, false) )
{
Stream.Printf(SG_T("%f\n%f\n%f\n%f\n%f\n%f\n"),
@@ -302,7 +303,7 @@ bool CGrid_Export::On_Execute(void)
pGrid->Get_YMax()
);
}
-
+
if( Parameters("FILE_KML")->asBool() && Stream.Open(SG_File_Make_Path(NULL, fName, SG_T("kml")), SG_FILE_W, false) )
{
Stream.Printf(SG_T("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"));
diff --git a/src/modules_io/grid/io_grid_image/grid_import.cpp b/src/modules_io/grid/io_grid_image/grid_import.cpp
index 09705b5..1c9d0c5 100644
--- a/src/modules_io/grid/io_grid_image/grid_import.cpp
+++ b/src/modules_io/grid/io_grid_image/grid_import.cpp
@@ -122,19 +122,14 @@ CGrid_Import::CGrid_Import(void)
Parameters.Add_Choice(
NULL , "METHOD" , _TL("Options"),
_TL(""),
-
CSG_String::Format(SG_T("%s|%s|%s|"),
_TL("Standard"),
_TL("Split Channels"),
_TL("Enforce True Color")
- )
+ ), 2
);
}
-//---------------------------------------------------------
-CGrid_Import::~CGrid_Import(void)
-{}
-
///////////////////////////////////////////////////////////
// //
@@ -143,145 +138,245 @@ CGrid_Import::~CGrid_Import(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define ADD_GRID(g, s, t) g = SG_Create_Grid(t, img.GetWidth(), img.GetHeight(), Cellsize, xMin, yMin); g->Set_Name(s);
-
-//---------------------------------------------------------
bool CGrid_Import::On_Execute(void)
{
+ bool bTransform;
int x, y, yy, Method;
- double d, Cellsize, xMin, yMin;
+ double ax, ay, dx, dy, rx, ry, xMin, yMin, Cellsize;
CSG_Colors Colors;
- CSG_Grid *pR, *pG, *pB;
- FILE *Stream;
- wxFileName fName;
- wxImage img;
- wxImageHistogram hst;
+ CSG_String fImage, fWorld, Name;
+ CSG_Grid *pImage;
+ CSG_File Stream;
+ wxImage Image;
+ wxImageHistogram Histogram;
//-----------------------------------------------------
- fName = Parameters("FILE") ->asString();
+ fImage = Parameters("FILE") ->asString();
Method = Parameters("METHOD") ->asInt();
- if( img.LoadFile(fName.GetFullPath()) )
+ Name = SG_File_Get_Name(fImage, false);
+
+ if( !Image.LoadFile(fImage.c_str()) )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ if( SG_File_Cmp_Extension(fImage, SG_T("bmp")) )
+ {
+ fWorld = SG_File_Make_Path(NULL, fImage, SG_T("bpw"));
+ }
+ else if( SG_File_Cmp_Extension(fImage, SG_T("jpg")) )
+ {
+ fWorld = SG_File_Make_Path(NULL, fImage, SG_T("jgw"));
+ }
+ else if( SG_File_Cmp_Extension(fImage, SG_T("png")) )
+ {
+ fWorld = SG_File_Make_Path(NULL, fImage, SG_T("pgw"));
+ }
+ else if( SG_File_Cmp_Extension(fImage, SG_T("tif")) )
+ {
+ fWorld = SG_File_Make_Path(NULL, fImage, SG_T("tfw"));
+ }
+ else
+ {
+ fWorld = SG_File_Make_Path(NULL, fImage, SG_T("world"));
+ }
+
+ bTransform = false;
+ xMin = 0.0;
+ yMin = 0.0;
+ Cellsize = 1.0;
+
+ if( Stream.Open(fWorld, SG_FILE_R, false) && fscanf(Stream.Get_Stream(), "%lf %lf %lf %lf %lf %lf ", &dx, &ry, &rx, &dy, &ax, &ay) == 6 )
{
- if( !fName.GetExt().CmpNoCase(SG_T("bmp")) )
+ if( dx != -dy || rx != 0.0 || ry != 0.0 )
{
- fName.SetExt(SG_T("bpw"));
+ bTransform = true;
}
- else if( !fName.GetExt().CmpNoCase(SG_T("jpg")) )
+ else
{
- fName.SetExt(SG_T("jgw"));
+ xMin = ax;
+ yMin = ay + dy * (Image.GetHeight() - 1);
+ Cellsize = dx;
}
- else if( !fName.GetExt().CmpNoCase(SG_T("png")) )
+ }
+
+
+ //-----------------------------------------------------
+ // color look-up table...
+
+ if( Method == 0 && (yy = Image.ComputeHistogram(Histogram)) <= 256 )
+ {
+ Colors.Set_Count(yy);
+
+ for(wxImageHistogram::iterator i=Histogram.begin(); i!=Histogram.end(); ++i)
{
- fName.SetExt(SG_T("pgw"));
+ Colors.Set_Color(i->second.index, SG_GET_R(i->first), SG_GET_G(i->first), SG_GET_B(i->first));
}
- else if( !fName.GetExt().CmpNoCase(SG_T("tif")) )
+
+ pImage = SG_Create_Grid(yy <= 2 ? SG_DATATYPE_Bit : SG_DATATYPE_Byte, Image.GetWidth(), Image.GetHeight(), Cellsize, xMin, yMin);
+
+ for(y=0; y<pImage->Get_NY() && Set_Progress(y, pImage->Get_NY()); y++)
{
- fName.SetExt(SG_T("tfw"));
+ yy = bTransform ? y : pImage->Get_NY() - 1 - y;
+
+ for(x=0; x<pImage->Get_NX(); x++)
+ {
+ pImage->Set_Value(x, y, Histogram[SG_GET_RGB(Image.GetRed(x, yy), Image.GetGreen(x, yy), Image.GetBlue(x, yy))].index);
+ }
}
- else
+
+ if( bTransform )
{
- fName.SetExt(SG_T("world"));
+ Set_Transformation(&pImage, ax, ay, dx, dy, rx, ry);
}
- //-------------------------------------------------
- if( (Stream = fopen(fName.GetFullPath().mb_str(), "r")) != NULL )
+ pImage->Set_Name(Name);
+ Parameters("OUT_GRID")->Set_Value(pImage);
+ DataObject_Set_Colors(pImage, Colors);
+ DataObject_Update(pImage, 0, Colors.Get_Count() - 1);
+ }
+
+ //-----------------------------------------------------
+ else // true color...
+ {
+ pImage = SG_Create_Grid(SG_DATATYPE_Int, Image.GetWidth(), Image.GetHeight(), Cellsize, xMin, yMin);
+ pImage ->Set_Name(Name);
+
+ for(y=0; y<pImage->Get_NY() && Set_Progress(y, pImage->Get_NY()); y++)
{
- fscanf(Stream, "%lf %lf %lf %lf %lf %lf ", &Cellsize, &d, &d, &d, &xMin, &yMin);
- yMin = yMin - (img.GetHeight() - 1) * Cellsize;
- fclose(Stream);
+ yy = bTransform ? y : pImage->Get_NY() - 1 - y;
+
+ for(x=0; x<pImage->Get_NX(); x++)
+ {
+ pImage->Set_Value(x, y, SG_GET_RGB(Image.GetRed(x, yy), Image.GetGreen(x, yy), Image.GetBlue(x, yy)));
+ }
}
- else
+
+ if( bTransform )
{
- Cellsize = 1.0;
- xMin = 0.0;
- yMin = 0.0;
+ Set_Transformation(&pImage, ax, ay, dx, dy, rx, ry);
}
//-------------------------------------------------
- if( Method == 1 )
+ if( Method != 1 ) // true color...
{
- ADD_GRID(pR, CSG_String::Format(SG_T("%s [R]"), fName.GetName().c_str()), SG_DATATYPE_Byte);
- ADD_GRID(pG, CSG_String::Format(SG_T("%s [G]"), fName.GetName().c_str()), SG_DATATYPE_Byte);
- ADD_GRID(pB, CSG_String::Format(SG_T("%s [B]"), fName.GetName().c_str()), SG_DATATYPE_Byte);
+ pImage->Get_Projection().Load(fImage, SG_PROJ_FMT_WKT);
+ pImage->Set_Name(Name);
+ Parameters("OUT_GRID")->Set_Value(pImage);
+ DataObject_Set_Colors(pImage, 100, SG_COLORS_BLACK_WHITE);
+ DataObject_Set_Parameter(pImage, "COLORS_TYPE", 3); // Color Classification Type: RGB
+ }
- for(y=0, yy=pR->Get_NY()-1; y<pR->Get_NY() && Set_Progress(y, pR->Get_NY()); y++, yy--)
+ //-------------------------------------------------
+ else // split channels...
+ {
+ CSG_Grid *pR, *pG, *pB;
+
+ pR = SG_Create_Grid(pImage->Get_System(), SG_DATATYPE_Byte);
+ pG = SG_Create_Grid(pImage->Get_System(), SG_DATATYPE_Byte);
+ pB = SG_Create_Grid(pImage->Get_System(), SG_DATATYPE_Byte);
+
+ for(y=0; y<pImage->Get_NY() && Set_Progress(y, pImage->Get_NY()); y++)
{
- for(x=0; x<pR->Get_NX(); x++)
+ for(x=0; x<pImage->Get_NX(); x++)
{
- pR->Set_Value(x, y, img.GetRed (x, yy));
- pG->Set_Value(x, y, img.GetGreen(x, yy));
- pB->Set_Value(x, y, img.GetBlue (x, yy));
+ pR->Set_Value(x, y, SG_GET_R(pImage->asInt(x, y)));
+ pG->Set_Value(x, y, SG_GET_G(pImage->asInt(x, y)));
+ pB->Set_Value(x, y, SG_GET_B(pImage->asInt(x, y)));
}
}
- Parameters("OUT_RED") ->Set_Value(pR);
- DataObject_Set_Colors(pR, 100, SG_COLORS_BLACK_RED);
+ pR->Get_Projection().Load(fImage, SG_PROJ_FMT_WKT);
+ pG->Get_Projection().Load(fImage, SG_PROJ_FMT_WKT);
+ pB->Get_Projection().Load(fImage, SG_PROJ_FMT_WKT);
- Parameters("OUT_GREEN") ->Set_Value(pG);
- DataObject_Set_Colors(pG, 100, SG_COLORS_BLACK_GREEN);
+ pR->Set_Name(CSG_String::Format(SG_T("%s [R]"), Name.c_str()));
+ pG->Set_Name(CSG_String::Format(SG_T("%s [G]"), Name.c_str()));
+ pB->Set_Name(CSG_String::Format(SG_T("%s [B]"), Name.c_str()));
+ Parameters("OUT_RED") ->Set_Value(pR);
+ Parameters("OUT_GREEN") ->Set_Value(pG);
Parameters("OUT_BLUE") ->Set_Value(pB);
+
+ DataObject_Set_Colors(pR, 100, SG_COLORS_BLACK_RED);
+ DataObject_Set_Colors(pG, 100, SG_COLORS_BLACK_GREEN);
DataObject_Set_Colors(pB, 100, SG_COLORS_BLACK_BLUE);
}
+ }
- //-------------------------------------------------
- else if( Method == 0 && (yy = img.ComputeHistogram(hst)) <= 256 )
- {
- Colors.Set_Count(yy);
+ //-----------------------------------------------------
+ return( true );
+}
- for(wxImageHistogram::iterator i=hst.begin(); i!=hst.end(); ++i)
- {
- Colors.Set_Color(i->second.index, SG_GET_R(i->first), SG_GET_G(i->first), SG_GET_B(i->first));
- }
- ADD_GRID(pR, CSG_String( fName.GetName() ), yy <= 2 ? SG_DATATYPE_Bit : SG_DATATYPE_Byte);
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
- for(y=0, yy=pR->Get_NY()-1; y<pR->Get_NY() && Set_Progress(y, pR->Get_NY()); y++, yy--)
- {
- for(x=0; x<pR->Get_NX(); x++)
- {
- pR->Set_Value(x, y, hst[SG_GET_RGB(img.GetRed(x, yy), img.GetGreen(x, yy), img.GetBlue(x, yy))].index);
- }
- }
+//---------------------------------------------------------
+void CGrid_Import::Set_Transformation(CSG_Grid **ppImage, double ax, double ay, double dx, double dy, double rx, double ry)
+{
+ int x, y;
+ double z;
+ TSG_Rect r;
+ CSG_Vector A(2), XSrc(2), XTgt(2);
+ CSG_Matrix D(2, 2), DInv;
+ CSG_Grid *pSource, *pTarget;
- Parameters("OUT_GRID") ->Set_Value(pR);
- DataObject_Set_Colors(pR, Colors);
- DataObject_Update(pR, 0, Colors.Get_Count() - 1);
- }
+ //-----------------------------------------------------
+ pSource = *ppImage;
- //-------------------------------------------------
- else
- {
- hst.clear();
+ A[0] = ax; A[1] = ay;
+ D[0][0] = dx; D[0][1] = rx;
+ D[1][0] = ry; D[1][1] = dy;
+ DInv = D.Get_Inverse();
- ADD_GRID(pR, CSG_String( fName.GetName() ).c_str(), SG_DATATYPE_Int);
+ //-----------------------------------------------------
+ XSrc[0] = pSource->Get_XMin(); XSrc[1] = pSource->Get_YMin(); XTgt = D * XSrc + A;
+ r.xMin = r.xMax = XTgt[0];
+ r.yMin = r.yMax = XTgt[1];
- for(y=0, yy=pR->Get_NY()-1; y<pR->Get_NY() && Set_Progress(y, pR->Get_NY()); y++, yy--)
- {
- for(x=0; x<pR->Get_NX(); x++)
- {
- pR->Set_Value(x, y, SG_GET_RGB(img.GetRed(x, yy), img.GetGreen(x, yy), img.GetBlue(x, yy)));
- }
- }
+ XSrc[0] = pSource->Get_XMin(); XSrc[1] = pSource->Get_YMax(); XTgt = D * XSrc + A;
+ if( r.xMin > XTgt[0] ) r.xMin = XTgt[0]; else if( r.xMax < XTgt[0] ) r.xMax = XTgt[0];
+ if( r.yMin > XTgt[1] ) r.yMin = XTgt[1]; else if( r.yMax < XTgt[1] ) r.yMax = XTgt[1];
- Parameters("OUT_GRID") ->Set_Value(pR);
- DataObject_Set_Colors(pR, 100, SG_COLORS_BLACK_WHITE);
+ XSrc[0] = pSource->Get_XMax(); XSrc[1] = pSource->Get_YMax(); XTgt = D * XSrc + A;
+ if( r.xMin > XTgt[0] ) r.xMin = XTgt[0]; else if( r.xMax < XTgt[0] ) r.xMax = XTgt[0];
+ if( r.yMin > XTgt[1] ) r.yMin = XTgt[1]; else if( r.yMax < XTgt[1] ) r.yMax = XTgt[1];
- CSG_Parameters Parms;
+ XSrc[0] = pSource->Get_XMax(); XSrc[1] = pSource->Get_YMin(); XTgt = D * XSrc + A;
+ if( r.xMin > XTgt[0] ) r.xMin = XTgt[0]; else if( r.xMax < XTgt[0] ) r.xMax = XTgt[0];
+ if( r.yMin > XTgt[1] ) r.yMin = XTgt[1]; else if( r.yMax < XTgt[1] ) r.yMax = XTgt[1];
- if( DataObject_Get_Parameters(pR, Parms) && Parms("COLORS_TYPE") )
- {
- Parms("COLORS_TYPE")->Set_Value(3); // Color Classification Type: RGB
+ z = fabs(dx) < fabs(dy) ? fabs(dx) : fabs(dy); // guess a suitable cellsize; could be improved...
+ x = 1 + (int)((r.xMax - r.xMin) / z);
+ y = 1 + (int)((r.yMax - r.yMin) / z);
+
+ //-----------------------------------------------------
+ pTarget = *ppImage = SG_Create_Grid(pSource->Get_Type(), x, y, z, r.xMin, r.yMin);
+
+ for(y=0, XTgt[1]=pTarget->Get_YMin(); y<pTarget->Get_NY() && Set_Progress(y, pTarget->Get_NY()); y++, XTgt[1]+=pTarget->Get_Cellsize())
+ {
+ for(x=0, XTgt[0]=pTarget->Get_XMin(); x<pTarget->Get_NX(); x++, XTgt[0]+=pTarget->Get_Cellsize())
+ {
+ XSrc = DInv * (XTgt - A);
- DataObject_Set_Parameters(pR, Parms);
+ if( pSource->Get_Value(XSrc[0], XSrc[1], z, GRID_INTERPOLATION_NearestNeighbour, false, true) )
+ {
+ pTarget->Set_Value(x, y, z);
+ }
+ else
+ {
+ pTarget->Set_NoData(x, y);
}
}
-
- return( true );
}
- return( false );
+ delete(pSource);
}
diff --git a/src/modules_io/grid/io_grid_image/grid_import.h b/src/modules_io/grid/io_grid_image/grid_import.h
index e4a60d6..107fba7 100644
--- a/src/modules_io/grid/io_grid_image/grid_import.h
+++ b/src/modules_io/grid/io_grid_image/grid_import.h
@@ -83,18 +83,18 @@ class io_grid_image_EXPORT CGrid_Import : public CSG_Module
{
public:
CGrid_Import(void);
- virtual ~CGrid_Import(void);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Import") ); }
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Import") ); }
protected:
- virtual bool On_Execute (void);
+ virtual bool On_Execute (void);
private:
+ void Set_Transformation (CSG_Grid **ppImage, double ax, double ay, double dx, double dy, double rx, double ry);
};
diff --git a/src/modules_io/shapes/Makefile.in b/src/modules_io/shapes/Makefile.in
index 76f933a..4977653 100644
--- a/src/modules_io/shapes/Makefile.in
+++ b/src/modules_io/shapes/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_io/shapes/io_shapes/MLB_Interface.cpp b/src/modules_io/shapes/io_shapes/MLB_Interface.cpp
index d6a8699..ab26c5e 100644
--- a/src/modules_io/shapes/io_shapes/MLB_Interface.cpp
+++ b/src/modules_io/shapes/io_shapes/MLB_Interface.cpp
@@ -1,145 +1,147 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// io_shapes //
-// //
-//-------------------------------------------------------//
-// //
-// MLB_Interface.cpp //
-// //
-// Copyright (C) 2003 by //
-// Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// The Module Link Library Interface //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-// 1. Include the appropriate SAGA-API header...
-
-#include "MLB_Interface.h"
-
-
-//---------------------------------------------------------
-// 2. Place general module library informations here...
-
-const SG_Char * Get_Info(int i)
-{
- switch( i )
- {
- case MLB_INFO_Name: default:
- return( _TL("Import/Export - Shapes") );
-
- case MLB_INFO_Author:
- return( _TL("SAGA User Group Associaton (c) 2002") );
-
- case MLB_INFO_Description:
- return( _TL("Tools for the import and export of vector data.") );
-
- case MLB_INFO_Version:
- return( SG_T("1.0") );
-
- case MLB_INFO_Menu_Path:
- return( _TL("File|Shapes") );
- }
-}
-
-
-//---------------------------------------------------------
-// 3. Include the headers of your modules here...
-
-#include "gstat.h"
-#include "xyz.h"
-#include "generate.h"
-#include "surfer_bln.h"
-#include "atlas_bna.h"
-#include "wasp_map.h"
-#include "stl.h"
-#include "gpx.h"
-#include "pointcloud_from_file.h"
-
-
-//---------------------------------------------------------
-// 4. Allow your modules to be created here...
-
-CSG_Module * Create_Module(int i)
-{
- switch( i )
- {
- case 0: return( new CGStat_Export );
- case 1: return( new CGStat_Import );
- case 2: return( new CXYZ_Export );
- case 3: return( new CXYZ_Import );
- case 4: return( new CGenerate_Export );
- case 5: return( new CSurfer_BLN_Export );
- case 6: return( new CSurfer_BLN_Import );
- case 7: return( new CAtlas_BNA_Export );
- case 8: return( new CAtlas_BNA_Import );
- case 9: return( new CWASP_MAP_Export );
- case 10: return( new CWASP_MAP_Import );
- case 11: return( new CSTL_Import );
- case 12: return( new CSTL_Export );
- case 13: return( new CGPX_Import );
- case 14: return( new CGPX_Export );
- case 15: return( new CPointCloud_From_File );
- }
-
- return( NULL );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-//{{AFX_SAGA
-
- MLB_INTERFACE
-
-//}}AFX_SAGA
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// io_shapes //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.cpp //
+// //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// The Module Link Library Interface //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+// 1. Include the appropriate SAGA-API header...
+
+#include "MLB_Interface.h"
+
+
+//---------------------------------------------------------
+// 2. Place general module library informations here...
+
+const SG_Char * Get_Info(int i)
+{
+ switch( i )
+ {
+ case MLB_INFO_Name: default:
+ return( _TL("Import/Export - Shapes") );
+
+ case MLB_INFO_Author:
+ return( _TL("SAGA User Group Associaton (c) 2002") );
+
+ case MLB_INFO_Description:
+ return( _TL("Tools for the import and export of vector data.") );
+
+ case MLB_INFO_Version:
+ return( SG_T("1.0") );
+
+ case MLB_INFO_Menu_Path:
+ return( _TL("File|Shapes") );
+ }
+}
+
+
+//---------------------------------------------------------
+// 3. Include the headers of your modules here...
+
+#include "gstat.h"
+#include "xyz.h"
+#include "generate.h"
+#include "surfer_bln.h"
+#include "atlas_bna.h"
+#include "wasp_map.h"
+#include "stl.h"
+#include "gpx.h"
+#include "pointcloud_from_file.h"
+#include "pointcloud_from_text_file.h"
+
+
+//---------------------------------------------------------
+// 4. Allow your modules to be created here...
+
+CSG_Module * Create_Module(int i)
+{
+ switch( i )
+ {
+ case 0: return( new CGStat_Export );
+ case 1: return( new CGStat_Import );
+ case 2: return( new CXYZ_Export );
+ case 3: return( new CXYZ_Import );
+ case 4: return( new CGenerate_Export );
+ case 5: return( new CSurfer_BLN_Export );
+ case 6: return( new CSurfer_BLN_Import );
+ case 7: return( new CAtlas_BNA_Export );
+ case 8: return( new CAtlas_BNA_Import );
+ case 9: return( new CWASP_MAP_Export );
+ case 10: return( new CWASP_MAP_Import );
+ case 11: return( new CSTL_Import );
+ case 12: return( new CSTL_Export );
+ case 13: return( new CGPX_Import );
+ case 14: return( new CGPX_Export );
+ case 15: return( new CPointCloud_From_File );
+ case 16: return( new CPointCloud_From_Text_File );
+ }
+
+ return( NULL );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+//{{AFX_SAGA
+
+ MLB_INTERFACE
+
+//}}AFX_SAGA
diff --git a/src/modules_io/shapes/io_shapes/Makefile.am b/src/modules_io/shapes/io_shapes/Makefile.am
index ae9156c..a41278c 100644
--- a/src/modules_io/shapes/io_shapes/Makefile.am
+++ b/src/modules_io/shapes/io_shapes/Makefile.am
@@ -1,38 +1,40 @@
-#
-# $Id: Makefile.am,v 1.12 2009/09/15 16:48:14 oconrad Exp $
-#
-if DEBUG
-DBGFLAGS = -g -DDEBUG
-endif
-if SAGA_UNICODE
-UC_DEFS = -D_SAGA_UNICODE
-endif
-DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
-CXX_INCS = -I$(top_srcdir)/src/saga_core
-AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
-pkglib_LTLIBRARIES = libio_shapes.la
-libio_shapes_la_SOURCES =\
-atlas_bna.cpp\
-generate.cpp\
-gpx.cpp\
-gstat.cpp\
-MLB_Interface.cpp\
-pointcloud_from_file.cpp\
-stl.cpp\
-surfer_bln.cpp\
-xyz.cpp\
-wasp_map.cpp\
-atlas_bna.h\
-generate.h\
-gpx.h\
-gstat.h\
-MLB_Interface.h\
-pointcloud_from_file.h\
-stl.h\
-surfer_bln.h\
-wasp_map.h\
-xyz.h
-
-libio_shapes_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS)
-
+#
+# $Id: Makefile.am,v 1.14 2010/07/08 14:11:49 johanvdw Exp $
+#
+if DEBUG
+DBGFLAGS = -g -DDEBUG
+endif
+if SAGA_UNICODE
+UC_DEFS = -D_SAGA_UNICODE
+endif
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -avoid-version
+pkglib_LTLIBRARIES = libio_shapes.la
+libio_shapes_la_SOURCES =\
+atlas_bna.cpp\
+generate.cpp\
+gpx.cpp\
+gstat.cpp\
+MLB_Interface.cpp\
+pointcloud_from_file.cpp\
+pointcloud_from_text_file.cpp\
+stl.cpp\
+surfer_bln.cpp\
+xyz.cpp\
+wasp_map.cpp\
+atlas_bna.h\
+generate.h\
+gpx.h\
+gstat.h\
+MLB_Interface.h\
+pointcloud_from_file.h\
+pointcloud_from_text_file.h\
+stl.h\
+surfer_bln.h\
+wasp_map.h\
+xyz.h
+
+libio_shapes_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS)
+
diff --git a/src/modules_io/shapes/io_shapes/Makefile.in b/src/modules_io/shapes/io_shapes/Makefile.in
index 6fa0d9c..d476339 100644
--- a/src/modules_io/shapes/io_shapes/Makefile.in
+++ b/src/modules_io/shapes/io_shapes/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -70,10 +69,11 @@ LTLIBRARIES = $(pkglib_LTLIBRARIES)
libio_shapes_la_DEPENDENCIES = \
$(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
am_libio_shapes_la_OBJECTS = atlas_bna.lo generate.lo gpx.lo gstat.lo \
- MLB_Interface.lo pointcloud_from_file.lo stl.lo surfer_bln.lo \
- xyz.lo wasp_map.lo
+ MLB_Interface.lo pointcloud_from_file.lo \
+ pointcloud_from_text_file.lo stl.lo surfer_bln.lo xyz.lo \
+ wasp_map.lo
libio_shapes_la_OBJECTS = $(am_libio_shapes_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +129,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,14 +220,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.12 2009/09/15 16:48:14 oconrad Exp $
+# $Id: Makefile.am,v 1.14 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libio_shapes.la
libio_shapes_la_SOURCES = \
atlas_bna.cpp\
@@ -234,6 +236,7 @@ gpx.cpp\
gstat.cpp\
MLB_Interface.cpp\
pointcloud_from_file.cpp\
+pointcloud_from_text_file.cpp\
stl.cpp\
surfer_bln.cpp\
xyz.cpp\
@@ -244,6 +247,7 @@ gpx.h\
gstat.h\
MLB_Interface.h\
pointcloud_from_file.h\
+pointcloud_from_text_file.h\
stl.h\
surfer_bln.h\
wasp_map.h\
@@ -330,6 +334,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gpx.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gstat.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pointcloud_from_file.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pointcloud_from_text_file.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stl.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/surfer_bln.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/wasp_map.Plo at am__quote@
diff --git a/src/modules_io/shapes/io_shapes/pointcloud_from_file.cpp b/src/modules_io/shapes/io_shapes/pointcloud_from_file.cpp
index 3b9f5ac..a214350 100644
--- a/src/modules_io/shapes/io_shapes/pointcloud_from_file.cpp
+++ b/src/modules_io/shapes/io_shapes/pointcloud_from_file.cpp
@@ -56,7 +56,7 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
- #include "pointcloud_from_file.h"
+#include "pointcloud_from_file.h"
///////////////////////////////////////////////////////////
@@ -69,7 +69,7 @@
CPointCloud_From_File::CPointCloud_From_File(void)
{
//-----------------------------------------------------
- Set_Name (_TL("Point Cloud from File"));
+ Set_Name (_TL("Import Point Cloud from File"));
Set_Author (_TL("O. Conrad (c) 2009"));
diff --git a/src/modules_io/shapes/io_shapes/pointcloud_from_text_file.cpp b/src/modules_io/shapes/io_shapes/pointcloud_from_text_file.cpp
new file mode 100644
index 0000000..200954f
--- /dev/null
+++ b/src/modules_io/shapes/io_shapes/pointcloud_from_text_file.cpp
@@ -0,0 +1,367 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Shapes_IO //
+// //
+//-------------------------------------------------------//
+// //
+// pointcloud_from_text_file.cpp //
+// //
+// Copyright (C) 2009 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata.at //
+// //
+// contact: LASERDATA GmbH //
+// Management and Analysis of //
+// Laserscanning Data //
+// Technikerstr. 21a //
+// 6020 Innsbruck //
+// Austria //
+// www.laserdata.at //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "pointcloud_from_text_file.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CPointCloud_From_Text_File::CPointCloud_From_Text_File(void)
+{
+ //-----------------------------------------------------
+ Set_Name (_TL("Import Point Cloud from Text File"));
+
+ Set_Author (SG_T("V. Wichmann, LASERDATA GmbH (c) 2009"));
+
+ Set_Description (_TW(
+ "Creates a point cloud from a text file.\n"
+ "The input file must have at least three columns holding the "
+ "x, y, z coordinates of each point. You must specify the field "
+ "numbers of these. In case you like to import additional attributes, "
+ "you have to provide the number of attribute fields. After module "
+ "execution, you will be prompted to provide their field numbers, "
+ "names and datatypes.\n"
+ "You have also to decide on which field separator to use and if "
+ "the first line of the input file should be skipped (in case it "
+ "contains column headings).\n"
+ "The columns in the input file can be in any order, and you can "
+ "omit columns, but you have to provide the correct field numbers "
+ "of those you like to import.\n\n"
+ ));
+
+
+ //-----------------------------------------------------
+ Parameters.Add_PointCloud_Output(
+ NULL , "POINTS" , _TL("Point Cloud"),
+ _TL("")
+ );
+
+ Parameters.Add_FilePath(
+ NULL , "FILE" , _TL("Text File"),
+ _TL("")
+ );
+
+ Parameters.Add_Value(
+ NULL , "XFIELD" , _TL("X is Column ..."),
+ _TL("The column holding the X-coordinate."),
+ PARAMETER_TYPE_Int, 1, 1, true
+ );
+ Parameters.Add_Value(
+ NULL , "YFIELD" , _TL("Y is Column ..."),
+ _TL("The column holding the Y-coordinate."),
+ PARAMETER_TYPE_Int, 2, 1, true
+ );
+ Parameters.Add_Value(
+ NULL , "ZFIELD" , _TL("Z is Column ..."),
+ _TL("The column holding the Z-coordinate."),
+ PARAMETER_TYPE_Int, 3, 1, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "ATTRIBS" , _TL("Number of Attributes"),
+ _TL("Number of additional attributes to import."),
+ PARAMETER_TYPE_Int, 0, 0, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "SKIP_HEADER" , _TL("Skip first line"),
+ _TL("Skip first line as it contains column names."),
+ PARAMETER_TYPE_Bool, false
+ );
+
+ Parameters.Add_Choice(
+ NULL , "FIELDSEP" , _TL("Field Separator"),
+ _TL("Field Separator"),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("tabulator"),
+ _TL("space"),
+ _TL("comma")
+ ), 0
+ );
+}
+
+//---------------------------------------------------------
+CPointCloud_From_Text_File::~CPointCloud_From_Text_File(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CPointCloud_From_Text_File::On_Execute(void)
+{
+ CSG_String fileName;
+ int iField, iType;
+ TSG_Data_Type Type;
+ CSG_String Name, Types, s;
+ CSG_PointCloud *pPoints;
+ CSG_Parameters P;
+ CSG_Parameter *pNode;
+ int xField, yField, zField, nAttribs, max_iField;
+ bool bSkipHeader;
+ char fieldSep;
+ std::vector<int> vCol;
+ std::ifstream tabStream;
+ std::string tabLine;
+ double lines;
+ long cntPt, cntInvalid;
+ double x, y, z, value;
+
+
+ //-----------------------------------------------------
+ fileName = Parameters("FILE") ->asString();
+ xField = Parameters("XFIELD") ->asInt() - 1;
+ yField = Parameters("YFIELD") ->asInt() - 1;
+ zField = Parameters("ZFIELD") ->asInt() - 1;
+ nAttribs = Parameters("ATTRIBS") ->asInt();
+ bSkipHeader = Parameters("SKIP_HEADER") ->asBool();
+
+ switch (Parameters("FIELDSEP")->asInt())
+ {
+ default:
+ case 0: fieldSep = '\t'; break;
+ case 1: fieldSep = ' '; break;
+ case 2: fieldSep = ','; break;
+ }
+
+ Types.Printf(SG_T("%s|%s|%s|%s|%s|"),
+ _TL("1 byte integer"),
+ _TL("2 byte integer"),
+ _TL("4 byte integer"),
+ _TL("4 byte floating point"),
+ _TL("8 byte floating point")
+ );
+
+ P.Set_Name(_TL("Attribute Field Properties"));
+
+ for(iField=1; iField<=nAttribs; iField++)
+ {
+ s.Printf(SG_T("NODE_%03d") , iField);
+ pNode = P.Add_Node(NULL, s, CSG_String::Format(SG_T("%d. %s"), iField, _TL("Field")), _TL(""));
+
+ s.Printf(SG_T("FIELD_%03d"), iField);
+ P.Add_String(pNode, s, _TL("Name"), _TL(""), s);
+
+ s.Printf(SG_T("COLUMN_%03d"), iField);
+ P.Add_Value(pNode, s, _TL("Attribute is Column ..."), _TL(""), PARAMETER_TYPE_Int, iField+3, 1, true);
+
+ s.Printf(SG_T("TYPE_%03d") , iField);
+ P.Add_Choice(pNode, s, _TL("Type"), _TL(""), Types, 3);
+ }
+
+ //-----------------------------------------------------
+ if( nAttribs > 0 )
+ {
+ if( Dlg_Parameters(&P, _TL("Field Properties")) )
+ {
+ pPoints = SG_Create_PointCloud();
+ pPoints->Set_Name(SG_File_Get_Name(fileName, false));
+ Parameters("POINTS")->Set_Value(pPoints);
+
+ for(iField=0; iField<nAttribs; iField++)
+ {
+
+ Name = P(CSG_String::Format(SG_T("FIELD_%03d" ), iField + 1).c_str())->asString();
+ iType = P(CSG_String::Format(SG_T("TYPE_%03d" ), iField + 1).c_str())->asInt();
+ vCol.push_back(P(CSG_String::Format(SG_T("COLUMN_%03d"), iField + 1).c_str())->asInt() - 1);
+
+ switch( iType )
+ {
+ default:
+ case 0: Type = SG_DATATYPE_Char; break;
+ case 1: Type = SG_DATATYPE_Short; break;
+ case 2: Type = SG_DATATYPE_Int; break;
+ case 3: Type = SG_DATATYPE_Float; break;
+ case 4: Type = SG_DATATYPE_Double; break;
+ }
+
+ pPoints->Add_Field(Name, Type);
+ }
+ }
+ else
+ return( false );
+ }
+ else
+ {
+ pPoints = SG_Create_PointCloud();
+ pPoints->Create();
+ pPoints->Set_Name(SG_File_Get_Name(fileName, false));
+ Parameters("POINTS")->Set_Value(pPoints);
+ }
+
+ max_iField = M_GET_MAX(xField, yField);
+ max_iField = M_GET_MAX(max_iField, zField);
+ for( unsigned int i=0; i<vCol.size(); i++ )
+ {
+ if( max_iField < vCol.at(i) )
+ max_iField = vCol.at(i);
+ }
+
+ // open input stream
+ //---------------------------------------------------------
+ tabStream.open(fileName.b_str(), std::ifstream::in);
+ if( !tabStream )
+ {
+ SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unable to open input file!")));
+ return (false);
+ }
+
+ tabStream.seekg(0, std::ios::end); // get length of file
+ lines = (double)tabStream.tellg();
+ tabStream.seekg(0, std::ios::beg);
+
+ std::getline(tabStream, tabLine); // as a workaround we assume the number of lines from the length of the first line
+ lines = lines / (double)tabStream.tellg();
+
+ if( !bSkipHeader )
+ {
+ tabStream.clear(); // let's forget we may have reached the EOF
+ tabStream.seekg(0, std::ios::beg); // and rewind to the beginning
+ }
+
+
+ // import
+ //---------------------------------------------------------
+ cntPt = cntInvalid = 0;
+
+ SG_UI_Process_Set_Text(CSG_String::Format(_TL("Importing data ...")));
+
+ while( std::getline(tabStream, tabLine) )
+ {
+ std::istringstream stream(tabLine);
+ std::vector<std::string> tabCols;
+ std::string tabEntry;
+
+ if( cntPt%10000 == 0 )
+ SG_UI_Process_Set_Progress((double)cntPt, lines);
+
+ cntPt++;
+
+ while( std::getline(stream, tabEntry, fieldSep) ) // read every column in this line and fill vector
+ {
+ if (tabEntry.length() == 0)
+ continue;
+ tabCols.push_back(tabEntry);
+ }
+
+ if ((int)tabCols.size() < max_iField - 1 )
+ {
+ SG_UI_Msg_Add(CSG_String::Format(_TL("WARNING: Skipping misformatted line (%.0f)!"), cntPt), true);
+ cntInvalid++;
+ continue;
+ }
+
+ x = strtod(tabCols[xField].c_str(), NULL);
+ y = strtod(tabCols[yField].c_str(), NULL);
+ z = strtod(tabCols[zField].c_str(), NULL);
+
+ pPoints->Add_Point(x, y, z);
+
+ for( int i=0; i<nAttribs; i++ )
+ {
+ value = strtod(tabCols.at(vCol.at(i)).c_str(), NULL);
+ pPoints->Set_Attribute(i, value);
+ }
+ }
+
+ // finalize
+ //---------------------------------------------------------
+ tabStream.close();
+
+ CSG_Parameters sParms;
+ DataObject_Get_Parameters(pPoints, sParms);
+ if (sParms("COLORS_ATTRIB") && sParms("COLORS_TYPE") && sParms("METRIC_COLORS")
+ && sParms("METRIC_ZRANGE") && sParms("COLORS_AGGREGATE"))
+ {
+ sParms("COLORS_AGGREGATE")->Set_Value(3); // highest z
+ sParms("COLORS_TYPE")->Set_Value(2); // graduated color
+ sParms("METRIC_COLORS")->asColors()->Set_Count(255); // number of colors
+ sParms("COLORS_ATTRIB")->Set_Value(2); // z attrib
+ sParms("METRIC_ZRANGE")->asRange()->Set_Range(pPoints->Get_Minimum(2),pPoints->Get_Maximum(2));
+ DataObject_Set_Parameters(pPoints, sParms);
+ DataObject_Update(pPoints);
+ }
+
+ if (cntInvalid > 0)
+ SG_UI_Msg_Add(CSG_String::Format(_TL("WARNING: Skipped %d invalid points!"), cntInvalid), true);
+
+ SG_UI_Msg_Add(CSG_String::Format(_TL("%d points sucessfully imported."), (cntPt-cntInvalid)), true);
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_io/shapes/io_shapes/pointcloud_from_text_file.h b/src/modules_io/shapes/io_shapes/pointcloud_from_text_file.h
new file mode 100644
index 0000000..346f413
--- /dev/null
+++ b/src/modules_io/shapes/io_shapes/pointcloud_from_text_file.h
@@ -0,0 +1,110 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Shapes_IO //
+// //
+//-------------------------------------------------------//
+// //
+// pointcloud_from_text_file.h //
+// //
+// Copyright (C) 2009 by //
+// Volker Wichmann //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: wichmann at laserdata.at //
+// //
+// contact: LASERDATA GmbH //
+// Management and Analysis of //
+// Laserscanning Data //
+// Technikerstr. 21a //
+// 6020 Innsbruck //
+// Austria //
+// www.laserdata.at //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__PointCloud_From_Text_File_H
+#define HEADER_INCLUDED__PointCloud_From_Text_File_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+#include <vector>
+#include <iostream>
+#include <fstream>
+#include <sstream>
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CPointCloud_From_Text_File : public CSG_Module
+{
+public:
+ CPointCloud_From_Text_File(void);
+ virtual ~CPointCloud_From_Text_File(void);
+
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Import") ); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__PointCloud_From_Text_File_H
diff --git a/src/modules_io/shapes/io_shapes/stl.cpp b/src/modules_io/shapes/io_shapes/stl.cpp
index 21b8ef0..7aef205 100644
--- a/src/modules_io/shapes/io_shapes/stl.cpp
+++ b/src/modules_io/shapes/io_shapes/stl.cpp
@@ -109,11 +109,12 @@ CSTL_Import::CSTL_Import(void)
Parameters.Add_Choice(
NULL , "METHOD" , _TL("Target"),
_TL(""),
- CSG_String::Format(SG_T("%s|%s|%s|"),
+ CSG_String::Format(SG_T("%s|%s|%s|%s|"),
_TL("point cloud"),
+ _TL("point cloud (centered)"),
_TL("points"),
_TL("raster")
- ), 2
+ ), 3
);
Parameters.Add_Value(
@@ -196,7 +197,36 @@ bool CSTL_Import::On_Execute(void)
{
//-----------------------------------------------------
- case 0: {
+ case 0: { // Point Cloud
+ CSG_Rect Extent;
+
+ if( Get_Extent(Stream, Extent, nFacettes) )
+ {
+ CSG_PRQuadTree Points(Extent);
+ CSG_PointCloud *pPoints = SG_Create_PointCloud();
+ Parameters("POINTS")->Set_Value(pPoints);
+ pPoints->Set_Name(SG_File_Get_Name(sFile, false));
+ pPoints->Add_Field((const char *)NULL, SG_DATATYPE_Undefined);
+
+ for(iFacette=0; iFacette<nFacettes && !Stream.is_EOF() && Set_Progress(iFacette, nFacettes); iFacette++)
+ {
+ if( Read_Facette(Stream, p) )
+ {
+ for(int i=0; i<3; i++)
+ {
+ if( Points.Add_Point(p[i].x, p[i].y, p[i].z) )
+ {
+ pPoints->Add_Point(p[i].x, p[i].y, p[i].z);
+ }
+ }
+ }
+ }
+ }
+
+ break; }
+
+ //-----------------------------------------------------
+ case 1: { // Point Cloud (centered)
CSG_PointCloud *pPoints = SG_Create_PointCloud();
Parameters("POINTS")->Set_Value(pPoints);
pPoints->Set_Name(SG_File_Get_Name(sFile, false));
@@ -217,7 +247,7 @@ bool CSTL_Import::On_Execute(void)
break; }
//-----------------------------------------------------
- case 1: {
+ case 2: { // Points
CSG_Shapes *pPoints = SG_Create_Shapes(SHAPE_TYPE_Point, SG_File_Get_Name(sFile, false));
pPoints->Add_Field(SG_T("Z"), SG_DATATYPE_Float);
Parameters("SHAPES")->Set_Value(pPoints);
@@ -242,40 +272,19 @@ bool CSTL_Import::On_Execute(void)
break; }
//-----------------------------------------------------
- case 2: {
- float xMin = 1, xMax = 0, yMin, yMax;
-
- for(iFacette=0; iFacette<nFacettes && !Stream.is_EOF() && Set_Progress(iFacette, nFacettes); iFacette++)
- {
- TSTL_Point p[3];
-
- if( Read_Facette(Stream, p) )
- {
- if( iFacette == 0 )
- {
- xMin = xMax = p[0].x;
- yMin = yMax = p[0].y;
- }
+ case 3: { // Raster
+ CSG_Rect Extent;
- for(int i=0; i<3; i++)
- {
- if( xMin > p[i].x ) { xMin = p[i].x; } else if( xMax < p[i].x ) { xMax = p[i].x; }
- if( yMin > p[i].y ) { yMin = p[i].y; } else if( yMax < p[i].y ) { yMax = p[i].y; }
- }
- }
- }
-
- //-------------------------------------------------
- if( xMin < xMax && yMin < yMax && Stream.Seek(80 + sizeof(nFacettes)) )
+ if( Get_Extent(Stream, Extent, nFacettes) )
{
int nx, ny;
double d;
nx = Parameters("GRID_RES")->asInt();
- d = (xMax - xMin) / nx;
- ny = 1 + (int)((yMax - yMin) / d);
+ d = Extent.Get_XRange() / nx;
+ ny = 1 + (int)(Extent.Get_YRange() / d);
- m_pGrid = SG_Create_Grid(SG_DATATYPE_Float, nx, ny, d, xMin, yMin);
+ m_pGrid = SG_Create_Grid(SG_DATATYPE_Float, nx, ny, d, Extent.Get_XMin(), Extent.Get_YMin());
m_pGrid->Set_Name(SG_File_Get_Name(sFile, false));
m_pGrid->Set_NoData_Value(-99999);
m_pGrid->Assign_NoData();
@@ -287,13 +296,13 @@ bool CSTL_Import::On_Execute(void)
{
if( Read_Facette(Stream, p) )
{
- TGRD_Point Point[3];
+ TSG_Point_Z Point[3];
for(int i=0; i<3; i++)
{
- Point[i].x = m_pGrid->Get_System().Get_xWorld_to_Grid(p[i].x);
- Point[i].y = m_pGrid->Get_System().Get_yWorld_to_Grid(p[i].y);
- Point[i].z = p[i].z;
+ Point[i].x = (p[i].x - m_pGrid->Get_XMin()) / m_pGrid->Get_Cellsize();
+ Point[i].y = (p[i].y - m_pGrid->Get_YMin()) / m_pGrid->Get_Cellsize();
+ Point[i].z = p[i].z;
}
Set_Triangle(Point);
@@ -358,136 +367,141 @@ inline void CSTL_Import::Rotate(TSTL_Point &p)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define SORT_POINTS_Y(a, b) if( p[a].y < p[b].y ) { pp = p[a]; p[a] = p[b]; p[b] = pp; }
-#define SORT_POINTS_X(a, b) if( p[a].x < p[b].x ) { pp = p[a]; p[a] = p[b]; p[b] = pp; }
-
-//---------------------------------------------------------
-void CSTL_Import::Set_Triangle(TGRD_Point p[3])
+bool CSTL_Import::Get_Extent(CSG_File &Stream, CSG_Rect &Extent, int nFacettes)
{
- int i, j, y, y_j;
- double x, x_a, dx, dx_a, dy, z, z_a, dz, dz_a;
- TGRD_Point pp;
-
- //-----------------------------------------------------
- SORT_POINTS_Y(1, 0);
- SORT_POINTS_Y(2, 0);
- SORT_POINTS_Y(2, 1);
+ float xMin = 1, xMax = 0, yMin, yMax;
- //-----------------------------------------------------
- if( p[2].y == p[0].y )
+ for(int iFacette=0; iFacette<nFacettes && !Stream.is_EOF() && Set_Progress(iFacette, nFacettes); iFacette++)
{
- if( p[0].y >= 0 && p[0].y < m_pGrid->Get_NY() )
- {
- SORT_POINTS_X(1, 0);
- SORT_POINTS_X(2, 0);
- SORT_POINTS_X(2, 1);
+ TSTL_Point p[3];
- //---------------------------------------------
- if( p[2].x == p[0].x )
+ if( Read_Facette(Stream, p) )
+ {
+ if( iFacette == 0 )
{
- if( p[0].x >= 0 && p[0].x < m_pGrid->Get_NX() )
- {
- Set_Triangle_Point(p[0].x, p[0].y, p[0].z > p[1].z
- ? (p[0].z > p[2].z ? p[0].z : p[2].z)
- : (p[1].z > p[2].z ? p[1].z : p[2].z)
- );
- }
+ xMin = xMax = p[0].x;
+ yMin = yMax = p[0].y;
}
- //---------------------------------------------
- else
+ for(int i=0; i<3; i++)
{
- Set_Triangle_Line(p[0].x, p[1].x, p[0].y, p[0].z, p[1].z);
- Set_Triangle_Line(p[1].x, p[2].x, p[0].y, p[1].z, p[2].z);
+ if( xMin > p[i].x ) { xMin = p[i].x; } else if( xMax < p[i].x ) { xMax = p[i].x; }
+ if( yMin > p[i].y ) { yMin = p[i].y; } else if( yMax < p[i].y ) { yMax = p[i].y; }
}
}
}
+ Extent.Assign(xMin, yMin, xMax, yMax);
+
+ return( xMin < xMax && yMin < yMax && Stream.Seek(80 + sizeof(nFacettes)) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CSTL_Import::Set_Triangle(TSG_Point_Z p[3])
+{
//-----------------------------------------------------
- else if( !((p[0].y < 0 && p[2].y < 0) || (p[0].y >= m_pGrid->Get_NY() && p[2].y >= m_pGrid->Get_NY())) )
- {
- dy = p[2].y - p[0].y;
- dx_a = (p[2].x - p[0].x) / dy;
- dz_a = (p[2].z - p[0].z) / dy;
- x_a = p[0].x;
- z_a = p[0].z;
+ if( p[1].y < p[0].y ) { TSG_Point_Z pp = p[1]; p[1] = p[0]; p[0] = pp; }
+ if( p[2].y < p[0].y ) { TSG_Point_Z pp = p[2]; p[2] = p[0]; p[0] = pp; }
+ if( p[2].y < p[1].y ) { TSG_Point_Z pp = p[2]; p[2] = p[1]; p[1] = pp; }
- for(i=0, j=1; i<2; i++, j++)
- {
- if( (dy = p[j].y - p[i].y) > 0.0 )
- {
- dx = (p[j].x - p[i].x) / dy;
- dz = (p[j].z - p[i].z) / dy;
- x = p[i].x;
- z = p[i].z;
+ //-----------------------------------------------------
+ TSG_Rect r;
- if( (y = p[i].y) < 0 )
- {
- x -= y * dx;
- z -= y * dz;
- y = 0;
- x_a = p[0].x - p[0].y * dx_a;
- z_a = p[0].z - p[0].y * dz_a;
- }
+ r.yMin = p[0].y;
+ r.yMax = p[2].y;
+ r.xMin = p[0].x < p[1].x ? (p[0].x < p[2].x ? p[0].x : p[2].x) : (p[1].x < p[2].x ? p[1].x : p[2].x);
+ r.xMax = p[0].x > p[1].x ? (p[0].x > p[2].x ? p[0].x : p[2].x) : (p[1].x > p[2].x ? p[1].x : p[2].x);
- if( (y_j = p[j].y) > m_pGrid->Get_NY() )
- {
- y_j = m_pGrid->Get_NY();
- }
+ if( r.yMin >= r.yMax || r.xMin >= r.xMax )
+ {
+ return; // no area
+ }
- for( ; y<y_j; y++, x+=dx, z+=dz, x_a+=dx_a, z_a+=dz_a)
- {
- if( x < x_a )
- {
- Set_Triangle_Line((int)x, (int)x_a, y, z, z_a);
- }
- else
- {
- Set_Triangle_Line((int)x_a, (int)x, y, z_a, z);
- }
- }
- }
- }
+ if( (r.yMin < 0.0 && r.yMax < 0.0) || (r.yMin >= m_pGrid->Get_NY() && r.yMax >= m_pGrid->Get_NY())
+ || (r.xMin < 0.0 && r.xMax < 0.0) || (r.xMin >= m_pGrid->Get_NX() && r.xMax >= m_pGrid->Get_NX()) )
+ {
+ return; // completely outside grid
}
-}
-//---------------------------------------------------------
-inline void CSTL_Import::Set_Triangle_Line(int xa, int xb, int y, double za, double zb)
-{
- double dz;
+ //-----------------------------------------------------
+ TSG_Point_Z d[3];
- if( (dz = xb - xa) > 0.0 )
+ if( (d[0].y = p[2].y - p[0].y) != 0.0 )
{
- dz = (zb - za) / dz;
+ d[0].x = (p[2].x - p[0].x) / d[0].y;
+ d[0].z = (p[2].z - p[0].z) / d[0].y;
+ }
- if( xa < 0 )
- {
- za -= dz * xa;
- xa = 0;
- }
+ if( (d[1].y = p[1].y - p[0].y) != 0.0 )
+ {
+ d[1].x = (p[1].x - p[0].x) / d[1].y;
+ d[1].z = (p[1].z - p[0].z) / d[1].y;
+ }
+
+ if( (d[2].y = p[2].y - p[1].y) != 0.0 )
+ {
+ d[2].x = (p[2].x - p[1].x) / d[2].y;
+ d[2].z = (p[2].z - p[1].z) / d[2].y;
+ }
+
+ //-----------------------------------------------------
+ int ay = (int)r.yMin; if( ay < 0 ) ay = 0; if( ay < r.yMin ) ay++;
+ int by = (int)r.yMax; if( by >= m_pGrid->Get_NY() ) by = m_pGrid->Get_NY() - 1;
- if( xb >= m_pGrid->Get_NX() )
+ for(int y=ay; y<=by; y++)
+ {
+ if( y <= p[1].y && d[1].y > 0.0 )
{
- xb = m_pGrid->Get_NX() - 1;
+ Set_Triangle_Line(y,
+ p[0].x + (y - p[0].y) * d[0].x,
+ p[0].z + (y - p[0].y) * d[0].z,
+ p[0].x + (y - p[0].y) * d[1].x,
+ p[0].z + (y - p[0].y) * d[1].z
+ );
}
-
- for(int x=xa; x<=xb; x++, za+=dz)
+ else if( d[2].y > 0.0 )
{
- Set_Triangle_Point(x, y, za);
+ Set_Triangle_Line(y,
+ p[0].x + (y - p[0].y) * d[0].x,
+ p[0].z + (y - p[0].y) * d[0].z,
+ p[1].x + (y - p[1].y) * d[2].x,
+ p[1].z + (y - p[1].y) * d[2].z
+ );
}
}
- else if( xa >= 0 && xa < m_pGrid->Get_NX() )
- {
- Set_Triangle_Point(xa, y, za);
- }
}
//---------------------------------------------------------
-inline void CSTL_Import::Set_Triangle_Point(int x, int y, double z)
+inline void CSTL_Import::Set_Triangle_Line(int y, double xa, double za, double xb, double zb)
{
- if( m_pGrid->is_NoData(x, y) || m_pGrid->asDouble(x, y) < z )
+ if( xb < xa )
+ {
+ double d;
+
+ d = xa; xa = xb; xb = d;
+ d = za; za = zb; zb = d;
+ }
+
+ if( xb > xa )
{
- m_pGrid->Set_Value(x, y, z);
+ double dz = (zb - za) / (xb - xa);
+ int ax = (int)xa; if( ax < 0 ) ax = 0; if( ax < xa ) ax++;
+ int bx = (int)xb; if( bx >= m_pGrid->Get_NX() ) bx = m_pGrid->Get_NX() - 1;
+
+ for(int x=ax; x<=bx; x++)
+ {
+ double z = za + dz * (x - xa);
+
+ if( m_pGrid->is_NoData(x, y) || m_pGrid->asDouble(x, y) < z )
+ {
+ m_pGrid->Set_Value(x, y, z);
+ }
+ }
}
}
diff --git a/src/modules_io/shapes/io_shapes/stl.h b/src/modules_io/shapes/io_shapes/stl.h
index 3392360..48a07bf 100644
--- a/src/modules_io/shapes/io_shapes/stl.h
+++ b/src/modules_io/shapes/io_shapes/stl.h
@@ -93,14 +93,6 @@ private:
}
TSTL_Point;
- typedef struct
- {
- int x, y;
-
- double z;
- }
- TGRD_Point;
-
double r_sin_x, r_cos_x, r_sin_y, r_cos_y, r_sin_z, r_cos_z;
@@ -110,9 +102,10 @@ private:
bool Read_Facette (CSG_File &Stream, TSTL_Point p[3]);
void Rotate (TSTL_Point &p);
- void Set_Triangle (TGRD_Point p[3]);
- void Set_Triangle_Line (int xa, int xb, int y, double za, double zb);
- void Set_Triangle_Point (int x, int y, double z);
+ bool Get_Extent (CSG_File &Stream, CSG_Rect &Extent, int nFacettes);
+
+ void Set_Triangle (TSG_Point_Z p[3]);
+ void Set_Triangle_Line (int y, double xa, double za, double xb, double zb);
};
diff --git a/src/modules_io/shapes/io_shapes/xyz.cpp b/src/modules_io/shapes/io_shapes/xyz.cpp
index 8f595e2..ad69010 100644
--- a/src/modules_io/shapes/io_shapes/xyz.cpp
+++ b/src/modules_io/shapes/io_shapes/xyz.cpp
@@ -1,363 +1,378 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// Shapes_IO //
-// //
-//-------------------------------------------------------//
-// //
-// Xyz.cpp //
-// //
-// Copyright (C) 2003 by //
-// Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "xyz.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// Export //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CXYZ_Export::CXYZ_Export(void)
-{
- CSG_Parameter *pNode_0, *pNode_1;
-
- //-----------------------------------------------------
- Set_Name(_TL("Export Shapes to XYZ"));
-
- Set_Author (SG_T("(c) 2003 by O.Conrad"));
-
- Set_Description(
- _TL("XYZ export filter for shapes. ")
- );
-
- //-----------------------------------------------------
- pNode_0 = Parameters.Add_Shapes(
- NULL , "SHAPES" , _TL("Shapes"),
- _TL(""),
- PARAMETER_INPUT
- );
-
- pNode_1 = Parameters.Add_Table_Field(
- pNode_0 , "FIELD" , _TL("Attribute"),
- _TL("")
- );
-
- pNode_0 = Parameters.Add_Value(
- NULL , "ALL" , _TL("Save All Attributes"),
- _TL("Ignores specified attribute ('Save Attribute') and saves all attributes."),
- PARAMETER_TYPE_Bool , false
- );
-
- pNode_0 = Parameters.Add_Value(
- NULL , "HEADER" , _TL("Save Table Header"),
- _TL(""),
- PARAMETER_TYPE_Bool , true
- );
-
- pNode_0 = Parameters.Add_Choice(
- NULL , "SEPARATE", _TL("Separate Line/Polygon Points"),
- _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|%s|"),
- _TL("none"),
- _TL("*"),
- _TL("number of points")
- ), 0
- );
-
- pNode_0 = Parameters.Add_FilePath(
- NULL , "FILENAME", _TL("File"),
- _TL(""),
- CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s"),
- _TL("XYZ Files (*.xyz)") , SG_T("*.xyz"),
- _TL("Text Files (*.txt)") , SG_T("*.txt"),
- _TL("All Files") , SG_T("*.*")
- ), NULL, true
- );
-}
-
-//---------------------------------------------------------
-CXYZ_Export::~CXYZ_Export(void)
-{}
-
-//---------------------------------------------------------
-bool CXYZ_Export::On_Execute(void)
-{
- bool bAll, bHeader;
- int iShape, iPart, iPoint, iField, Separate;
- FILE *Stream;
- TSG_Point Point;
- CSG_Shape *pShape;
- CSG_Shapes *pShapes;
- CSG_String fName;
-
- //-----------------------------------------------------
- pShapes = Parameters("SHAPES") ->asShapes();
- fName = Parameters("FILENAME")->asString();
- bAll = Parameters("ALL") ->asBool();
- bHeader = Parameters("HEADER") ->asBool();
- iField = Parameters("FIELD") ->asInt();
- Separate = pShapes->Get_Type() == SHAPE_TYPE_Point ? 0
- : Parameters("SEPARATE")->asInt();
-
- if( bAll && (iField < 0 || iField >= pShapes->Get_Field_Count()) )
- {
- return( false );
- }
-
- //-----------------------------------------------------
- if( (Stream = fopen(fName.b_str(), "w")) != NULL )
- {
- if( bHeader )
- {
- fprintf(Stream, "X\tY");
-
- if( bAll )
- {
- for(iField=0; iField<pShapes->Get_Field_Count(); iField++)
- {
- fprintf(Stream, "\t%s", pShapes->Get_Field_Name(iField));
- }
- }
- else
- {
- fprintf(Stream, "\tZ");
- }
-
- fprintf(Stream, "\n");
- }
-
- //-------------------------------------------------
- for(iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
- {
- pShape = pShapes->Get_Shape(iShape);
-
- for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
- {
- switch( Separate )
- {
- case 1: // *
- fprintf(Stream, "*\n");
- break;
-
- case 2: // number of points
- fprintf(Stream, "%d\n", pShape->Get_Point_Count(iPart));
- break;
- }
-
- for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
- {
- Point = pShape->Get_Point(iPoint, iPart);
- fprintf(Stream, "%f\t%f", Point.x, Point.y);
-
- if( bAll )
- {
- for(iField=0; iField<pShapes->Get_Field_Count(); iField++)
- {
- switch( pShapes->Get_Field_Type(iField) )
- {
- case SG_DATATYPE_String:
- fprintf(Stream, "\t\"%s\"" ,pShape->asString(iField));
- break;
-
- default:
- fprintf(Stream, "\t%f" ,pShape->asDouble(iField));
- break;
- }
- }
- }
- else
- {
- switch( pShapes->Get_Field_Type(iField) )
- {
- case SG_DATATYPE_String:
- fprintf(Stream, "\t\"%s\"" ,pShape->asString(iField));
- break;
-
- default:
- fprintf(Stream, "\t%f" ,pShape->asDouble(iField));
- break;
- }
- }
-
- fprintf(Stream, "\n");
- }
- }
- }
-
- //-------------------------------------------------
- fclose(Stream);
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// Import //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CXYZ_Import::CXYZ_Import(void)
-{
- CSG_Parameter *pNode_0, *pNode_1;
-
- //-----------------------------------------------------
- Set_Name(_TL("Import Shapes from XYZ"));
-
- Set_Author (SG_T("(c) 2003 by O.Conrad"));
-
- Set_Description(
- _TL("Point shapes import from text formated XYZ-table.")
- );
-
- //-----------------------------------------------------
- pNode_0 = Parameters.Add_Shapes(
- NULL , "SHAPES" , _TL("Points"),
- _TL(""),
- PARAMETER_OUTPUT, SHAPE_TYPE_Point
- );
-
-// pNode_0 = Parameters.Add_Value(
-// NULL , "HEADLINE" , "File contains headline",
-// _TL(""),
-// PARAMETER_TYPE_Bool , true
-// );
-
- pNode_1 = Parameters.Add_Value(
- pNode_0 , "X_FIELD" , _TL("X Column"),
- _TL(""),
- PARAMETER_TYPE_Int , 1, 1, true
- );
-
- pNode_1 = Parameters.Add_Value(
- pNode_0 , "Y_FIELD" , _TL("Y Column"),
- _TL(""),
- PARAMETER_TYPE_Int , 2, 1, true
- );
-
- pNode_0 = Parameters.Add_FilePath(
- NULL , "FILENAME" , _TL("File"),
- _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s"),
- _TL("XYZ Files (*.xyz)") , SG_T("*.xyz"),
- _TL("Text Files (*.txt)") , SG_T("*.txt"),
- _TL("All Files") , SG_T("*.*")
- ), NULL, false
- );
-}
-
-//---------------------------------------------------------
-CXYZ_Import::~CXYZ_Import(void)
-{}
-
-//---------------------------------------------------------
-bool CXYZ_Import::On_Execute(void)
-{
- int xField, yField, iRecord;
- CSG_Table Table;
- CSG_Table_Record *pRecord;
- CSG_Shapes *pShapes;
- CSG_Shape *pShape;
-
- //-----------------------------------------------------
- pShapes = Parameters("SHAPES") ->asShapes();
- xField = Parameters("X_FIELD") ->asInt() - 1;
- yField = Parameters("Y_FIELD") ->asInt() - 1;
-
- //-----------------------------------------------------
- if( !Table.Create(Parameters("FILENAME")->asString()) ) // Parameters("HEADLINE")->asBool()
- {
- Message_Add(_TL("Table could not be opened."));
- }
- else if( Table.Get_Record_Count() <= 0 )
- {
- Message_Add(_TL("Table does not contain any data."));
- }
- else if( xField == yField || xField < 0 || xField >= Table.Get_Field_Count() || yField < 0 || yField >= Table.Get_Field_Count() )
- {
- Message_Add(_TL("Invalid X/Y fields."));
- }
-
- //-----------------------------------------------------
- else
- {
- pShapes->Create(SHAPE_TYPE_Point, Table.Get_Name(), &Table);
-
- for(iRecord=0; iRecord<Table.Get_Record_Count(); iRecord++)
- {
- pRecord = Table.Get_Record(iRecord);
- pShape = pShapes->Add_Shape(pRecord);
- pShape->Add_Point(pRecord->asDouble(xField), pRecord->asDouble(yField));
- }
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// Shapes_IO //
+// //
+//-------------------------------------------------------//
+// //
+// Xyz.cpp //
+// //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "xyz.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// Export //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CXYZ_Export::CXYZ_Export(void)
+{
+ CSG_Parameter *pNode_0, *pNode_1;
+
+ //-----------------------------------------------------
+ Set_Name(_TL("Export Shapes to XYZ"));
+
+ Set_Author (SG_T("(c) 2003 by O.Conrad"));
+
+ Set_Description(
+ _TL("XYZ export filter for shapes. ")
+ );
+
+ //-----------------------------------------------------
+ pNode_0 = Parameters.Add_Shapes(
+ NULL , "SHAPES" , _TL("Shapes"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ pNode_1 = Parameters.Add_Table_Field(
+ pNode_0 , "FIELD" , _TL("Attribute"),
+ _TL("")
+ );
+
+ pNode_0 = Parameters.Add_Value(
+ NULL , "ALL" , _TL("Save All Attributes"),
+ _TL("Ignores specified attribute ('Save Attribute') and saves all attributes."),
+ PARAMETER_TYPE_Bool , false
+ );
+
+ pNode_0 = Parameters.Add_Value(
+ NULL , "HEADER" , _TL("Save Table Header"),
+ _TL(""),
+ PARAMETER_TYPE_Bool , true
+ );
+
+ pNode_0 = Parameters.Add_Choice(
+ NULL , "SEPARATE", _TL("Separate Line/Polygon Points"),
+ _TL(""),
+
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("none"),
+ _TL("*"),
+ _TL("number of points")
+ ), 0
+ );
+
+ pNode_0 = Parameters.Add_FilePath(
+ NULL , "FILENAME", _TL("File"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s"),
+ _TL("XYZ Files (*.xyz)") , SG_T("*.xyz"),
+ _TL("Text Files (*.txt)") , SG_T("*.txt"),
+ _TL("All Files") , SG_T("*.*")
+ ), NULL, true
+ );
+}
+
+//---------------------------------------------------------
+CXYZ_Export::~CXYZ_Export(void)
+{}
+
+//---------------------------------------------------------
+bool CXYZ_Export::On_Execute(void)
+{
+ bool bAll, bHeader, bPCloud;
+ int iShape, iPart, iPoint, iField, Separate;
+ FILE *Stream;
+ TSG_Point Point;
+ CSG_Shape *pShape;
+ CSG_Shapes *pShapes;
+ CSG_String fName;
+
+ //-----------------------------------------------------
+ pShapes = Parameters("SHAPES") ->asShapes();
+ fName = Parameters("FILENAME")->asString();
+ bAll = Parameters("ALL") ->asBool();
+ bHeader = Parameters("HEADER") ->asBool();
+ iField = Parameters("FIELD") ->asInt();
+ Separate = pShapes->Get_Type() == SHAPE_TYPE_Point ? 0
+ : Parameters("SEPARATE")->asInt();
+
+ if( bAll && (iField < 0 || iField >= pShapes->Get_Field_Count()) )
+ {
+ return( false );
+ }
+
+ if( pShapes->Get_ObjectType() == DATAOBJECT_TYPE_PointCloud )
+ bPCloud = true;
+ else
+ bPCloud = false;
+
+ //-----------------------------------------------------
+ if( (Stream = fopen(fName.b_str(), "w")) != NULL )
+ {
+ if( bHeader )
+ {
+ fprintf(Stream, "X\tY");
+
+ if( bAll )
+ {
+ if (bPCloud)
+ iField = 2;
+ else
+ iField = 0;
+
+ for(iField; iField<pShapes->Get_Field_Count(); iField++)
+ {
+ fprintf(Stream, "\t%s", pShapes->Get_Field_Name(iField));
+ }
+ }
+ else
+ {
+ fprintf(Stream, "\tZ");
+ }
+
+ fprintf(Stream, "\n");
+ }
+
+ //-------------------------------------------------
+ for(iShape=0; iShape<pShapes->Get_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++)
+ {
+ pShape = pShapes->Get_Shape(iShape);
+
+ for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ switch( Separate )
+ {
+ case 1: // *
+ fprintf(Stream, "*\n");
+ break;
+
+ case 2: // number of points
+ fprintf(Stream, "%d\n", pShape->Get_Point_Count(iPart));
+ break;
+ }
+
+ for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ Point = pShape->Get_Point(iPoint, iPart);
+ fprintf(Stream, "%f\t%f", Point.x, Point.y);
+
+ if( bAll )
+ {
+ if (bPCloud)
+ iField = 2;
+ else
+ iField = 0;
+
+ for(iField; iField<pShapes->Get_Field_Count(); iField++)
+ {
+ switch( pShapes->Get_Field_Type(iField) )
+ {
+ case SG_DATATYPE_String:
+ fprintf(Stream, "\t\"%s\"" ,pShape->asString(iField));
+ break;
+
+ default:
+ fprintf(Stream, "\t%f" ,pShape->asDouble(iField));
+ break;
+ }
+ }
+ }
+ else
+ {
+ switch( pShapes->Get_Field_Type(iField) )
+ {
+ case SG_DATATYPE_String:
+ fprintf(Stream, "\t\"%s\"" ,pShape->asString(iField));
+ break;
+
+ default:
+ fprintf(Stream, "\t%f" ,pShape->asDouble(iField));
+ break;
+ }
+ }
+
+ fprintf(Stream, "\n");
+ }
+ }
+ }
+
+ //-------------------------------------------------
+ fclose(Stream);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Import //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CXYZ_Import::CXYZ_Import(void)
+{
+ CSG_Parameter *pNode_0, *pNode_1;
+
+ //-----------------------------------------------------
+ Set_Name(_TL("Import Shapes from XYZ"));
+
+ Set_Author (SG_T("(c) 2003 by O.Conrad"));
+
+ Set_Description(
+ _TL("Point shapes import from text formated XYZ-table.")
+ );
+
+ //-----------------------------------------------------
+ pNode_0 = Parameters.Add_Shapes(
+ NULL , "SHAPES" , _TL("Points"),
+ _TL(""),
+ PARAMETER_OUTPUT, SHAPE_TYPE_Point
+ );
+
+// pNode_0 = Parameters.Add_Value(
+// NULL , "HEADLINE" , "File contains headline",
+// _TL(""),
+// PARAMETER_TYPE_Bool , true
+// );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "X_FIELD" , _TL("X Column"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 1, 1, true
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "Y_FIELD" , _TL("Y Column"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 2, 1, true
+ );
+
+ pNode_0 = Parameters.Add_FilePath(
+ NULL , "FILENAME" , _TL("File"),
+ _TL(""),
+
+ CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s"),
+ _TL("XYZ Files (*.xyz)") , SG_T("*.xyz"),
+ _TL("Text Files (*.txt)") , SG_T("*.txt"),
+ _TL("All Files") , SG_T("*.*")
+ ), NULL, false
+ );
+}
+
+//---------------------------------------------------------
+CXYZ_Import::~CXYZ_Import(void)
+{}
+
+//---------------------------------------------------------
+bool CXYZ_Import::On_Execute(void)
+{
+ int xField, yField, iRecord;
+ CSG_Table Table;
+ CSG_Table_Record *pRecord;
+ CSG_Shapes *pShapes;
+ CSG_Shape *pShape;
+
+ //-----------------------------------------------------
+ pShapes = Parameters("SHAPES") ->asShapes();
+ xField = Parameters("X_FIELD") ->asInt() - 1;
+ yField = Parameters("Y_FIELD") ->asInt() - 1;
+
+ //-----------------------------------------------------
+ if( !Table.Create(Parameters("FILENAME")->asString()) ) // Parameters("HEADLINE")->asBool()
+ {
+ Message_Add(_TL("Table could not be opened."));
+ }
+ else if( Table.Get_Record_Count() <= 0 )
+ {
+ Message_Add(_TL("Table does not contain any data."));
+ }
+ else if( xField == yField || xField < 0 || xField >= Table.Get_Field_Count() || yField < 0 || yField >= Table.Get_Field_Count() )
+ {
+ Message_Add(_TL("Invalid X/Y fields."));
+ }
+
+ //-----------------------------------------------------
+ else
+ {
+ pShapes->Create(SHAPE_TYPE_Point, Table.Get_Name(), &Table);
+
+ for(iRecord=0; iRecord<Table.Get_Record_Count(); iRecord++)
+ {
+ pRecord = Table.Get_Record(iRecord);
+ pShape = pShapes->Add_Shape(pRecord);
+ pShape->Add_Point(pRecord->asDouble(xField), pRecord->asDouble(yField));
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_io/shapes/io_shapes_dxf/Makefile.am b/src/modules_io/shapes/io_shapes_dxf/Makefile.am
index 40c8ab0..80abd43 100644
--- a/src/modules_io/shapes/io_shapes_dxf/Makefile.am
+++ b/src/modules_io/shapes/io_shapes_dxf/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.1 2007/10/08 15:31:19 oconrad Exp $
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:50 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libio_shapes_dxf.la
libio_shapes_dxf_la_SOURCES =\
dxf_import.cpp\
diff --git a/src/modules_io/shapes/io_shapes_dxf/Makefile.in b/src/modules_io/shapes/io_shapes_dxf/Makefile.in
index 7888b6b..be5aa82 100644
--- a/src/modules_io/shapes/io_shapes_dxf/Makefile.in
+++ b/src/modules_io/shapes/io_shapes_dxf/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -72,7 +71,7 @@ libio_shapes_dxf_la_DEPENDENCIES = \
am_libio_shapes_dxf_la_OBJECTS = dxf_import.lo MLB_Interface.lo \
dl_dxf.lo dl_writer_ascii.lo
libio_shapes_dxf_la_OBJECTS = $(am_libio_shapes_dxf_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -118,6 +117,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -127,6 +127,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -217,14 +218,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.1 2007/10/08 15:31:19 oconrad Exp $
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:50 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libio_shapes_dxf.la
libio_shapes_dxf_la_SOURCES = \
dxf_import.cpp\
diff --git a/src/modules_io/shapes/io_shapes_dxf/dxf_import.h b/src/modules_io/shapes/io_shapes_dxf/dxf_import.h
index 844d18a..c656eb2 100644
--- a/src/modules_io/shapes/io_shapes_dxf/dxf_import.h
+++ b/src/modules_io/shapes/io_shapes_dxf/dxf_import.h
@@ -100,7 +100,7 @@ private:
double m_dArc;
- TSG_Point_3D m_Offset;
+ TSG_Point_Z m_Offset;
CSG_Shape *m_pPolyLine;
diff --git a/src/modules_io/table/Makefile.in b/src/modules_io/table/Makefile.in
index 0e8f7f8..7c04f8c 100644
--- a/src/modules_io/table/Makefile.in
+++ b/src/modules_io/table/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_io/table/io_table/MLB_Interface.cpp b/src/modules_io/table/io_table/MLB_Interface.cpp
index 473efd3..7ae18b7 100644
--- a/src/modules_io/table/io_table/MLB_Interface.cpp
+++ b/src/modules_io/table/io_table/MLB_Interface.cpp
@@ -104,6 +104,7 @@ CSG_Module * Create_Module(int i)
case 0: return( new CTable_Text_Export );
case 1: return( new CTable_Text_Import );
case 2: return( new CTable_Text_Import_Numbers );
+ case 3: return( new CTable_Text_Import_Fixed_Cols );
}
return( NULL );
diff --git a/src/modules_io/table/io_table/Makefile.am b/src/modules_io/table/io_table/Makefile.am
index bf5a3ae..bb1ba82 100644
--- a/src/modules_io/table/io_table/Makefile.am
+++ b/src/modules_io/table/io_table/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.1 2008/09/18 15:13:25 oconrad Exp $
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:51 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libio_table.la
libio_table_la_SOURCES =\
io_table_txt.cpp\
diff --git a/src/modules_io/table/io_table/Makefile.in b/src/modules_io/table/io_table/Makefile.in
index 8e83b94..00780cc 100644
--- a/src/modules_io/table/io_table/Makefile.in
+++ b/src/modules_io/table/io_table/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -71,7 +70,7 @@ libio_table_la_DEPENDENCIES = \
$(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
am_libio_table_la_OBJECTS = io_table_txt.lo MLB_Interface.lo
libio_table_la_OBJECTS = $(am_libio_table_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -117,6 +116,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -126,6 +126,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -216,14 +217,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.1 2008/09/18 15:13:25 oconrad Exp $
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:51 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libio_table.la
libio_table_la_SOURCES = \
io_table_txt.cpp\
diff --git a/src/modules_io/table/io_table/io_table_txt.cpp b/src/modules_io/table/io_table/io_table_txt.cpp
index ac92070..393f4d7 100644
--- a/src/modules_io/table/io_table/io_table_txt.cpp
+++ b/src/modules_io/table/io_table/io_table_txt.cpp
@@ -223,7 +223,7 @@ CTable_Text_Import::CTable_Text_Import(void)
//-----------------------------------------------------
Parameters.Add_Table(
- NULL , "TABLE" , _TL("Points"),
+ NULL , "TABLE" , _TL("Table"),
_TL(""),
PARAMETER_OUTPUT
);
@@ -453,3 +453,236 @@ bool CTable_Text_Import_Numbers::On_Execute(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+CTable_Text_Import_Fixed_Cols::CTable_Text_Import_Fixed_Cols(void)
+{
+ Set_Name (_TL("Import Text Table (Fixed Column Sizes)"));
+
+ Set_Author (SG_T("O. Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ ""
+ ));
+
+ //-----------------------------------------------------
+ Parameters.Add_Table(
+ NULL , "TABLE" , _TL("Table"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Value(
+ NULL , "HEADLINE" , _TL("File contains headline"),
+ _TL(""),
+ PARAMETER_TYPE_Bool , true
+ );
+
+ Parameters.Add_Choice(
+ NULL , "FIELDDEF" , _TL("Field Definition"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("mark breaks in first line"),
+ _TL("specify fields with type")
+ ), 0
+ );
+
+ Parameters.Add_Value(
+ NULL , "NFIELDS" , _TL("Numver of Fields"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 1, 1, true
+ );
+
+ Parameters.Add_FilePath(
+ NULL , "FILENAME" , _TL("File"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|%s"),
+ _TL("Text Files (*.txt)") , SG_T("*.txt"),
+ _TL("All Files") , SG_T("*.*")
+ ), NULL, false
+ );
+
+ Add_Parameters("BREAKS", _TL("Breaks"), _TL(""));
+ Add_Parameters("FIELDS", _TL("Fields"), _TL(""));
+}
+
+//---------------------------------------------------------
+bool CTable_Text_Import_Fixed_Cols::On_Execute(void)
+{
+ bool bHeader;
+ int i, nChars, iField, nFields, *iFirst, *iLength;
+ CSG_String sLine;
+ CSG_File Stream;
+ CSG_Table *pTable;
+
+ //-----------------------------------------------------
+ pTable = Parameters("TABLE") ->asTable();
+ bHeader = Parameters("HEADLINE") ->asBool();
+
+ //-----------------------------------------------------
+ if( !Stream.Open(Parameters("FILENAME")->asString(), SG_FILE_R, true) )
+ {
+ Message_Add(_TL("file could not be opened"));
+
+ return( false );
+ }
+
+ if( !Stream.Read_Line(sLine) || (nChars = sLine.Length()) <= 0 )
+ {
+ Message_Add(_TL("empty or corrupted file"));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ pTable->Destroy();
+ pTable->Set_Name(SG_File_Get_Name(Parameters("FILENAME")->asString(), false));
+
+ //-----------------------------------------------------
+ if( Parameters("FIELDDEF")->asInt() == 0 )
+ {
+ CSG_Parameters *pBreaks = Get_Parameters("BREAKS");
+
+ pBreaks->Del_Parameters();
+
+ for(i=0; i<nChars; i++)
+ {
+ pBreaks->Add_Value(NULL,
+ CSG_String::Format(SG_T("%03d"), i),
+ CSG_String::Format(SG_T("%03d %c"), i + 1, sLine[i]),
+ _TL(""), PARAMETER_TYPE_Bool, false
+ );
+ }
+
+ if( !Dlg_Parameters("BREAKS") )
+ {
+ return( false );
+ }
+
+ //-------------------------------------------------
+ for(i=0, nFields=1; i<pBreaks->Get_Count(); i++)
+ {
+ if( pBreaks->Get_Parameter(i)->asBool() )
+ {
+ nFields++;
+ }
+ }
+
+ //-------------------------------------------------
+ iFirst = new int[nFields];
+ iLength = new int[nFields];
+
+ iFirst[0] = 0;
+
+ for(i=0, iField=1; i<pBreaks->Get_Count() && iField<nFields; i++)
+ {
+ if( pBreaks->Get_Parameter(i)->asBool() )
+ {
+ iFirst[iField++] = i + 1;
+ }
+ }
+
+ //-------------------------------------------------
+ for(iField=0; iField<nFields; iField++)
+ {
+ iLength[iField] = (iField < nFields - 1 ? iFirst[iField + 1] : sLine.Length()) - iFirst[iField];
+
+ pTable->Add_Field(bHeader ? sLine.Mid(iFirst[iField], iLength[iField]) : CSG_String::Format(SG_T("FIELD%03d"), iField + 1), SG_DATATYPE_String);
+ }
+ }
+
+ //-----------------------------------------------------
+ else
+ {
+ CSG_Parameters *pFields = Get_Parameters("FIELDS");
+
+ pFields->Del_Parameters();
+
+ nFields = Parameters("NFIELDS")->asInt();
+
+ for(iField=0; iField<nFields; iField++)
+ {
+ CSG_String s = CSG_String::Format(SG_T("%03d"), iField);
+ CSG_Parameter *pNode = pFields->Add_Node(NULL, SG_T("NODE") + s, _TL("Field") + s, _TL(""));
+ pFields->Add_Value (pNode, SG_T("LENGTH") + s, _TL("Length"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true);
+ // pFields->Add_Value (pNode, SG_T("IMPORT") + s, _TL("Import"), _TL(""), PARAMETER_TYPE_Bool, true);
+ pFields->Add_Choice (pNode, SG_T("TYPE") + s, _TL("Type") , _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"),
+ _TL("text"),
+ _TL("2 byte integer"),
+ _TL("4 byte integer"),
+ _TL("4 byte float"),
+ _TL("8 byte float"))
+ );
+ }
+
+ if( !Dlg_Parameters("FIELDS") )
+ {
+ return( false );
+ }
+
+ //-------------------------------------------------
+ iFirst = new int[nFields];
+ iLength = new int[nFields];
+
+ iFirst[0] = 0;
+
+ for(iField=0, i=0; iField<nFields && i<nChars; iField++)
+ {
+ CSG_String s = CSG_String::Format(SG_T("%03d"), iField);
+
+ iFirst [iField] = i;
+ iLength[iField] = pFields->Get_Parameter(SG_T("LENGTH") + s)->asInt();
+
+ i += iLength[iField];
+
+ CSG_String Name = bHeader ? sLine.Mid(iFirst[iField], iLength[iField]) : CSG_String::Format(SG_T("FIELD%03d"), iField + 1);
+
+ switch( pFields->Get_Parameter(SG_T("TYPE") + s)->asInt() )
+ {
+ default:
+ case 0: pTable->Add_Field(Name, SG_DATATYPE_String); break;
+ case 1: pTable->Add_Field(Name, SG_DATATYPE_Short); break;
+ case 2: pTable->Add_Field(Name, SG_DATATYPE_Int); break;
+ case 3: pTable->Add_Field(Name, SG_DATATYPE_Float); break;
+ case 4: pTable->Add_Field(Name, SG_DATATYPE_Double); break;
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ if( bHeader )
+ {
+ Stream.Read_Line(sLine);
+ }
+
+ //-----------------------------------------------------
+ int fLength = Stream.Length();
+
+ do
+ {
+ if( sLine.Length() == nChars )
+ {
+ CSG_Table_Record *pRecord = pTable->Add_Record();
+
+ for(iField=0; iField<nFields; iField++)
+ {
+ pRecord->Set_Value(iField, sLine.Mid(iFirst[iField], iLength[iField]));
+ }
+ }
+ }
+ while( Stream.Read_Line(sLine) && Set_Progress(Stream.Tell(), fLength) );
+
+ //-----------------------------------------------------
+ delete[](iFirst);
+ delete[](iLength);
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_io/table/io_table/io_table_txt.h b/src/modules_io/table/io_table/io_table_txt.h
index cfb8d69..a7a5412 100644
--- a/src/modules_io/table/io_table/io_table_txt.h
+++ b/src/modules_io/table/io_table/io_table_txt.h
@@ -123,6 +123,21 @@ protected:
};
+//---------------------------------------------------------
+class CTable_Text_Import_Fixed_Cols : public CSG_Module
+{
+public:
+ CTable_Text_Import_Fixed_Cols(void);
+
+ virtual const SG_Char * Get_MenuPath(void) { return( _TL("R:Import") ); }
+
+
+protected:
+
+ virtual bool On_Execute(void);
+
+};
+
///////////////////////////////////////////////////////////
// //
diff --git a/src/modules_lectures/Makefile.in b/src/modules_lectures/Makefile.in
index daf166e..4825e30 100644
--- a/src/modules_lectures/Makefile.in
+++ b/src/modules_lectures/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_lectures/lectures/Makefile.in b/src/modules_lectures/lectures/Makefile.in
index ba8ed98..ffc6dbe 100644
--- a/src/modules_lectures/lectures/Makefile.in
+++ b/src/modules_lectures/lectures/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_lectures/lectures/lectures_introduction/Exercise_01.cpp b/src/modules_lectures/lectures/lectures_introduction/Exercise_01.cpp
index e3d1ac8..ad8bfd9 100644
--- a/src/modules_lectures/lectures/lectures_introduction/Exercise_01.cpp
+++ b/src/modules_lectures/lectures/lectures_introduction/Exercise_01.cpp
@@ -110,7 +110,7 @@ CExercise_01::CExercise_01(void)
_TL("Choose a method"),
CSG_String::Format(SG_T("%s|%s|%s|%s|"),
- _TL("Addition|"),
+ _TL("Addition"),
_TL("Subtraction"),
_TL("Multiplication"),
_TL("Division")
diff --git a/src/modules_lectures/lectures/lectures_introduction/Makefile.am b/src/modules_lectures/lectures/lectures_introduction/Makefile.am
index 689a9ef..431a2ee 100644
--- a/src/modules_lectures/lectures/lectures_introduction/Makefile.am
+++ b/src/modules_lectures/lectures/lectures_introduction/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:26 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = liblectures_introduction.la
liblectures_introduction_la_SOURCES =\
Exercise_01.cpp\
diff --git a/src/modules_lectures/lectures/lectures_introduction/Makefile.in b/src/modules_lectures/lectures/lectures_introduction/Makefile.in
index 38e15e5..11d528b 100644
--- a/src/modules_lectures/lectures/lectures_introduction/Makefile.in
+++ b/src/modules_lectures/lectures/lectures_introduction/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -76,7 +75,7 @@ am_liblectures_introduction_la_OBJECTS = Exercise_01.lo Exercise_02.lo \
MLB_Interface.lo
liblectures_introduction_la_OBJECTS = \
$(am_liblectures_introduction_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -122,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -131,6 +131,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -221,14 +222,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:26 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = liblectures_introduction.la
liblectures_introduction_la_SOURCES = \
Exercise_01.cpp\
diff --git a/src/modules_projection/Makefile.in b/src/modules_projection/Makefile.in
index 35ba393..5595163 100644
--- a/src/modules_projection/Makefile.in
+++ b/src/modules_projection/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_projection/pj_georeference/Makefile.in b/src/modules_projection/pj_georeference/Makefile.in
index 607b643..2e8ada6 100644
--- a/src/modules_projection/pj_georeference/Makefile.in
+++ b/src/modules_projection/pj_georeference/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_projection/pj_georeference/pj_georeference/Georef_Grid.cpp b/src/modules_projection/pj_georeference/pj_georeference/Georef_Grid.cpp
index 3b1e952..28569c9 100644
--- a/src/modules_projection/pj_georeference/pj_georeference/Georef_Grid.cpp
+++ b/src/modules_projection/pj_georeference/pj_georeference/Georef_Grid.cpp
@@ -62,8 +62,6 @@
//---------------------------------------------------------
#include "Georef_Grid.h"
-#include <string.h>
-
///////////////////////////////////////////////////////////
// //
@@ -100,11 +98,6 @@ CGeoref_Grid::CGeoref_Grid(void)
//-----------------------------------------------------
- Parameters.Add_Grid_Output(
- NULL , "GRID" , _TL("Grid"),
- _TL("")
- );
-
Parameters.Add_Shapes_Output(
NULL , "SHAPES" , _TL("Shapes"),
_TL("")
@@ -142,23 +135,8 @@ CGeoref_Grid::CGeoref_Grid(void)
);
Parameters.Add_Choice(
- Parameters("TARGET_NODE"),
- "TARGET_TYPE" , _TL("Target"),
- _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"),
- _TL("User defined"),
- _TL("Automatic fit"),
- _TL("Grid Project"),
- _TL("Grid"),
- _TL("Shapes")
- ), 0
- );
-
- Parameters.Add_Choice(
Parameters("TARGET_NODE") , "INTERPOLATION" , _TL("Grid Interpolation"),
_TL(""),
-
CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"),
_TL("Nearest Neigbhor"),
_TL("Bilinear Interpolation"),
@@ -170,64 +148,20 @@ CGeoref_Grid::CGeoref_Grid(void)
//-----------------------------------------------------
- pParameters = Add_Parameters("GET_AUTOFIT" , _TL("Automatic fit") , _TL(""));
-
- pParameters->Add_Value(
- NULL, "GRIDSIZE" , _TL("Grid Size") , _TL(""), PARAMETER_TYPE_Double, 10000.0, 0.0, true
- );
-
- pParameters->Add_Choice(
- NULL, "AUTOEXTMODE" , _TL("Fit Size") , _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|"),
- _TL("Extent only (fast)"),
- _TL("Check each point")
+ Parameters.Add_Choice(
+ Parameters("TARGET_NODE"),
+ "TARGET_TYPE" , _TL("Target"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("user defined"),
+ _TL("grid"),
+ _TL("shapes")
), 0
);
-
//-----------------------------------------------------
- pParameters = Add_Parameters("GET_USER" , _TL("User defined") , _TL(""));
-
- pParameters->Add_Value(
- NULL, "XMIN" , _TL("Left") , _TL(""), PARAMETER_TYPE_Double
- );
- pParameters->Add_Value(
- NULL, "XMAX" , _TL("Right") , _TL(""), PARAMETER_TYPE_Double
- );
- pParameters->Add_Value(
- NULL, "YMIN" , _TL("Bottom") , _TL(""), PARAMETER_TYPE_Double
- );
- pParameters->Add_Value(
- NULL, "YMAX" , _TL("Top") , _TL(""), PARAMETER_TYPE_Double
- );
-
- pParameters->Add_Value(
- NULL, "SIZE" , _TL("Grid Size") , _TL(""), PARAMETER_TYPE_Double, 10000.0, 0.0, true
- );
-
- pParameters->Add_Info_Value(
- NULL, "NX" , _TL("Columns") , _TL(""), PARAMETER_TYPE_Int
- );
- pParameters->Add_Info_Value(
- NULL, "NY" , _TL("Rows") , _TL(""), PARAMETER_TYPE_Int
- );
-
-
- //-----------------------------------------------------
- pParameters = Add_Parameters("GET_SYSTEM" , _TL("Choose Grid Project"), _TL(""));
-
- pParameters->Add_Grid_System(
- NULL, "SYSTEM" , _TL("System") , _TL("")
- );
-
- //-----------------------------------------------------
- pParameters = Add_Parameters("GET_GRID" , _TL("Choose Grid") , _TL(""));
-
- pParameters->Add_Grid(
- NULL, "GRID" , _TL("Grid") , _TL(""), PARAMETER_INPUT , false
- );
-
+ m_Grid_Target.Add_Parameters_User(Add_Parameters("GET_USER", _TL("User Defined Grid") , _TL("")));
+ m_Grid_Target.Add_Parameters_Grid(Add_Parameters("GET_GRID", _TL("Choose Grid") , _TL("")));
//-----------------------------------------------------
pParameters = Add_Parameters("GET_SHAPES" , _TL("Choose Shapes") , _TL(""));
@@ -237,10 +171,6 @@ CGeoref_Grid::CGeoref_Grid(void)
);
}
-//---------------------------------------------------------
-CGeoref_Grid::~CGeoref_Grid(void)
-{}
-
///////////////////////////////////////////////////////////
// //
@@ -251,72 +181,7 @@ CGeoref_Grid::~CGeoref_Grid(void)
//---------------------------------------------------------
int CGeoref_Grid::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
{
- double xMin, xMax, yMin, yMax, size;
-
- if( !SG_STR_CMP(pParameters->Get_Identifier(), SG_T("GET_USER")) )
- {
- xMin = pParameters->Get_Parameter("XMIN")->asDouble();
- xMax = pParameters->Get_Parameter("XMAX")->asDouble();
- yMin = pParameters->Get_Parameter("YMIN")->asDouble();
- yMax = pParameters->Get_Parameter("YMAX")->asDouble();
- size = pParameters->Get_Parameter("SIZE")->asDouble();
-
- if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("SIZE")) )
- {
- pParameters->Get_Parameter("XMAX")->Set_Value((xMax = xMin + ((int)((xMax - xMin) / size)) * size));
- pParameters->Get_Parameter("YMAX")->Set_Value((yMax = yMin + ((int)((yMax - yMin) / size)) * size));
- }
- else
- {
- if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("XMIN")) )
- {
- if( xMin >= xMax )
- {
- xMin = xMax - pParameters->Get_Parameter("NX")->asInt() * size;
- pParameter->Set_Value(xMin);
- }
-
- pParameters->Get_Parameter("XMAX")->Set_Value(xMin + ((int)((xMax - xMin) / size)) * size);
- }
- else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("XMAX")) )
- {
- if( xMin >= xMax )
- {
- xMax = xMin + pParameters->Get_Parameter("NX")->asInt() * size;
- pParameter->Set_Value(xMax);
- }
-
- pParameters->Get_Parameter("XMIN")->Set_Value(xMax - ((int)((xMax - xMin) / size)) * size);
- }
- else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("YMIN")) )
- {
- if( yMin >= yMax )
- {
- yMin = yMax - pParameters->Get_Parameter("NY")->asInt() * size;
- pParameter->Set_Value(yMin);
- }
-
- pParameters->Get_Parameter("YMAX")->Set_Value(yMin + ((int)((yMax - yMin) / size)) * size);
- }
- else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("YMAX")) )
- {
- if( yMin >= yMax )
- {
- yMax = yMin + pParameters->Get_Parameter("NY")->asInt() * size;
- pParameter->Set_Value(yMax);
- }
-
- pParameters->Get_Parameter("YMIN")->Set_Value(yMax - ((int)((yMax - yMin) / size)) * size);
- }
- }
-
- pParameters->Get_Parameter("NX")->Set_Value(1 + (int)((xMax - xMin) / size));
- pParameters->Get_Parameter("NY")->Set_Value(1 + (int)((yMax - yMin) / size));
-
- return( true );
- }
-
- return( false );
+ return( m_Grid_Target.On_User_Changed(pParameters, pParameter) ? 1 : 0 );
}
@@ -364,6 +229,7 @@ bool CGeoref_Grid::Get_Conversion(void)
{
int Interpolation;
TSG_Data_Type Type;
+ TSG_Rect Extent;
CSG_Grid *pSource, *pGrid;
CSG_Shapes *pShapes;
@@ -380,63 +246,43 @@ bool CGeoref_Grid::Get_Conversion(void)
switch( Parameters("TARGET_TYPE")->asInt() )
{
case 0: // create new user defined grid...
- pGrid = Get_Target_Userdef(pSource, Type);
- break;
-
- case 1: // create new with chosen grid size and fitted extent...
- if( Dlg_Parameters("GET_AUTOFIT") )
- {
- pGrid = Get_Target_Autofit(
- pSource,
- Get_Parameters("GET_AUTOFIT")->Get_Parameter("GRIDSIZE") ->asDouble(),
- Get_Parameters("GET_AUTOFIT")->Get_Parameter("AUTOEXTMODE") ->asInt(),
- Type
- );
- }
- break;
-
- case 2: // select grid project...
- if( Dlg_Parameters("GET_SYSTEM") )
+ if( Get_Target_Extent(pSource, Extent, true) && m_Grid_Target.Init_User(Extent, pSource->Get_NY()) && Dlg_Parameters("GET_USER") )
{
- pGrid = SG_Create_Grid(
- *Get_Parameters("GET_SYSTEM")->Get_Parameter("SYSTEM")->asGrid_System()
- );
+ pGrid = m_Grid_Target.Get_User(Type);
}
break;
- case 3: // select grid...
+ case 1: // select grid...
if( Dlg_Parameters("GET_GRID") )
{
- pGrid = Get_Parameters("GET_GRID")->Get_Parameter("GRID")->asGrid();
+ pGrid = m_Grid_Target.Get_Grid(Type);
}
break;
- case 4: // shapes...
+ case 2: // shapes...
if( Dlg_Parameters("GET_SHAPES") )
{
pShapes = Get_Parameters("GET_SHAPES")->Get_Parameter("SHAPES")->asShapes();
+
+ if( pShapes == DATAOBJECT_NOTSET || pShapes == DATAOBJECT_CREATE )
+ {
+ Get_Parameters("GET_SHAPES")->Get_Parameter("SHAPES")->Set_Value(pShapes = SG_Create_Shapes());
+ }
}
break;
-
- default:
- return( false );
}
//-----------------------------------------------------
if( pShapes )
{
- Set_Shapes (pSource, pShapes);
+ Parameters("SHAPES")->Set_Value(pShapes);
- Parameters("SHAPES") ->Set_Value(pShapes);
+ Set_Shapes(pSource, pShapes);
}
-
- //-----------------------------------------------------
if( pGrid )
{
- Set_Grid (pSource, pGrid, Interpolation);
-
- Parameters("GRID") ->Set_Value(pGrid);
+ Set_Grid(pSource, pGrid, Interpolation);
}
//-----------------------------------------------------
@@ -451,175 +297,84 @@ bool CGeoref_Grid::Get_Conversion(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-CSG_Grid * CGeoref_Grid::Get_Target_Userdef(CSG_Grid *pSource, TSG_Data_Type Type)
+inline void CGeoref_Grid::Get_MinMax(TSG_Rect &r, double x, double y)
{
- int x, y;
- double xMin, yMin, xMax, yMax, size;
- TSG_Point Pt_Source;
- CSG_Grid *pTarget;
- CSG_Parameters *pParameters;
-
- pTarget = NULL;
-
- if( pSource )
+ if( m_Engine.Get_Converted(x, y) )
{
- //-------------------------------------------------
- xMin = yMin = 1.0;
- xMax = yMax = 0.0;
-
- for(y=0, Pt_Source.y=0; y<pSource->Get_NY(); y++, Pt_Source.y+=1)
+ if( r.xMin > r.xMax )
{
- Pt_Source.x = 0;
- Get_MinMax(xMin, xMax, yMin, yMax, Pt_Source);
-
- Pt_Source.x = pSource->Get_NX();
- Get_MinMax(xMin, xMax, yMin, yMax, Pt_Source);
+ r.xMin = r.xMax = x;
}
-
- for(x=0, Pt_Source.x=0; x<pSource->Get_NX(); x++, Pt_Source.x+=1)
+ else if( r.xMin > x )
{
- Pt_Source.y = 0;
- Get_MinMax(xMin, xMax, yMin, yMax, Pt_Source);
-
- Pt_Source.y = pSource->Get_NY();
- Get_MinMax(xMin, xMax, yMin, yMax, Pt_Source);
+ r.xMin = x;
+ }
+ else if( r.xMax < x )
+ {
+ r.xMax = x;
}
- //-------------------------------------------------
- if( xMin < xMax && yMin < yMax )
+ if( r.yMin > r.yMax )
{
- pParameters = Get_Parameters("GET_USER");
-
- pParameters->Get_Parameter("XMIN")->Set_Value(xMin);
- pParameters->Get_Parameter("XMAX")->Set_Value(xMax);
- pParameters->Get_Parameter("YMIN")->Set_Value(yMin);
- pParameters->Get_Parameter("YMAX")->Set_Value(yMax);
- size = (yMax - yMin) / pSource->Get_NY();
- pParameters->Get_Parameter("SIZE")->Set_Value(size);
- pParameters->Get_Parameter("NX")->Set_Value(1 + (int)((xMax - xMin) / size));
- pParameters->Get_Parameter("NY")->Set_Value(1 + (int)((yMax - yMin) / size));
-
- if( Dlg_Parameters("GET_USER") )
- {
- size = pParameters->Get_Parameter("SIZE")->asDouble();
-
- pTarget = SG_Create_Grid(
- Type,
- pParameters->Get_Parameter("NX")->asInt(),
- pParameters->Get_Parameter("NY")->asInt(),
- size,
- pParameters->Get_Parameter("XMIN")->asDouble(),
- pParameters->Get_Parameter("YMIN")->asDouble()
- );
- }
+ r.yMin = r.yMax = y;
+ }
+ else if( r.yMin > y )
+ {
+ r.yMin = y;
+ }
+ else if( r.yMax < y )
+ {
+ r.yMax = y;
}
}
-
- return( pTarget );
}
//---------------------------------------------------------
-CSG_Grid * CGeoref_Grid::Get_Target_Autofit(CSG_Grid *pSource, double Grid_Size, int AutoExtMode, TSG_Data_Type Type)
+bool CGeoref_Grid::Get_Target_Extent(CSG_Grid *pSource, TSG_Rect &Extent, bool bEdge)
{
+ if( !pSource )
+ {
+ return( false );
+ }
+
int x, y;
- double xMin, yMin, xMax, yMax;
- TSG_Point Pt_Source;
- CSG_Grid *pTarget;
- pTarget = NULL;
+ Extent.xMin = Extent.yMin = 1.0;
+ Extent.xMax = Extent.yMax = 0.0;
- if( pSource )
+ if( bEdge )
{
- xMin = yMin = 1.0;
- xMax = yMax = 0.0;
+ double d;
- //---------------------------------------------
- switch( AutoExtMode )
+ for(y=0, d=pSource->Get_YMin(); y<pSource->Get_NY(); y++, d+=pSource->Get_Cellsize())
{
- case 0: default:
- for(y=0, Pt_Source.y=0; y<pSource->Get_NY(); y++, Pt_Source.y+=1)
- {
- Pt_Source.x = 0;
- Get_MinMax(xMin, xMax, yMin, yMax, Pt_Source);
-
- Pt_Source.x = pSource->Get_NX();
- Get_MinMax(xMin, xMax, yMin, yMax, Pt_Source);
- }
-
- for(x=0, Pt_Source.x=0; x<pSource->Get_NX(); x++, Pt_Source.x+=1)
- {
- Pt_Source.y = 0;
- Get_MinMax(xMin, xMax, yMin, yMax, Pt_Source);
-
- Pt_Source.y = pSource->Get_NY();
- Get_MinMax(xMin, xMax, yMin, yMax, Pt_Source);
- }
-
- break;
-
- //---------------------------------------------
- case 1:
- for(y=0, Pt_Source.y=0; y<pSource->Get_NY() && Set_Progress(y, pSource->Get_NY()); y++, Pt_Source.y+=1)
- {
- for(x=0, Pt_Source.x=0; x<pSource->Get_NX(); x++, Pt_Source.x+=1)
- {
- if( !pSource->is_NoData(x, y) )
- {
- Get_MinMax(xMin, xMax, yMin, yMax, Pt_Source);
- }
- }
- }
-
- break;
+ Get_MinMax(Extent, pSource->Get_XMin(), d);
+ Get_MinMax(Extent, pSource->Get_XMax(), d);
}
- //---------------------------------------------
- if( is_Progress() && xMin < xMax && yMin < yMax )
+ for(x=0, d=pSource->Get_XMin(); x<pSource->Get_NX(); x++, d+=pSource->Get_Cellsize())
{
- pTarget = SG_Create_Grid(
- Type,
- 1 + (int)((xMax - xMin) / Grid_Size),
- 1 + (int)((yMax - yMin) / Grid_Size),
- Grid_Size,
- xMin, yMin
- );
+ Get_MinMax(Extent, d, pSource->Get_YMin());
+ Get_MinMax(Extent, d, pSource->Get_YMax());
}
}
-
- return( pTarget );
-}
-
-//---------------------------------------------------------
-inline void CGeoref_Grid::Get_MinMax(double &xMin, double &xMax, double &yMin, double &yMax, TSG_Point Point)
-{
- if( m_Engine.Get_Converted(Point) )
+ else
{
- if( xMin > xMax )
- {
- xMin = xMax = Point.x;
- }
- else if( xMin > Point.x )
- {
- xMin = Point.x;
- }
- else if( xMax < Point.x )
- {
- xMax = Point.x;
- }
+ TSG_Point p;
- if( yMin > yMax )
+ for(y=0, p.y=pSource->Get_YMin(); y<pSource->Get_NY() && Set_Progress(y, pSource->Get_NY()); y++, p.y+=pSource->Get_Cellsize())
{
- yMin = yMax = Point.y;
- }
- else if( yMin > Point.y )
- {
- yMin = Point.y;
- }
- else if( yMax < Point.y )
- {
- yMax = Point.y;
+ for(x=0, p.x=pSource->Get_XMin(); x<pSource->Get_NX(); x++, p.x+=pSource->Get_Cellsize())
+ {
+ if( !pSource->is_NoData(x, y) )
+ {
+ Get_MinMax(Extent, p.x, p.y);
+ }
+ }
}
}
+
+ return( is_Progress() && Extent.xMin < Extent.xMax && Extent.yMin < Extent.yMax );
}
diff --git a/src/modules_projection/pj_georeference/pj_georeference/Georef_Grid.h b/src/modules_projection/pj_georeference/pj_georeference/Georef_Grid.h
index 302efe5..e55db2b 100644
--- a/src/modules_projection/pj_georeference/pj_georeference/Georef_Grid.h
+++ b/src/modules_projection/pj_georeference/pj_georeference/Georef_Grid.h
@@ -85,28 +85,29 @@ class CGeoref_Grid : public CSG_Module
{
public:
CGeoref_Grid(void);
- virtual ~CGeoref_Grid(void);
protected:
- virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
+ virtual bool On_Execute (void);
+
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
- virtual bool On_Execute (void);
private:
- CGeoref_Engine m_Engine;
+ CSG_Parameters_Grid_Target m_Grid_Target;
+
+ CGeoref_Engine m_Engine;
- bool Get_Conversion (void);
+ bool Get_Conversion (void);
- void Get_MinMax (double &xMin, double &xMax, double &yMin, double &yMax, TSG_Point Point);
- CSG_Grid * Get_Target_Userdef (CSG_Grid *pSource, TSG_Data_Type Type);
- CSG_Grid * Get_Target_Autofit (CSG_Grid *pSource, double Grid_Size, int AutoExtMode, TSG_Data_Type Type);
+ void Get_MinMax (TSG_Rect &r, double x, double y);
+ bool Get_Target_Extent (CSG_Grid *pSource, TSG_Rect &Extent, bool bEdge);
- bool Set_Grid (CSG_Grid *pSource, CSG_Grid *pTarget, int Interpolation);
- bool Set_Shapes (CSG_Grid *pSource, CSG_Shapes *pTarget);
+ bool Set_Grid (CSG_Grid *pSource, CSG_Grid *pTarget, int Interpolation);
+ bool Set_Shapes (CSG_Grid *pSource, CSG_Shapes *pTarget);
};
diff --git a/src/modules_projection/pj_georeference/pj_georeference/Makefile.am b/src/modules_projection/pj_georeference/pj_georeference/Makefile.am
index d0982c0..8491a2c 100644
--- a/src/modules_projection/pj_georeference/pj_georeference/Makefile.am
+++ b/src/modules_projection/pj_georeference/pj_georeference/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.6 2008/02/15 14:30:51 oconrad Exp $
+# $Id: Makefile.am,v 1.7 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libpj_georeference.la
libpj_georeference_la_SOURCES =\
Collect_Points.cpp\
diff --git a/src/modules_projection/pj_georeference/pj_georeference/Makefile.in b/src/modules_projection/pj_georeference/pj_georeference/Makefile.in
index 05c4e2f..a5a9c52 100644
--- a/src/modules_projection/pj_georeference/pj_georeference/Makefile.in
+++ b/src/modules_projection/pj_georeference/pj_georeference/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -74,7 +73,7 @@ am_libpj_georeference_la_OBJECTS = Collect_Points.lo Georef_Engine.lo \
MLB_Interface.lo enorm.lo fdjac2.lo lmdif.lo lmdif0.lo \
lmpar.lo qrfac.lo qrsolv.lo
libpj_georeference_la_OBJECTS = $(am_libpj_georeference_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -120,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -129,6 +129,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -219,14 +220,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.6 2008/02/15 14:30:51 oconrad Exp $
+# $Id: Makefile.am,v 1.7 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at DEP_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libpj_georeference.la
libpj_georeference_la_SOURCES = \
Collect_Points.cpp\
diff --git a/src/modules_projection/pj_georeference/pj_georeference/lmdif0.c b/src/modules_projection/pj_georeference/pj_georeference/lmdif0.c
index 6de2391..226b0ba 100644
--- a/src/modules_projection/pj_georeference/pj_georeference/lmdif0.c
+++ b/src/modules_projection/pj_georeference/pj_georeference/lmdif0.c
@@ -1,6 +1,9 @@
/* lmdif0.c -- driver for lmdif */
#include <math.h>
+#if !defined(__APPLE__)
#include <malloc.h>
+#endif
+#include <stdlib.h>
#include "cminpak.h"
int lmdif0(void fcn(int,int,double [],double [],int *),int m, int n,double x[],int msk[],
diff --git a/src/modules_projection/pj_proj4/Makefile.in b/src/modules_projection/pj_proj4/Makefile.in
index d1751d9..ba78597 100644
--- a/src/modules_projection/pj_proj4/Makefile.in
+++ b/src/modules_projection/pj_proj4/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_projection/pj_proj4/pj_proj4/Makefile.am b/src/modules_projection/pj_proj4/pj_proj4/Makefile.am
index f5f97d3..6f68bc0 100644
--- a/src/modules_projection/pj_proj4/pj_proj4/Makefile.am
+++ b/src/modules_projection/pj_proj4/pj_proj4/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:27 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
#
DEP_LIBS = -lproj
if DEBUG
@@ -11,7 +11,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared $(DEP_LIBS)
+AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS)
pkglib_LTLIBRARIES = libpj_proj4.la
libpj_proj4_la_SOURCES =\
MLB_Interface.cpp\
diff --git a/src/modules_projection/pj_proj4/pj_proj4/Makefile.in b/src/modules_projection/pj_proj4/pj_proj4/Makefile.in
index 03bdba8..0bc06fb 100644
--- a/src/modules_projection/pj_proj4/pj_proj4/Makefile.in
+++ b/src/modules_projection/pj_proj4/pj_proj4/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -72,7 +71,7 @@ libpj_proj4_la_DEPENDENCIES = \
am_libpj_proj4_la_OBJECTS = MLB_Interface.lo PROJ4_Base.lo \
PROJ4_Grid.lo PROJ4_Shapes.lo
libpj_proj4_la_OBJECTS = $(am_libpj_proj4_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -118,6 +117,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -127,6 +127,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -217,7 +218,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:27 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
#
DEP_LIBS = -lproj
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@@ -225,7 +226,7 @@ DEP_LIBS = -lproj
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared $(DEP_LIBS)
+AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS)
pkglib_LTLIBRARIES = libpj_proj4.la
libpj_proj4_la_SOURCES = \
MLB_Interface.cpp\
diff --git a/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Base.cpp b/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Base.cpp
index d91a159..f67541a 100644
--- a/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Base.cpp
+++ b/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Base.cpp
@@ -168,6 +168,26 @@ CPROJ4_Base::CPROJ4_Base(int Interface, bool bInputList)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+int CPROJ4_Base::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ if( !m_bInputList && m_Interface == PROJ4_INTERFACE_SIMPLE
+ && !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("SOURCE"))
+ && pParameter->asDataObject()->Get_Projection().Get_Proj4().Length() > 0 )
+ {
+ pParameters->Get_Parameter("SOURCE_PROJ")->Set_Value(pParameter->asDataObject()->Get_Projection().Get_Proj4());
+ }
+
+ return( 0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
bool CPROJ4_Base::On_Execute(void)
{
bool bResult = false;
@@ -267,11 +287,13 @@ bool CPROJ4_Base::Set_Inverse(bool bOn)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-CSG_String CPROJ4_Base::Get_Proj_Name(void)
+CSG_String CPROJ4_Base::Get_Proj_Name(bool bDestination)
{
- if( m_pPrjDst )
+ PJ *pProjection = bDestination ? m_pPrjDst : m_pPrjSrc;
+
+ if( pProjection )
{
- return( CSG_String(m_pPrjDst->descr).BeforeFirst('\n') );
+ return( CSG_String(pProjection->descr).BeforeFirst('\n') );
}
return( _TL("") );
@@ -348,11 +370,11 @@ bool CPROJ4_Base::_Get_Projection(CSG_String &sPrj, CSG_Parameters &P)
sPrj += STR_ADD_STR(SG_T("proj") , SG_STR_MBTOSG(pj_list[P("PROJ_TYPE")->asInt()].id));
- sPrj += STR_ADD_FLT(SG_T("lon_0") , P("LON_0")->asDouble());
- sPrj += STR_ADD_FLT(SG_T("lat_0") , P("LAT_0")->asDouble());
+ if( P("LON_0")->asDouble() ) sPrj += STR_ADD_FLT(SG_T("lon_0") , P("LON_0")->asDouble());
+ if( P("LAT_0")->asDouble() ) sPrj += STR_ADD_FLT(SG_T("lat_0") , P("LAT_0")->asDouble());
- sPrj += STR_ADD_FLT(SG_T("x_0") , P("X_0" )->asDouble());
- sPrj += STR_ADD_FLT(SG_T("y_0") , P("Y_0" )->asDouble());
+ if( P("X_0" )->asDouble() ) sPrj += STR_ADD_FLT(SG_T("x_0") , P("X_0" )->asDouble());
+ if( P("Y_0" )->asDouble() ) sPrj += STR_ADD_FLT(SG_T("y_0") , P("Y_0" )->asDouble());
if( P("K_0")->asDouble() != 1.0 && P("K_0")->asDouble() > 0.0 )
{
@@ -362,14 +384,17 @@ bool CPROJ4_Base::_Get_Projection(CSG_String &sPrj, CSG_Parameters &P)
sPrj += STR_ADD_STR(SG_T("units") , SG_STR_MBTOSG(pj_units[P("UNIT")->asInt()].id));
//-----------------------------------------------------
- if( P("DATUM_DEF")->asInt() == 0 ) // predefined datum
+ switch( P("DATUM_DEF")->asInt() )
{
+ case 0: // predefined datum
+
sPrj += STR_ADD_STR(SG_T("datum") , SG_STR_MBTOSG(pj_datums[P("DATUM")->asInt()].id));
- }
+
+ break;
//-----------------------------------------------------
- else // user defined datum
- {
+ case 1: // user defined datum
+
switch( P("ELLIPSOID")->asInt() )
{
case 0: // Predefined Ellipsoid
@@ -424,6 +449,14 @@ bool CPROJ4_Base::_Get_Projection(CSG_String &sPrj, CSG_Parameters &P)
);
break;
}
+
+ break;
+ }
+
+ // datum shift grid...
+ if( SG_File_Exists(P("DATUM_GRID")->asString()) )
+ {
+ sPrj += STR_ADD_STR(SG_T("nadgrids"), P("DATUM_GRID")->asString());
}
//-----------------------------------------------------
@@ -508,6 +541,8 @@ bool CPROJ4_Base::_Init_Projection(CSG_Parameters &P)
);
//-----------------------------------------------------
+ // Predefined datum...
+
sList.Clear();
for(struct PJ_DATUMS *pDatum=pj_datums; pDatum->id; ++pDatum)
@@ -529,6 +564,19 @@ bool CPROJ4_Base::_Init_Projection(CSG_Parameters &P)
//-----------------------------------------------------
+ // Datum shift grid(s)...
+
+ P.Add_FilePath(
+ pNode_1, "DATUM_GRID" , _TL("Datum Shift Grid File"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|%s"),
+ _TL("NTv2 Grid Shift Binary (*.gsb)") , SG_T("*.gsb"),
+ _TL("All Files") , SG_T("*.*")
+ ), NULL, false, false, false
+ );
+
+
+ //-----------------------------------------------------
// User defined ellipsoid and datum shift...
pNode_2 = P.Add_Node(
@@ -605,10 +653,11 @@ bool CPROJ4_Base::_Init_Projection(CSG_Parameters &P)
pNode_3 = P.Add_Choice(
pNode_2, "DATUM_SHIFT" , _TL("Datum Shift"),
_TL(""),
- CSG_String::Format(SG_T("%s|%s|%s|"),
+ CSG_String::Format(SG_T("%s|%s|%s|%s|"),
_TL("none"),
_TL("3 parameters (translation only)"),
- _TL("7 parameters")
+ _TL("7 parameters"),
+ _TL("Datum Shift Grid")
)
);
diff --git a/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Base.h b/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Base.h
index 77de092..70ec20c 100644
--- a/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Base.h
+++ b/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Base.h
@@ -99,12 +99,14 @@ protected:
bool m_bInputList;
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
+
virtual bool On_Execute (void);
virtual bool On_Execute_Conversion (void) = 0;
bool Set_Inverse (bool bOn = true);
- CSG_String Get_Proj_Name (void);
+ CSG_String Get_Proj_Name (bool bDestination = true);
bool Get_Converted (double &x, double &y);
bool Get_Converted (TSG_Point &Point);
diff --git a/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Grid.cpp b/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Grid.cpp
index 6320e55..5666111 100644
--- a/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Grid.cpp
+++ b/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Grid.cpp
@@ -106,6 +106,14 @@ CPROJ4_Grid::CPROJ4_Grid(int Interface, bool bInputList)
_TL(""),
PARAMETER_OUTPUT_OPTIONAL
);
+
+ m_Grid_Target.Add_Parameters_User(Add_Parameters("GET_USER", _TL("User Defined Grid") , _TL("")), false);
+
+ pParameters = Add_Parameters("GET_SYSTEM" , _TL("Choose Grid Project"), _TL(""));
+
+ pParameters->Add_Grid_System(
+ NULL, "SYSTEM" , _TL("System") , _TL("")
+ );
}
else
{
@@ -116,53 +124,36 @@ CPROJ4_Grid::CPROJ4_Grid(int Interface, bool bInputList)
PARAMETER_INPUT
);
- Parameters.Add_Grid_Output(
- NULL,
- "TARGET" , _TL("Target"),
- _TL("")
- );
-
- Parameters.Add_Shapes_Output(
- NULL,
- "SHAPES" , _TL("Shapes"),
- _TL("")
- );
+ m_Grid_Target.Add_Parameters_User(Add_Parameters("GET_USER", _TL("User Defined Grid") , _TL("")));
+ m_Grid_Target.Add_Parameters_Grid(Add_Parameters("GET_GRID", _TL("Choose Grid") , _TL("")));
}
-
- //-----------------------------------------------------
- Parameters.Add_Grid_Output(
- NULL , "OUT_X" , _TL("X Coordinates"),
- _TL("")
- );
-
- Parameters.Add_Grid_Output(
- NULL , "OUT_Y" , _TL("Y Coordinates"),
+ Parameters.Add_Shapes_Output(
+ NULL,
+ "SHAPES" , _TL("Shapes"),
_TL("")
);
//-----------------------------------------------------
Parameters.Add_Value(
- Parameters("TARGET_NODE"),
- "CREATE_XY" , _TL("Create X/Y Grids"),
+ Parameters("TARGET_NODE") , "CREATE_XY" , _TL("Create X/Y Grids"),
_TL(""),
PARAMETER_TYPE_Bool, false
);
- Parameters.Add_Choice(
- Parameters("TARGET_NODE"),
- "TARGET_TYPE" , _TL("Target"),
- _TL(""),
- CSG_String::Format(m_bInputList ? SG_T("%s|%s|%s|") : SG_T("%s|%s|%s|%s|%s|"),
- _TL("user defined"),
- _TL("automatic fit"),
- _TL("grid system"),
- _TL("grid"),
- _TL("shapes")
- ), 0
+ Parameters.Add_Grid_Output(
+ NULL , "OUT_X" , _TL("X Coordinates"),
+ _TL("")
);
+ Parameters.Add_Grid_Output(
+ NULL , "OUT_Y" , _TL("Y Coordinates"),
+ _TL("")
+ );
+
+
+ //-----------------------------------------------------
Parameters.Add_Choice(
Parameters("TARGET_NODE") , "INTERPOLATION" , _TL("Interpolation"),
_TL(""),
@@ -177,72 +168,38 @@ CPROJ4_Grid::CPROJ4_Grid(int Interface, bool bInputList)
//-----------------------------------------------------
- pParameters = Add_Parameters("GET_AUTOFIT" , _TL("Automatic fit") , _TL(""));
-
- pParameters->Add_Value(
- NULL, "GRIDSIZE" , _TL("Grid Size") , _TL(""), PARAMETER_TYPE_Double, 10000.0, 0.0, true
- );
-
- pParameters->Add_Choice(
- NULL, "AUTOEXTMODE" , _TL("Fit Size") , _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|"),
- _TL("Extent only (fast)"),
- _TL("Check each point|")
+ Parameters.Add_Choice(
+ Parameters("TARGET_NODE") , "TARGET_TYPE" , _TL("Target"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("user defined"),
+ _TL("grid"),
+ _TL("shapes")
), 0
);
//-----------------------------------------------------
- pParameters = Add_Parameters("GET_USER" , _TL("User defined") , _TL(""));
-
- pParameters->Add_Value(
- NULL, "XMIN" , _TL("Left") , _TL(""), PARAMETER_TYPE_Double
- );
- pParameters->Add_Value(
- NULL, "XMAX" , _TL("Right") , _TL(""), PARAMETER_TYPE_Double
- );
- pParameters->Add_Value(
- NULL, "YMIN" , _TL("Bottom") , _TL(""), PARAMETER_TYPE_Double
- );
- pParameters->Add_Value(
- NULL, "YMAX" , _TL("Top") , _TL(""), PARAMETER_TYPE_Double
- );
-
- pParameters->Add_Value(
- NULL, "SIZE" , _TL("Grid Size") , _TL(""), PARAMETER_TYPE_Double, 10000.0, 0.0, true
- );
-
- pParameters->Add_Info_Value(
- NULL, "NX" , _TL("Columns") , _TL(""), PARAMETER_TYPE_Int
- );
- pParameters->Add_Info_Value(
- NULL, "NY" , _TL("Rows") , _TL(""), PARAMETER_TYPE_Int
- );
-
-
- //-----------------------------------------------------
- pParameters = Add_Parameters("GET_SYSTEM" , _TL("Choose Grid Project"), _TL(""));
+ pParameters = Add_Parameters("GET_SHAPES" , _TL("Choose Shapes") , _TL(""));
- pParameters->Add_Grid_System(
- NULL, "SYSTEM" , _TL("System") , _TL("")
+ pParameters->Add_Shapes(
+ NULL, "SHAPES" , _TL("Shapes") , _TL(""), PARAMETER_OUTPUT , SHAPE_TYPE_Point
);
+}
- //-----------------------------------------------------
- pParameters = Add_Parameters("GET_GRID" , _TL("Choose Grid") , _TL(""));
-
- pParameters->Add_Grid(
- NULL, "GRID" , _TL("Grid") , _TL(""), PARAMETER_INPUT , false
- );
-
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
- //-----------------------------------------------------
- pParameters = Add_Parameters("GET_SHAPES" , _TL("Choose Shapes") , _TL(""));
+//---------------------------------------------------------
+int CPROJ4_Grid::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ CPROJ4_Base::On_Parameter_Changed(pParameters, pParameter);
- pParameters->Add_Shapes(
- NULL, "SHAPES" ,_TL("Shapes") , _TL(""), PARAMETER_OUTPUT , SHAPE_TYPE_Point
- );
+ return( m_Grid_Target.On_User_Changed(pParameters, pParameter) ? 1 : 0 );
}
@@ -255,7 +212,10 @@ CPROJ4_Grid::CPROJ4_Grid(int Interface, bool bInputList)
//---------------------------------------------------------
bool CPROJ4_Grid::On_Execute_Conversion(void)
{
- CSG_Grid_System System;
+ TSG_Data_Type Type;
+ TSG_Rect Extent;
+ CSG_Grid *pSource, *pGrid;
+ CSG_Shapes *pShapes;
m_Interpolation = Parameters("INTERPOLATION")->asInt();
@@ -265,50 +225,121 @@ bool CPROJ4_Grid::On_Execute_Conversion(void)
CSG_Parameter_Grid_List *pSources = Parameters("SOURCE")->asGridList();
CSG_Parameter_Grid_List *pTargets = Parameters("TARGET")->asGridList();
- if( pSources->Get_Count() > 0 && Get_Target_System(pSources->asGrid(0)->Get_System(), System) )
+ if( pSources->Get_Count() < 1 )
{
- return( Set_Grids(System, pSources, pTargets) );
+ return( false );
+ }
+
+ pSource = pSources->asGrid(0);
+ pGrid = NULL;
+ pShapes = NULL;
+ Type = m_Interpolation == 0 ? pSource->Get_Type() : SG_DATATYPE_Float;
+
+ switch( Parameters("TARGET_TYPE")->asInt() )
+ {
+ case 0: // create new user defined grid...
+ if( Get_Target_Extent(pSource, Extent, true) && m_Grid_Target.Init_User(Extent, pSource->Get_NY()) && Dlg_Parameters("GET_USER") )
+ {
+ pGrid = m_Grid_Target.Get_User(Type);
+ }
+ break;
+
+ case 1: // select grid system...
+ if( Dlg_Parameters("GET_SYSTEM") && Get_Parameters("GET_SYSTEM")->Get_Parameter("SYSTEM")->asGrid_System()->is_Valid() )
+ {
+ pGrid = SG_Create_Grid(*Get_Parameters("GET_SYSTEM")->Get_Parameter("SYSTEM")->asGrid_System(), Type);
+ }
+ break;
+
+ case 2: // shapes...
+ if( Dlg_Parameters("GET_SHAPES") )
+ {
+ pShapes = Get_Parameters("GET_SHAPES")->Get_Parameter("SHAPES")->asShapes();
+
+ if( pShapes == DATAOBJECT_NOTSET || pShapes == DATAOBJECT_CREATE )
+ {
+ Get_Parameters("GET_SHAPES")->Get_Parameter("SHAPES")->Set_Value(pShapes = SG_Create_Shapes());
+ }
+ }
+ break;
+ }
+
+ //-------------------------------------------------
+ if( pShapes )
+ {
+ Parameters("SHAPES")->Set_Value(pShapes);
+
+ return( Set_Shapes(pSources, pShapes) );
+ }
+
+ if( pGrid )
+ {
+ pTargets->Del_Items();
+
+ pTargets->Add_Item(pGrid);
+
+ Init_Target(pSource, pGrid);
+
+ for(int i=1; i<pSources->Get_Count(); i++)
+ {
+ pTargets->Add_Item(SG_Create_Grid(pGrid->Get_System(), m_Interpolation == 0 ? pSources->asGrid(i)->Get_Type() : SG_DATATYPE_Float));
+
+ Init_Target(pSources->asGrid(i), pTargets->asGrid(i));
+ }
+
+ return( Set_Grids(pSources, pTargets) );
}
}
//-----------------------------------------------------
else
{
- CSG_Grid *pSource, *pTarget;
-
- pSource = Parameters("SOURCE")->asGrid();
+ pSource = Parameters("SOURCE")->asGrid();
+ pGrid = NULL;
+ pShapes = NULL;
+ Type = m_Interpolation == 0 ? pSource->Get_Type() : SG_DATATYPE_Float;
switch( Parameters("TARGET_TYPE")->asInt() )
{
- default: // create new grid...
- if( Get_Target_System(pSource->Get_System(), System) )
+ case 0: // create new user defined grid...
+ if( Get_Target_Extent(pSource, Extent, true) && m_Grid_Target.Init_User(Extent, pSource->Get_NY()) && Dlg_Parameters("GET_USER") )
{
- Parameters("TARGET")->Set_Value(pTarget = SG_Create_Grid(System, m_Interpolation == 0 ? pSource->Get_Type() : SG_DATATYPE_Float));
-
- return( Set_Grid(pSource, pTarget) );
+ pGrid = m_Grid_Target.Get_User(Type);
}
break;
- case 3: // select existing grid...
+ case 1: // select grid...
if( Dlg_Parameters("GET_GRID") )
{
- Parameters("TARGET")->Set_Value(pTarget = Get_Parameters("GET_GRID")->Get_Parameter("GRID")->asGrid());
-
- return( Set_Grid(pSource, pTarget) );
+ pGrid = m_Grid_Target.Get_Grid(Type);
}
break;
- case 4: // create grid points as shapes...
+ case 2: // shapes...
if( Dlg_Parameters("GET_SHAPES") )
{
- CSG_Shapes *pShapes;
+ pShapes = Get_Parameters("GET_SHAPES")->Get_Parameter("SHAPES")->asShapes();
- Parameters("SHAPES")->Set_Value(pShapes = Get_Parameters("GET_SHAPES")->Get_Parameter("SHAPES")->asShapes());
-
- return( Set_Shapes(pSource, pShapes) );
+ if( pShapes == DATAOBJECT_NOTSET || pShapes == DATAOBJECT_CREATE )
+ {
+ Get_Parameters("GET_SHAPES")->Get_Parameter("SHAPES")->Set_Value(pShapes = SG_Create_Shapes());
+ }
}
break;
}
+
+ //-------------------------------------------------
+ if( pShapes )
+ {
+ Parameters("SHAPES")->Set_Value(pShapes);
+
+ return( Set_Shapes(pSource, pShapes) );
+ }
+
+ if( pGrid )
+ {
+ return( Set_Grid(pSource, pGrid) );
+ }
}
//-----------------------------------------------------
@@ -323,43 +354,93 @@ bool CPROJ4_Grid::On_Execute_Conversion(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-bool CPROJ4_Grid::Set_Grids(const CSG_Grid_System &System, CSG_Parameter_Grid_List *pSources, CSG_Parameter_Grid_List *pTargets)
+bool CPROJ4_Grid::Set_Grids(CSG_Parameter_Grid_List *pSources, CSG_Parameter_Grid_List *pTargets)
{
- if( pSources && pSources->Get_Count() > 0 && pTargets && System.is_Valid() && Set_Inverse() )
+ if( !pSources || pSources->Get_Count() < 1 || !pTargets || pTargets->Get_Count() != pSources->Get_Count() || !Set_Inverse() )
{
- int x, y, i;
- double z;
- TSG_Point Pt_Source, Pt_Target;
- CSG_Grid *pX, *pY;
+ return( false );
+ }
+
+ //-------------------------------------------------
+ int x, y, i;
+ double z;
+ TSG_Point Pt_Source, Pt_Target;
+ CSG_Grid_System System;
+ CSG_Grid *pX, *pY;
- Init_XY(System, &pX, &pY);
+ System = pTargets->asGrid(0)->Get_System();
- pTargets->Del_Items();
+ Init_XY(System, &pX, &pY);
- for(i=0; i<pSources->Get_Count(); i++)
+ //-------------------------------------------------
+ for(y=0, Pt_Target.y=System.Get_YMin(); y<System.Get_NY() && Set_Progress(y, System.Get_NY()); y++, Pt_Target.y+=System.Get_Cellsize())
+ {
+ for(x=0, Pt_Target.x=System.Get_XMin(); x<System.Get_NX(); x++, Pt_Target.x+=System.Get_Cellsize())
{
- pTargets->Add_Item(SG_Create_Grid(System, pSources->asGrid(i)->Get_Type()));
+ Pt_Source = Pt_Target;
+
+ if( Get_Converted(Pt_Source) )
+ {
+ if( pX ) pX->Set_Value(x, y, Pt_Source.x);
+ if( pY ) pY->Set_Value(x, y, Pt_Source.y);
- Init_Target(pSources->asGrid(i), pTargets->asGrid(i));
+ for(i=0; i<pSources->Get_Count(); i++)
+ {
+ if( pSources->asGrid(i)->Get_Value(Pt_Source, z, m_Interpolation) )
+ {
+ pTargets->asGrid(i)->Set_Value(x, y, z);
+ }
+ }
+ }
}
+ }
- //-------------------------------------------------
- for(y=0, Pt_Target.y=System.Get_YMin(); y<System.Get_NY() && Set_Progress(y, System.Get_NY()); y++, Pt_Target.y+=System.Get_Cellsize())
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CPROJ4_Grid::Set_Shapes(CSG_Parameter_Grid_List *pSources, CSG_Shapes *pTarget)
+{
+ int x, y, i;
+ double z;
+ TSG_Point Pt_Source, Pt_Target;
+ CSG_Grid *pSource;
+ CSG_Shape *pShape;
+
+ if( pSources && pSources->Get_Count() > 0 && pTarget )
+ {
+ pSource = pSources->asGrid(0);
+
+ pTarget->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pSource->Get_Name(), Get_Proj_Name().c_str()));
+
+ for(i=0; i<pSources->Get_Count(); i++)
{
- for(x=0, Pt_Target.x=System.Get_XMin(); x<System.Get_NX(); x++, Pt_Target.x+=System.Get_Cellsize())
- {
- Pt_Source = Pt_Target;
+ pTarget->Add_Field(pSources->asGrid(i)->Get_Name(), pSources->asGrid(i)->Get_Type());
+ }
- if( Get_Converted(Pt_Source) )
+ for(y=0, Pt_Source.y=pSource->Get_YMin(); y<pSource->Get_NY() && Set_Progress(y, pSource->Get_NY()); y++, Pt_Source.y+=pSource->Get_Cellsize())
+ {
+ for(x=0, Pt_Source.x=pSource->Get_XMin(); x<pSource->Get_NX(); x++, Pt_Source.x+=pSource->Get_Cellsize())
+ {
+ if( !pSource->is_NoData(x, y) )
{
- if( pX ) pX->Set_Value(x, y, Pt_Source.x);
- if( pY ) pY->Set_Value(x, y, Pt_Source.y);
+ Pt_Target = Pt_Source;
- for(i=0; i<pSources->Get_Count(); i++)
+ if( Get_Converted(Pt_Target) )
{
- if( pSources->asGrid(i)->Get_Value(Pt_Source, z, m_Interpolation) )
+ pShape = pTarget->Add_Shape();
+ pShape->Add_Point(Pt_Target);
+
+ for(i=0; i<pSources->Get_Count(); i++)
{
- pTargets->asGrid(i)->Set_Value(x, y, z);
+ if( pSources->asGrid(i)->Get_Value(Pt_Source, z, m_Interpolation) )
+ {
+ pShape->Set_Value(i, z);
+ }
+ else
+ {
+ pShape->Set_NoData(i);
+ }
}
}
}
@@ -372,6 +453,11 @@ bool CPROJ4_Grid::Set_Grids(const CSG_Grid_System &System, CSG_Parameter_Grid_Li
return( false );
}
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
bool CPROJ4_Grid::Set_Grid(CSG_Grid *pSource, CSG_Grid *pTarget)
{
@@ -483,7 +569,7 @@ bool CPROJ4_Grid::Init_Target(CSG_Grid *pSource, CSG_Grid *pTarget)
{
pTarget->Set_NoData_Value_Range(pSource->Get_NoData_Value(), pSource->Get_NoData_hiValue());
pTarget->Set_ZFactor(pSource->Get_ZFactor());
- pTarget->Set_Name (CSG_String::Format(SG_T("%s [%s]"), pSource->Get_Name(), Get_Proj_Name().c_str()));
+ pTarget->Set_Name (CSG_String::Format(SG_T("%s [%s]"), pSource->Get_Name(), Get_Proj_Name(false).c_str()));
pTarget->Set_Unit (pSource->Get_Unit());
pTarget->Assign_NoData();
@@ -501,255 +587,84 @@ bool CPROJ4_Grid::Init_Target(CSG_Grid *pSource, CSG_Grid *pTarget)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-inline bool CPROJ4_Grid::Get_MinMax(TSG_Rect &r, TSG_Point p)
+inline void CPROJ4_Grid::Get_MinMax(TSG_Rect &r, double x, double y)
{
- if( Get_Converted(p) )
+ if( Get_Converted(x, y) )
{
if( r.xMin > r.xMax )
{
- r.xMin = r.xMax = p.x;
+ r.xMin = r.xMax = x;
}
- else if( r.xMin > p.x )
+ else if( r.xMin > x )
{
- r.xMin = p.x;
+ r.xMin = x;
}
- else if( r.xMax < p.x )
+ else if( r.xMax < x )
{
- r.xMax = p.x;
+ r.xMax = x;
}
if( r.yMin > r.yMax )
{
- r.yMin = r.yMax = p.y;
- }
- else if( r.yMin > p.y )
- {
- r.yMin = p.y;
+ r.yMin = r.yMax = y;
}
- else if( r.yMax < p.y )
+ else if( r.yMin > y )
{
- r.yMax = p.y;
+ r.yMin = y;
}
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CPROJ4_Grid::Get_Target_System(const CSG_Grid_System &Source, CSG_Grid_System &Target)
-{
- switch( Parameters("TARGET_TYPE")->asInt() )
- {
- case 0: // create new user defined grid...
- return( Get_Target_Userdef(Source, Target) );
-
- case 1: // create new with chosen cell size and fitted extent...
- return( Get_Target_Autofit(Source, Target) );
-
- case 2: // select grid system...
- if( Dlg_Parameters("GET_SYSTEM") )
+ else if( r.yMax < y )
{
- Target = *Get_Parameters("GET_SYSTEM")->Get_Parameter("SYSTEM")->asGrid_System();
-
- return( true );
+ r.yMax = y;
}
- break;
}
-
- return( false );
}
//---------------------------------------------------------
-bool CPROJ4_Grid::Get_Target_Userdef(const CSG_Grid_System &Source, CSG_Grid_System &Target)
+bool CPROJ4_Grid::Get_Target_Extent(CSG_Grid *pSource, TSG_Rect &Extent, bool bEdge)
{
- int x, y;
- TSG_Point p;
- TSG_Rect r;
-
- r.xMin = r.yMin = 1.0; r.xMax = r.yMax = 0.0;
-
- //-------------------------------------------------
- for(y=0, p.y=Source.Get_YMin(); y<Source.Get_NY(); y++, p.y+=Source.Get_Cellsize())
- {
- p.x = Source.Get_XMin(); Get_MinMax(r, p);
- p.x = Source.Get_XMax(); Get_MinMax(r, p);
- }
-
- for(x=0, p.x=Source.Get_XMin(); x<Source.Get_NX(); x++, p.x+=Source.Get_Cellsize())
+ if( !pSource )
{
- p.y = Source.Get_YMin(); Get_MinMax(r, p);
- p.y = Source.Get_YMax(); Get_MinMax(r, p);
+ return( false );
}
- //-------------------------------------------------
- if( r.xMin < r.xMax && r.yMin < r.yMax )
- {
- CSG_Parameters *pParameters = Get_Parameters("GET_USER");
- double Cellsize = (r.yMax - r.yMin) / Source.Get_NY();
-
- pParameters->Get_Parameter("XMIN") ->Set_Value(r.xMin);
- pParameters->Get_Parameter("XMAX") ->Set_Value(r.xMax);
- pParameters->Get_Parameter("YMIN") ->Set_Value(r.yMin);
- pParameters->Get_Parameter("YMAX") ->Set_Value(r.yMax);
- pParameters->Get_Parameter("SIZE") ->Set_Value(Cellsize);
- pParameters->Get_Parameter("NX") ->Set_Value(1 + (int)((r.xMax - r.xMin) / Cellsize));
- pParameters->Get_Parameter("NY") ->Set_Value(1 + (int)((r.yMax - r.yMin) / Cellsize));
-
- if( Dlg_Parameters("GET_USER") )
- {
- Target.Assign(
- pParameters->Get_Parameter("SIZE") ->asDouble(),
- pParameters->Get_Parameter("XMIN") ->asDouble(),
- pParameters->Get_Parameter("YMIN") ->asDouble(),
- pParameters->Get_Parameter("NX") ->asInt(),
- pParameters->Get_Parameter("NY") ->asInt()
- );
-
- return( true );
- }
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CPROJ4_Grid::Get_Target_Autofit(const CSG_Grid_System &Source, CSG_Grid_System &Target)
-{
int x, y;
- TSG_Point p;
- TSG_Rect r;
- double Cellsize = Get_Parameters("GET_AUTOFIT")->Get_Parameter("GRIDSIZE") ->asDouble();
- int AutoExtMode = Get_Parameters("GET_AUTOFIT")->Get_Parameter("AUTOEXTMODE") ->asInt();
+ Extent.xMin = Extent.yMin = 1.0;
+ Extent.xMax = Extent.yMax = 0.0;
- r.xMin = r.yMin = 1.0; r.xMax = r.yMax = 0.0;
-
- //---------------------------------------------
- switch( AutoExtMode )
+ if( bEdge )
{
- case 0: default:
- for(y=0, p.y=Source.Get_YMin(); y<Source.Get_NY(); y++, p.y+=Source.Get_Cellsize())
- {
- p.x = Source.Get_XMin(); Get_MinMax(r, p);
- p.x = Source.Get_XMax(); Get_MinMax(r, p);
- }
+ double d;
- for(x=0, p.x=Source.Get_XMin(); x<Source.Get_NX(); x++, p.x+=Source.Get_Cellsize())
+ for(y=0, d=pSource->Get_YMin(); y<pSource->Get_NY(); y++, d+=pSource->Get_Cellsize())
{
- p.y = Source.Get_YMin(); Get_MinMax(r, p);
- p.y = Source.Get_YMax(); Get_MinMax(r, p);
+ Get_MinMax(Extent, pSource->Get_XMin(), d);
+ Get_MinMax(Extent, pSource->Get_XMax(), d);
}
- break;
-
- //---------------------------------------------
- case 1:
- for(y=0, p.y=Source.Get_YMin(); y<Source.Get_NY() && Set_Progress(y, Source.Get_NY()); y++, p.y+=Source.Get_Cellsize())
+ for(x=0, d=pSource->Get_XMin(); x<pSource->Get_NX(); x++, d+=pSource->Get_Cellsize())
{
- for(x=0, p.x=Source.Get_XMin(); x<Source.Get_NX(); x++, p.x+=Source.Get_Cellsize())
- {
- Get_MinMax(r, p);
- }
+ Get_MinMax(Extent, d, pSource->Get_YMin());
+ Get_MinMax(Extent, d, pSource->Get_YMax());
}
-
- break;
- }
-
- //---------------------------------------------
- if( is_Progress() && r.xMin < r.xMax && r.yMin < r.yMax )
- {
- Target.Assign(
- Cellsize,
- r.xMin, r.yMin,
- 1 + (int)((r.xMax - r.xMin) / Cellsize),
- 1 + (int)((r.yMax - r.yMin) / Cellsize)
- );
}
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include <string.h>
-
-//---------------------------------------------------------
-int CPROJ4_Grid::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
-{
- double xMin, xMax, yMin, yMax, Cellsize;
-
- if( !SG_STR_CMP(pParameters->Get_Identifier(), SG_T("GET_USER")) )
+ else
{
- xMin = pParameters->Get_Parameter("XMIN")->asDouble();
- xMax = pParameters->Get_Parameter("XMAX")->asDouble();
- yMin = pParameters->Get_Parameter("YMIN")->asDouble();
- yMax = pParameters->Get_Parameter("YMAX")->asDouble();
- Cellsize = pParameters->Get_Parameter("SIZE")->asDouble();
+ TSG_Point p;
- if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("SIZE")) )
- {
- pParameters->Get_Parameter("XMAX")->Set_Value((xMax = xMin + ((int)((xMax - xMin) / Cellsize)) * Cellsize));
- pParameters->Get_Parameter("YMAX")->Set_Value((yMax = yMin + ((int)((yMax - yMin) / Cellsize)) * Cellsize));
- }
- else
+ for(y=0, p.y=pSource->Get_YMin(); y<pSource->Get_NY() && Set_Progress(y, pSource->Get_NY()); y++, p.y+=pSource->Get_Cellsize())
{
- if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("XMIN")) )
- {
- if( xMin >= xMax )
- {
- xMin = xMax - pParameters->Get_Parameter("NX")->asInt() * Cellsize;
- pParameter->Set_Value(xMin);
- }
-
- pParameters->Get_Parameter("XMAX")->Set_Value(xMin + ((int)((xMax - xMin) / Cellsize)) * Cellsize);
- }
- else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("XMAX")) )
+ for(x=0, p.x=pSource->Get_XMin(); x<pSource->Get_NX(); x++, p.x+=pSource->Get_Cellsize())
{
- if( xMin >= xMax )
- {
- xMax = xMin + pParameters->Get_Parameter("NX")->asInt() * Cellsize;
- pParameter->Set_Value(xMax);
- }
-
- pParameters->Get_Parameter("XMIN")->Set_Value(xMax - ((int)((xMax - xMin) / Cellsize)) * Cellsize);
- }
- else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("YMIN")) )
- {
- if( yMin >= yMax )
- {
- yMin = yMax - pParameters->Get_Parameter("NY")->asInt() * Cellsize;
- pParameter->Set_Value(yMin);
- }
-
- pParameters->Get_Parameter("YMAX")->Set_Value(yMin + ((int)((yMax - yMin) / Cellsize)) * Cellsize);
- }
- else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("YMAX")) )
- {
- if( yMin >= yMax )
+ if( !pSource->is_NoData(x, y) )
{
- yMax = yMin + pParameters->Get_Parameter("NY")->asInt() * Cellsize;
- pParameter->Set_Value(yMax);
+ Get_MinMax(Extent, p.x, p.y);
}
-
- pParameters->Get_Parameter("YMIN")->Set_Value(yMax - ((int)((yMax - yMin) / Cellsize)) * Cellsize);
}
}
-
- pParameters->Get_Parameter("NX")->Set_Value(1 + (int)((xMax - xMin) / Cellsize));
- pParameters->Get_Parameter("NY")->Set_Value(1 + (int)((yMax - yMin) / Cellsize));
-
- return( true );
}
- return( false );
+ return( is_Progress() && Extent.xMin < Extent.xMax && Extent.yMin < Extent.yMax );
}
diff --git a/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Grid.h b/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Grid.h
index b14845f..7e0c17c 100644
--- a/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Grid.h
+++ b/src/modules_projection/pj_proj4/pj_proj4/PROJ4_Grid.h
@@ -77,32 +77,33 @@ class pj_proj4_EXPORT CPROJ4_Grid : public CPROJ4_Base
public:
CPROJ4_Grid(int Interface, bool bInputList);
- virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Grid") ); }
+ virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Grid") ); }
protected:
- virtual bool On_Execute_Conversion (void);
+ virtual bool On_Execute_Conversion (void);
- virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
+ virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
private:
- int m_Interpolation;
+ int m_Interpolation;
+ CSG_Parameters_Grid_Target m_Grid_Target;
- bool Set_Grids (const CSG_Grid_System &System, CSG_Parameter_Grid_List *pSources, CSG_Parameter_Grid_List *pTargets);
- bool Set_Grid (CSG_Grid *pSource, CSG_Grid *pTarget);
- bool Set_Shapes (CSG_Grid *pSource, CSG_Shapes *pTarget);
- bool Init_XY (const CSG_Grid_System &System, CSG_Grid **ppX, CSG_Grid **ppY);
- bool Init_Target (CSG_Grid *pSource, CSG_Grid *pTarget);
+ bool Set_Grids (CSG_Parameter_Grid_List *pSources, CSG_Parameter_Grid_List *pTargets);
+ bool Set_Shapes (CSG_Parameter_Grid_List *pSources, CSG_Shapes *pTarget );
+ bool Set_Grid (CSG_Grid *pSource, CSG_Grid *pTarget);
+ bool Set_Shapes (CSG_Grid *pSource, CSG_Shapes *pTarget);
- bool Get_MinMax (TSG_Rect &r, TSG_Point p);
- bool Get_Target_System (const CSG_Grid_System &Source, CSG_Grid_System &Target);
- bool Get_Target_Userdef (const CSG_Grid_System &Source, CSG_Grid_System &Target);
- bool Get_Target_Autofit (const CSG_Grid_System &Source, CSG_Grid_System &Target);
+ bool Init_XY (const CSG_Grid_System &System, CSG_Grid **ppX, CSG_Grid **ppY);
+ bool Init_Target (CSG_Grid *pSource, CSG_Grid *pTarget);
+
+ void Get_MinMax (TSG_Rect &r, double x, double y);
+ bool Get_Target_Extent (CSG_Grid *pSource, TSG_Rect &Extent, bool bEdge);
};
diff --git a/src/modules_recreations/Makefile.in b/src/modules_recreations/Makefile.in
index cc372d7..7f9699e 100644
--- a/src/modules_recreations/Makefile.in
+++ b/src/modules_recreations/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_recreations/recreations/Makefile.in b/src/modules_recreations/recreations/Makefile.in
index 9753edf..81d6ca5 100644
--- a/src/modules_recreations/recreations/Makefile.in
+++ b/src/modules_recreations/recreations/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_recreations/recreations/recreations_fractals/Makefile.am b/src/modules_recreations/recreations/recreations_fractals/Makefile.am
index 5e81141..04de327 100644
--- a/src/modules_recreations/recreations/recreations_fractals/Makefile.am
+++ b/src/modules_recreations/recreations/recreations_fractals/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:27 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:48 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = librecreations_fractals.la
librecreations_fractals_la_SOURCES =\
Bifurcation.cpp\
diff --git a/src/modules_recreations/recreations/recreations_fractals/Makefile.in b/src/modules_recreations/recreations/recreations_fractals/Makefile.in
index e838c95..324f633 100644
--- a/src/modules_recreations/recreations/recreations_fractals/Makefile.in
+++ b/src/modules_recreations/recreations/recreations_fractals/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -74,7 +73,7 @@ am_librecreations_fractals_la_OBJECTS = Bifurcation.lo \
MLB_Interface.lo Newton.lo Pythagoras_Tree.lo
librecreations_fractals_la_OBJECTS = \
$(am_librecreations_fractals_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -120,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -129,6 +129,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -219,14 +220,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:27 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:48 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = librecreations_fractals.la
librecreations_fractals_la_SOURCES = \
Bifurcation.cpp\
diff --git a/src/modules_recreations/recreations/recreations_fractals/Mandelbrot.cpp b/src/modules_recreations/recreations/recreations_fractals/Mandelbrot.cpp
index de91283..4fec892 100644
--- a/src/modules_recreations/recreations/recreations_fractals/Mandelbrot.cpp
+++ b/src/modules_recreations/recreations/recreations_fractals/Mandelbrot.cpp
@@ -187,8 +187,8 @@ bool CMandelbrot::On_Execute(void)
m_Extent.Get_XMin() + m_Extent.Get_XRange() * (ptWorld.Get_X() - m_pGrid->Get_XMin()) / m_pGrid->Get_XRange(),\
m_Extent.Get_YMin() + m_Extent.Get_YRange() * (ptWorld.Get_Y() - m_pGrid->Get_YMin()) / m_pGrid->Get_YRange());
-#define SET_POS(a, b) if( a.Get_X() > b.Get_X() ) { d = a.m_point.x; a.m_point.x = b.m_point.x; b.m_point.x = d; }\
- if( a.Get_Y() > b.Get_Y() ) { d = a.m_point.y; a.m_point.y = b.m_point.y; b.m_point.y = d; }
+#define SET_POS(a, b) if( a.Get_X() > b.Get_X() ) { d = a.Get_X(); a.Set_X(b.Get_X()); b.Set_X(d); }\
+ if( a.Get_Y() > b.Get_Y() ) { d = a.Get_Y(); a.Set_Y(b.Get_Y()); b.Set_Y(d); }
//---------------------------------------------------------
bool CMandelbrot::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode)
diff --git a/src/modules_recreations/recreations/recreations_games/Makefile.am b/src/modules_recreations/recreations/recreations_games/Makefile.am
index 0e4a5e8..268f157 100644
--- a/src/modules_recreations/recreations/recreations_games/Makefile.am
+++ b/src/modules_recreations/recreations/recreations_games/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:28 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:51 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = librecreations_games.la
librecreations_games_la_SOURCES =\
Mine_Sweeper.cpp\
diff --git a/src/modules_recreations/recreations/recreations_games/Makefile.in b/src/modules_recreations/recreations/recreations_games/Makefile.in
index 0c1ddce..cd0d0f8 100644
--- a/src/modules_recreations/recreations/recreations_games/Makefile.in
+++ b/src/modules_recreations/recreations/recreations_games/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,7 +72,7 @@ am_librecreations_games_la_OBJECTS = Mine_Sweeper.lo \
Mine_Sweeper_Res.lo MLB_Interface.lo Sudoku.lo
librecreations_games_la_OBJECTS = \
$(am_librecreations_games_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +128,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,14 +219,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:28 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:51 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = librecreations_games.la
librecreations_games_la_SOURCES = \
Mine_Sweeper.cpp\
diff --git a/src/modules_simulation/Makefile.in b/src/modules_simulation/Makefile.in
index 887f855..bd4b499 100644
--- a/src/modules_simulation/Makefile.in
+++ b/src/modules_simulation/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_simulation/cellular_automata/Makefile.in b/src/modules_simulation/cellular_automata/Makefile.in
index 424bf8c..590706a 100644
--- a/src/modules_simulation/cellular_automata/Makefile.in
+++ b/src/modules_simulation/cellular_automata/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_simulation/cellular_automata/sim_cellular_automata/Makefile.am b/src/modules_simulation/cellular_automata/sim_cellular_automata/Makefile.am
index 173cb11..8993c52 100644
--- a/src/modules_simulation/cellular_automata/sim_cellular_automata/Makefile.am
+++ b/src/modules_simulation/cellular_automata/sim_cellular_automata/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:30 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:51 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libsim_cellular_automata.la
libsim_cellular_automata_la_SOURCES =\
Life.cpp\
diff --git a/src/modules_simulation/cellular_automata/sim_cellular_automata/Makefile.in b/src/modules_simulation/cellular_automata/sim_cellular_automata/Makefile.in
index 32673d2..bc8d2b8 100644
--- a/src/modules_simulation/cellular_automata/sim_cellular_automata/Makefile.in
+++ b/src/modules_simulation/cellular_automata/sim_cellular_automata/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,7 +72,7 @@ am_libsim_cellular_automata_la_OBJECTS = Life.lo MLB_Interface.lo \
Wator.lo
libsim_cellular_automata_la_OBJECTS = \
$(am_libsim_cellular_automata_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +128,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,14 +219,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:30 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:51 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libsim_cellular_automata.la
libsim_cellular_automata_la_SOURCES = \
Life.cpp\
diff --git a/src/modules_simulation/ecosystems/Makefile.in b/src/modules_simulation/ecosystems/Makefile.in
index 50d66e1..8efe649 100644
--- a/src/modules_simulation/ecosystems/Makefile.in
+++ b/src/modules_simulation/ecosystems/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_simulation/ecosystems/sim_ecosystems_hugget/Makefile.am b/src/modules_simulation/ecosystems/sim_ecosystems_hugget/Makefile.am
index ea9a1a1..9fd4cb5 100644
--- a/src/modules_simulation/ecosystems/sim_ecosystems_hugget/Makefile.am
+++ b/src/modules_simulation/ecosystems/sim_ecosystems_hugget/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:31 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libsim_ecosystems_hugget.la
libsim_ecosystems_hugget_la_SOURCES =\
Hugget_01.cpp\
diff --git a/src/modules_simulation/ecosystems/sim_ecosystems_hugget/Makefile.in b/src/modules_simulation/ecosystems/sim_ecosystems_hugget/Makefile.in
index 1245def..3964610 100644
--- a/src/modules_simulation/ecosystems/sim_ecosystems_hugget/Makefile.in
+++ b/src/modules_simulation/ecosystems/sim_ecosystems_hugget/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,7 +72,7 @@ am_libsim_ecosystems_hugget_la_OBJECTS = Hugget_01.lo Hugget_02.lo \
Hugget_03.lo MLB_Interface.lo
libsim_ecosystems_hugget_la_OBJECTS = \
$(am_libsim_ecosystems_hugget_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +128,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,14 +219,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:31 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libsim_ecosystems_hugget.la
libsim_ecosystems_hugget_la_SOURCES = \
Hugget_01.cpp\
diff --git a/src/modules_simulation/fire/Makefile.in b/src/modules_simulation/fire/Makefile.in
index c5980b3..bb98e0e 100644
--- a/src/modules_simulation/fire/Makefile.in
+++ b/src/modules_simulation/fire/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_simulation/fire/sim_fire_spreading/Makefile.am b/src/modules_simulation/fire/sim_fire_spreading/Makefile.am
index f50c9b0..8d49b88 100644
--- a/src/modules_simulation/fire/sim_fire_spreading/Makefile.am
+++ b/src/modules_simulation/fire/sim_fire_spreading/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.1 2008/03/07 14:33:39 oconrad Exp $
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core -I$(top_srcdir)/src/modules/grid/grid_tools
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libsim_fire_spreading.la
libsim_fire_spreading_la_SOURCES =\
fireLib.c\
diff --git a/src/modules_simulation/fire/sim_fire_spreading/Makefile.in b/src/modules_simulation/fire/sim_fire_spreading/Makefile.in
index 63dc777..f6ecc4b 100644
--- a/src/modules_simulation/fire/sim_fire_spreading/Makefile.in
+++ b/src/modules_simulation/fire/sim_fire_spreading/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,7 +72,7 @@ am_libsim_fire_spreading_la_OBJECTS = fireLib.lo Forecasting.lo \
MLB_Interface.lo Simulate.lo
libsim_fire_spreading_la_OBJECTS = \
$(am_libsim_fire_spreading_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +128,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,14 +219,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.1 2008/03/07 14:33:39 oconrad Exp $
+# $Id: Makefile.am,v 1.2 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core -I$(top_srcdir)/src/modules/grid/grid_tools
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libsim_fire_spreading.la
libsim_fire_spreading_la_SOURCES = \
fireLib.c\
diff --git a/src/modules_simulation/hydrology/Makefile.in b/src/modules_simulation/hydrology/Makefile.in
index 7e97849..b15d90e 100644
--- a/src/modules_simulation/hydrology/Makefile.in
+++ b/src/modules_simulation/hydrology/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_simulation/hydrology/sim_hydrology/Makefile.am b/src/modules_simulation/hydrology/sim_hydrology/Makefile.am
index 4d51f2a..734b8da 100644
--- a/src/modules_simulation/hydrology/sim_hydrology/Makefile.am
+++ b/src/modules_simulation/hydrology/sim_hydrology/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:31 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libsim_hydrology.la
libsim_hydrology_la_SOURCES =\
DVWK_SoilMoisture.cpp\
diff --git a/src/modules_simulation/hydrology/sim_hydrology/Makefile.in b/src/modules_simulation/hydrology/sim_hydrology/Makefile.in
index 8102368..773ba74 100644
--- a/src/modules_simulation/hydrology/sim_hydrology/Makefile.in
+++ b/src/modules_simulation/hydrology/sim_hydrology/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,7 +72,7 @@ am_libsim_hydrology_la_OBJECTS = DVWK_SoilMoisture.lo idw.lo \
KinWav_D8.lo MLB_Interface.lo topmodel.lo topmodel_values.lo \
WaterRetentionCapacity.lo
libsim_hydrology_la_OBJECTS = $(am_libsim_hydrology_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +128,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,14 +219,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:31 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libsim_hydrology.la
libsim_hydrology_la_SOURCES = \
DVWK_SoilMoisture.cpp\
diff --git a/src/modules_terrain_analysis/Makefile.in b/src/modules_terrain_analysis/Makefile.in
index c969e8c..e841c00 100644
--- a/src/modules_terrain_analysis/Makefile.in
+++ b/src/modules_terrain_analysis/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
diff --git a/src/modules_terrain_analysis/terrain_analysis/Makefile.am b/src/modules_terrain_analysis/terrain_analysis/Makefile.am
index 061fb8b..a6bf604 100644
--- a/src/modules_terrain_analysis/terrain_analysis/Makefile.am
+++ b/src/modules_terrain_analysis/terrain_analysis/Makefile.am
@@ -1 +1 @@
-SUBDIRS = ta_profiles ta_preprocessor ta_morphometry ta_lighting ta_hydrology ta_channels
+SUBDIRS = ta_profiles ta_preprocessor ta_morphometry ta_lighting ta_hydrology ta_channels ta_compound
diff --git a/src/modules_terrain_analysis/terrain_analysis/Makefile.in b/src/modules_terrain_analysis/terrain_analysis/Makefile.in
index e1aab66..d809829 100644
--- a/src/modules_terrain_analysis/terrain_analysis/Makefile.in
+++ b/src/modules_terrain_analysis/terrain_analysis/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -202,7 +203,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = ta_profiles ta_preprocessor ta_morphometry ta_lighting ta_hydrology ta_channels
+SUBDIRS = ta_profiles ta_preprocessor ta_morphometry ta_lighting ta_hydrology ta_channels ta_compound
all: all-recursive
.SUFFIXES:
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile.am b/src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile.am
index 506e64c..1c92655 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile.am
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:31 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libta_channels.la
libta_channels_la_SOURCES =\
ChannelNetwork.cpp\
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile.in b/src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile.in
index 74ad9e0..43887d4 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile.in
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_channels/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -74,7 +73,7 @@ am_libta_channels_la_OBJECTS = ChannelNetwork.lo \
D8_Flow_Analysis.lo Helper.lo MLB_Interface.lo Strahler.lo \
Watersheds.lo Watersheds_ext.lo
libta_channels_la_OBJECTS = $(am_libta_channels_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -120,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -129,6 +129,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -219,14 +220,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.5 2007/02/13 12:49:31 tschorr Exp $
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libta_channels.la
libta_channels_la_SOURCES = \
ChannelNetwork.cpp\
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_compound/MLB_Interface.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_compound/MLB_Interface.cpp
new file mode 100644
index 0000000..4e61342
--- /dev/null
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_compound/MLB_Interface.cpp
@@ -0,0 +1,122 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ta_compound //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.cpp //
+// //
+// Copyright (C) 2005 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// The Module Link Library Interface //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+//---------------------------------------------------------
+const SG_Char * Get_Info(int i)
+{
+ switch( i )
+ {
+ case MLB_INFO_Name: default:
+ return( _TL("Terrain Analysis - Compound Analyses" ));
+
+ case MLB_INFO_Author:
+ return( SG_T("Olaf Conrad, Goettingen (c) 2005") );
+
+ case MLB_INFO_Description:
+ return( _TL("Terrain Analysis: Compound Analyses.\nThis library depends on the following SAGA module libraries:\n- ta_channels\n- ta_flow\n- ta_indices\n- ta_lighting\n- ta_morphometry\n- ta_preproc\n") );
+
+ case MLB_INFO_Version:
+ return( SG_T("1.0") );
+
+ case MLB_INFO_Menu_Path:
+ return( _TL("Terrain Analysis") );
+ }
+}
+
+
+//---------------------------------------------------------
+#include "TA_Standard.h"
+
+
+//---------------------------------------------------------
+CSG_Module * Create_Module(int i)
+{
+ CSG_Module *pModule;
+
+ switch( i )
+ {
+ case 0:
+ pModule = new CTA_Standard;
+ break;
+
+ default:
+ pModule = NULL;
+ break;
+ }
+
+ return( pModule );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+//{{AFX_SAGA
+
+ MLB_INTERFACE
+
+//}}AFX_SAGA
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_compound/MLB_Interface.h b/src/modules_terrain_analysis/terrain_analysis/ta_compound/MLB_Interface.h
new file mode 100644
index 0000000..f91531a
--- /dev/null
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_compound/MLB_Interface.h
@@ -0,0 +1,75 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ta_compound //
+// //
+//-------------------------------------------------------//
+// //
+// MLB_Interface.h //
+// //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// Include the SAGA-API here //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__ta_compound_H
+#define HEADER_INCLUDED__ta_compound_H
+
+//---------------------------------------------------------
+#include <saga_api/saga_api.h>
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__ta_compound_H
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_compound/Makefile.am b/src/modules_terrain_analysis/terrain_analysis/ta_compound/Makefile.am
new file mode 100644
index 0000000..69dd137
--- /dev/null
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_compound/Makefile.am
@@ -0,0 +1,23 @@
+#
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
+#
+ADD_MLBS = ../ta_channels/libta_channels.la ../ta_hydrology/libta_hydrology.la ../ta_lighting/libta_lighting.la ../ta_morphometry/libta_morphometry.la ../ta_preprocessor/libta_preprocessor.la
+if DEBUG
+DBGFLAGS = -g -DDEBUG
+endif
+if SAGA_UNICODE
+UC_DEFS = -D_SAGA_UNICODE
+endif
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS)
+AM_LDFLAGS = -fPIC -shared -avoid-version
+pkglib_LTLIBRARIES = libta_compound.la
+libta_compound_la_SOURCES =\
+MLB_Interface.cpp\
+TA_Standard.cpp\
+MLB_Interface.h\
+TA_Standard.h
+
+libta_compound_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS)
+
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_compound/Makefile.in b/src/modules_terrain_analysis/terrain_analysis/ta_compound/Makefile.in
new file mode 100644
index 0000000..8ab816e
--- /dev/null
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_compound/Makefile.in
@@ -0,0 +1,546 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/modules_terrain_analysis/terrain_analysis/ta_compound
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkglibdir)"
+LTLIBRARIES = $(pkglib_LTLIBRARIES)
+libta_compound_la_DEPENDENCIES = \
+ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la \
+ $(ADD_MLBS)
+am_libta_compound_la_OBJECTS = MLB_Interface.lo TA_Standard.lo
+libta_compound_la_OBJECTS = $(am_libta_compound_la_OBJECTS)
+DEFAULT_INCLUDES = -I. at am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libta_compound_la_SOURCES)
+DIST_SOURCES = $(libta_compound_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+HARU_LIB = @HARU_LIB@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POW_LIB = @POW_LIB@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#
+# $Id: Makefile.am,v 1.6 2010/07/08 14:11:50 johanvdw Exp $
+#
+ADD_MLBS = ../ta_channels/libta_channels.la ../ta_hydrology/libta_hydrology.la ../ta_lighting/libta_lighting.la ../ta_morphometry/libta_morphometry.la ../ta_preprocessor/libta_preprocessor.la
+ at DEBUG_TRUE@DBGFLAGS = -g -DDEBUG
+ at SAGA_UNICODE_TRUE@UC_DEFS = -D_SAGA_UNICODE
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS)
+AM_LDFLAGS = -fPIC -shared -avoid-version
+pkglib_LTLIBRARIES = libta_compound.la
+libta_compound_la_SOURCES = \
+MLB_Interface.cpp\
+TA_Standard.cpp\
+MLB_Interface.h\
+TA_Standard.h
+
+libta_compound_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/modules_terrain_analysis/terrain_analysis/ta_compound/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/modules_terrain_analysis/terrain_analysis/ta_compound/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \
+ }
+
+uninstall-pkglibLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \
+ done
+
+clean-pkglibLTLIBRARIES:
+ -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
+ @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libta_compound.la: $(libta_compound_la_OBJECTS) $(libta_compound_la_DEPENDENCIES)
+ $(CXXLINK) -rpath $(pkglibdir) $(libta_compound_la_OBJECTS) $(libta_compound_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/TA_Standard.Plo at am__quote@
+
+.cpp.o:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+ at am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(pkglibdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-pkglibLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkglibLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+ 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 uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+
+
+# 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:
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_compound/TA_Standard.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_compound/TA_Standard.cpp
new file mode 100644
index 0000000..1429c7c
--- /dev/null
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_compound/TA_Standard.cpp
@@ -0,0 +1,414 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ta_compound //
+// //
+//-------------------------------------------------------//
+// //
+// TA_Standard.cpp //
+// //
+// Copyright (C) 2005 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "TA_Standard.h"
+
+#include "./../ta_preprocessor/Pit_Eliminator.h"
+#include "./../ta_lighting/HillShade.h"
+#include "./../ta_morphometry/Morphometry.h"
+#include "./../ta_morphometry/Convergence.h"
+#include "./../ta_morphometry/Curvature_Classification.h"
+#include "./../ta_hydrology/Flow_Parallel.h"
+#include "./../ta_hydrology/TopographicIndices.h"
+#include "./../ta_channels/ChannelNetwork.h"
+#include "./../ta_channels/ChannelNetwork_Altitude.h"
+#include "./../ta_channels/Watersheds.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CTA_Standard::CTA_Standard(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name(_TL("Standard Terrain Analysis"));
+
+ Set_Author (SG_T("(c) 2005 by O.Conrad"));
+
+ Set_Description(
+ _TL("Standard Terrain Analysis")
+ );
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid(
+ NULL , "ELEVATION" , _TL("Elevation"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "SHADE" , _TL("Analytical Hillshading"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ pNode = Parameters.Add_Node(
+ NULL , "SHADE_NODE" , _TL("Analytical Hillshading"),
+ _TL("")
+ );
+
+ Parameters.Add_Value(
+ pNode , "SHADE_AZIM" , _TL("Azimuth []"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 315
+ );
+
+ Parameters.Add_Value(
+ pNode , "SHADE_DECL" , _TL("Declination []"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 45
+ );
+
+ Parameters.Add_Value(
+ pNode , "SHADE_EXAG" , _TL("Exaggeration"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 4
+ );
+
+ Parameters.Add_Grid(
+ NULL , "SLOPE" , _TL("Slope"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "ASPECT" , _TL("Aspect"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "CURV" , _TL("Curvature"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "HCURV" , _TL("Plan Curvature"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "VCURV" , _TL("Profile Curvature"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "CONVERGENCE" , _TL("Convergence Index"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "CURVCLASS" , _TL("Curvature Classification"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "CAREA" , _TL("Catchment Area"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "WETNESS" , _TL("Wetness Index"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "STREAMPOW" , _TL("Stream Power"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "LSFACTOR" , _TL("LS-Factor"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "CHNL_GRID" , _TL("Channel Network"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Shapes(
+ NULL , "CHNL_SHAPES" , _TL("Channel Network"),
+ _TL(""),
+ PARAMETER_OUTPUT , SHAPE_TYPE_Line
+ );
+
+ pNode = Parameters.Add_Node(
+ NULL , "CHNL_NODE" , _TL("Channel Network"),
+ _TL("")
+ );
+
+ Parameters.Add_Value(
+ pNode , "CHNL_INIT" , _TL("Network Density [%]"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 5.0, 0.0, true, 100.0, true
+ );
+
+ Parameters.Add_Grid(
+ NULL , "CHNL_ALTI" , _TL("Altitude above Channel Network"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "CHNL_BASE" , _TL("Channel Network Base Level"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "BASINS" , _TL("Watershed Subbasins"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+}
+
+//---------------------------------------------------------
+CTA_Standard::~CTA_Standard(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CTA_Standard::On_Execute(void)
+{
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("Pre-Processing"));
+
+ CPit_Eliminator Pit_Eliminator;
+
+ if( !Pit_Eliminator.Get_Parameters()->Set_Parameter(SG_T("DEM") , Parameters("ELEVATION"))
+
+ || !Pit_Eliminator.Execute() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("Analytical Hillshading"));
+
+ CHillShade HillShade;
+
+ if( !HillShade.Get_Parameters()->Set_Parameter(SG_T("ELEVATION") , Parameters("ELEVATION"))
+ || !HillShade.Get_Parameters()->Set_Parameter(SG_T("SHADE") , Parameters("SHADE"))
+ || !HillShade.Get_Parameters()->Set_Parameter(SG_T("AZIMUTH") , Parameters("SHADE_AZIM"))
+ || !HillShade.Get_Parameters()->Set_Parameter(SG_T("DECLINATION") , Parameters("SHADE_DECL"))
+ || !HillShade.Get_Parameters()->Set_Parameter(SG_T("EXAGGERATION") , Parameters("SHADE_EXAG"))
+
+ || !HillShade.Execute() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("Basic Morphometry"));
+
+ CMorphometry Morphometry;
+
+ if( !Morphometry.Get_Parameters()->Set_Parameter(SG_T("ELEVATION") , Parameters("ELEVATION"))
+ || !Morphometry.Get_Parameters()->Set_Parameter(SG_T("SLOPE") , Parameters("SLOPE"))
+ || !Morphometry.Get_Parameters()->Set_Parameter(SG_T("ASPECT") , Parameters("ASPECT"))
+ || !Morphometry.Get_Parameters()->Set_Parameter(SG_T("CURV") , Parameters("CURV"))
+ || !Morphometry.Get_Parameters()->Set_Parameter(SG_T("HCURV") , Parameters("HCURV"))
+ || !Morphometry.Get_Parameters()->Set_Parameter(SG_T("VCURV") , Parameters("VCURV"))
+
+ || !Morphometry.Execute() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("Convergence Index"));
+
+ CConvergence Convergence;
+
+ if( !Convergence.Get_Parameters()->Set_Parameter(SG_T("ELEVATION") , Parameters("ELEVATION"))
+ || !Convergence.Get_Parameters()->Set_Parameter(SG_T("RESULT") , Parameters("CONVERGENCE"))
+
+ || !Convergence.Execute() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("Curvature Classification"));
+
+ CCurvature_Classification Curvature_Classification;
+
+ if( !Curvature_Classification.Get_Parameters()->Set_Parameter(SG_T("CPLAN") , Parameters("HCURV"))
+ || !Curvature_Classification.Get_Parameters()->Set_Parameter(SG_T("CPROF") , Parameters("VCURV"))
+ || !Curvature_Classification.Get_Parameters()->Set_Parameter(SG_T("CLASS") , Parameters("CURVCLASS"))
+
+ || !Curvature_Classification.Execute() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("Flow Accumulation"));
+
+ CFlow_Parallel Flow_Parallel;
+
+ if( !Flow_Parallel.Get_Parameters()->Set_Parameter(SG_T("ELEVATION") , Parameters("ELEVATION"))
+ || !Flow_Parallel.Get_Parameters()->Set_Parameter(SG_T("CAREA") , Parameters("CAREA"))
+
+ || !Flow_Parallel.Execute() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("Topographic Indices"));
+
+ CTopographicIndices TopographicIndices;
+
+ if( !TopographicIndices.Get_Parameters()->Set_Parameter(SG_T("SLOPE") , Parameters("SLOPE"))
+ || !TopographicIndices.Get_Parameters()->Set_Parameter(SG_T("AREA") , Parameters("CAREA"))
+ || !TopographicIndices.Get_Parameters()->Set_Parameter(SG_T("WETNESS") , Parameters("WETNESS"))
+ || !TopographicIndices.Get_Parameters()->Set_Parameter(SG_T("STREAMPOW") , Parameters("STREAMPOW"))
+ || !TopographicIndices.Get_Parameters()->Set_Parameter(SG_T("LSFACTOR") , Parameters("LSFACTOR"))
+
+ || !TopographicIndices.Execute() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("Channel Network"));
+
+ double d = Parameters("CAREA")->asGrid()->Get_Percentile(Parameters("CHNL_INIT")->asDouble());
+ CSG_Grid Grid(Parameters("ELEVATION")->asGrid(), SG_DATATYPE_Byte);
+
+ CChannelNetwork ChannelNetwork;
+
+ if( !ChannelNetwork.Get_Parameters()->Set_Parameter(SG_T("ELEVATION") , Parameters("ELEVATION"))
+ || !ChannelNetwork.Get_Parameters()->Set_Parameter(SG_T("CHNLNTWRK") , Parameters("CHNL_GRID"))
+ || !ChannelNetwork.Get_Parameters()->Set_Parameter(SG_T("CHNLROUTE") , PARAMETER_TYPE_Grid, &Grid)
+ || !ChannelNetwork.Get_Parameters()->Set_Parameter(SG_T("SHAPES") , Parameters("CHNL_SHAPES"))
+ || !ChannelNetwork.Get_Parameters()->Set_Parameter(SG_T("INIT_GRID") , Parameters("CAREA"))
+ || !ChannelNetwork.Get_Parameters()->Set_Parameter(SG_T("INIT_VALUE") , PARAMETER_TYPE_Double, d)
+
+ || !ChannelNetwork.Execute() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("Watershed Basins"));
+
+ CWatersheds Watersheds;
+
+ if( !Watersheds.Get_Parameters()->Set_Parameter(SG_T("ELEVATION") , Parameters("ELEVATION"))
+ || !Watersheds.Get_Parameters()->Set_Parameter(SG_T("CHANNELS") , Parameters("CHNL_GRID"))
+ || !Watersheds.Get_Parameters()->Set_Parameter(SG_T("BASINS") , Parameters("BASINS"))
+
+ || !Watersheds.Execute() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("Vertical Distance to Channel Network"));
+
+ CChannelNetwork_Altitude ChannelNetwork_Altitude;
+
+ if( !ChannelNetwork_Altitude.Get_Parameters()->Set_Parameter(SG_T("ELEVATION") , Parameters("ELEVATION"))
+ || !ChannelNetwork_Altitude.Get_Parameters()->Set_Parameter(SG_T("CHANNELS") , Parameters("CHNL_GRID"))
+ || !ChannelNetwork_Altitude.Get_Parameters()->Set_Parameter(SG_T("ALTITUDE") , Parameters("CHNL_ALTI"))
+ || !ChannelNetwork_Altitude.Get_Parameters()->Set_Parameter(SG_T("BASELEVEL") , Parameters("CHNL_BASE"))
+
+ || !ChannelNetwork_Altitude.Execute() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_compound/TA_Standard.h b/src/modules_terrain_analysis/terrain_analysis/ta_compound/TA_Standard.h
new file mode 100644
index 0000000..55c0b90
--- /dev/null
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_compound/TA_Standard.h
@@ -0,0 +1,103 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ta_compound //
+// //
+//-------------------------------------------------------//
+// //
+// TA_Standard.h //
+// //
+// Copyright (C) 2005 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__TA_Standard_H
+#define HEADER_INCLUDED__TA_Standard_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CTA_Standard : public CSG_Module_Grid
+{
+public:
+ CTA_Standard(void);
+ virtual ~CTA_Standard(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__TA_Standard_H
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow.h b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow.h
index de4ce3b..f302c1c 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow.h
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow.h
@@ -131,8 +131,8 @@ protected:
virtual void On_Initialize (void) = 0;
virtual void On_Finalize (void) {}
- virtual void Calculate (void) = 0;
- virtual void Calculate (int x, int y) = 0;
+ virtual bool Calculate (void) = 0;
+ virtual bool Calculate (int x, int y) = 0;
void Init_Cell (int x, int y);
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_Parallel.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_Parallel.cpp
index 9a6a257..944a917 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_Parallel.cpp
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_Parallel.cpp
@@ -206,27 +206,25 @@ void CFlow_Parallel::On_Initialize(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-void CFlow_Parallel::Calculate(void)
+bool CFlow_Parallel::Calculate(void)
{
- int x, y;
-
- for(y=0; y<Get_NY() && Set_Progress(y); y+=Step)
+ for(int y=0; y<Get_NY() && Set_Progress(y); y+=Step)
{
- for(x=0; x<Get_NX(); x+=Step)
+ for(int x=0; x<Get_NX(); x+=Step)
{
Init_Cell(x, y);
}
}
- Set_Flow();
+ return( Set_Flow() );
}
//---------------------------------------------------------
-void CFlow_Parallel::Calculate(int x, int y)
+bool CFlow_Parallel::Calculate(int x, int y)
{
Init_Cell(x, y);
- Set_Flow();
+ return( Set_Flow() );
}
@@ -237,14 +235,18 @@ void CFlow_Parallel::Calculate(int x, int y)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-void CFlow_Parallel::Set_Flow(void)
+bool CFlow_Parallel::Set_Flow(void)
{
- int Method, x, y;
+ int n, x, y;
- long n;
+ //-----------------------------------------------------
+ if( !pDTM->Get_Sorted(0, x, y, true, false) )
+ {
+ return( false );
+ }
//-----------------------------------------------------
- Method = Parameters("Method")->asInt();
+ int Method = Parameters("Method")->asInt();
if( Method == 2 )
{
@@ -254,17 +256,13 @@ void CFlow_Parallel::Set_Flow(void)
//-----------------------------------------------------
for(n=0; n<Get_NCells() && Set_Progress_NCells(n); n++)
{
- pDTM->Get_Sorted(n,x,y, true, false);
-
- //if( !(n%(4*Get_NX())) )DataObject_Update(pFlow);
-
- if( TH_LinearFlow > 0.0 && pCatch->asDouble(x, y) >= TH_LinearFlow )
- {
- Set_D8(x, y);
- }
- else
- {
- switch( Method )
+ if( pDTM->Get_Sorted(n, x, y, true, false) )
+ { //if( !(n%(4*Get_NX())) )DataObject_Update(pFlow);
+ if( TH_LinearFlow > 0.0 && pCatch->asDouble(x, y) >= TH_LinearFlow )
+ {
+ Set_D8(x, y);
+ }
+ else switch( Method )
{
case 0: Set_D8 (x, y); break;
case 1: Set_Rho8 (x, y); break;
@@ -287,6 +285,9 @@ void CFlow_Parallel::Set_Flow(void)
}
}
}
+
+ //-----------------------------------------------------
+ return( true );
}
//---------------------------------------------------------
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_Parallel.h b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_Parallel.h
index 51e4dde..fde9a80 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_Parallel.h
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_Parallel.h
@@ -90,8 +90,8 @@ protected:
virtual void On_Initialize (void);
- virtual void Calculate (void);
- virtual void Calculate (int x, int y);
+ virtual bool Calculate (void);
+ virtual bool Calculate (int x, int y);
private:
@@ -101,7 +101,7 @@ private:
double TH_LinearFlow, BRM_sinus[361], BRM_cosin[361];
- void Set_Flow (void);
+ bool Set_Flow (void);
void Check_Route (int x, int y);
void Set_D8 (int x, int y);
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveDown.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveDown.cpp
index e162d16..c09dc2e 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveDown.cpp
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveDown.cpp
@@ -258,23 +258,21 @@ void CFlow_RecursiveDown::On_Finalize(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-void CFlow_RecursiveDown::Calculate(void)
+bool CFlow_RecursiveDown::Calculate(void)
{
- int x, y;
-
- for(y=0; y<Get_NY() && Set_Progress(y); y+=Step)
- {
- //if( !(y%2) )DataObject_Update(pFlow);
-
- for(x=0; x<Get_NX(); x+=Step)
+ for(int y=0; y<Get_NY() && Set_Progress(y); y+=Step)
+ { //if( !(y%2) )DataObject_Update(pFlow);
+ for(int x=0; x<Get_NX(); x+=Step)
{
Calculate(x, y);
}
}
+
+ return( true );
}
//---------------------------------------------------------
-void CFlow_RecursiveDown::Calculate(int x, int y)
+bool CFlow_RecursiveDown::Calculate(int x, int y)
{
double Slope, Aspect, qFlow;
@@ -306,6 +304,8 @@ void CFlow_RecursiveDown::Calculate(int x, int y)
Lock_Set(x, y, 0);
}
+
+ return( true );
}
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveDown.h b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveDown.h
index 039da2f..1f8e300 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveDown.h
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveDown.h
@@ -91,8 +91,8 @@ protected:
virtual void On_Initialize (void);
virtual void On_Finalize (void);
- virtual void Calculate (void);
- virtual void Calculate (int x, int y);
+ virtual bool Calculate (void);
+ virtual bool Calculate (int x, int y);
private:
@@ -103,7 +103,7 @@ private:
double Src_Height, Src_Slope, DEMON_minDQV;
- CSG_Grid *pLinear, *pDir, *pDif;
+ CSG_Grid *pLinear, *pDir, *pDif;
void Add_Flow (int x, int y, double qFlow);
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveUp.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveUp.cpp
index 8c1576c..af12808 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveUp.cpp
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveUp.cpp
@@ -276,16 +276,15 @@ void CFlow_RecursiveUp::On_Initialize(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-void CFlow_RecursiveUp::Calculate(void)
+bool CFlow_RecursiveUp::Calculate(void)
{
- int x, y;
CSG_Grid *pTargets = Parameters("TARGETS")->asGrid();
On_Create();
- for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
{
- for(x=0; x<Get_NX(); x++)
+ for(int x=0; x<Get_NX(); x++)
{
if( !pTargets || !pTargets->is_NoData(x, y) )
{
@@ -295,16 +294,20 @@ void CFlow_RecursiveUp::Calculate(void)
}
On_Destroy();
+
+ return( true );
}
//---------------------------------------------------------
-void CFlow_RecursiveUp::Calculate(int x, int y)
+bool CFlow_RecursiveUp::Calculate(int x, int y)
{
On_Create();
Get_Flow(x,y);
On_Destroy();
+
+ return( true );
}
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveUp.h b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveUp.h
index 5dfd72d..e5265e5 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveUp.h
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Flow_RecursiveUp.h
@@ -90,8 +90,8 @@ protected:
virtual void On_Initialize (void);
- virtual void Calculate (void);
- virtual void Calculate (int x, int y);
+ virtual bool Calculate (void);
+ virtual bool Calculate (int x, int y);
private:
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile.am b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile.am
index 5ccd908..8e6e5d9 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile.am
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.8 2009/01/19 14:01:55 oconrad Exp $
+# $Id: Makefile.am,v 1.9 2010/07/08 14:11:48 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libta_hydrology.la
libta_hydrology_la_SOURCES =\
BasinGrid.cpp\
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile.in b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile.in
index 8f75128..37cc8e8 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile.in
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_hydrology/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -78,7 +77,7 @@ am_libta_hydrology_la_OBJECTS = BasinGrid.lo CellBalance.lo \
MLB_Interface.lo SAGA_Wetness_Index.lo Sinuosity.lo \
SlopeLength.lo TopographicIndices.lo
libta_hydrology_la_OBJECTS = $(am_libta_hydrology_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -124,6 +123,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -133,6 +133,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -223,14 +224,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.8 2009/01/19 14:01:55 oconrad Exp $
+# $Id: Makefile.am,v 1.9 2010/07/08 14:11:48 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libta_hydrology.la
libta_hydrology_la_SOURCES = \
BasinGrid.cpp\
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile.am b/src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile.am
index ece4697..cd620b8 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile.am
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.9 2009/09/01 14:12:30 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libta_lighting.la
libta_lighting_la_SOURCES =\
HillShade.cpp\
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile.in b/src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile.in
index 7d57abe..cc9e694 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile.in
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_lighting/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -73,7 +72,7 @@ am_libta_lighting_la_OBJECTS = HillShade.lo MLB_Interface.lo \
SADO_SolarRadiation.lo SolarRadiation.lo \
topographic_correction.lo view_shed.lo Visibility_Point.lo
libta_lighting_la_OBJECTS = $(am_libta_lighting_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -119,6 +118,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -128,6 +128,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -218,14 +219,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.9 2009/09/01 14:12:30 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libta_lighting.la
libta_lighting_la_SOURCES = \
HillShade.cpp\
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_lighting/SADO_SolarRadiation.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_lighting/SADO_SolarRadiation.cpp
index aaa935d..5d91e93 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_lighting/SADO_SolarRadiation.cpp
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_lighting/SADO_SolarRadiation.cpp
@@ -1,1166 +1,1166 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// ta_lighting //
-// //
-//-------------------------------------------------------//
-// //
-// SADO_SolarRadiation.cpp //
-// //
-// Copyright (C) 2006 by //
-// Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "SADO_SolarRadiation.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSADO_SolarRadiation::CSADO_SolarRadiation(void)
-{
- CSG_Parameter *pNode;
-
- //-----------------------------------------------------
- Set_Name (_TL("Insolation"));
-
- Set_Author (SG_T("(c) 2006 by O.Conrad"));
-
- Set_Description (_TW(
- "Calculation of incoming solar radiation (insolation). "
- "Based on the SADO (System for the Analysis of Discrete Surfaces) routines "
- "developed by Boehner & Trachinow. "
- "\n\n"
- "References:\n"
- ));
-
- //-----------------------------------------------------
- Parameters.Add_Grid(
- NULL , "GRD_DEM" , _TL("Elevation"),
- _TL(""),
- PARAMETER_INPUT
- );
-
- Parameters.Add_Grid(
- NULL , "GRD_VAPOUR" , _TL("Water Vapour Pressure [mbar]"),
- _TL(""),
- PARAMETER_INPUT_OPTIONAL
- );
-
- Parameters.Add_Grid(
- NULL , "GRD_LAT" , _TL("Latitude [degree]"),
- _TL(""),
- PARAMETER_INPUT_OPTIONAL
- );
-
- Parameters.Add_Grid(
- NULL , "GRD_LON" , _TL("Longitude [degree]"),
- _TL(""),
- PARAMETER_INPUT_OPTIONAL
- );
-
- Parameters.Add_Grid(
- NULL , "GRD_DIRECT" , _TL("Direct Insolation"),
- _TL(""),
- PARAMETER_OUTPUT_OPTIONAL
- );
-
- Parameters.Add_Grid(
- NULL , "GRD_DIFFUS" , _TL("Diffuse Insolation"),
- _TL(""),
- PARAMETER_OUTPUT_OPTIONAL
- );
-
- Parameters.Add_Grid(
- NULL , "GRD_TOTAL" , _TL("Total Insolation"),
- _TL("Total insolation, the sum of direct and diffuse incoming solar radiation."),
- PARAMETER_OUTPUT_OPTIONAL
- );
-
- //-----------------------------------------------------
- Parameters.Add_Value(
- NULL , "BHORIZON" , _TL("Horizontal Projection"),
- _TL(""),
- PARAMETER_TYPE_Bool , false
- );
-
- Parameters.Add_Value(
- NULL , "SOLARCONST" , _TL("Solar Constant [J]"),
- _TL(""),
- PARAMETER_TYPE_Double , 8.164, 0.0, true
- );
-
- Parameters.Add_Value(
- NULL , "ATMOSPHERE" , _TL("Height of Atmosphere [m]"),
- _TL(""),
- PARAMETER_TYPE_Double , 12000.0, 0.0, true
- );
-
- Parameters.Add_Value(
- NULL , "VAPOUR" , _TL("Water Vapour Pressure [mbar]"),
- _TL("This value is used as constant if no vapour pressure grid is given."),
- PARAMETER_TYPE_Double , 10, 0.0, true
- );
-
- //-----------------------------------------------------
- pNode = Parameters.Add_Node(
- NULL , "NODE_TIME" , _TL("Time"),
- _TL("")
- );
-
- Parameters.Add_Choice(
- pNode , "PERIOD" , _TL("Time Period"),
- _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|%s|%s|"),
- _TL("moment"),
- _TL("day"),
- _TL("range of days"),
- _TL("same moment for a range of days")
- ), 1
- );
-
- Parameters.Add_Value(
- pNode , "DHOUR" , _TL("Daily Time Resolution [h]"),
- _TL("Time resolution for a day's calculation."),
- PARAMETER_TYPE_Double , 1.0, 0.0, true, 24.0, true
- );
-
- Parameters.Add_Value(
- pNode , "DDAYS" , _TL("Range of Days Time Resolution [days]"),
- _TL("Time resolution for a range of days calculation."),
- PARAMETER_TYPE_Int , 1, 1, true
- );
-
- Parameters.Add_Value(
- pNode , "DAY_A" , _TL("Day of Year"),
- _TL(""),
- PARAMETER_TYPE_Int , 81
- );
-
- Parameters.Add_Value(
- pNode , "DAY_B" , _TL("Day of Year (Range End)"),
- _TL(""),
- PARAMETER_TYPE_Int , 87
- );
-
- Parameters.Add_Value(
- pNode , "MOMENT" , _TL("Moment [h]"),
- _TL(""),
- PARAMETER_TYPE_Double , 12.0, 0.0, true, 24.0, true
- );
-
- //-----------------------------------------------------
- pNode = Parameters.Add_Node(
- NULL , "NODE_LOCATION" , _TL("Location"),
- _TL("")
- );
-
- Parameters.Add_Value(
- pNode , "LATITUDE" , _TL("Latitude"),
- _TL(""),
- PARAMETER_TYPE_Degree , 53.0, -90.0, true, 90.0, true
- );
-
- Parameters.Add_Value(
- pNode , "BENDING" , _TL("Planetery Bending"),
- _TL(""),
- PARAMETER_TYPE_Bool , false
- );
-
- Parameters.Add_Value(
- pNode , "RADIUS" , _TL("Planetary Radius"),
- _TL(""),
- PARAMETER_TYPE_Double , 6366737.96, 0.0, true
- );
-
- Parameters.Add_Choice(
- pNode , "LAT_OFFSET" , _TL("Latitude relates to grid's..."),
- _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|%s|%s|"),
- _TL("bottom"),
- _TL("center"),
- _TL("top"),
- _TL("user defined reference")
- ), 3
- );
-
- Parameters.Add_Choice(
- pNode , "LON_OFFSET" , _TL("Local time relates to grid's..."),
- _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|%s|%s|"),
- _TL("left"),
- _TL("center"),
- _TL("right"),
- _TL("user defined reference")
- ), 1
- );
-
- Parameters.Add_Value(
- pNode , "LAT_REF_USER" , _TL("Latitude (user defined reference)"),
- _TL(""),
- PARAMETER_TYPE_Double , 0.0
- );
-
- Parameters.Add_Value(
- pNode , "LON_REF_USER" , _TL("Local Time (user defined reference)"),
- _TL(""),
- PARAMETER_TYPE_Double , 0.0
- );
-
- //-----------------------------------------------------
- pNode = Parameters.Add_Node(
- NULL , "NODE_UPDATEVIEW" , _TL("Update View"),
- _TL("")
- );
-
- Parameters.Add_Value(
- pNode , "UPD_DIRECT" , _TL("Direct Insolation"),
- _TL(""),
- PARAMETER_TYPE_Bool , false
- );
-
- Parameters.Add_Value(
- pNode , "UPD_DIFFUS" , _TL("Diffuse Insolation"),
- _TL(""),
- PARAMETER_TYPE_Bool , false
- );
-
- Parameters.Add_Value(
- pNode , "UPD_TOTAL" , _TL("Total Insolation"),
- _TL(""),
- PARAMETER_TYPE_Bool , false
- );
-}
-
-//---------------------------------------------------------
-CSADO_SolarRadiation::~CSADO_SolarRadiation(void)
-{}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSADO_SolarRadiation::On_Execute(void)
-{
- //-----------------------------------------------------
- m_pDEM = Parameters("GRD_DEM") ->asGrid();
- m_pVP = Parameters("GRD_VAPOUR") ->asGrid();
-
- m_pSumDirect = Parameters("GRD_DIRECT") ->asGrid();
- m_bUpdateDirect = Parameters("UPD_DIRECT") ->asBool() && m_pSumDirect;
- m_pSumDiffus = Parameters("GRD_DIFFUS") ->asGrid();
- m_bUpdateDiffus = Parameters("UPD_DIFFUS") ->asBool() && m_pSumDiffus;
- m_pSumTotal = Parameters("GRD_TOTAL") ->asGrid();
- m_bUpdateTotal = Parameters("UPD_TOTAL") ->asBool() && m_pSumTotal;
-
- m_Solar_Const = Parameters("SOLARCONST") ->asDouble();
- m_Atmosphere = Parameters("ATMOSPHERE") ->asDouble();
- m_VP = Parameters("VAPOUR") ->asDouble();
- m_bHorizon = Parameters("BHORIZON") ->asBool();
-
- m_Latitude = Parameters("LATITUDE") ->asDouble() * M_DEG_TO_RAD;
- m_bBending = Parameters("BENDING") ->asBool();
-
- m_Hour = Parameters("MOMENT") ->asDouble();
- m_dHour = Parameters("DHOUR") ->asDouble();
- m_dDays = Parameters("DDAYS") ->asInt();
- m_Day_A = Parameters("DAY_A") ->asInt();
- m_Day_B = Parameters("DAY_B") ->asInt();
-
- switch( Parameters("PERIOD")->asInt() )
- {
- case 0: // moment
- m_bMoment = true;
- m_bUpdateDirect = m_bUpdateDiffus = m_bUpdateTotal = false;
- break;
-
- case 1: // day
- m_bMoment = false;
- m_Day_B = m_Day_A;
- m_Hour = 0.0;
- break;
-
- case 2: // range of days
- m_bMoment = false;
- m_Hour = 0.0;
- break;
-
- case 3: // same moment for a range of days
- m_bMoment = false;
- m_dHour = 24.0;
- break;
- }
-
- //-----------------------------------------------------
- if( !m_pSumDirect && !m_pSumDiffus && !m_pSumTotal )
- {
- Message_Dlg(_TL("No output grid has been choosen."), Get_Name());
- }
- else if( m_pSumDirect == m_pDEM || m_pSumDiffus == m_pDEM || m_pSumTotal == m_pDEM )
- {
- Message_Dlg(_TL("Output must not overwrite elevation grid."), Get_Name());
- }
- else
- {
- return( Get_Insolation() );
- }
-
- //-----------------------------------------------------
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSADO_SolarRadiation::Initialise(void)
-{
- int x, y;
-
- Process_Set_Text(_TL("initialising..."));
-
- //-----------------------------------------------------
- CSG_Colors c(100, SG_COLORS_YELLOW_RED, true);
-
- c.Set_Ramp(SG_GET_RGB( 0, 0, 64), SG_GET_RGB(255, 159, 0), 0, 50);
- c.Set_Ramp(SG_GET_RGB(255, 159, 0), SG_GET_RGB(255, 255, 255), 50, 99);
-
- if( m_pSumDirect )
- {
- m_pSumDirect->Assign(0.0);
- m_pSumDirect->Set_Unit(_TL("Joule"));
- DataObject_Set_Colors(m_pSumDirect, c);
-
- if( m_bUpdateDirect )
- {
- m_TmpDirect.Create(*Get_System(), SG_DATATYPE_Float);
- DataObject_Update(m_pSumDirect, true);
- }
- }
-
- if( m_pSumDiffus )
- {
- m_pSumDiffus->Assign(0.0);
- m_pSumDiffus->Set_Unit(_TL("Joule"));
- DataObject_Set_Colors(m_pSumDiffus, c);
-
- if( m_bUpdateDiffus )
- {
- m_TmpDiffus.Create(*Get_System(), SG_DATATYPE_Float);
- DataObject_Update(m_pSumDiffus, true);
- }
- }
-
- if( m_pSumTotal )
- {
- m_pSumTotal ->Assign(0.0);
- m_pSumTotal ->Set_Unit(_TL("Joule"));
- DataObject_Set_Colors(m_pSumTotal , c);
-
- if( m_bUpdateTotal )
- {
- m_TmpTotal.Create(*Get_System(), SG_DATATYPE_Float);
- DataObject_Update(m_pSumTotal , true);
- }
- }
-
- //-----------------------------------------------------
- Process_Set_Text(_TL("initialising gradient..."));
-
- m_Shade .Create(*Get_System(), SG_DATATYPE_Byte);
- m_Slope .Create(*Get_System(), SG_DATATYPE_Float);
- m_Aspect.Create(*Get_System(), SG_DATATYPE_Float);
-
- for(y=0; y<Get_NY() && Set_Progress(y); y++)
- {
- for(x=0; x<Get_NX(); x++)
- {
- double s, a;
-
- if( m_pDEM->Get_Gradient(x, y, s, a) )
- {
- m_Slope .Set_Value(x, y, s);
- m_Aspect.Set_Value(x, y, a);
- }
- else
- {
- m_Slope .Set_NoData(x, y);
- m_Aspect.Set_NoData(x, y);
- }
- }
- }
-
- //-----------------------------------------------------
- if( m_bBending )
- {
- Process_Set_Text(_TL("initialising planetary bending..."));
-
- CSG_Grid *pLat = Parameters("GRD_LAT")->asGrid(),
- *pLon = Parameters("GRD_LON")->asGrid();
-
- m_Lat .Create(*Get_System(), SG_DATATYPE_Float);
- m_Lon .Create(*Get_System(), SG_DATATYPE_Float);
- m_Decline .Create(*Get_System(), SG_DATATYPE_Float);
- m_Azimuth .Create(*Get_System(), SG_DATATYPE_Float);
-
- if( pLat || pLon )
- {
- if( pLat )
- {
- m_Lat = *pLat;
- m_Lat *= M_DEG_TO_RAD;
- }
-
- if( pLon )
- {
- m_Lon = *pLon;
- m_Lon *= M_DEG_TO_RAD;
- }
- }
-
- //-------------------------------------------------
- else
- {
- double d, dx, dy, dxA, dyA;
-
- d = M_DEG_TO_RAD / (Parameters("RADIUS")->asDouble() * M_PI / 180.0);
-
- switch( Parameters("LON_OFFSET")->asInt() )
- {
- case 0: dxA = Get_System()->Get_Extent().Get_XMin(); break; // left
- case 1: dxA = Get_System()->Get_Extent().Get_XCenter(); break; // center
- case 2: dxA = Get_System()->Get_Extent().Get_XMax(); break; // right
- case 3: dxA = Parameters("LON_REF_USER")->asDouble(); break; // user defined coordinate
- }
-
- switch( Parameters("LAT_OFFSET")->asInt() )
- {
- case 0: dyA = Get_System()->Get_Extent().Get_YMin(); break; // bottom
- case 1: dyA = Get_System()->Get_Extent().Get_YCenter(); break; // center
- case 2: dyA = Get_System()->Get_Extent().Get_YMax(); break; // top
- case 3: dyA = Parameters("LAT_REF_USER")->asDouble(); break; // user defined coordinate
- }
-
- dxA = d * (Get_XMin() - dxA);
- dyA = d * (Get_YMin() - dyA) + m_Latitude;
- d *= Get_Cellsize();
-
- for(y=0, dy=dyA; y<Get_NY() && Set_Progress(y); y++, dy+=d)
- {
- for(x=0, dx=dxA; x<Get_NX(); x++, dx+=d)
- {
- m_Lat.Set_Value(x, y, dy);
- m_Lon.Set_Value(x, y, dx);
- }
- }
- }
- }
-
- //-----------------------------------------------------
- return( true );
-}
-
-//---------------------------------------------------------
-bool CSADO_SolarRadiation::Finalise(double SumFactor)
-{
- //-----------------------------------------------------
- if( m_pSumDirect )
- {
- if( m_bUpdateDirect ) m_pSumDirect->Assign(&m_TmpDirect);
- if( SumFactor != 1.0 ) *m_pSumDirect *= SumFactor;
- }
-
- if( m_pSumDiffus )
- {
- if( m_bUpdateDiffus ) m_pSumDiffus->Assign(&m_TmpDiffus);
- if( SumFactor != 1.0 ) *m_pSumDiffus *= SumFactor;
- }
-
- if( m_pSumTotal )
- {
- if( m_bUpdateTotal ) m_pSumTotal->Assign(&m_TmpTotal);
- if( SumFactor != 1.0 ) *m_pSumTotal *= SumFactor;
- }
-
- //-----------------------------------------------------
- m_Shade .Destroy();
- m_Slope .Destroy();
- m_Aspect .Destroy();
-
- m_Lat .Destroy();
- m_Lon .Destroy();
- m_Decline .Destroy();
- m_Azimuth .Destroy();
-
- m_TmpDirect .Destroy();
- m_TmpDiffus .Destroy();
- m_TmpTotal .Destroy();
-
- //-----------------------------------------------------
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSADO_SolarRadiation::Get_Insolation(void)
-{
- //-----------------------------------------------------
- if( Initialise() )
- {
- if( m_bMoment )
- {
- Get_Insolation(m_Day_A, m_Hour);
-
- Finalise();
- }
-
- //-------------------------------------------------
- else
- {
- for(int Day=m_Day_A; Day<=m_Day_B && Process_Get_Okay(false); Day+=m_dDays)
- {
- for(double Hour=m_Hour; Hour<24.0 && Process_Get_Okay(false); Hour+=m_dHour)
- {
- Process_Set_Text(CSG_String::Format(SG_T("%s: %d(%d-%d), %s: %f"), _TL("Day"), Day, m_Day_A, m_Day_B, _TL("Hour"), Hour));
-
- if( m_bUpdateDirect ) m_pSumDirect->Assign(0.0);
- if( m_bUpdateDiffus ) m_pSumDiffus->Assign(0.0);
- if( m_bUpdateTotal ) m_pSumTotal ->Assign(0.0);
-
- if( Get_Insolation(Day, Hour) )
- {
- if( m_bUpdateDirect )
- {
- m_TmpDirect += *m_pSumDirect;
- DataObject_Update(m_pSumDirect);
- }
-
- if( m_bUpdateDiffus )
- {
- m_TmpDiffus += *m_pSumDiffus;
- DataObject_Update(m_pSumDiffus);
- }
-
- if( m_bUpdateTotal )
- {
- m_TmpTotal += *m_pSumTotal;
- DataObject_Update(m_pSumTotal);
- }
- }
- }
- }
-
- Finalise(m_dHour / (24.0 * (1 + m_Day_B - m_Day_A))); // *m_pSumDirect *= m_dHour / D->size();
- }
- }
-
- //-----------------------------------------------------
- return( true );
-}
-
-//---------------------------------------------------------
-bool CSADO_SolarRadiation::Get_Insolation(int Day, double Hour)
-{
- double Azimuth, Decline;
-
- if( m_bBending )
- {
- bool bGo = false;
-
- for(int y=0; y<Get_NY() && Set_Progress(y); y++)
- {
- for(int x=0; x<Get_NX(); x++)
- {
- Get_Solar_Position(Day, Hour, m_Lat.asDouble(x, y), m_Lon.asDouble(x, y), Decline, Azimuth);
-
- m_Azimuth.Set_Value(x, y, Azimuth);
- m_Decline.Set_Value(x, y, Decline);
-
- if( Decline > 0.0 )
- {
- bGo = true;
- }
- }
- }
-
- if( bGo )
- {
- return( Set_Insolation(Decline, Azimuth) );
- }
- }
- else if( Get_Solar_Position(Day, Hour, m_Latitude, 0.0, Decline, Azimuth) )
- {
- return( Set_Insolation(Decline, Azimuth) );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-inline double CSADO_SolarRadiation::Get_Vapour_Exponent(double VapourPressure)
-{
- return( 0.916 - (VapourPressure > 0.0 ? 0.05125 * sqrt(VapourPressure) : 0.0) );
-}
-
-//---------------------------------------------------------
-inline double CSADO_SolarRadiation::Get_Vapour_A(double VapourPressure)
-{
- return( 0.4158 + (VapourPressure > 0.0 ? 0.0399 * sqrt(VapourPressure) : 0.0) );
-}
-
-//---------------------------------------------------------
-bool CSADO_SolarRadiation::Set_Insolation(double Decline, double Azimuth)
-{
- int x, y;
- double a, e, Direct, Diffus;
-
- Get_Shade(Decline, Azimuth);
-
- e = Get_Vapour_Exponent (m_VP);
- a = Get_Vapour_A (m_VP);
-
- for(y=0; y<Get_NY() && Set_Progress(y); y++)
- {
- for(x=0; x<Get_NX(); x++)
- {
- if( m_pDEM->is_NoData(x, y) )
- {
- if( m_pSumDirect ) m_pSumDirect->Set_NoData(x, y);
- if( m_pSumDiffus ) m_pSumDiffus->Set_NoData(x, y);
- if( m_pSumTotal ) m_pSumTotal ->Set_NoData(x, y);
- }
- else
- {
- if( m_pVP != NULL )
- {
- e = Get_Vapour_Exponent (m_pVP->asDouble(x, y));
- a = Get_Vapour_A (m_pVP->asDouble(x, y));
- }
-
- if( m_bBending )
- {
- Azimuth = m_Azimuth.asDouble(x, y);
- Decline = m_Decline.asDouble(x, y);
- }
-
- if( Decline > 0.0 )
- {
- Direct = Get_Solar_Direct(x, y, Decline, Azimuth, e);
- Diffus = Get_Solar_Diffus(x, y, Decline, a , e);
-
- if( m_pSumDirect ) m_pSumDirect->Add_Value(x, y, Direct);
- if( m_pSumDiffus ) m_pSumDiffus->Add_Value(x, y, Diffus);
- if( m_pSumTotal ) m_pSumTotal ->Add_Value(x, y, Direct + Diffus);
- }
- }
- }
- }
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-inline double CSADO_SolarRadiation::Get_Solar_Reduction(double Elevation, double Decline, double Reduction)
-{
- return( Decline > 0.0 ? (m_Solar_Const * pow(Reduction, (1.0 - Elevation / m_Atmosphere) / sin(Decline))) : 0.0 );
-}
-
-//---------------------------------------------------------
-inline double CSADO_SolarRadiation::Get_Solar_Direct(int x, int y, double Decline, double Azimuth, double Exponent)
-{
- if( m_Shade.asInt(x, y) == 0 )
- {
- double Angle, Slope;
-
- Slope = m_bHorizon ? 0.0 : m_Slope.asDouble(x, y);
-
- Angle = cos(Slope) * cos(Decline - M_PI_090)
- + sin(Slope) * sin(M_PI_090 - Decline)
- * cos(Azimuth - m_Aspect.asDouble(x, y));
-
- if( Angle > 0.0 )
- {
- return( Angle * Get_Solar_Reduction(m_pDEM->asDouble(x, y), Decline, Exponent) );
- }
- }
-
- return( 0.0 );
-}
-
-//---------------------------------------------------------
-inline double CSADO_SolarRadiation::Get_Solar_Diffus(int x, int y, double Decline, double A, double Exponent)
-{
- double Dh, Ih, d, Slope, srad;
-
- Ih = Get_Solar_Reduction(m_pDEM->asDouble(x, y), Decline, Exponent) * sin(Decline);
-// Decline *= M_RAD_TO_DEG; // Fehler in SADO ????!!!!!
- d = m_Atmosphere / (m_Atmosphere - m_pDEM->asDouble(x, y))
- * (0.0001165 * Decline*Decline - 0.0152 * Decline + A);
- d = 1.0 - d;
- Dh = Ih / d - Ih;
-
- Slope = m_bHorizon ? 0.0 : m_Slope.asDouble(x, y);
-
- srad = (Dh + Dh * cos(Slope)) / 2.0;
-
- return( srad < 0.0 || srad > m_Solar_Const ? m_Solar_Const : srad );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSADO_SolarRadiation::Get_Shade(double Decline, double Azimuth)
-{
- //-----------------------------------------------------
- m_Shade.Assign(0.0);
-
- if( !m_bBending )
- {
- int i, x, y;
- double dx, dy, dz;
-
- Get_Shade_Params(Decline, Azimuth, dx, dy, dz);
-
- for(i=0; i<Get_NCells() && Set_Progress_NCells(i); i++)
- {
- if( m_pDEM->Get_Sorted(i, x, y) && !Get_Shade_Complete(x, y) )
- {
- Set_Shade(x, y, dx, dy, dz);
- }
- }
- }
-
- //-----------------------------------------------------
- else
- {
- int i, x, y, iLock;
-
- for(i=0, iLock=1; i<Get_NCells() && Set_Progress_NCells(i); i++, iLock++)
- {
- if( m_pDEM->Get_Sorted(i, x, y) && !Get_Shade_Complete(x, y) )
- {
- if( iLock >= 255 )
- iLock = 1;
-
- if( iLock == 1 )
- Lock_Create();
-
- Set_Shade_Bended(x, y, iLock);
- }
- }
- }
-
- return( true );
-}
-
-//---------------------------------------------------------
-void CSADO_SolarRadiation::Set_Shade(int x, int y, double dx, double dy, double dz)
-{
- for(double ix=x+0.5, iy=y+0.5, iz=m_pDEM->asDouble(x, y); ; )
- {
- x = (int)(ix += dx);
- y = (int)(iy += dy);
- iz -= dz;
-
- if( !is_InGrid(x, y) || m_pDEM->asDouble(x, y) > iz )
- {
- return;
- }
-
- m_Shade.Set_Value(x, y, 1);
- }
-}
-
-//---------------------------------------------------------
-void CSADO_SolarRadiation::Set_Shade_Bended(int x, int y, char iLock)
-{
- double dx, dy, dz;
-
- Get_Shade_Params(m_Decline.asDouble(x, y), m_Azimuth.asDouble(x, y), dx, dy, dz);
-
- for(double ix=x+0.5, iy=y+0.5, iz=m_pDEM->asDouble(x, y); ; )
- {
- x = (int)(ix += dx);
- y = (int)(iy += dy);
- iz -= dz;
-
- if( !is_InGrid(x, y) || m_pDEM->asDouble(x, y) > iz || Lock_Get(x, y) == iLock )
- {
- return;
- }
-
- m_Shade.Set_Value(x, y, 1);
-
- //---------------------------------------------
- Lock_Set(x, y, iLock);
-
- Get_Shade_Params(m_Decline.asDouble(x, y), m_Azimuth.asDouble(x, y), dx, dy, dz);
- }
-}
-
-//---------------------------------------------------------
-inline bool CSADO_SolarRadiation::Get_Shade_Complete(int x, int y)
-{
- if( m_Shade.asInt(x, y) == 1 )
- {
- for(int iy=y-1; iy<=y+1; iy++)
- {
- for(int ix=x-1; ix<x+1; ix++)
- {
- if( is_InGrid(ix, iy) && m_Shade.asInt(ix, iy) == 0 )
- {
- return( false );
- }
- }
- }
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-inline void CSADO_SolarRadiation::Get_Shade_Params(double Decline, double Azimuth, double &dx, double &dy, double &dz)
-{
- dz = Azimuth + M_PI_180;
- dx = sin(dz);
- dy = cos(dz);
-
- if( fabs(dx) > fabs(dy) )
- {
- dy /= fabs(dx);
- dx = dx < 0 ? -1 : 1;
- }
- else if( fabs(dy) > fabs(dx) )
- {
- dx /= fabs(dy);
- dy = dy < 0 ? -1 : 1;
- }
- else
- {
- dx = dx < 0 ? -1 : 1;
- dy = dy < 0 ? -1 : 1;
- }
-
- dz = tan(Decline) * sqrt(dx*dx + dy*dy) * Get_Cellsize();
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-inline bool CSADO_SolarRadiation::Get_Solar_Position(int Day, double Hour, double LAT, double LON, double &Declination, double &Azimuth)
-{
- static const int Day2Month[13] = { 0, 31, 49, 80, 109, 140, 170, 201, 232, 272, 303, 333, 366 };
-
- static const double ECLIPTIC_OBL = M_DEG_TO_RAD * 23.43999; // obliquity of ecliptic
-
- int i;
-
- double JD, T, M, L, X, Y, Z, R, UTime,
- DEC, RA, theta, tau,
- Month, Year = 2000;
-
- //-----------------------------------------------------
-
- for(Month=1, i=0; i<=12; i++)
- {
- if( Day < Day2Month[i] )
- {
- Month = i;
- Day -= Day2Month[i - 1];
- break;
- }
- }
-
- if( Month < 1 || Month > 12 ) // nur Tag (1 - 365) zaehlt...
- {
- Month = 1;
- }
-
- if( Month <= 2 )
- {
- Month += 12;
- Year -= 1;
- }
-
-
- //-----------------------------------------------------
-
-// UTime = Hour - LON * 12.0 / M_PI;
- UTime = Hour;
-
-
- //-----------------------------------------------------
- // 1. Julian Date...
-
- JD = (int)(365.25 * Year) + (int)(30.6001 * (Month + 1)) - 15 + 1720996.5 + Day + UTime / 24.0;
- T = (JD - 2451545.0 ) / 36525.0; // number of Julian centuries since 2000/01/01 at 12 UT (JD = 2451545.0)
-
-
- //-----------------------------------------------------
- // 2. Solar Coordinates (according to: Jean Meeus: Astronomical Algorithms), accuracy of 0.01 degree
-
- M = M_DEG_TO_RAD * (357.52910 + 35999.05030 * T - 0.0001559 * T * T - 0.00000048 * T * T * T); // mean anomaly
- L = M_DEG_TO_RAD * ( (280.46645 + 36000.76983 * T + 0.0003032 * T * T) // mean longitude
- + ( (1.914600 - 0.004817 * T - 0.000014 * T * T) * sin(M)
- + (0.019993 - 0.000101 * T) * sin(2 * M) + 0.000290 * sin(3 * M) // true longitude
- )
- );
-
-
- //-----------------------------------------------------
- // 3. convert ecliptic longitude to right ascension RA and declination delta
-
- X = cos(L);
- Y = cos(ECLIPTIC_OBL) * sin(L);
- Z = sin(ECLIPTIC_OBL) * sin(L);
- R = sqrt(1.0 - Z*Z);
-
- DEC = atan2(Z, R);
- RA = 2.0 * atan2(Y, (X + R));
-
-
- //-----------------------------------------------------
- // 4. compute sidereal time (degree) at Greenwich local sidereal time at longitude (Degree)
-
- theta = LON + M_DEG_TO_RAD * (280.46061837 + 360.98564736629 * (JD - 2451545.0) + T*T * (0.000387933 - T / 38710000.0));
-
-
- //-----------------------------------------------------
- // 5. compute local hour angle (degree)
-
- tau = theta - RA;
-
-
- //-----------------------------------------------------
- // 6. convert (tau, delta) to horizon coordinates (h, az) of the observer
-
- Declination = asin ( sin(LAT) * sin(DEC) + cos(LAT) * cos(DEC) * cos(tau) );
-
- Azimuth = atan2( -sin(tau) * cos(DEC), cos(LAT) * sin(DEC) - sin(LAT) * cos(DEC) * cos(tau) );
-// Azimuth = atan2( -sin(Tau), cos(LAT) * tan(DEC) - sin(LAT) * cos(Tau) ); // previous formula gives same result but is better because of division by zero effects...
-
- return( Declination > 0.0 );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-/*/---------------------------------------------------------
-#define CHECK_SHADOW(X, Y) if( (d = SG_Get_Distance(x, y, X, Y) * Get_Cellsize()) > 0.0 )\
- {\
- if( (t = (m_pDEM->asDouble(X, Y) - z) / d) > tMax )\
- {\
- tMax = t;\
- }\
- \
- if( (d = zMax / d) < tanDec || d < tMax )\
- {\
- return( false );\
- }\
- else if( tMax > tanDec )\
- {\
- return( true );\
- }\
- }
-
-//---------------------------------------------------------
-bool CSADO_SolarRadiation::Get_Solar_Shadow(int x, int y, double Decline, double Azimuth)
-{
- static double Zenith = 89.9999 * M_DEG_TO_RAD;
-
- //-----------------------------------------------------
- if( Decline >= Zenith || Decline > m_Slope.Get_ZMax() )
- {
- return( false );
- }
-
- if( Decline <= 0.0 )
- {
- return( true );
- }
-
- //-----------------------------------------------------
- bool bGo;
- int dx, nx, ix, iy, iy_Last, jy;
- double dy, d, t, tMax, z, zMax, tanDec;
-
- //-----------------------------------------------------
- Azimuth = fmod(Azimuth, M_PI_360); if( Azimuth < 0.0 ) Azimuth += M_PI_360;
-
- if( Azimuth < M_PI_180 )
- {
- dx = 1;
- nx = Get_NX() - 1;
- }
- else
- {
- dx = -1;
- nx = 0;
- }
-
- Azimuth = M_PI_090 - Azimuth;
-
- if( Azimuth == M_PI_090 )
- Azimuth = 89.9999 * M_DEG_TO_RAD;
- else if( Azimuth == -M_PI_090 )
- Azimuth = - 89.9999 * M_DEG_TO_RAD;
- else if( Azimuth == -M_PI_180 )
- Azimuth = -179.9999 * M_DEG_TO_RAD;
- else if( Azimuth == -M_PI_270)
- Azimuth = -269.9999 * M_DEG_TO_RAD;
-
- dy = tan(Azimuth);
-
- //-----------------------------------------------------
- z = m_pDEM->asDouble(x, y);
- zMax = m_pDEM->Get_ZMax();
- tanDec = tan(Decline);
- tMax = 0.0;
-
- //-----------------------------------------------------
- for(ix=x, iy=y, bGo=true; ix!=nx && bGo; ix+=dx)
- {
- iy_Last = iy;
- iy = y + (int)floor(dy * (ix - x + (dx > 0 ? 0.5 : -0.5)));
-
- if( iy < 0 )
- {
- bGo = false;
- iy = 0;
- }
- else if( iy >= Get_NY() )
- {
- bGo = false;
- iy = Get_NY() - 1;
- }
-
- //-------------------------------------------------
- if( iy_Last < iy )
- {
- for(jy=iy_Last+1; jy<=iy; jy++)
- {
- CHECK_SHADOW(ix, jy);
- }
- }
- else if( iy_Last > iy )
- {
- for(jy=iy_Last; jy>iy; jy--)
- {
- CHECK_SHADOW(ix, jy);
- }
- }
- else if( iy_Last == iy )
- {
- CHECK_SHADOW(ix, iy);
- }
- }
-
- return( false );
-}/**/
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ta_lighting //
+// //
+//-------------------------------------------------------//
+// //
+// SADO_SolarRadiation.cpp //
+// //
+// Copyright (C) 2006 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "SADO_SolarRadiation.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSADO_SolarRadiation::CSADO_SolarRadiation(void)
+{
+ CSG_Parameter *pNode;
+
+ //-----------------------------------------------------
+ Set_Name (_TL("Insolation"));
+
+ Set_Author (SG_T("(c) 2006 by O.Conrad"));
+
+ Set_Description (_TW(
+ "Calculation of incoming solar radiation (insolation). "
+ "Based on the SADO (System for the Analysis of Discrete Surfaces) routines "
+ "developed by Boehner & Trachinow. "
+ "\n\n"
+ "References:\n"
+ ));
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid(
+ NULL , "GRD_DEM" , _TL("Elevation"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "GRD_VAPOUR" , _TL("Water Vapour Pressure [mbar]"),
+ _TL(""),
+ PARAMETER_INPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid(
+ NULL , "GRD_LAT" , _TL("Latitude [degree]"),
+ _TL(""),
+ PARAMETER_INPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid(
+ NULL , "GRD_LON" , _TL("Longitude [degree]"),
+ _TL(""),
+ PARAMETER_INPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid(
+ NULL , "GRD_DIRECT" , _TL("Direct Insolation"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid(
+ NULL , "GRD_DIFFUS" , _TL("Diffuse Insolation"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid(
+ NULL , "GRD_TOTAL" , _TL("Total Insolation"),
+ _TL("Total insolation, the sum of direct and diffuse incoming solar radiation."),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ //-----------------------------------------------------
+ Parameters.Add_Value(
+ NULL , "BHORIZON" , _TL("Horizontal Projection"),
+ _TL(""),
+ PARAMETER_TYPE_Bool , false
+ );
+
+ Parameters.Add_Value(
+ NULL , "SOLARCONST" , _TL("Solar Constant [J]"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 8.164, 0.0, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "ATMOSPHERE" , _TL("Height of Atmosphere [m]"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 12000.0, 0.0, true
+ );
+
+ Parameters.Add_Value(
+ NULL , "VAPOUR" , _TL("Water Vapour Pressure [mbar]"),
+ _TL("This value is used as constant if no vapour pressure grid is given."),
+ PARAMETER_TYPE_Double , 10, 0.0, true
+ );
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Node(
+ NULL , "NODE_TIME" , _TL("Time"),
+ _TL("")
+ );
+
+ Parameters.Add_Choice(
+ pNode , "PERIOD" , _TL("Time Period"),
+ _TL(""),
+
+ CSG_String::Format(SG_T("%s|%s|%s|%s|"),
+ _TL("moment"),
+ _TL("day"),
+ _TL("range of days"),
+ _TL("same moment for a range of days")
+ ), 1
+ );
+
+ Parameters.Add_Value(
+ pNode , "DHOUR" , _TL("Daily Time Resolution [h]"),
+ _TL("Time resolution for a day's calculation."),
+ PARAMETER_TYPE_Double , 1.0, 0.0, true, 24.0, true
+ );
+
+ Parameters.Add_Value(
+ pNode , "DDAYS" , _TL("Range of Days Time Resolution [days]"),
+ _TL("Time resolution for a range of days calculation."),
+ PARAMETER_TYPE_Int , 1, 1, true
+ );
+
+ Parameters.Add_Value(
+ pNode , "DAY_A" , _TL("Day of Year"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 81
+ );
+
+ Parameters.Add_Value(
+ pNode , "DAY_B" , _TL("Day of Year (Range End)"),
+ _TL(""),
+ PARAMETER_TYPE_Int , 87
+ );
+
+ Parameters.Add_Value(
+ pNode , "MOMENT" , _TL("Moment [h]"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 12.0, 0.0, true, 24.0, true
+ );
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Node(
+ NULL , "NODE_LOCATION" , _TL("Location"),
+ _TL("")
+ );
+
+ Parameters.Add_Value(
+ pNode , "LATITUDE" , _TL("Latitude"),
+ _TL(""),
+ PARAMETER_TYPE_Degree , 53.0, -90.0, true, 90.0, true
+ );
+
+ Parameters.Add_Value(
+ pNode , "BENDING" , _TL("Planetery Bending"),
+ _TL(""),
+ PARAMETER_TYPE_Bool , false
+ );
+
+ Parameters.Add_Value(
+ pNode , "RADIUS" , _TL("Planetary Radius"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 6366737.96, 0.0, true
+ );
+
+ Parameters.Add_Choice(
+ pNode , "LAT_OFFSET" , _TL("Latitude relates to grid's..."),
+ _TL(""),
+
+ CSG_String::Format(SG_T("%s|%s|%s|%s|"),
+ _TL("bottom"),
+ _TL("center"),
+ _TL("top"),
+ _TL("user defined reference")
+ ), 3
+ );
+
+ Parameters.Add_Choice(
+ pNode , "LON_OFFSET" , _TL("Local time relates to grid's..."),
+ _TL(""),
+
+ CSG_String::Format(SG_T("%s|%s|%s|%s|"),
+ _TL("left"),
+ _TL("center"),
+ _TL("right"),
+ _TL("user defined reference")
+ ), 1
+ );
+
+ Parameters.Add_Value(
+ pNode , "LAT_REF_USER" , _TL("Latitude (user defined reference)"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 0.0
+ );
+
+ Parameters.Add_Value(
+ pNode , "LON_REF_USER" , _TL("Local Time (user defined reference)"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 0.0
+ );
+
+ //-----------------------------------------------------
+ pNode = Parameters.Add_Node(
+ NULL , "NODE_UPDATEVIEW" , _TL("Update View"),
+ _TL("")
+ );
+
+ Parameters.Add_Value(
+ pNode , "UPD_DIRECT" , _TL("Direct Insolation"),
+ _TL(""),
+ PARAMETER_TYPE_Bool , false
+ );
+
+ Parameters.Add_Value(
+ pNode , "UPD_DIFFUS" , _TL("Diffuse Insolation"),
+ _TL(""),
+ PARAMETER_TYPE_Bool , false
+ );
+
+ Parameters.Add_Value(
+ pNode , "UPD_TOTAL" , _TL("Total Insolation"),
+ _TL(""),
+ PARAMETER_TYPE_Bool , false
+ );
+}
+
+//---------------------------------------------------------
+CSADO_SolarRadiation::~CSADO_SolarRadiation(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSADO_SolarRadiation::On_Execute(void)
+{
+ //-----------------------------------------------------
+ m_pDEM = Parameters("GRD_DEM") ->asGrid();
+ m_pVP = Parameters("GRD_VAPOUR") ->asGrid();
+
+ m_pSumDirect = Parameters("GRD_DIRECT") ->asGrid();
+ m_bUpdateDirect = Parameters("UPD_DIRECT") ->asBool() && m_pSumDirect;
+ m_pSumDiffus = Parameters("GRD_DIFFUS") ->asGrid();
+ m_bUpdateDiffus = Parameters("UPD_DIFFUS") ->asBool() && m_pSumDiffus;
+ m_pSumTotal = Parameters("GRD_TOTAL") ->asGrid();
+ m_bUpdateTotal = Parameters("UPD_TOTAL") ->asBool() && m_pSumTotal;
+
+ m_Solar_Const = Parameters("SOLARCONST") ->asDouble();
+ m_Atmosphere = Parameters("ATMOSPHERE") ->asDouble();
+ m_VP = Parameters("VAPOUR") ->asDouble();
+ m_bHorizon = Parameters("BHORIZON") ->asBool();
+
+ m_Latitude = Parameters("LATITUDE") ->asDouble() * M_DEG_TO_RAD;
+ m_bBending = Parameters("BENDING") ->asBool();
+
+ m_Hour = Parameters("MOMENT") ->asDouble();
+ m_dHour = Parameters("DHOUR") ->asDouble();
+ m_dDays = Parameters("DDAYS") ->asInt();
+ m_Day_A = Parameters("DAY_A") ->asInt();
+ m_Day_B = Parameters("DAY_B") ->asInt();
+
+ switch( Parameters("PERIOD")->asInt() )
+ {
+ case 0: // moment
+ m_bMoment = true;
+ m_bUpdateDirect = m_bUpdateDiffus = m_bUpdateTotal = false;
+ break;
+
+ case 1: // day
+ m_bMoment = false;
+ m_Day_B = m_Day_A;
+ m_Hour = 0.0;
+ break;
+
+ case 2: // range of days
+ m_bMoment = false;
+ m_Hour = 0.0;
+ break;
+
+ case 3: // same moment for a range of days
+ m_bMoment = false;
+ m_dHour = 24.0;
+ break;
+ }
+
+ //-----------------------------------------------------
+ if( !m_pSumDirect && !m_pSumDiffus && !m_pSumTotal )
+ {
+ Message_Dlg(_TL("No output grid has been choosen."), Get_Name());
+ }
+ else if( m_pSumDirect == m_pDEM || m_pSumDiffus == m_pDEM || m_pSumTotal == m_pDEM )
+ {
+ Message_Dlg(_TL("Output must not overwrite elevation grid."), Get_Name());
+ }
+ else
+ {
+ return( Get_Insolation() );
+ }
+
+ //-----------------------------------------------------
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSADO_SolarRadiation::Initialise(void)
+{
+ int x, y;
+
+ Process_Set_Text(_TL("initialising..."));
+
+ //-----------------------------------------------------
+ CSG_Colors c(100, SG_COLORS_YELLOW_RED, true);
+
+ c.Set_Ramp(SG_GET_RGB( 0, 0, 64), SG_GET_RGB(255, 159, 0), 0, 50);
+ c.Set_Ramp(SG_GET_RGB(255, 159, 0), SG_GET_RGB(255, 255, 255), 50, 99);
+
+ if( m_pSumDirect )
+ {
+ m_pSumDirect->Assign(0.0);
+ m_pSumDirect->Set_Unit(_TL("Joule"));
+ DataObject_Set_Colors(m_pSumDirect, c);
+
+ if( m_bUpdateDirect )
+ {
+ m_TmpDirect.Create(*Get_System(), SG_DATATYPE_Float);
+ DataObject_Update(m_pSumDirect, true);
+ }
+ }
+
+ if( m_pSumDiffus )
+ {
+ m_pSumDiffus->Assign(0.0);
+ m_pSumDiffus->Set_Unit(_TL("Joule"));
+ DataObject_Set_Colors(m_pSumDiffus, c);
+
+ if( m_bUpdateDiffus )
+ {
+ m_TmpDiffus.Create(*Get_System(), SG_DATATYPE_Float);
+ DataObject_Update(m_pSumDiffus, true);
+ }
+ }
+
+ if( m_pSumTotal )
+ {
+ m_pSumTotal ->Assign(0.0);
+ m_pSumTotal ->Set_Unit(_TL("Joule"));
+ DataObject_Set_Colors(m_pSumTotal , c);
+
+ if( m_bUpdateTotal )
+ {
+ m_TmpTotal.Create(*Get_System(), SG_DATATYPE_Float);
+ DataObject_Update(m_pSumTotal , true);
+ }
+ }
+
+ //-----------------------------------------------------
+ Process_Set_Text(_TL("initialising gradient..."));
+
+ m_Shade .Create(*Get_System(), SG_DATATYPE_Byte);
+ m_Slope .Create(*Get_System(), SG_DATATYPE_Float);
+ m_Aspect.Create(*Get_System(), SG_DATATYPE_Float);
+
+ for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ double s, a;
+
+ if( m_pDEM->Get_Gradient(x, y, s, a) )
+ {
+ m_Slope .Set_Value(x, y, s);
+ m_Aspect.Set_Value(x, y, a);
+ }
+ else
+ {
+ m_Slope .Set_NoData(x, y);
+ m_Aspect.Set_NoData(x, y);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ if( m_bBending )
+ {
+ Process_Set_Text(_TL("initialising planetary bending..."));
+
+ CSG_Grid *pLat = Parameters("GRD_LAT")->asGrid(),
+ *pLon = Parameters("GRD_LON")->asGrid();
+
+ m_Lat .Create(*Get_System(), SG_DATATYPE_Float);
+ m_Lon .Create(*Get_System(), SG_DATATYPE_Float);
+ m_Decline .Create(*Get_System(), SG_DATATYPE_Float);
+ m_Azimuth .Create(*Get_System(), SG_DATATYPE_Float);
+
+ if( pLat || pLon )
+ {
+ if( pLat )
+ {
+ m_Lat = *pLat;
+ m_Lat *= M_DEG_TO_RAD;
+ }
+
+ if( pLon )
+ {
+ m_Lon = *pLon;
+ m_Lon *= M_DEG_TO_RAD;
+ }
+ }
+
+ //-------------------------------------------------
+ else
+ {
+ double d, dx, dy, dxA, dyA;
+
+ d = M_DEG_TO_RAD / (Parameters("RADIUS")->asDouble() * M_PI / 180.0);
+
+ switch( Parameters("LON_OFFSET")->asInt() )
+ {
+ case 0: dxA = Get_System()->Get_Extent().Get_XMin(); break; // left
+ case 1: dxA = Get_System()->Get_Extent().Get_XCenter(); break; // center
+ case 2: dxA = Get_System()->Get_Extent().Get_XMax(); break; // right
+ case 3: dxA = Parameters("LON_REF_USER")->asDouble(); break; // user defined coordinate
+ }
+
+ switch( Parameters("LAT_OFFSET")->asInt() )
+ {
+ case 0: dyA = Get_System()->Get_Extent().Get_YMin(); break; // bottom
+ case 1: dyA = Get_System()->Get_Extent().Get_YCenter(); break; // center
+ case 2: dyA = Get_System()->Get_Extent().Get_YMax(); break; // top
+ case 3: dyA = Parameters("LAT_REF_USER")->asDouble(); break; // user defined coordinate
+ }
+
+ dxA = d * (Get_XMin() - dxA);
+ dyA = d * (Get_YMin() - dyA) + m_Latitude;
+ d *= Get_Cellsize();
+
+ for(y=0, dy=dyA; y<Get_NY() && Set_Progress(y); y++, dy+=d)
+ {
+ for(x=0, dx=dxA; x<Get_NX(); x++, dx+=d)
+ {
+ m_Lat.Set_Value(x, y, dy);
+ m_Lon.Set_Value(x, y, dx);
+ }
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSADO_SolarRadiation::Finalise(double SumFactor)
+{
+ //-----------------------------------------------------
+ if( m_pSumDirect )
+ {
+ if( m_bUpdateDirect ) m_pSumDirect->Assign(&m_TmpDirect);
+ if( SumFactor != 1.0 ) *m_pSumDirect *= SumFactor;
+ }
+
+ if( m_pSumDiffus )
+ {
+ if( m_bUpdateDiffus ) m_pSumDiffus->Assign(&m_TmpDiffus);
+ if( SumFactor != 1.0 ) *m_pSumDiffus *= SumFactor;
+ }
+
+ if( m_pSumTotal )
+ {
+ if( m_bUpdateTotal ) m_pSumTotal->Assign(&m_TmpTotal);
+ if( SumFactor != 1.0 ) *m_pSumTotal *= SumFactor;
+ }
+
+ //-----------------------------------------------------
+ m_Shade .Destroy();
+ m_Slope .Destroy();
+ m_Aspect .Destroy();
+
+ m_Lat .Destroy();
+ m_Lon .Destroy();
+ m_Decline .Destroy();
+ m_Azimuth .Destroy();
+
+ m_TmpDirect .Destroy();
+ m_TmpDiffus .Destroy();
+ m_TmpTotal .Destroy();
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSADO_SolarRadiation::Get_Insolation(void)
+{
+ //-----------------------------------------------------
+ if( Initialise() )
+ {
+ if( m_bMoment )
+ {
+ Get_Insolation(m_Day_A, m_Hour);
+
+ Finalise();
+ }
+
+ //-------------------------------------------------
+ else
+ {
+ for(int Day=m_Day_A; Day<=m_Day_B && Process_Get_Okay(false); Day+=m_dDays)
+ {
+ for(double Hour=m_Hour; Hour<24.0 && Process_Get_Okay(false); Hour+=m_dHour)
+ {
+ Process_Set_Text(CSG_String::Format(SG_T("%s: %d(%d-%d), %s: %f"), _TL("Day"), Day, m_Day_A, m_Day_B, _TL("Hour"), Hour));
+
+ if( m_bUpdateDirect ) m_pSumDirect->Assign(0.0);
+ if( m_bUpdateDiffus ) m_pSumDiffus->Assign(0.0);
+ if( m_bUpdateTotal ) m_pSumTotal ->Assign(0.0);
+
+ if( Get_Insolation(Day, Hour) )
+ {
+ if( m_bUpdateDirect )
+ {
+ m_TmpDirect += *m_pSumDirect;
+ DataObject_Update(m_pSumDirect);
+ }
+
+ if( m_bUpdateDiffus )
+ {
+ m_TmpDiffus += *m_pSumDiffus;
+ DataObject_Update(m_pSumDiffus);
+ }
+
+ if( m_bUpdateTotal )
+ {
+ m_TmpTotal += *m_pSumTotal;
+ DataObject_Update(m_pSumTotal);
+ }
+ }
+ }
+ }
+
+ Finalise(m_dHour / (24.0 * (1 + m_Day_B - m_Day_A))); // *m_pSumDirect *= m_dHour / D->size();
+ }
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSADO_SolarRadiation::Get_Insolation(int Day, double Hour)
+{
+ double Azimuth, Decline;
+
+ if( m_bBending )
+ {
+ bool bGo = false;
+
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
+ {
+ Get_Solar_Position(Day, Hour, m_Lat.asDouble(x, y), m_Lon.asDouble(x, y), Decline, Azimuth);
+
+ m_Azimuth.Set_Value(x, y, Azimuth);
+ m_Decline.Set_Value(x, y, Decline);
+
+ if( Decline > 0.0 )
+ {
+ bGo = true;
+ }
+ }
+ }
+
+ if( bGo )
+ {
+ return( Set_Insolation(Decline, Azimuth) );
+ }
+ }
+ else if( Get_Solar_Position(Day, Hour, m_Latitude, 0.0, Decline, Azimuth) )
+ {
+ return( Set_Insolation(Decline, Azimuth) );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+inline double CSADO_SolarRadiation::Get_Vapour_Exponent(double VapourPressure)
+{
+ return( 0.916 - (VapourPressure > 0.0 ? 0.05125 * sqrt(VapourPressure) : 0.0) );
+}
+
+//---------------------------------------------------------
+inline double CSADO_SolarRadiation::Get_Vapour_A(double VapourPressure)
+{
+ return( 0.4158 + (VapourPressure > 0.0 ? 0.0399 * sqrt(VapourPressure) : 0.0) );
+}
+
+//---------------------------------------------------------
+bool CSADO_SolarRadiation::Set_Insolation(double Decline, double Azimuth)
+{
+ int x, y;
+ double a, e, Direct, Diffus;
+
+ Get_Shade(Decline, Azimuth);
+
+ e = Get_Vapour_Exponent (m_VP);
+ a = Get_Vapour_A (m_VP);
+
+ for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ if( m_pDEM->is_NoData(x, y) )
+ {
+ if( m_pSumDirect ) m_pSumDirect->Set_NoData(x, y);
+ if( m_pSumDiffus ) m_pSumDiffus->Set_NoData(x, y);
+ if( m_pSumTotal ) m_pSumTotal ->Set_NoData(x, y);
+ }
+ else
+ {
+ if( m_pVP != NULL )
+ {
+ e = Get_Vapour_Exponent (m_pVP->asDouble(x, y));
+ a = Get_Vapour_A (m_pVP->asDouble(x, y));
+ }
+
+ if( m_bBending )
+ {
+ Azimuth = m_Azimuth.asDouble(x, y);
+ Decline = m_Decline.asDouble(x, y);
+ }
+
+ if( Decline > 0.0 )
+ {
+ Direct = Get_Solar_Direct(x, y, Decline, Azimuth, e);
+ Diffus = Get_Solar_Diffus(x, y, Decline, a , e);
+
+ if( m_pSumDirect ) m_pSumDirect->Add_Value(x, y, Direct);
+ if( m_pSumDiffus ) m_pSumDiffus->Add_Value(x, y, Diffus);
+ if( m_pSumTotal ) m_pSumTotal ->Add_Value(x, y, Direct + Diffus);
+ }
+ }
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+inline double CSADO_SolarRadiation::Get_Solar_Reduction(double Elevation, double Decline, double Reduction)
+{
+ return( Decline > 0.0 ? (m_Solar_Const * pow(Reduction, (1.0 - Elevation / m_Atmosphere) / sin(Decline))) : 0.0 );
+}
+
+//---------------------------------------------------------
+inline double CSADO_SolarRadiation::Get_Solar_Direct(int x, int y, double Decline, double Azimuth, double Exponent)
+{
+ if( m_Shade.asInt(x, y) == 0 )
+ {
+ double Angle, Slope;
+
+ Slope = m_bHorizon ? 0.0 : m_Slope.asDouble(x, y);
+
+ Angle = cos(Slope) * cos(Decline - M_PI_090)
+ + sin(Slope) * sin(M_PI_090 - Decline)
+ * cos(Azimuth - m_Aspect.asDouble(x, y));
+
+ if( Angle > 0.0 )
+ {
+ return( Angle * Get_Solar_Reduction(m_pDEM->asDouble(x, y), Decline, Exponent) );
+ }
+ }
+
+ return( 0.0 );
+}
+
+//---------------------------------------------------------
+inline double CSADO_SolarRadiation::Get_Solar_Diffus(int x, int y, double Decline, double A, double Exponent)
+{
+ double Dh, Ih, d, Slope, srad;
+
+ Ih = Get_Solar_Reduction(m_pDEM->asDouble(x, y), Decline, Exponent) * sin(Decline);
+// Decline *= M_RAD_TO_DEG; // Fehler in SADO ????!!!!!
+ d = m_Atmosphere / (m_Atmosphere - m_pDEM->asDouble(x, y))
+ * (0.0001165 * Decline*Decline - 0.0152 * Decline + A);
+ d = 1.0 - d;
+ Dh = Ih / d - Ih;
+
+ Slope = m_bHorizon ? 0.0 : m_Slope.asDouble(x, y);
+
+ srad = (Dh + Dh * cos(Slope)) / 2.0;
+
+ return( srad < 0.0 || srad > m_Solar_Const ? m_Solar_Const : srad );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSADO_SolarRadiation::Get_Shade(double Decline, double Azimuth)
+{
+ //-----------------------------------------------------
+ m_Shade.Assign(0.0);
+
+ if( !m_bBending )
+ {
+ int i, x, y;
+ double dx, dy, dz;
+
+ Get_Shade_Params(Decline, Azimuth, dx, dy, dz);
+
+ for(i=0; i<Get_NCells() && Set_Progress_NCells(i); i++)
+ {
+ if( m_pDEM->Get_Sorted(i, x, y) && !Get_Shade_Complete(x, y) )
+ {
+ Set_Shade(x, y, dx, dy, dz);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ else
+ {
+ int i, x, y, iLock;
+
+ for(i=0, iLock=1; i<Get_NCells() && Set_Progress_NCells(i); i++, iLock++)
+ {
+ if( m_pDEM->Get_Sorted(i, x, y) && !Get_Shade_Complete(x, y) )
+ {
+ if( iLock >= 255 )
+ iLock = 1;
+
+ if( iLock == 1 )
+ Lock_Create();
+
+ Set_Shade_Bended(x, y, iLock);
+ }
+ }
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+void CSADO_SolarRadiation::Set_Shade(int x, int y, double dx, double dy, double dz)
+{
+ for(double ix=x+0.5, iy=y+0.5, iz=m_pDEM->asDouble(x, y); ; )
+ {
+ x = (int)(ix += dx);
+ y = (int)(iy += dy);
+ iz -= dz;
+
+ if( !is_InGrid(x, y) || m_pDEM->asDouble(x, y) > iz )
+ {
+ return;
+ }
+
+ m_Shade.Set_Value(x, y, 1);
+ }
+}
+
+//---------------------------------------------------------
+void CSADO_SolarRadiation::Set_Shade_Bended(int x, int y, char iLock)
+{
+ double dx, dy, dz;
+
+ Get_Shade_Params(m_Decline.asDouble(x, y), m_Azimuth.asDouble(x, y), dx, dy, dz);
+
+ for(double ix=x+0.5, iy=y+0.5, iz=m_pDEM->asDouble(x, y); ; )
+ {
+ x = (int)(ix += dx);
+ y = (int)(iy += dy);
+ iz -= dz;
+
+ if( !is_InGrid(x, y) || m_pDEM->asDouble(x, y) > iz || Lock_Get(x, y) == iLock )
+ {
+ return;
+ }
+
+ m_Shade.Set_Value(x, y, 1);
+
+ //---------------------------------------------
+ Lock_Set(x, y, iLock);
+
+ Get_Shade_Params(m_Decline.asDouble(x, y), m_Azimuth.asDouble(x, y), dx, dy, dz);
+ }
+}
+
+//---------------------------------------------------------
+inline bool CSADO_SolarRadiation::Get_Shade_Complete(int x, int y)
+{
+ if( m_Shade.asInt(x, y) == 1 )
+ {
+ for(int iy=y-1; iy<=y+1; iy++)
+ {
+ for(int ix=x-1; ix<x+1; ix++)
+ {
+ if( is_InGrid(ix, iy) && m_Shade.asInt(ix, iy) == 0 )
+ {
+ return( false );
+ }
+ }
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+inline void CSADO_SolarRadiation::Get_Shade_Params(double Decline, double Azimuth, double &dx, double &dy, double &dz)
+{
+ dz = Azimuth + M_PI_180;
+ dx = sin(dz);
+ dy = cos(dz);
+
+ if( fabs(dx) > fabs(dy) )
+ {
+ dy /= fabs(dx);
+ dx = dx < 0 ? -1 : 1;
+ }
+ else if( fabs(dy) > fabs(dx) )
+ {
+ dx /= fabs(dy);
+ dy = dy < 0 ? -1 : 1;
+ }
+ else
+ {
+ dx = dx < 0 ? -1 : 1;
+ dy = dy < 0 ? -1 : 1;
+ }
+
+ dz = tan(Decline) * sqrt(dx*dx + dy*dy) * Get_Cellsize();
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+inline bool CSADO_SolarRadiation::Get_Solar_Position(int Day, double Hour, double LAT, double LON, double &Declination, double &Azimuth)
+{
+ static const int Day2Month[13] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 366 };
+
+ static const double ECLIPTIC_OBL = M_DEG_TO_RAD * 23.43999; // obliquity of ecliptic
+
+ int i;
+
+ double JD, T, M, L, X, Y, Z, R, UTime,
+ DEC, RA, theta, tau,
+ Month, Year = 2000;
+
+ //-----------------------------------------------------
+
+ for(Month=1, i=0; i<=12; i++)
+ {
+ if( Day < Day2Month[i] )
+ {
+ Month = i;
+ Day -= Day2Month[i - 1];
+ break;
+ }
+ }
+
+ if( Month < 1 || Month > 12 ) // nur Tag (1 - 365) zaehlt...
+ {
+ Month = 1;
+ }
+
+ if( Month <= 2 )
+ {
+ Month += 12;
+ Year -= 1;
+ }
+
+
+ //-----------------------------------------------------
+
+// UTime = Hour - LON * 12.0 / M_PI;
+ UTime = Hour;
+
+
+ //-----------------------------------------------------
+ // 1. Julian Date...
+
+ JD = (int)(365.25 * Year) + (int)(30.6001 * (Month + 1)) - 15 + 1720996.5 + Day + UTime / 24.0;
+ T = (JD - 2451545.0 ) / 36525.0; // number of Julian centuries since 2000/01/01 at 12 UT (JD = 2451545.0)
+
+
+ //-----------------------------------------------------
+ // 2. Solar Coordinates (according to: Jean Meeus: Astronomical Algorithms), accuracy of 0.01 degree
+
+ M = M_DEG_TO_RAD * (357.52910 + 35999.05030 * T - 0.0001559 * T * T - 0.00000048 * T * T * T); // mean anomaly
+ L = M_DEG_TO_RAD * ( (280.46645 + 36000.76983 * T + 0.0003032 * T * T) // mean longitude
+ + ( (1.914600 - 0.004817 * T - 0.000014 * T * T) * sin(M)
+ + (0.019993 - 0.000101 * T) * sin(2 * M) + 0.000290 * sin(3 * M) // true longitude
+ )
+ );
+
+
+ //-----------------------------------------------------
+ // 3. convert ecliptic longitude to right ascension RA and declination delta
+
+ X = cos(L);
+ Y = cos(ECLIPTIC_OBL) * sin(L);
+ Z = sin(ECLIPTIC_OBL) * sin(L);
+ R = sqrt(1.0 - Z*Z);
+
+ DEC = atan2(Z, R);
+ RA = 2.0 * atan2(Y, (X + R));
+
+
+ //-----------------------------------------------------
+ // 4. compute sidereal time (degree) at Greenwich local sidereal time at longitude (Degree)
+
+ theta = LON + M_DEG_TO_RAD * (280.46061837 + 360.98564736629 * (JD - 2451545.0) + T*T * (0.000387933 - T / 38710000.0));
+
+
+ //-----------------------------------------------------
+ // 5. compute local hour angle (degree)
+
+ tau = theta - RA;
+
+
+ //-----------------------------------------------------
+ // 6. convert (tau, delta) to horizon coordinates (h, az) of the observer
+
+ Declination = asin ( sin(LAT) * sin(DEC) + cos(LAT) * cos(DEC) * cos(tau) );
+
+ Azimuth = atan2( -sin(tau) * cos(DEC), cos(LAT) * sin(DEC) - sin(LAT) * cos(DEC) * cos(tau) );
+// Azimuth = atan2( -sin(Tau), cos(LAT) * tan(DEC) - sin(LAT) * cos(Tau) ); // previous formula gives same result but is better because of division by zero effects...
+
+ return( Declination > 0.0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+/*/---------------------------------------------------------
+#define CHECK_SHADOW(X, Y) if( (d = SG_Get_Distance(x, y, X, Y) * Get_Cellsize()) > 0.0 )\
+ {\
+ if( (t = (m_pDEM->asDouble(X, Y) - z) / d) > tMax )\
+ {\
+ tMax = t;\
+ }\
+ \
+ if( (d = zMax / d) < tanDec || d < tMax )\
+ {\
+ return( false );\
+ }\
+ else if( tMax > tanDec )\
+ {\
+ return( true );\
+ }\
+ }
+
+//---------------------------------------------------------
+bool CSADO_SolarRadiation::Get_Solar_Shadow(int x, int y, double Decline, double Azimuth)
+{
+ static double Zenith = 89.9999 * M_DEG_TO_RAD;
+
+ //-----------------------------------------------------
+ if( Decline >= Zenith || Decline > m_Slope.Get_ZMax() )
+ {
+ return( false );
+ }
+
+ if( Decline <= 0.0 )
+ {
+ return( true );
+ }
+
+ //-----------------------------------------------------
+ bool bGo;
+ int dx, nx, ix, iy, iy_Last, jy;
+ double dy, d, t, tMax, z, zMax, tanDec;
+
+ //-----------------------------------------------------
+ Azimuth = fmod(Azimuth, M_PI_360); if( Azimuth < 0.0 ) Azimuth += M_PI_360;
+
+ if( Azimuth < M_PI_180 )
+ {
+ dx = 1;
+ nx = Get_NX() - 1;
+ }
+ else
+ {
+ dx = -1;
+ nx = 0;
+ }
+
+ Azimuth = M_PI_090 - Azimuth;
+
+ if( Azimuth == M_PI_090 )
+ Azimuth = 89.9999 * M_DEG_TO_RAD;
+ else if( Azimuth == -M_PI_090 )
+ Azimuth = - 89.9999 * M_DEG_TO_RAD;
+ else if( Azimuth == -M_PI_180 )
+ Azimuth = -179.9999 * M_DEG_TO_RAD;
+ else if( Azimuth == -M_PI_270)
+ Azimuth = -269.9999 * M_DEG_TO_RAD;
+
+ dy = tan(Azimuth);
+
+ //-----------------------------------------------------
+ z = m_pDEM->asDouble(x, y);
+ zMax = m_pDEM->Get_ZMax();
+ tanDec = tan(Decline);
+ tMax = 0.0;
+
+ //-----------------------------------------------------
+ for(ix=x, iy=y, bGo=true; ix!=nx && bGo; ix+=dx)
+ {
+ iy_Last = iy;
+ iy = y + (int)floor(dy * (ix - x + (dx > 0 ? 0.5 : -0.5)));
+
+ if( iy < 0 )
+ {
+ bGo = false;
+ iy = 0;
+ }
+ else if( iy >= Get_NY() )
+ {
+ bGo = false;
+ iy = Get_NY() - 1;
+ }
+
+ //-------------------------------------------------
+ if( iy_Last < iy )
+ {
+ for(jy=iy_Last+1; jy<=iy; jy++)
+ {
+ CHECK_SHADOW(ix, jy);
+ }
+ }
+ else if( iy_Last > iy )
+ {
+ for(jy=iy_Last; jy>iy; jy--)
+ {
+ CHECK_SHADOW(ix, jy);
+ }
+ }
+ else if( iy_Last == iy )
+ {
+ CHECK_SHADOW(ix, iy);
+ }
+ }
+
+ return( false );
+}/**/
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_lighting/SolarRadiation.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_lighting/SolarRadiation.cpp
index 3285f9b..1778b39 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_lighting/SolarRadiation.cpp
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_lighting/SolarRadiation.cpp
@@ -1,796 +1,841 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Module Library: //
-// ta_lighting //
-// //
-//-------------------------------------------------------//
-// //
-// SolarRadiation.cpp //
-// //
-// Copyright (C) 2003 by //
-// Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "SolarRadiation.h"
-#include "HillShade.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSolarRadiation::CSolarRadiation(void)
-{
- CSG_Parameter *pNode_0, *pNode_1, *pNode_2;
-
- //-----------------------------------------------------
- Set_Name(_TL("Incoming Solar Radiation"));
-
- Set_Author (SG_T("(c) 2001 by O.Conrad"));
-
- Set_Description (_TW(
- "Calculation of the potential incoming solar radiation.\n\n"
- "Reference:\n"
- "- Wilson, J.P., Gallant, J.C., (Eds.), 2000:\n"
- " 'Terrain analysis - principles and applications',\n"
- " New York, John Wiley & Sons, Inc.")
- );
-
-
- //-----------------------------------------------------
- pNode_0 = Parameters.Add_Grid(
- NULL , "ELEVATION" , _TL("Elevation"),
- _TL(""),
- PARAMETER_INPUT
- );
-
-
- //-----------------------------------------------------
- pNode_0 = Parameters.Add_Grid(
- NULL , "INSOLAT" , _TL("Solar Radiation"),
- _TL(""),
- PARAMETER_OUTPUT
- );
-
- pNode_0 = Parameters.Add_Grid(
- NULL , "DURATION" , _TL("Duration of Insolation"),
- _TL(""),
- PARAMETER_OUTPUT
- );
-
- pNode_1 = Parameters.Add_Value(
- pNode_0 , "UPDATE" , _TL("Update View"),
- _TL("Show each time step during calculation."),
- PARAMETER_TYPE_Bool , true
- );
-
- pNode_1 = Parameters.Add_Choice(
- pNode_0 , "UNIT" , _TL("Unit"),
- _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|"),
- _TL("kWh/m\xc2\xb2"),
- _TL("J/m\xc2\xb2")
- ), 0
- );
-
-
- //-----------------------------------------------------
- pNode_0 = Parameters.Add_Node(
- NULL , "NODE_SOLAR" , _TL("Solar Radiation"),
- _TL("")
- );
-
- pNode_1 = Parameters.Add_Value(
- pNode_0 , "SOLCONST" , _TL("Solar Constant [W/m\xc2\xb2]"),
- _TL(""),
- PARAMETER_TYPE_Double , 1367
- );
-
- pNode_1 = Parameters.Add_Choice(
- pNode_0 , "METHOD" , _TL("Atmospheric Effects"),
- _TL("Account for atmospheric effects using either a lumped atmospheric transmittance approach or by calculating the components (water and dust)."),
-
- CSG_String::Format(SG_T("%s|%s|"),
- _TL("Lumped atmospheric transmittance"),
- _TL("Calculating the components")
- ), 0
- );
-
- pNode_1 = Parameters.Add_Value(
- pNode_0 , "TRANSMITT" , _TL("Lumped Transmittance [%]"),
- _TL("The transmittance of the atmosphere (usually between 60 and 80%)"),
- PARAMETER_TYPE_Double , 70,
- 0.0 , true,
- 100.0 , true
- );
-
- pNode_1 = Parameters.Add_Value(
- pNode_0 , "PRESSURE" , _TL("Atmospheric Pressure [mb]"),
- _TL(""),
- PARAMETER_TYPE_Double , 1013,
- 0.0 , true
- );
-
- pNode_1 = Parameters.Add_Value(
- pNode_0 , "WATER" , _TL("Water Content [cm]"),
- _TL("Water content of a vertical slice of atmosphere in cm: 1.5 to 1.7, average=1.68"),
- PARAMETER_TYPE_Double , 1.68,
- 0.0 , true
- );
-
- pNode_1 = Parameters.Add_Value(
- pNode_0 , "DUST" , _TL("Dust [ppm]"),
- _TL("Dust factor: 100 ppm (standard)"),
- PARAMETER_TYPE_Double , 100,
- 0.0 , true
- );
-
- pNode_1 = Parameters.Add_Value(
- pNode_0 , "LATITUDE" , _TL("Latitude [Degree]"),
- _TL(""),
- PARAMETER_TYPE_Double , 53.5,
- -90.0 , true,
- 90.0 , true
- );
-
-
- //-----------------------------------------------------
- // Daily Time Resolution...
-
- pNode_0 = Parameters.Add_Node(
- NULL , "NODE_HOUR" , _TL("Daily Time Resolution"),
- _TL("")
- );
-
- pNode_1 = Parameters.Add_Range(
- pNode_0 , "HOUR_RANGE" , _TL("Time Span [h]"),
- _TL("Time span used for the calculation of daily radiation sums."),
- 0.0 , 24.0,
- 0.0 , true,
- 24.0 , true
- );
-
- pNode_1 = Parameters.Add_Value(
- pNode_0 , "HOUR_STEP" , _TL("Time Step [h]"),
- _TL("Time step size used for the calculation of daily radiation sums."),
- PARAMETER_TYPE_Double , 1.0,
- 0.001 , true,
- 12.0 , true
- );
-
-
- //-----------------------------------------------------
- // Time Settings...
-
- pNode_0 = Parameters.Add_Choice(
- NULL , "TIMESPAN" , _TL("Simulation Time"),
- _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|%s|"),
- _TL("Single Day"),
- _TL("Range of Days"),
- _TL("One Year")
- ), 0
- );
-
- //-----------------------------------------------------
- pNode_1 = Parameters.Add_Node(
- pNode_0 , "NODE_SINGLE_DAY" , _TL("Single Day"),
- _TL("")
- );
-
- pNode_2 = Parameters.Add_Choice(
- pNode_1 , "SINGLE_DAY_DAY" , _TL("Day"),
- _TL(""),
-
- SG_T(" 1| 2| 3| 4| 5| 6| 7| 8| 9| 10|")
- SG_T(" 11| 12| 13| 14| 15| 16| 17| 18| 19| 20|")
- SG_T(" 21| 22| 23| 24| 25| 26| 27| 28| 29| 30|")
- SG_T(" 31|"), 20
- );
-
- pNode_2 = Parameters.Add_Choice(
- pNode_1 , "SINGLE_DAY_MONTH" , _TL("Month"),
- _TL(""),
-
- CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"),
- _TL("January"),
- _TL("February"),
- _TL("March"),
- _TL("April"),
- _TL("May"),
- _TL("June"),
- _TL("July"),
- _TL("August"),
- _TL("September"),
- _TL("October"),
- _TL("November"),
- _TL("December")
- ), 2
- );
-
-
- //-----------------------------------------------------
- // Range of Days...
-
- pNode_1 = Parameters.Add_Node(
- pNode_0 , "NODE_DAY_RANGE" , _TL("Range of Days"),
- _TL("")
- );
-
- pNode_2 = Parameters.Add_Range(
- pNode_1 , "DAY_RANGE" , _TL("Time Span [day of year]"),
- _TL(""),
- 1 , 31,
- -365 , true,
- 366 , true
- );
-
- pNode_2 = Parameters.Add_Value(
- pNode_1 , "DAY_STEP" , _TL("Time Step [number of days]"),
- _TL(""),
- PARAMETER_TYPE_Int, 5,
- 1 , true,
- 100 , true
- );
-}
-
-//---------------------------------------------------------
-CSolarRadiation::~CSolarRadiation(void)
-{}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSolarRadiation::On_Execute(void)
-{
- static const int Month2Day[12] = { 0, 31, 49, 80, 109, 140, 170, 201, 232, 272, 303, 333 };
-
- //-----------------------------------------------------
- int Day_Step, Day_Start, Day_Stop;
- double Latitude, Hour_Step, Hour_Start, Hour_Stop;
- CSG_Colors Colors;
-
- //-----------------------------------------------------
- m_pDTM = Parameters("ELEVATION") ->asGrid();
- m_pRadiation = Parameters("INSOLAT") ->asGrid();
- m_pDuration = Parameters("DURATION") ->asGrid();
-
- m_SolarConstant = Parameters("SOLCONST") ->asDouble() / 1000.0; // [kW / m²]
-
- m_Method = Parameters("METHOD") ->asInt();
- m_Transmittance = Parameters("TRANSMITT") ->asDouble() / 100.0;
- m_Pressure = Parameters("PRESSURE") ->asDouble();
- m_Water = Parameters("WATER") ->asDouble();
- m_Dust = Parameters("DUST") ->asDouble();
-
- Latitude = Parameters("LATITUDE") ->asDouble() * M_DEG_TO_RAD;
-
- Day_Step = Parameters("DAY_STEP") ->asInt();
- Hour_Step = Parameters("HOUR_STEP") ->asDouble();
- Hour_Start = Parameters("HOUR_RANGE") ->asRange()->Get_LoVal();
- Hour_Stop = Parameters("HOUR_RANGE") ->asRange()->Get_HiVal();
-
- //-----------------------------------------------------
- m_pSum = SG_Create_Grid(m_pDTM);
-
- //-----------------------------------------------------
- switch( Parameters("TIMESPAN")->asInt() )
- {
- case 0: // single day...
- Day_Start = Parameters("SINGLE_DAY_MONTH")->asInt();
- Day_Start = Parameters("SINGLE_DAY_DAY") ->asInt() + (Day_Start >= 0 && Day_Start < 12 ? Month2Day[Day_Start] : 0);
-
- Execute_DailySum (Latitude, Hour_Step, Hour_Start, Hour_Stop, Day_Start);
- break;
-
- case 1: // range of days...
- Day_Start = (int)Parameters("DAY_RANGE") ->asRange()->Get_LoVal() - 1;
- Day_Stop = (int)Parameters("DAY_RANGE") ->asRange()->Get_HiVal() - 1;
-
- Execute_SumOfDays(Latitude, Hour_Step, Hour_Start, Hour_Stop, Day_Step, Day_Start, Day_Stop);
- break;
-
- case 2: // one year...
- Day_Start = -10; // winter solstitute...
- Day_Stop = 173; // until half year has passed...
-
- Execute_SumOfDays(Latitude, Hour_Step, Hour_Start, Hour_Stop, Day_Step, Day_Start, Day_Stop);
-
- *m_pRadiation *= 2.0; // two times...
- *m_pDuration *= 2.0; // two times...
- break;
- }
-
- //-----------------------------------------------------
- delete( m_pSum );
-
- Colors.Set_Count(100);
- Colors.Set_Ramp(SG_GET_RGB( 0, 0, 64), SG_GET_RGB(255, 159, 0), 0, 50);
- Colors.Set_Ramp(SG_GET_RGB(255, 159, 0), SG_GET_RGB(255, 255, 255), 50, 99);
-
- DataObject_Set_Colors(m_pRadiation, Colors);
- DataObject_Set_Colors(m_pDuration , Colors);
-
- m_pDuration->Set_Unit(_TL("h"));
-
- if( Parameters("UNIT")->asInt() == 1 ) // Joule...
- {
- *m_pRadiation *= 10.0 / 36.0; // 1 J = 1 Ws = 1/(60*60) Wh = 1/3600 Wh >> 1 J = 1000/3600 kWh = 10/36 kWh
-
- m_pRadiation->Set_Unit(_TL("J/m\xc2\xb2"));
- }
- else
- {
- m_pRadiation->Set_Unit(_TL("kWh/m\xc2\xb2"));
- }
-
- //-----------------------------------------------------
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CSolarRadiation::Execute_DailySum(double Latitude_RAD, double Hour_Step, double Hour_Start, double Hour_Stop, int Day)
-{
- Get_DailySum(Latitude_RAD, Hour_Step, Hour_Start, Hour_Stop, Day);
-
- m_pRadiation->Assign(m_pSum);
-}
-
-//---------------------------------------------------------
-void CSolarRadiation::Execute_SumOfDays(double Latitude_RAD, double Hour_Step, double Hour_Start, double Hour_Stop, int Day_Step, int Day_Start, int Day_Stop)
-{
- int Day, nDays;
- CSG_Grid *pSumOfDays, *pDur_Total;
-
- //-----------------------------------------------------
- nDays = Day_Stop - Day_Start;
-
- if( nDays < 1 )
- {
- Execute_DailySum(Latitude_RAD, Hour_Step, Hour_Start, Hour_Stop, Day_Start);
- }
-
- //-----------------------------------------------------
- else
- {
- pSumOfDays = SG_Create_Grid(m_pDTM);
- pDur_Total = SG_Create_Grid(m_pDTM);
-
- if( Day_Step < 1 || Day_Step > nDays )
- {
- Day_Step = 1;
- }
-
- //-------------------------------------------------
- for(Day=Day_Start; Day<Day_Stop && Set_Progress(Day - Day_Start, nDays); Day+=Day_Step)
- {
- Get_DailySum(Latitude_RAD, Hour_Step, Hour_Start, Hour_Stop, Day, false);
-
- *m_pSum *= Day_Step;
- *pSumOfDays += *m_pSum;
-
- *m_pDuration *= Day_Step;
- *pDur_Total += *m_pDuration;
- }
-
- if( (Day_Step = Day_Stop - Day) > 0 ) // Rest...
- {
- Get_DailySum(Latitude_RAD, Hour_Step, Hour_Start, Hour_Stop, Day, false);
-
- *m_pSum *= Day_Step;
- *pSumOfDays += *m_pSum;
-
- *m_pDuration *= Day_Step;
- *pDur_Total += *m_pDuration;
- }
-
- //-------------------------------------------------
- m_pRadiation ->Assign(pSumOfDays);
- delete(pSumOfDays);
-
- m_pDuration ->Assign(pDur_Total);
- delete(pDur_Total);
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// Daily Sum //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CSolarRadiation::Get_DailySum(double Latitude_RAD, double Hour_Step, double Hour_Start, double Hour_Stop, int Day, bool bProgressBar)
-{
- bool bNight;
- double time, Sol_Height, Sol_Azimuth, Solar_Angle, RDIRN, RDIFN, d;
- CHillShade HillShade;
-
- //-----------------------------------------------------
- Day %= 366;
-
- if( Day < 0 )
- {
- Day += 366;
- }
-
- Hour_Start += Hour_Step / 2.0;
-
- m_pSum ->Assign(0.0);
- m_pDuration ->Assign(0.0);
-
- HillShade.Get_Parameters()->Set_Parameter(SG_T("ELEVATION") , PARAMETER_TYPE_Grid , m_pDTM);
- HillShade.Get_Parameters()->Set_Parameter(SG_T("SHADE") , PARAMETER_TYPE_Grid , m_pRadiation);
- HillShade.Get_Parameters()->Set_Parameter(SG_T("METHOD") , PARAMETER_TYPE_Choice , 3);
- HillShade.Get_Parameters()->Set_Parameter(SG_T("EXAGGERATION") , PARAMETER_TYPE_Double , 1.0);
- HillShade.Set_Show_Progress(false);
-
- //-----------------------------------------------------
- for(time=Hour_Start, bNight=false; time<Hour_Stop && is_Progress(); time+=Hour_Step)
- {
- Process_Set_Text(CSG_String::Format(_TL("%d. Day of Year, Local Time: %dh %02dm"), Day + 1, (int)time, (int)(60.0 * fmod(time, 1.0))));
-
- if( bProgressBar )
- {
- Set_Progress(time, 24.0);
- }
- else
- {
- Process_Get_Okay(false);
- }
-
- //-------------------------------------------------
- if( Get_SolarPosition(Day, time, Latitude_RAD, 0.0, Sol_Azimuth, Sol_Height, false) )
- {
- bNight = false;
-
- HillShade.Get_Parameters()->Set_Parameter(SG_T("AZIMUTH") , PARAMETER_TYPE_Double, (double)M_RAD_TO_DEG * Sol_Azimuth);
- HillShade.Get_Parameters()->Set_Parameter(SG_T("DECLINATION") , PARAMETER_TYPE_Double, (double)M_RAD_TO_DEG * Sol_Height);
- HillShade.Execute();
-
- for(int n=0; n<Get_NCells(); n++)
- {
- if( m_pRadiation->is_NoData(n) )
- {
- m_pSum ->Set_NoData(n);
- m_pDuration ->Set_NoData(n);
- }
- else
- {
- Solar_Angle = m_pRadiation->asDouble(n);
-
- if( Solar_Angle < M_PI_090 )
- {
- Get_SolarCorrection(M_PI_090 - Sol_Height, m_pDTM->asDouble(n), RDIRN, RDIFN);
-
- d = m_SolarConstant * Hour_Step * RDIRN * cos(Solar_Angle);
- // Dir[q,a] = SConst * SunDuration[q,a] * t^m(q) * cos(AngIn[q,a])
-
- m_pSum ->Add_Value(n, d);
- m_pDuration ->Add_Value(n, Hour_Step);
- }
- }
- }
-
- if( Parameters("UPDATE")->asBool() )
- {
- DataObject_Update(m_pRadiation, 20 * M_DEG_TO_RAD, 90.0 * M_DEG_TO_RAD, true);
- }
- }
-
- //-------------------------------------------------
- else if( !bNight )
- {
- bNight = true;
-
- if( Parameters("UPDATE")->asBool() )
- {
- m_pRadiation->Assign(M_PI_090);
-
- DataObject_Update(m_pRadiation, 0, 90.0 * M_DEG_TO_RAD, true);
- }
- }
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// Atmosphere //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CSolarRadiation::Get_SolarCorrection(double ZenithAngle, double Elevation, double &RDIRN, double &RDIFN)
-{
- const double AM[32] = // AM Optical air mass in 1 degree increments for zenith angles >=60 [after LIST, 1968; p. 422]
- {
- 2.00, 2.06, 2.12, 2.19, 2.27, 2.36, 2.45, 2.55,
- 2.65, 2.77, 2.90, 3.05, 3.21, 3.39, 3.59, 3.82,
- 4.07, 4.37, 4.72, 5.12, 5.60, 6.18, 6.88, 7.77,
- 8.90, 10.39, 12.44, 15.36, 19.79, 26.96, 26.96, 26.96
- };
-
- const double Pressure_0 = 1013.0; // Standard atmospheric pressure = 1013 mb
-
- int i;
- double z, AMASS, AMASS2, AW, TW, TD, TDC;
-
- //-----------------------------------------------------
- z = M_RAD_TO_DEG * ZenithAngle;
-
- if( z <= 60.0 )
- {
- AMASS = 1.0 / cos(ZenithAngle);
- }
- else
- {
- z -= 60.0;
- i = (int)z;
- AMASS = AM[i] + (z - i) * (AM[i + 1] - AM[i]);
- }
-
- z = m_Pressure / pow(10.0, Elevation * 5.4667E-05); // P Barometric pressure in mb
- AMASS2 = AMASS * z / Pressure_0;
-
- //-----------------------------------------------------
- switch( m_Method )
- {
- case 0: default:
- RDIRN = pow(m_Transmittance, AMASS2);
- RDIFN = 0.271 - 0.294 * RDIRN;
- break;
-
- case 1:
- AW = 1.0 - 0.077 * pow(m_Water * AMASS2, 0.3); // AW Accounts for absorption by water vapour
- TW = pow(0.975, m_Water * AMASS); // TW Accounts for scattering by water vapour
- TD = pow(0.950, m_Water * m_Dust / 100.0); // TD Accounts for scattering by dust
- TDC = pow(0.900, AMASS2) + 0.026 * (AMASS2 - 1.0); // TDC Accounts for scattering by a dust free atmosphere
-
- RDIRN = AW * TW * TD * TDC;
- RDIFN = 0.5 * (AW - RDIRN);
- break;
- }
-
- // Optical Pathlength (solar zenith angle < 80Degree) =>
- // m(t) = exp(-0.000118 * Elevation - 1.638 * 10e-9 * Elevation) / cos(SolarZenithAngle)
- // if( Method == 2 && Zenithangle < 80 ) // nach bla...
- // RDIRN = pow(m_Transmittance, exp((-0.000118 - 1.638e-8 * Elevation) * Elevation) / cos(ZenithAngle));
-}
-
-/* The original TAPES-G source code for the optical air mass computation
-C ==================================================================
- SUBROUTINE SOLAR(ZA,RDIRN,RDIFN,ITEST)
- COMMON/SOL1/U,D,P,TRANSM
- PARAMETER (PI=3.14159265358979323846)
- PARAMETER (DTOR=PI/180.)
- DIMENSION AM(32)
- DATA AM/2.0,2.06,2.12,2.19,2.27,2.36,2.45,2.55,2.65,2.77,2.9,
- * 3.05,3.21,3.39,3.59,3.82,4.07,4.37,4.72,5.12,5.6,6.18,6.88,
- * 7.77,8.9,10.39,12.44,15.36,19.79,26.96,26.96,26.96/
- DATA PO/1013./
-C ***************************************************************
-C AM Optical air mass in 1 degree increments for zenith angles
-C >=60 [LIST, 1968; p. 422]
-C U Water content of a vertical slice of atmosphere in cm:
-C 1.5 to 1.7, average=1.68
-C D Dust factor: 1=100 ppm (standard); 2=300 ppm
-C P Barometric pressure in mb
-C PO Standard atmospheric pressure = 1013 mb
-C TRANSM Transmittance of the atmosphere (0.6-0.8)
-C AW Accounts for absorption by water vapour
-C TW Accounts for scattering by water vapour
-C TD Accounts for scattering by dust
-C TDC Accounts for scattering by a dust free atmosphere
-C **************************************************************
-C Compute optical air mass
-C
- IF(ZA.LE.60.) THEN
- AMASS=1./COS(ZA*DTOR)
- ELSE
- Y=ZA-59.
- I=INT(Y)
- AMASS=AM(I)+(Y-FLOAT(I))*(AM(I+1)-AM(I))
- ENDIF
- AMASS2=AMASS*P/PO
-C --------------------------------------------------------------
-C Account for atmospheric effects using either a lumped atmos-
-C pheric transmittance approach (ITEST=1) or by calculating the
-C components (ITEST=2)
-C
- IF(ITEST.EQ.1) THEN
- RDIRN=TRANSM**AMASS2
- RDIFN=0.271-0.294*RDIRN
- ELSE
- AW=1.0-0.077*(U*AMASS2)**0.3
- TW=0.975**(U*AMASS)
- TD=0.95**(U*D)
- TDC=0.9**AMASS2+0.026*(AMASS2-1.0)
- RDIRN=AW*TW*TD*TDC
- RDIFN=0.5*(AW-RDIRN)
- ENDIF
- RETURN
- END
-C ====================================================================*/
-
-
-///////////////////////////////////////////////////////////
-// //
-// Solar Position //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSolarRadiation::Get_SolarPosition(int Day, double Time, double LAT, double LON, double &Azimuth, double &Declination, bool bDegree)
-{
- static const int Day2Month[13] = { 0, 31, 49, 80, 109, 140, 170, 201, 232, 272, 303, 333, 366 };
-
- static const double ECLIPTIC_OBL = M_DEG_TO_RAD * 23.43999; // obliquity of ecliptic
-
- int i;
-
- double JD, T, M, L, X, Y, Z, R, UTime,
- DEC, RA, theta, tau,
- Month, Year = 2000;
-
- //-----------------------------------------------------
-
- for(Month=1, i=0; i<=12; i++)
- {
- if( Day < Day2Month[i] )
- {
- Month = i;
- Day -= Day2Month[i - 1];
- break;
- }
- }
-
- if( Month < 1 || Month > 12 ) // nur Tag (1 - 365) zaehlt...
- {
- Month = 1;
- }
-
- if( Month <= 2 )
- {
- Month += 12;
- Year -= 1;
- }
-
-
- //-----------------------------------------------------
-
-// UTime = Time - LON * 12.0 / M_PI;
- UTime = Time;
-
-
- //-----------------------------------------------------
- // 1. Julian Date...
-
- JD = (int)(365.25 * Year) + (int)(30.6001 * (Month + 1)) - 15 + 1720996.5 + Day + UTime / 24.0;
- T = (JD - 2451545.0 ) / 36525.0; // number of Julian centuries since 2000/01/01 at 12 UT (JD = 2451545.0)
-
-
- //-----------------------------------------------------
- // 2. Solar Coordinates (according to: Jean Meeus: Astronomical Algorithms), accuracy of 0.01 degree
-
- M = M_DEG_TO_RAD * (357.52910 + 35999.05030 * T - 0.0001559 * T * T - 0.00000048 * T * T * T); // mean anomaly
- L = M_DEG_TO_RAD * ( (280.46645 + 36000.76983 * T + 0.0003032 * T * T) // mean longitude
- + ( (1.914600 - 0.004817 * T - 0.000014 * T * T) * sin(M)
- + (0.019993 - 0.000101 * T) * sin(2 * M) + 0.000290 * sin(3 * M) // true longitude
- )
- );
-
-
- //-----------------------------------------------------
- // 3. convert ecliptic longitude to right ascension RA and declination delta
-
- X = cos(L);
- Y = cos(ECLIPTIC_OBL) * sin(L);
- Z = sin(ECLIPTIC_OBL) * sin(L);
- R = sqrt(1.0 - Z*Z);
-
- DEC = atan2(Z, R);
- RA = 2 * atan2(Y, (X + R));
-
-
- //-----------------------------------------------------
- // 4. compute sidereal time (degree) at Greenwich local sidereal time at longitude (DegreeE)
-
- theta = LON + M_DEG_TO_RAD * (280.46061837 + 360.98564736629 * (JD - 2451545.0) + T * T * (0.000387933 - T / 38710000.0));
-
-
- //-----------------------------------------------------
- // 5. compute local hour angle (degree)
-
- tau = theta - RA;
-
-
- //-----------------------------------------------------
- // 6. convert (tau, delta) to horizon coordinates (h, az) of the observer
-
- Declination = asin( sin(LAT) * sin(DEC) + cos(LAT) * cos(DEC) * cos(tau) );
- Azimuth = atan2( -sin(tau) * cos(DEC), cos(LAT) * sin(DEC) - sin(LAT) * cos(DEC) * cos(tau) );
- //Azimuth = atan2( -sin(Tau), cos(LAT) * tan(DEC) - sin(LAT) * cos(Tau) ); // erstere ist besser wegen division by zero effects...
-
- if( bDegree )
- {
- Declination *= M_RAD_TO_DEG;
- Azimuth *= M_RAD_TO_DEG;
- }
-
- return( Declination >= 0.0 );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ta_lighting //
+// //
+//-------------------------------------------------------//
+// //
+// SolarRadiation.cpp //
+// //
+// Copyright (C) 2003 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "SolarRadiation.h"
+#include "HillShade.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSolarRadiation::CSolarRadiation(void)
+{
+ CSG_Parameter *pNode_0, *pNode_1, *pNode_2;
+
+ //-----------------------------------------------------
+ Set_Name(_TL("Incoming Solar Radiation"));
+
+ Set_Author (SG_T("(c) 2001 by O.Conrad"));
+
+ Set_Description (_TW(
+ "Calculation of the potential incoming solar radiation.\n\n"
+ "Reference:\n"
+ "- Wilson, J.P., Gallant, J.C., (Eds.), 2000:\n"
+ " 'Terrain analysis - principles and applications',\n"
+ " New York, John Wiley & Sons, Inc.")
+ );
+
+
+ //-----------------------------------------------------
+ pNode_0 = Parameters.Add_Grid(
+ NULL , "ELEVATION" , _TL("Elevation"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+
+ //-----------------------------------------------------
+ pNode_0 = Parameters.Add_Grid(
+ NULL , "INSOLAT" , _TL("Solar Radiation"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "UPDATE" , _TL("Update View"),
+ _TL("Show each time step during calculation."),
+ PARAMETER_TYPE_Bool , true
+ );
+
+ pNode_1 = Parameters.Add_Choice(
+ pNode_0 , "UNIT" , _TL("Unit"),
+ _TL(""),
+
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("kWh/m\xc2\xb2"),
+ _TL("J/m\xc2\xb2")
+ ), 0
+ );
+
+ Parameters.Add_Grid(
+ NULL , "DURATION" , _TL("Duration of Insolation"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "SUNRISE" , _TL("Sunrise"),
+ _TL("time of sunrise/sunset is only calculated if time span is set to single day"),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid(
+ NULL , "SUNSET" , _TL("Sunset"),
+ _TL("time of sunrise/sunset is only calculated if time span is set to single day"),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+
+ //-----------------------------------------------------
+ pNode_0 = Parameters.Add_Node(
+ NULL , "NODE_SOLAR" , _TL("Solar Radiation"),
+ _TL("")
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "SOLCONST" , _TL("Solar Constant [W/m\xc2\xb2]"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 1367
+ );
+
+ pNode_1 = Parameters.Add_Choice(
+ pNode_0 , "METHOD" , _TL("Atmospheric Effects"),
+ _TL("Account for atmospheric effects using either a lumped atmospheric transmittance approach or by calculating the components (water and dust)."),
+
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("Lumped atmospheric transmittance"),
+ _TL("Calculating the components")
+ ), 0
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "TRANSMITT" , _TL("Lumped Transmittance [%]"),
+ _TL("The transmittance of the atmosphere (usually between 60 and 80%)"),
+ PARAMETER_TYPE_Double , 70,
+ 0.0 , true,
+ 100.0 , true
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "PRESSURE" , _TL("Atmospheric Pressure [mb]"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 1013,
+ 0.0 , true
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "WATER" , _TL("Water Content [cm]"),
+ _TL("Water content of a vertical slice of atmosphere in cm: 1.5 to 1.7, average=1.68"),
+ PARAMETER_TYPE_Double , 1.68,
+ 0.0 , true
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "DUST" , _TL("Dust [ppm]"),
+ _TL("Dust factor: 100 ppm (standard)"),
+ PARAMETER_TYPE_Double , 100,
+ 0.0 , true
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "LATITUDE" , _TL("Latitude [Degree]"),
+ _TL(""),
+ PARAMETER_TYPE_Double , 53.5,
+ -90.0 , true,
+ 90.0 , true
+ );
+
+
+ //-----------------------------------------------------
+ // Daily Time Resolution...
+
+ pNode_0 = Parameters.Add_Node(
+ NULL , "NODE_HOUR" , _TL("Daily Time Resolution"),
+ _TL("")
+ );
+
+ pNode_1 = Parameters.Add_Range(
+ pNode_0 , "HOUR_RANGE" , _TL("Time Span [h]"),
+ _TL("Time span used for the calculation of daily radiation sums."),
+ 0.0 , 24.0,
+ 0.0 , true,
+ 24.0 , true
+ );
+
+ pNode_1 = Parameters.Add_Value(
+ pNode_0 , "HOUR_STEP" , _TL("Time Step [h]"),
+ _TL("Time step size used for the calculation of daily radiation sums."),
+ PARAMETER_TYPE_Double , 1.0,
+ 0.001 , true,
+ 12.0 , true
+ );
+
+
+ //-----------------------------------------------------
+ // Time Settings...
+
+ pNode_0 = Parameters.Add_Choice(
+ NULL , "TIMESPAN" , _TL("Simulation Time"),
+ _TL(""),
+
+ CSG_String::Format(SG_T("%s|%s|%s|"),
+ _TL("Single Day"),
+ _TL("Range of Days"),
+ _TL("One Year")
+ ), 0
+ );
+
+ //-----------------------------------------------------
+ pNode_1 = Parameters.Add_Node(
+ pNode_0 , "NODE_SINGLE_DAY" , _TL("Single Day"),
+ _TL("")
+ );
+
+ pNode_2 = Parameters.Add_Choice(
+ pNode_1 , "SINGLE_DAY_DAY" , _TL("Day"),
+ _TL(""),
+
+ SG_T(" 1| 2| 3| 4| 5| 6| 7| 8| 9| 10|")
+ SG_T(" 11| 12| 13| 14| 15| 16| 17| 18| 19| 20|")
+ SG_T(" 21| 22| 23| 24| 25| 26| 27| 28| 29| 30|")
+ SG_T(" 31|"), 20
+ );
+
+ pNode_2 = Parameters.Add_Choice(
+ pNode_1 , "SINGLE_DAY_MONTH" , _TL("Month"),
+ _TL(""),
+
+ CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"),
+ _TL("January"),
+ _TL("February"),
+ _TL("March"),
+ _TL("April"),
+ _TL("May"),
+ _TL("June"),
+ _TL("July"),
+ _TL("August"),
+ _TL("September"),
+ _TL("October"),
+ _TL("November"),
+ _TL("December")
+ ), 2
+ );
+
+
+ //-----------------------------------------------------
+ // Range of Days...
+
+ pNode_1 = Parameters.Add_Node(
+ pNode_0 , "NODE_DAY_RANGE" , _TL("Range of Days"),
+ _TL("")
+ );
+
+ pNode_2 = Parameters.Add_Range(
+ pNode_1 , "DAY_RANGE" , _TL("Time Span [day of year]"),
+ _TL(""),
+ 1 , 31,
+ -365 , true,
+ 366 , true
+ );
+
+ pNode_2 = Parameters.Add_Value(
+ pNode_1 , "DAY_STEP" , _TL("Time Step [number of days]"),
+ _TL(""),
+ PARAMETER_TYPE_Int, 5,
+ 1 , true,
+ 100 , true
+ );
+}
+
+//---------------------------------------------------------
+CSolarRadiation::~CSolarRadiation(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSolarRadiation::On_Execute(void)
+{
+ static const int Month2Day[12] = { 0, 31, 49, 80, 109, 140, 170, 201, 232, 272, 303, 333 };
+
+ //-----------------------------------------------------
+ int Day_Step, Day_Start, Day_Stop;
+ double Latitude, Hour_Step, Hour_Start, Hour_Stop;
+ CSG_Colors Colors;
+
+ //-----------------------------------------------------
+ m_pDTM = Parameters("ELEVATION") ->asGrid();
+ m_pRadiation = Parameters("INSOLAT") ->asGrid();
+ m_pDuration = Parameters("DURATION") ->asGrid();
+ m_pSunrise = Parameters("SUNRISE") ->asGrid();
+ m_pSunset = Parameters("SUNSET") ->asGrid();
+
+ m_SolarConstant = Parameters("SOLCONST") ->asDouble() / 1000.0; // [kW / m²]
+
+ m_Method = Parameters("METHOD") ->asInt();
+ m_Transmittance = Parameters("TRANSMITT") ->asDouble() / 100.0;
+ m_Pressure = Parameters("PRESSURE") ->asDouble();
+ m_Water = Parameters("WATER") ->asDouble();
+ m_Dust = Parameters("DUST") ->asDouble();
+
+ Latitude = Parameters("LATITUDE") ->asDouble() * M_DEG_TO_RAD;
+
+ Day_Step = Parameters("DAY_STEP") ->asInt();
+ Hour_Step = Parameters("HOUR_STEP") ->asDouble();
+ Hour_Start = Parameters("HOUR_RANGE") ->asRange()->Get_LoVal();
+ Hour_Stop = Parameters("HOUR_RANGE") ->asRange()->Get_HiVal();
+
+ //-----------------------------------------------------
+ m_pSum = SG_Create_Grid(m_pDTM);
+
+ //-----------------------------------------------------
+ switch( Parameters("TIMESPAN")->asInt() )
+ {
+ case 0: // single day...
+ Day_Start = Parameters("SINGLE_DAY_MONTH")->asInt();
+ Day_Start = Parameters("SINGLE_DAY_DAY") ->asInt() + (Day_Start >= 0 && Day_Start < 12 ? Month2Day[Day_Start] : 0);
+
+ if( m_pSunrise ) { m_pSunrise->Assign_NoData(); DataObject_Set_Colors(m_pSunrise, 100, SG_COLORS_YELLOW_RED, false); }
+ if( m_pSunset ) { m_pSunset ->Assign_NoData(); DataObject_Set_Colors(m_pSunset , 100, SG_COLORS_YELLOW_RED, true ); }
+
+ Execute_DailySum (Latitude, Hour_Step, Hour_Start, Hour_Stop, Day_Start);
+ break;
+
+ case 1: // range of days...
+ Day_Start = (int)Parameters("DAY_RANGE") ->asRange()->Get_LoVal() - 1;
+ Day_Stop = (int)Parameters("DAY_RANGE") ->asRange()->Get_HiVal() - 1;
+
+ Execute_SumOfDays(Latitude, Hour_Step, Hour_Start, Hour_Stop, Day_Step, Day_Start, Day_Stop);
+ break;
+
+ case 2: // one year...
+ Day_Start = -10; // winter solstitute...
+ Day_Stop = 173; // until half year has passed...
+
+ Execute_SumOfDays(Latitude, Hour_Step, Hour_Start, Hour_Stop, Day_Step, Day_Start, Day_Stop);
+
+ *m_pRadiation *= 2.0; // two times...
+ *m_pDuration *= 2.0; // two times...
+ break;
+ }
+
+ //-----------------------------------------------------
+ delete( m_pSum );
+
+ Colors.Set_Count(100);
+ Colors.Set_Ramp(SG_GET_RGB( 0, 0, 64), SG_GET_RGB(255, 159, 0), 0, 50);
+ Colors.Set_Ramp(SG_GET_RGB(255, 159, 0), SG_GET_RGB(255, 255, 255), 50, 99);
+
+ DataObject_Set_Colors(m_pRadiation, Colors);
+ DataObject_Set_Colors(m_pDuration , Colors);
+
+ m_pDuration->Set_Unit(_TL("h"));
+
+ if( Parameters("UNIT")->asInt() == 1 ) // Joule...
+ {
+ *m_pRadiation *= 10.0 / 36.0; // 1 J = 1 Ws = 1/(60*60) Wh = 1/3600 Wh >> 1 J = 1000/3600 kWh = 10/36 kWh
+
+ m_pRadiation->Set_Unit(_TL("J/m\xc2\xb2"));
+ }
+ else
+ {
+ m_pRadiation->Set_Unit(_TL("kWh/m\xc2\xb2"));
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CSolarRadiation::Execute_DailySum(double Latitude_RAD, double Hour_Step, double Hour_Start, double Hour_Stop, int Day)
+{
+ Get_DailySum(Latitude_RAD, Hour_Step, Hour_Start, Hour_Stop, Day);
+
+ m_pRadiation->Assign(m_pSum);
+}
+
+//---------------------------------------------------------
+void CSolarRadiation::Execute_SumOfDays(double Latitude_RAD, double Hour_Step, double Hour_Start, double Hour_Stop, int Day_Step, int Day_Start, int Day_Stop)
+{
+ int Day, nDays;
+ CSG_Grid *pSumOfDays, *pDur_Total;
+
+ //-----------------------------------------------------
+ nDays = Day_Stop - Day_Start;
+
+ if( nDays < 1 )
+ {
+ Execute_DailySum(Latitude_RAD, Hour_Step, Hour_Start, Hour_Stop, Day_Start);
+ }
+
+ //-----------------------------------------------------
+ else
+ {
+ pSumOfDays = SG_Create_Grid(m_pDTM);
+ pDur_Total = SG_Create_Grid(m_pDTM);
+
+ if( Day_Step < 1 || Day_Step > nDays )
+ {
+ Day_Step = 1;
+ }
+
+ //-------------------------------------------------
+ for(Day=Day_Start; Day<Day_Stop && Set_Progress(Day - Day_Start, nDays); Day+=Day_Step)
+ {
+ Get_DailySum(Latitude_RAD, Hour_Step, Hour_Start, Hour_Stop, Day, false);
+
+ *m_pSum *= Day_Step;
+ *pSumOfDays += *m_pSum;
+
+ *m_pDuration *= Day_Step;
+ *pDur_Total += *m_pDuration;
+ }
+
+ if( (Day_Step = Day_Stop - Day) > 0 ) // Rest...
+ {
+ Get_DailySum(Latitude_RAD, Hour_Step, Hour_Start, Hour_Stop, Day, false);
+
+ *m_pSum *= Day_Step;
+ *pSumOfDays += *m_pSum;
+
+ *m_pDuration *= Day_Step;
+ *pDur_Total += *m_pDuration;
+ }
+
+ //-------------------------------------------------
+ m_pRadiation ->Assign(pSumOfDays);
+ delete(pSumOfDays);
+
+ m_pDuration ->Assign(pDur_Total);
+ delete(pDur_Total);
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Daily Sum //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CSolarRadiation::Get_DailySum(double Latitude_RAD, double Hour_Step, double Hour_Start, double Hour_Stop, int Day, bool bProgressBar)
+{
+ bool bNight;
+ double time, Sol_Height, Sol_Azimuth, Solar_Angle, RDIRN, RDIFN, d;
+ CHillShade HillShade;
+
+ //-----------------------------------------------------
+ Day %= 366;
+
+ if( Day < 0 )
+ {
+ Day += 366;
+ }
+
+ Hour_Start += Hour_Step / 2.0;
+
+ m_pSum ->Assign(0.0);
+ m_pDuration ->Assign(0.0);
+
+ HillShade.Get_Parameters()->Set_Parameter(SG_T("ELEVATION") , PARAMETER_TYPE_Grid , m_pDTM);
+ HillShade.Get_Parameters()->Set_Parameter(SG_T("SHADE") , PARAMETER_TYPE_Grid , m_pRadiation);
+ HillShade.Get_Parameters()->Set_Parameter(SG_T("METHOD") , PARAMETER_TYPE_Choice , 3);
+ HillShade.Get_Parameters()->Set_Parameter(SG_T("EXAGGERATION") , PARAMETER_TYPE_Double , 1.0);
+ HillShade.Set_Show_Progress(false);
+
+ //-----------------------------------------------------
+ for(time=Hour_Start, bNight=false; time<Hour_Stop && is_Progress(); time+=Hour_Step)
+ {
+ Process_Set_Text(CSG_String::Format(_TL("%d. Day of Year, Local Time: %dh %02dm"), Day + 1, (int)time, (int)(60.0 * fmod(time, 1.0))));
+
+ if( bProgressBar )
+ {
+ Set_Progress(time, 24.0);
+ }
+ else
+ {
+ Process_Get_Okay(false);
+ }
+
+ //-------------------------------------------------
+ if( Get_SolarPosition(Day, time, Latitude_RAD, 0.0, Sol_Azimuth, Sol_Height, false) )
+ {
+ bNight = false;
+
+ HillShade.Get_Parameters()->Set_Parameter(SG_T("AZIMUTH") , PARAMETER_TYPE_Double, (double)M_RAD_TO_DEG * Sol_Azimuth);
+ HillShade.Get_Parameters()->Set_Parameter(SG_T("DECLINATION") , PARAMETER_TYPE_Double, (double)M_RAD_TO_DEG * Sol_Height);
+ HillShade.Execute();
+
+ for(int n=0; n<Get_NCells(); n++)
+ {
+ if( m_pRadiation->is_NoData(n) )
+ {
+ m_pSum ->Set_NoData(n);
+ m_pDuration ->Set_NoData(n);
+ }
+ else
+ {
+ Solar_Angle = m_pRadiation->asDouble(n);
+
+ if( Solar_Angle < M_PI_090 )
+ {
+ Get_SolarCorrection(M_PI_090 - Sol_Height, m_pDTM->asDouble(n), RDIRN, RDIFN);
+
+ d = m_SolarConstant * Hour_Step * RDIRN * cos(Solar_Angle);
+ // Dir[q,a] = SConst * SunDuration[q,a] * t^m(q) * cos(AngIn[q,a])
+
+ m_pSum ->Add_Value(n, d);
+ m_pDuration ->Add_Value(n, Hour_Step);
+
+ if( m_pSunrise && m_pSunrise->is_NoData(n) )
+ {
+ m_pSunrise->Set_Value(n, time);
+ }
+
+ if( m_pSunset && !m_pSunset->is_NoData(n) )
+ {
+ m_pSunset->Set_NoData(n);
+ }
+ }
+ else
+ {
+ if( m_pSunset && m_pSunset->is_NoData(n) && m_pSum->asDouble(n) > 0.0 )
+ {
+ m_pSunset->Set_Value(n, time);
+ }
+ }
+ }
+ }
+
+ if( Parameters("UPDATE")->asBool() )
+ {
+ DataObject_Update(m_pRadiation, 20 * M_DEG_TO_RAD, 90.0 * M_DEG_TO_RAD, true);
+ }
+ }
+
+ //-------------------------------------------------
+ else if( !bNight )
+ {
+ bNight = true;
+
+ if( Parameters("UPDATE")->asBool() )
+ {
+ m_pRadiation->Assign(M_PI_090);
+
+ DataObject_Update(m_pRadiation, 0, 90.0 * M_DEG_TO_RAD, true);
+ }
+
+ if( m_pSunset )
+ {
+ for(int n=0; n<Get_NCells(); n++)
+ {
+ if( m_pSunset->is_NoData(n) && m_pSum->asDouble(n) > 0.0 )
+ {
+ m_pSunset->Set_Value(n, time);
+ }
+ }
+ }
+ }
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Atmosphere //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CSolarRadiation::Get_SolarCorrection(double ZenithAngle, double Elevation, double &RDIRN, double &RDIFN)
+{
+ const double AM[32] = // AM Optical air mass in 1 degree increments for zenith angles >=60 [after LIST, 1968; p. 422]
+ {
+ 2.00, 2.06, 2.12, 2.19, 2.27, 2.36, 2.45, 2.55,
+ 2.65, 2.77, 2.90, 3.05, 3.21, 3.39, 3.59, 3.82,
+ 4.07, 4.37, 4.72, 5.12, 5.60, 6.18, 6.88, 7.77,
+ 8.90, 10.39, 12.44, 15.36, 19.79, 26.96, 26.96, 26.96
+ };
+
+ const double Pressure_0 = 1013.0; // Standard atmospheric pressure = 1013 mb
+
+ int i;
+ double z, AMASS, AMASS2, AW, TW, TD, TDC;
+
+ //-----------------------------------------------------
+ z = M_RAD_TO_DEG * ZenithAngle;
+
+ if( z <= 60.0 )
+ {
+ AMASS = 1.0 / cos(ZenithAngle);
+ }
+ else
+ {
+ z -= 60.0;
+ i = (int)z;
+ AMASS = AM[i] + (z - i) * (AM[i + 1] - AM[i]);
+ }
+
+ z = m_Pressure / pow(10.0, Elevation * 5.4667E-05); // P Barometric pressure in mb
+ AMASS2 = AMASS * z / Pressure_0;
+
+ //-----------------------------------------------------
+ switch( m_Method )
+ {
+ case 0: default:
+ RDIRN = pow(m_Transmittance, AMASS2);
+ RDIFN = 0.271 - 0.294 * RDIRN;
+ break;
+
+ case 1:
+ AW = 1.0 - 0.077 * pow(m_Water * AMASS2, 0.3); // AW Accounts for absorption by water vapour
+ TW = pow(0.975, m_Water * AMASS); // TW Accounts for scattering by water vapour
+ TD = pow(0.950, m_Water * m_Dust / 100.0); // TD Accounts for scattering by dust
+ TDC = pow(0.900, AMASS2) + 0.026 * (AMASS2 - 1.0); // TDC Accounts for scattering by a dust free atmosphere
+
+ RDIRN = AW * TW * TD * TDC;
+ RDIFN = 0.5 * (AW - RDIRN);
+ break;
+ }
+
+ // Optical Pathlength (solar zenith angle < 80Degree) =>
+ // m(t) = exp(-0.000118 * Elevation - 1.638 * 10e-9 * Elevation) / cos(SolarZenithAngle)
+ // if( Method == 2 && Zenithangle < 80 ) // nach bla...
+ // RDIRN = pow(m_Transmittance, exp((-0.000118 - 1.638e-8 * Elevation) * Elevation) / cos(ZenithAngle));
+}
+
+/* The original TAPES-G source code for the optical air mass computation
+C ==================================================================
+ SUBROUTINE SOLAR(ZA,RDIRN,RDIFN,ITEST)
+ COMMON/SOL1/U,D,P,TRANSM
+ PARAMETER (PI=3.14159265358979323846)
+ PARAMETER (DTOR=PI/180.)
+ DIMENSION AM(32)
+ DATA AM/2.0,2.06,2.12,2.19,2.27,2.36,2.45,2.55,2.65,2.77,2.9,
+ * 3.05,3.21,3.39,3.59,3.82,4.07,4.37,4.72,5.12,5.6,6.18,6.88,
+ * 7.77,8.9,10.39,12.44,15.36,19.79,26.96,26.96,26.96/
+ DATA PO/1013./
+C ***************************************************************
+C AM Optical air mass in 1 degree increments for zenith angles
+C >=60 [LIST, 1968; p. 422]
+C U Water content of a vertical slice of atmosphere in cm:
+C 1.5 to 1.7, average=1.68
+C D Dust factor: 1=100 ppm (standard); 2=300 ppm
+C P Barometric pressure in mb
+C PO Standard atmospheric pressure = 1013 mb
+C TRANSM Transmittance of the atmosphere (0.6-0.8)
+C AW Accounts for absorption by water vapour
+C TW Accounts for scattering by water vapour
+C TD Accounts for scattering by dust
+C TDC Accounts for scattering by a dust free atmosphere
+C **************************************************************
+C Compute optical air mass
+C
+ IF(ZA.LE.60.) THEN
+ AMASS=1./COS(ZA*DTOR)
+ ELSE
+ Y=ZA-59.
+ I=INT(Y)
+ AMASS=AM(I)+(Y-FLOAT(I))*(AM(I+1)-AM(I))
+ ENDIF
+ AMASS2=AMASS*P/PO
+C --------------------------------------------------------------
+C Account for atmospheric effects using either a lumped atmos-
+C pheric transmittance approach (ITEST=1) or by calculating the
+C components (ITEST=2)
+C
+ IF(ITEST.EQ.1) THEN
+ RDIRN=TRANSM**AMASS2
+ RDIFN=0.271-0.294*RDIRN
+ ELSE
+ AW=1.0-0.077*(U*AMASS2)**0.3
+ TW=0.975**(U*AMASS)
+ TD=0.95**(U*D)
+ TDC=0.9**AMASS2+0.026*(AMASS2-1.0)
+ RDIRN=AW*TW*TD*TDC
+ RDIFN=0.5*(AW-RDIRN)
+ ENDIF
+ RETURN
+ END
+C ====================================================================*/
+
+
+///////////////////////////////////////////////////////////
+// //
+// Solar Position //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSolarRadiation::Get_SolarPosition(int Day, double Time, double LAT, double LON, double &Azimuth, double &Declination, bool bDegree)
+{
+ static const int Day2Month[13] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 366 };
+
+ static const double ECLIPTIC_OBL = M_DEG_TO_RAD * 23.43999; // obliquity of ecliptic
+
+ int i;
+
+ double JD, T, M, L, X, Y, Z, R, UTime,
+ DEC, RA, theta, tau,
+ Month, Year = 2000;
+
+ //-----------------------------------------------------
+
+ for(Month=1, i=0; i<=12; i++)
+ {
+ if( Day < Day2Month[i] )
+ {
+ Month = i;
+ Day -= Day2Month[i - 1];
+ break;
+ }
+ }
+
+ if( Month < 1 || Month > 12 ) // nur Tag (1 - 365) zaehlt...
+ {
+ Month = 1;
+ }
+
+ if( Month <= 2 )
+ {
+ Month += 12;
+ Year -= 1;
+ }
+
+
+ //-----------------------------------------------------
+
+// UTime = Time - LON * 12.0 / M_PI;
+ UTime = Time;
+
+
+ //-----------------------------------------------------
+ // 1. Julian Date...
+
+ JD = (int)(365.25 * Year) + (int)(30.6001 * (Month + 1)) - 15 + 1720996.5 + Day + UTime / 24.0;
+ T = (JD - 2451545.0 ) / 36525.0; // number of Julian centuries since 2000/01/01 at 12 UT (JD = 2451545.0)
+
+
+ //-----------------------------------------------------
+ // 2. Solar Coordinates (according to: Jean Meeus: Astronomical Algorithms), accuracy of 0.01 degree
+
+ M = M_DEG_TO_RAD * (357.52910 + 35999.05030 * T - 0.0001559 * T * T - 0.00000048 * T * T * T); // mean anomaly
+ L = M_DEG_TO_RAD * ( (280.46645 + 36000.76983 * T + 0.0003032 * T * T) // mean longitude
+ + ( (1.914600 - 0.004817 * T - 0.000014 * T * T) * sin(M)
+ + (0.019993 - 0.000101 * T) * sin(2 * M) + 0.000290 * sin(3 * M) // true longitude
+ )
+ );
+
+
+ //-----------------------------------------------------
+ // 3. convert ecliptic longitude to right ascension RA and declination delta
+
+ X = cos(L);
+ Y = cos(ECLIPTIC_OBL) * sin(L);
+ Z = sin(ECLIPTIC_OBL) * sin(L);
+ R = sqrt(1.0 - Z*Z);
+
+ DEC = atan2(Z, R);
+ RA = 2 * atan2(Y, (X + R));
+
+
+ //-----------------------------------------------------
+ // 4. compute sidereal time (degree) at Greenwich local sidereal time at longitude (DegreeE)
+
+ theta = LON + M_DEG_TO_RAD * (280.46061837 + 360.98564736629 * (JD - 2451545.0) + T * T * (0.000387933 - T / 38710000.0));
+
+
+ //-----------------------------------------------------
+ // 5. compute local hour angle (degree)
+
+ tau = theta - RA;
+
+
+ //-----------------------------------------------------
+ // 6. convert (tau, delta) to horizon coordinates (h, az) of the observer
+
+ Declination = asin( sin(LAT) * sin(DEC) + cos(LAT) * cos(DEC) * cos(tau) );
+ Azimuth = atan2( -sin(tau) * cos(DEC), cos(LAT) * sin(DEC) - sin(LAT) * cos(DEC) * cos(tau) );
+ //Azimuth = atan2( -sin(Tau), cos(LAT) * tan(DEC) - sin(LAT) * cos(Tau) ); // erstere ist besser wegen division by zero effects...
+
+ if( bDegree )
+ {
+ Declination *= M_RAD_TO_DEG;
+ Azimuth *= M_RAD_TO_DEG;
+ }
+
+ return( Declination >= 0.0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_lighting/SolarRadiation.h b/src/modules_terrain_analysis/terrain_analysis/ta_lighting/SolarRadiation.h
index 29ba20e..1b630e9 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_lighting/SolarRadiation.h
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_lighting/SolarRadiation.h
@@ -97,7 +97,7 @@ private:
double m_SolarConstant, m_Transmittance, m_Pressure, m_Water, m_Dust;
- CSG_Grid *m_pDTM, *m_pSum, *m_pRadiation, *m_pDuration;
+ CSG_Grid *m_pDTM, *m_pSum, *m_pRadiation, *m_pDuration, *m_pSunrise, *m_pSunset;
void Execute_DailySum (double Latitude_RAD, double Hour_Step, double Hour_Start, double Hour_Stop, int Day);
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_lighting/view_shed.h b/src/modules_terrain_analysis/terrain_analysis/ta_lighting/view_shed.h
index d664e7e..4b81ed6 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_lighting/view_shed.h
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_lighting/view_shed.h
@@ -90,7 +90,7 @@ private:
double m_MaxRadius;
- CSG_Points_3D m_Direction;
+ CSG_Points_Z m_Direction;
CSG_Vector m_Angles;
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/MLB_Interface.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/MLB_Interface.cpp
index 0a7ea7f..1cce80d 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/MLB_Interface.cpp
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/MLB_Interface.cpp
@@ -101,6 +101,7 @@ const SG_Char * Get_Info(int i)
#include "land_surface_temperature.h"
#include "relative_heights.h"
#include "wind_effect.h"
+#include "ruggedness.h"
//---------------------------------------------------------
@@ -124,6 +125,8 @@ CSG_Module * Create_Module(int i)
case 13: return( new CLand_Surface_Temperature );
case 14: return( new CRelative_Heights );
case 15: return( new CWind_Effect );
+ case 16: return( new CRuggedness_TRI );
+ case 17: return( new CRuggedness_VRM );
}
return( NULL );
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile.am b/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile.am
index 6387831..96f8f8f 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile.am
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.8 2009/04/28 16:31:58 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:18:53 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libta_morphometry.la
libta_morphometry_la_SOURCES =\
Convergence.cpp\
@@ -22,6 +22,7 @@ mass_balance_index.cpp\
Morphometry.cpp\
ProtectionIndex.cpp\
RealArea.cpp\
+ruggedness.cpp\
SurfaceSpecificPoints.cpp\
mrvbf.cpp\
distance_gradient.cpp\
@@ -39,6 +40,7 @@ mass_balance_index.h\
Morphometry.h\
ProtectionIndex.h\
RealArea.h\
+ruggedness.h\
SurfaceSpecificPoints.h\
mrvbf.h\
distance_gradient.h\
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile.in b/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile.in
index 1ff145e..4fc871c 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile.in
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -72,11 +71,11 @@ libta_morphometry_la_DEPENDENCIES = \
am_libta_morphometry_la_OBJECTS = Convergence.lo Convergence_Radius.lo \
Curvature_Classification.lo Hypsometry.lo MLB_Interface.lo \
mass_balance_index.lo Morphometry.lo ProtectionIndex.lo \
- RealArea.lo SurfaceSpecificPoints.lo mrvbf.lo \
+ RealArea.lo ruggedness.lo SurfaceSpecificPoints.lo mrvbf.lo \
distance_gradient.lo air_flow_height.lo anisotropic_heating.lo \
land_surface_temperature.lo relative_heights.lo wind_effect.lo
libta_morphometry_la_OBJECTS = $(am_libta_morphometry_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -122,6 +121,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -131,6 +131,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -221,14 +222,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.8 2009/04/28 16:31:58 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:18:53 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libta_morphometry.la
libta_morphometry_la_SOURCES = \
Convergence.cpp\
@@ -240,6 +241,7 @@ mass_balance_index.cpp\
Morphometry.cpp\
ProtectionIndex.cpp\
RealArea.cpp\
+ruggedness.cpp\
SurfaceSpecificPoints.cpp\
mrvbf.cpp\
distance_gradient.cpp\
@@ -257,6 +259,7 @@ mass_balance_index.h\
Morphometry.h\
ProtectionIndex.h\
RealArea.h\
+ruggedness.h\
SurfaceSpecificPoints.h\
mrvbf.h\
distance_gradient.h\
@@ -357,6 +360,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mass_balance_index.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/mrvbf.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/relative_heights.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ruggedness.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/wind_effect.Plo at am__quote@
.cpp.o:
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/ProtectionIndex.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/ProtectionIndex.cpp
index 78d5932..e895553 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/ProtectionIndex.cpp
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/ProtectionIndex.cpp
@@ -23,9 +23,11 @@
CProtectionIndex::CProtectionIndex(void){
- Parameters.Set_Name(_TL("Morphometric Protection Index"));
- Parameters.Set_Description(_TW(
- "(c) 2005 by Victor Olaya."));
+ Set_Name(_TL("Morphometric Protection Index"));
+ Set_Author(_TL("(c) 2005 by Victor Olaya"));
+ Set_Description(_TW(
+ "This algorithm analyses the immediate surrounding of each cell up to an given distance and evaluates how the relief protects it.\n"
+ "It is equivalent to the positive openness described in: Visualizing Topography by Openness: A New Application of Image Processing to Digital Elevation Models, Photogrammetric Engineering and Remote Sensing(68), No. 3, March 2002, pp. 257-266."));
Parameters.Add_Grid(NULL,
"DEM",
@@ -116,4 +118,4 @@ double CProtectionIndex::getProtectionIndex(int x, int y){
delete [] pAngle;
return (dProtectionIndex / 8.);
-}//method
\ No newline at end of file
+}//method
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/ruggedness.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/ruggedness.cpp
new file mode 100644
index 0000000..cafa376
--- /dev/null
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/ruggedness.cpp
@@ -0,0 +1,344 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ta_morphometry //
+// //
+//-------------------------------------------------------//
+// //
+// Ruggedness.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "ruggedness.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CRuggedness_TRI::CRuggedness_TRI(void)
+{
+ Set_Name (_TL("Terrain Ruggedness Index (TRI)"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ "\n"
+ "References:\n"
+ "\n"
+ "Riley, S.J., De Gloria, S.D., Elliot, R. (1999): "
+ "A Terrain Ruggedness that Quantifies Topographic Heterogeneity. "
+ "Intermountain Journal of Science, Vol.5, No.1-4, pp.23-27. "
+ "<a href=\"http://www.fw.msu.edu/~rileysh2/Terrain%20Ruggedness%20Index.pdf\">pdf</a>.\n"
+ "\n"
+ ));
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid(
+ NULL , "DEM" , _TL("Elevation"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "TRI" , _TL("Terrain Ruggedness Index (TRI)"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Value(
+ NULL , "RADIUS" , _TL("Radius (Cells)"),
+ _TL(""),
+ PARAMETER_TYPE_Int, 1, 1, true
+ );
+
+ Parameters.Add_Parameters(
+ NULL , "WEIGHTING" , _TL("Weighting"),
+ _TL("")
+ )->asParameters()->Assign(m_Cells.Get_Weighting().Get_Parameters());
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CRuggedness_TRI::On_Execute(void)
+{
+ int x, y;
+
+ //-----------------------------------------------------
+ m_pDEM = Parameters("DEM") ->asGrid();
+ m_pTRI = Parameters("TRI") ->asGrid();
+
+ DataObject_Set_Colors(m_pTRI, 100, SG_COLORS_RED_GREY_BLUE, true);
+
+ m_Cells.Get_Weighting().Set_Parameters(Parameters("WEIGHTING")->asParameters());
+
+ if( !m_Cells.Set_Radius(Parameters("RADIUS")->asInt()) )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ Set_Index(x, y);
+ }
+ }
+
+ //-----------------------------------------------------
+ m_Cells.Destroy();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CRuggedness_TRI::Set_Index(int x, int y)
+{
+ if( m_pDEM->is_InGrid(x, y) )
+ {
+ int i, ix, iy;
+ double z, iz, iDistance, iWeight, n, s;
+
+ for(i=0, n=0, s=0.0, z=m_pDEM->asDouble(x, y); i<m_Cells.Get_Count(); i++)
+ {
+ if( m_Cells.Get_Values(i, ix = x, iy = y, iDistance, iWeight, true) && iDistance > 0.0 && m_pDEM->is_InGrid(ix, iy) )
+ {
+ iz = m_pDEM->asDouble(ix, iy);
+ s += SG_Get_Square((z - iz) * iWeight);
+ n += iWeight;
+ }
+ }
+
+ //-------------------------------------------------
+ if( n > 0.0 )
+ {
+ m_pTRI->Set_Value(x, y, sqrt(s / n));
+
+ return( true );
+ }
+ }
+
+ //-----------------------------------------------------
+ m_pTRI->Set_NoData(x, y);
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CRuggedness_VRM::CRuggedness_VRM(void)
+{
+ Set_Name (_TL("Vector Ruggedness Measure (VRM)"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ "\n"
+ "References:\n"
+ "Sappington, J.M., Longshore, K.M., Thompson, D.B. (2007): "
+ "Quantifying Landscape Ruggedness for Animal Habitat Analysis: A Case Study Using Bighorn Sheep in the Mojave Desert. "
+ "Journal of Wildlife Management 71(5):14191426.\n"
+ "<a href=\"http://www.wildlifejournals.org/perlserv/?request=get-toc&issn=0022-541X&volume=71&issue=5\">pdf</a>.\n"
+ "\n"
+ ));
+
+ //-----------------------------------------------------
+ Parameters.Add_Grid(
+ NULL , "DEM" , _TL("Elevation"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL , "VRM" , _TL("Vector Terrain Ruggedness (VRM)"),
+ _TL(""),
+ PARAMETER_OUTPUT
+ );
+
+ Parameters.Add_Value(
+ NULL , "RADIUS" , _TL("Radius (Cells)"),
+ _TL(""),
+ PARAMETER_TYPE_Int, 1, 1, true
+ );
+
+ Parameters.Add_Parameters(
+ NULL , "WEIGHTING" , _TL("Weighting"),
+ _TL("")
+ )->asParameters()->Assign(m_Cells.Get_Weighting().Get_Parameters());
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CRuggedness_VRM::On_Execute(void)
+{
+ int x, y;
+
+ //-----------------------------------------------------
+ m_pDEM = Parameters("DEM") ->asGrid();
+ m_pVRM = Parameters("VRM") ->asGrid();
+
+ DataObject_Set_Colors(m_pVRM, 100, SG_COLORS_RED_GREY_BLUE, true);
+
+ m_Cells.Get_Weighting().Set_Parameters(Parameters("WEIGHTING")->asParameters());
+
+ if( !m_Cells.Set_Radius(Parameters("RADIUS")->asInt()) )
+ {
+ return( false );
+ }
+
+ m_X.Create(*Get_System(), SG_DATATYPE_Float);
+ m_Y.Create(*Get_System(), SG_DATATYPE_Float);
+ m_Z.Create(*Get_System(), SG_DATATYPE_Float);
+
+ for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ double slope, aspect;
+
+ if( m_pDEM->Get_Gradient(x, y, slope, aspect) )
+ {
+ m_Y.Set_Value(x, y, sin(slope) * sin(aspect));
+ m_Y.Set_Value(x, y, sin(slope) * cos(aspect));
+ m_Z.Set_Value(x, y, cos(slope));
+ }
+ else
+ {
+ m_X.Set_NoData(x, y);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ for(y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(x=0; x<Get_NX(); x++)
+ {
+ Set_Index(x, y);
+ }
+ }
+
+ //-----------------------------------------------------
+ m_Cells.Destroy();
+
+ m_X.Destroy();
+ m_Y.Destroy();
+ m_Z.Destroy();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CRuggedness_VRM::Set_Index(int x, int y)
+{
+ if( m_pDEM->is_InGrid(x, y) )
+ {
+ int i, ix, iy;
+ double iDistance, iWeight, n, sx, sy, sz;
+
+ for(i=0, n=0, sx=0.0, sy=0.0, sz=0.0; i<m_Cells.Get_Count(); i++)
+ {
+ if( m_Cells.Get_Values(i, ix = x, iy = y, iDistance, iWeight, true) && iDistance > 0.0 && m_X.is_InGrid(ix, iy) )
+ {
+ sx += iWeight * m_X.asDouble(ix, iy);
+ sy += iWeight * m_Y.asDouble(ix, iy);
+ sz += iWeight * m_Z.asDouble(ix, iy);
+ n += iWeight;
+ }
+ }
+
+ //-------------------------------------------------
+ if( n > 0.0 )
+ {
+ m_pVRM->Set_Value(x, y, 1.0 - sqrt(sx*sx + sy*sy + sz*sz) / n);
+
+ return( true );
+ }
+ }
+
+ //-----------------------------------------------------
+ m_pVRM->Set_NoData(x, y);
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/ruggedness.h b/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/ruggedness.h
new file mode 100644
index 0000000..1c311c1
--- /dev/null
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_morphometry/ruggedness.h
@@ -0,0 +1,134 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ta_morphometry //
+// //
+//-------------------------------------------------------//
+// //
+// ruggedness.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Ruggedness_H
+#define HEADER_INCLUDED__Ruggedness_H
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CRuggedness_TRI : public CSG_Module_Grid
+{
+public:
+ CRuggedness_TRI(void);
+
+// virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Indices" )); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ CSG_Grid *m_pDEM, *m_pTRI;
+
+ CSG_Grid_Cell_Addressor m_Cells;
+
+
+ bool Set_Index (int x, int y);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CRuggedness_VRM : public CSG_Module_Grid
+{
+public:
+ CRuggedness_VRM(void);
+
+// virtual const SG_Char * Get_MenuPath (void) { return( _TL("R:Indices" )); }
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ CSG_Grid *m_pDEM, *m_pVRM, m_X, m_Y, m_Z;
+
+ CSG_Grid_Cell_Addressor m_Cells;
+
+
+ bool Set_Index (int x, int y);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Ruggedness_H
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/FillSinks.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/FillSinks.cpp
index 347e6da..613fee8 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/FillSinks.cpp
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/FillSinks.cpp
@@ -91,9 +91,9 @@ CFillSinks::CFillSinks(void)
);
Parameters.Add_Value(
- NULL, "MINSLOPE", _TL("Slope"),
+ NULL, "MINSLOPE", _TL("Minimum Slope [Degree]"),
_TL("minimum slope angle preserved from one cell to the next, zero results in flat areas [Degree]"),
- PARAMETER_TYPE_Double, 0.01
+ PARAMETER_TYPE_Double, 0.01, 0.0, true
);
}
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/FillSinks_WL.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/FillSinks_WL.cpp
index 2276f41..25667ea 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/FillSinks_WL.cpp
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/FillSinks_WL.cpp
@@ -104,9 +104,9 @@ CFillSinks_WL::CFillSinks_WL(void)
);
Parameters.Add_Value(
- NULL, "MINSLOPE", _TL("Minimum Slope"),
+ NULL, "MINSLOPE", _TL("Minimum Slope [Degree]"),
_TL("Minimum slope gradient to preserve from cell to cell; with a value of zero sinks are filled up to the spill elevation (which results in flat areas). Unit [Degree]"),
- PARAMETER_TYPE_Double, 0.0, 0.0, true
+ PARAMETER_TYPE_Double, 0.1, 0.0, true
);
}
@@ -141,7 +141,7 @@ bool CFillSinks_WL::On_Execute(void)
pFilled = Parameters("FILLED")->asGrid();
pFdir = Parameters("FDIR")->asGrid();
pWshed = Parameters("WSHED")->asGrid();
- minslope = Parameters("MINSLOPE")->asDouble();
+ minslope = Parameters("MINSLOPE")->asDouble();
if( minslope > 0.0 )
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/FillSinks_WL_XXL.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/FillSinks_WL_XXL.cpp
index d8a2ca7..7e7b3c5 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/FillSinks_WL_XXL.cpp
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/FillSinks_WL_XXL.cpp
@@ -91,9 +91,9 @@ CFillSinks_WL_XXL::CFillSinks_WL_XXL(void)
);
Parameters.Add_Value(
- NULL, "MINSLOPE", _TL("Minimum Slope"),
+ NULL, "MINSLOPE", _TL("Minimum Slope [Degree]"),
_TL("Minimum slope gradient to preserve from cell to cell; with a value of zero sinks are filled up to the spill elevation (which results in flat areas). Unit [Degree]"),
- PARAMETER_TYPE_Double, 0.0, 0.0, true
+ PARAMETER_TYPE_Double, 0.1, 0.0, true
);
}
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Flat_Detection.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Flat_Detection.cpp
new file mode 100644
index 0000000..06e0393
--- /dev/null
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Flat_Detection.cpp
@@ -0,0 +1,266 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ta_preprocessor //
+// //
+//-------------------------------------------------------//
+// //
+// Flat_Detection.cpp //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "Flat_Detection.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CFlat_Detection::CFlat_Detection(void)
+{
+ Set_Name (_TL("Flat Detection"));
+
+ Set_Author (SG_T("O.Conrad (c) 2010"));
+
+ Set_Description (_TW(
+ ""
+ ));
+
+ Parameters.Add_Grid(
+ NULL, "DEM" , _TL("DEM"),
+ _TL(""),
+ PARAMETER_INPUT
+ );
+
+ Parameters.Add_Grid(
+ NULL, "NOFLATS" , _TL("No Flats"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Grid(
+ NULL, "FLATS" , _TL("Flat Areas"),
+ _TL(""),
+ PARAMETER_OUTPUT_OPTIONAL
+ );
+
+ Parameters.Add_Choice(
+ NULL, "FLAT_OUTPUT" , _TL("Flat Area Values"),
+ _TL(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ _TL("elevation"),
+ _TL("enumeration")
+ ), 0
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CFlat_Detection::On_Execute(void)
+{
+ //-----------------------------------------------------
+ m_pDEM = Parameters("DEM") ->asGrid();
+ m_pNoFlats = Parameters("NOFLATS") ->asGrid();
+ m_pFlats = Parameters("FLATS") ->asGrid();
+ m_Flat_Output = Parameters("FLAT_OUTPUT") ->asInt();
+
+ //-----------------------------------------------------
+ if( m_pNoFlats )
+ {
+ m_pNoFlats ->Assign(m_pDEM);
+ m_pNoFlats ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pDEM->Get_Name(), _TL("No Flats")));
+ }
+
+ if( m_pFlats )
+ {
+ m_pFlats ->Assign_NoData();
+ m_pFlats ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), m_pDEM->Get_Name(), _TL("Flats")));
+ }
+
+ m_Flats.Create(*Get_System(), SG_DATATYPE_Int);
+
+ m_Flats.Assign(0.0);
+ m_nFlats = 0;
+
+ //-----------------------------------------------------
+ for(int y=0; y<Get_NY() && Set_Progress(y); y++)
+ {
+ for(int x=0; x<Get_NX(); x++)
+ {
+ if( !m_Flats.asInt(x, y) && is_Flat(x, y) )
+ {
+ Set_Flat(x, y);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ m_Stack.Destroy();
+ m_Flats.Destroy();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CFlat_Detection::is_Flat(int x, int y)
+{
+ if( m_pDEM->is_NoData(x, y) )
+ {
+ return( false );
+ }
+
+ int i, ix, iy, n;
+ double z;
+
+ for(i=0, n=0, z=m_pDEM->asDouble(x, y); i<8; i++)
+ {
+ ix = Get_xTo(i, x);
+ iy = Get_yTo(i, y);
+
+ if( m_pDEM->is_InGrid(ix, iy) )
+ {
+ if( z != m_pDEM->asDouble(ix, iy) )
+ {
+ return( false );
+ }
+
+ n++;
+ }
+ }
+
+ return( n > 0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CFlat_Detection::Set_Flat_Cell(int x, int y)
+{
+ if( m_pDEM->is_InGrid(x, y) && m_Flats.asInt(x, y) != m_nFlats && m_zFlat == m_pDEM->asDouble(x, y) )
+ {
+ m_Stack.Push(x, y);
+
+ m_Flats.Set_Value(x, y, m_nFlats);
+
+ if( m_pNoFlats )
+ {
+ m_pNoFlats->Set_NoData(x, y);
+ }
+
+ if( m_pFlats )
+ {
+ switch( m_Flat_Output )
+ {
+ default:
+ case 0: m_pFlats->Set_Value(x, y, m_zFlat); break;
+ case 1: m_pFlats->Set_Value(x, y, m_nFlats); break;
+ }
+ }
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CFlat_Detection::Set_Flat(int x, int y)
+{
+ m_zFlat = m_pDEM->asDouble(x, y);
+ m_nFlats ++;
+
+ m_Stack.Clear();
+
+ Set_Flat_Cell(x, y);
+
+ //-----------------------------------------------------
+ while( m_Stack.Get_Size() > 0 && Process_Get_Okay() )
+ {
+ m_Stack.Pop(x, y);
+
+ for(int i=0; i<8; i++)
+ {
+ Set_Flat_Cell(Get_xTo(i, x), Get_yTo(i, y));
+ }
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Flat_Detection.h b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Flat_Detection.h
new file mode 100644
index 0000000..08b59de
--- /dev/null
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Flat_Detection.h
@@ -0,0 +1,116 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// ta_preprocessor //
+// //
+//-------------------------------------------------------//
+// //
+// Flat_Detection.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__Flat_Detection_H
+#define HEADER_INCLUDED__Flat_Detection_H
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "MLB_Interface.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CFlat_Detection : public CSG_Module_Grid
+{
+public:
+ CFlat_Detection(void);
+
+
+protected:
+
+ virtual bool On_Execute (void);
+
+
+private:
+
+ int m_Flat_Output, m_nFlats;
+
+ double m_zFlat;
+
+ CSG_Grid_Stack m_Stack;
+
+ CSG_Grid *m_pDEM, *m_pNoFlats, *m_pFlats, m_Flats;
+
+
+ bool is_Flat (int x, int y);
+
+ void Set_Flat_Cell (int x, int y);
+ void Set_Flat (int x, int y);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__Flat_Detection_H
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/MLB_Interface.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/MLB_Interface.cpp
index 6a54958..91656a4 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/MLB_Interface.cpp
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/MLB_Interface.cpp
@@ -85,8 +85,10 @@ const SG_Char * Get_Info(int i)
//---------------------------------------------------------
+#include "Flat_Detection.h"
#include "Pit_Router.h"
#include "Pit_Eliminator.h"
+
#include "FillSinks.h"
#include "FillSinks_WL.h"
@@ -94,36 +96,18 @@ const SG_Char * Get_Info(int i)
//---------------------------------------------------------
CSG_Module * Create_Module(int i)
{
- CSG_Module *pModule;
-
switch( i )
{
- case 0:
- pModule = new CPit_Router;
- break;
-
- case 1:
- pModule = new CPit_Eliminator;
- break;
-
- case 2:
- pModule = new CFillSinks;
- break;
-
- case 3:
- pModule = new CFillSinks_WL;
- break;
-
- case 4:
- pModule = new CFillSinks_WL_XXL;
- break;
+ case 0: return( new CFlat_Detection );
+ case 1: return( new CPit_Router );
+ case 2: return( new CPit_Eliminator );
- default:
- pModule = NULL;
- break;
+ case 3: return( new CFillSinks );
+ case 4: return( new CFillSinks_WL );
+ case 5: return( new CFillSinks_WL_XXL );
}
- return( pModule );
+ return( NULL );
}
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Makefile.am b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Makefile.am
index dde5a03..9b62264 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Makefile.am
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.6 2007/07/30 07:29:24 oconrad Exp $
+# $Id: Makefile.am,v 1.8 2010/07/08 14:11:48 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,18 +10,20 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libta_preprocessor.la
libta_preprocessor_la_SOURCES =\
FillSinks.cpp\
FillSinks_WL.cpp\
FillSinks_WL_XXL.cpp\
MLB_Interface.cpp\
+Flat_Detection.cpp\
Pit_Eliminator.cpp\
Pit_Router.cpp\
FillSinks.h\
FillSinks_WL.h\
MLB_Interface.h\
+Flat_Detection.h\
Pit_Eliminator.h\
Pit_Router.h
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Makefile.in b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Makefile.in
index 24bbe86..2f8313c 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Makefile.in
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Makefile.in
@@ -42,7 +42,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -71,10 +70,10 @@ LTLIBRARIES = $(pkglib_LTLIBRARIES)
libta_preprocessor_la_DEPENDENCIES = \
$(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
am_libta_preprocessor_la_OBJECTS = FillSinks.lo FillSinks_WL.lo \
- FillSinks_WL_XXL.lo MLB_Interface.lo Pit_Eliminator.lo \
- Pit_Router.lo
+ FillSinks_WL_XXL.lo MLB_Interface.lo Flat_Detection.lo \
+ Pit_Eliminator.lo Pit_Router.lo
libta_preprocessor_la_OBJECTS = $(am_libta_preprocessor_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -120,6 +119,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -129,6 +129,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -219,25 +220,27 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.6 2007/07/30 07:29:24 oconrad Exp $
+# $Id: Makefile.am,v 1.8 2010/07/08 14:11:48 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libta_preprocessor.la
libta_preprocessor_la_SOURCES = \
FillSinks.cpp\
FillSinks_WL.cpp\
FillSinks_WL_XXL.cpp\
MLB_Interface.cpp\
+Flat_Detection.cpp\
Pit_Eliminator.cpp\
Pit_Router.cpp\
FillSinks.h\
FillSinks_WL.h\
MLB_Interface.h\
+Flat_Detection.h\
Pit_Eliminator.h\
Pit_Router.h
@@ -319,6 +322,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FillSinks.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FillSinks_WL.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/FillSinks_WL_XXL.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Flat_Detection.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MLB_Interface.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Pit_Eliminator.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Pit_Router.Plo at am__quote@
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Pit_Router.cpp b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Pit_Router.cpp
index 890e22a..c6ae9c1 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Pit_Router.cpp
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_preprocessor/Pit_Router.cpp
@@ -58,8 +58,6 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#include <memory.h>
-
#include "Pit_Router.h"
@@ -356,10 +354,10 @@ int CPit_Router::Find_Pits(void)
for(n=0; n<Get_NCells() && SG_UI_Process_Set_Progress(n, Get_NCells()); n++)
{
- m_pDEM->Get_Sorted(n,x,y,false,false); // von tief nach hoch...
+ m_pDEM->Get_Sorted(n,x,y,false); // von tief nach hoch...
if( x > 0 && x < Get_NX() - 1 && y > 0 && y < Get_NY() - 1 // Randzellen und Missing Values sind
- && !m_pDEM->is_NoData(x, y) // per Definition drainiert (:= 0)...
+ && !m_pDEM->is_NoData(x, y) // per Definition drainiert (:= 0)...
&& m_pPits->asInt(x, y) == 0 ) // ...oder schon als m_Flat markiert sein...
{
z = m_pDEM->asDouble(x,y);
@@ -433,7 +431,7 @@ int CPit_Router::Find_Outlets(int nPits)
//-------------------------------------------------
for(n=0; n<Get_NCells() && SG_UI_Process_Set_Progress(n, Get_NCells()); n++)
{
- if( m_pDEM->Get_Sorted(n, x, y, false) && m_pPits->asInt(x,y) == 0 )
+ if( m_pDEM->Get_Sorted(n, x, y, false) && m_pPits->asInt(x,y) == 0 )
{
z = m_pDEM->asDouble(x,y);
iMin = -1;
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_profiles/Makefile.am b/src/modules_terrain_analysis/terrain_analysis/ta_profiles/Makefile.am
index 3107268..06f5fb1 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_profiles/Makefile.am
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_profiles/Makefile.am
@@ -1,5 +1,5 @@
#
-# $Id: Makefile.am,v 1.9 2008/04/16 16:21:03 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:11:49 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
@@ -10,7 +10,7 @@ endif
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libta_profiles.la
libta_profiles_la_SOURCES =\
Grid_Cross_Profiles.cpp\
diff --git a/src/modules_terrain_analysis/terrain_analysis/ta_profiles/Makefile.in b/src/modules_terrain_analysis/terrain_analysis/ta_profiles/Makefile.in
index d8ae02d..fa394b5 100644
--- a/src/modules_terrain_analysis/terrain_analysis/ta_profiles/Makefile.in
+++ b/src/modules_terrain_analysis/terrain_analysis/ta_profiles/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -75,7 +74,7 @@ am_libta_profiles_la_OBJECTS = Grid_Cross_Profiles.lo \
Grid_Swath_Profile.lo Polygon_Clipper.lo MLB_Interface.lo \
PDFDocEngine_CrossSections.lo
libta_profiles_la_OBJECTS = $(am_libta_profiles_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -121,6 +120,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -130,6 +130,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -220,14 +221,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.9 2008/04/16 16:21:03 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/08 14:11:49 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
@SAGA_UNICODE_TRUE at UC_DEFS = -D_SAGA_UNICODE
DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(UC_DEFS) $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared
+AM_LDFLAGS = -fPIC -shared -avoid-version
pkglib_LTLIBRARIES = libta_profiles.la
libta_profiles_la_SOURCES = \
Grid_Cross_Profiles.cpp\
diff --git a/src/saga_core/Makefile.am b/src/saga_core/Makefile.am
index a7404e3..d228d60 100644
--- a/src/saga_core/Makefile.am
+++ b/src/saga_core/Makefile.am
@@ -1 +1 @@
-SUBDIRS = saga_api saga_gdi saga_cmd saga_gui
+SUBDIRS = saga_api saga_odbc saga_gdi saga_cmd saga_gui
diff --git a/src/saga_core/Makefile.in b/src/saga_core/Makefile.in
index d1581bb..655491c 100644
--- a/src/saga_core/Makefile.in
+++ b/src/saga_core/Makefile.in
@@ -40,7 +40,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
SOURCES =
@@ -105,6 +104,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -114,6 +114,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -202,7 +203,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-SUBDIRS = saga_api saga_gdi saga_cmd saga_gui
+SUBDIRS = saga_api saga_odbc saga_gdi saga_cmd saga_gui
all: all-recursive
.SUFFIXES:
diff --git a/src/saga_core/saga_api/Makefile.am b/src/saga_core/saga_api/Makefile.am
index e64ee9f..f53585f 100644
--- a/src/saga_core/saga_api/Makefile.am
+++ b/src/saga_core/saga_api/Makefile.am
@@ -1,16 +1,17 @@
#
-# $Id: Makefile.am,v 1.17 2009/10/01 14:01:19 oconrad Exp $
+# $Id: Makefile.am,v 1.20 2010/06/28 23:22:27 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
endif
if SAGA_UNICODE
-AM_CXXFLAGS = -fPIC -Wall `wx-config --unicode=yes --cxxflags` -D_SAGA_LINUX -D_SAGA_UNICODE -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_API_EXPORTS -D_SAGA_DONOTUSE_HARU $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared -Wall `wx-config --unicode=yes --libs`
+AM_CXXFLAGS = -fPIC -Wall `wx-config --unicode=yes --cxxflags` -D_SAGA_LINUX -D_SAGA_UNICODE -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_API_EXPORTS $(DISABLELIBHARU) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -Wall `wx-config --unicode=yes --libs` $(HARU_LIB)
else
-AM_CXXFLAGS = -fPIC -Wall `wx-config --unicode=no --cxxflags` -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_API_EXPORTS -D_SAGA_DONOTUSE_HARU $(DBGFLAGS)
-AM_LDFLAGS = -fPIC -shared -Wall `wx-config --unicode=no --libs`
+AM_CXXFLAGS = -fPIC -Wall `wx-config --unicode=no --cxxflags` -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_API_EXPORTS $(DISABLELIBHARU) $(DBGFLAGS)
+AM_LDFLAGS = -fPIC -shared -Wall `wx-config --unicode=no --libs` $(HARU_LIB)
endif
+libsaga_api_la_LDFLAGS =$(AM_LDFLAGS) -release $(VERSION)
lib_LTLIBRARIES = libsaga_api.la
libsaga_api_la_SOURCES =\
@@ -65,6 +66,7 @@ shape_points.cpp\
shape_polygon.cpp\
shapes.cpp\
shapes_io.cpp\
+shapes_ogis.cpp\
shapes_search.cpp\
shapes_selection.cpp\
table.cpp\
diff --git a/src/saga_core/saga_api/Makefile.in b/src/saga_core/saga_api/Makefile.in
index 6b8dc78..e302543 100644
--- a/src/saga_core/saga_api/Makefile.in
+++ b/src/saga_core/saga_api/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -82,11 +81,15 @@ am_libsaga_api_la_OBJECTS = api_callback.lo api_colors.lo api_core.lo \
parameter_data.lo parameters.lo pointcloud.lo projections.lo \
quadtree.lo saga_api.lo shape.lo shape_line.lo shape_part.lo \
shape_point.lo shape_points.lo shape_polygon.lo shapes.lo \
- shapes_io.lo shapes_search.lo shapes_selection.lo table.lo \
- table_dbase.lo table_io.lo table_record.lo table_selection.lo \
- tin.lo tin_elements.lo tin_triangulation.lo
+ shapes_io.lo shapes_ogis.lo shapes_search.lo \
+ shapes_selection.lo table.lo table_dbase.lo table_io.lo \
+ table_record.lo table_selection.lo tin.lo tin_elements.lo \
+ tin_triangulation.lo
libsaga_api_la_OBJECTS = $(am_libsaga_api_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+libsaga_api_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(libsaga_api_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -132,6 +135,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -141,6 +145,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -231,13 +236,14 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.17 2009/10/01 14:01:19 oconrad Exp $
+# $Id: Makefile.am,v 1.20 2010/06/28 23:22:27 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
- at SAGA_UNICODE_FALSE@AM_CXXFLAGS = -fPIC -Wall `wx-config --unicode=no --cxxflags` -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_API_EXPORTS -D_SAGA_DONOTUSE_HARU $(DBGFLAGS)
- at SAGA_UNICODE_TRUE@AM_CXXFLAGS = -fPIC -Wall `wx-config --unicode=yes --cxxflags` -D_SAGA_LINUX -D_SAGA_UNICODE -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_API_EXPORTS -D_SAGA_DONOTUSE_HARU $(DBGFLAGS)
- at SAGA_UNICODE_FALSE@AM_LDFLAGS = -fPIC -shared -Wall `wx-config --unicode=no --libs`
- at SAGA_UNICODE_TRUE@AM_LDFLAGS = -fPIC -shared -Wall `wx-config --unicode=yes --libs`
+ at SAGA_UNICODE_FALSE@AM_CXXFLAGS = -fPIC -Wall `wx-config --unicode=no --cxxflags` -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_API_EXPORTS $(DISABLELIBHARU) $(DBGFLAGS)
+ at SAGA_UNICODE_TRUE@AM_CXXFLAGS = -fPIC -Wall `wx-config --unicode=yes --cxxflags` -D_SAGA_LINUX -D_SAGA_UNICODE -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_API_EXPORTS $(DISABLELIBHARU) $(DBGFLAGS)
+ at SAGA_UNICODE_FALSE@AM_LDFLAGS = -fPIC -shared -Wall `wx-config --unicode=no --libs` $(HARU_LIB)
+ at SAGA_UNICODE_TRUE@AM_LDFLAGS = -fPIC -shared -Wall `wx-config --unicode=yes --libs` $(HARU_LIB)
+libsaga_api_la_LDFLAGS = $(AM_LDFLAGS) -release $(VERSION)
lib_LTLIBRARIES = libsaga_api.la
libsaga_api_la_SOURCES = \
api_callback.cpp\
@@ -291,6 +297,7 @@ shape_points.cpp\
shape_polygon.cpp\
shapes.cpp\
shapes_io.cpp\
+shapes_ogis.cpp\
shapes_search.cpp\
shapes_selection.cpp\
table.cpp\
@@ -388,7 +395,7 @@ clean-libLTLIBRARIES:
rm -f "$${dir}/so_locations"; \
done
libsaga_api.la: $(libsaga_api_la_OBJECTS) $(libsaga_api_la_DEPENDENCIES)
- $(CXXLINK) -rpath $(libdir) $(libsaga_api_la_OBJECTS) $(libsaga_api_la_LIBADD) $(LIBS)
+ $(libsaga_api_la_LINK) -rpath $(libdir) $(libsaga_api_la_OBJECTS) $(libsaga_api_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -447,6 +454,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/shape_polygon.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/shapes.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/shapes_io.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/shapes_ogis.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/shapes_search.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/shapes_selection.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/table.Plo at am__quote@
diff --git a/src/saga_core/saga_api/api_callback.cpp b/src/saga_core/saga_api/api_callback.cpp
index 16f66e9..3a49c48 100644
--- a/src/saga_core/saga_api/api_callback.cpp
+++ b/src/saga_core/saga_api/api_callback.cpp
@@ -60,6 +60,8 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+#include <wx/stdpaths.h>
+
#include "api_core.h"
#include "grid.h"
#include "parameters.h"
@@ -208,6 +210,24 @@ void SG_UI_Process_Set_Text(const SG_Char *Text)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+bool SG_UI_Stop_Execution(void)
+{
+ if( gSG_UI_Callback )
+ {
+ return( gSG_UI_Callback(CALLBACK_STOP_EXECUTION, 0, 0) != 0 );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
void SG_UI_Dlg_Message(const SG_Char *Message, const SG_Char *Caption)
{
if( gSG_UI_Callback )
@@ -509,6 +529,12 @@ void * SG_UI_Get_Window_Main(void)
return( NULL );
}
+//---------------------------------------------------------
+CSG_String SG_UI_Get_Application_Path(void)
+{
+ return( wxStandardPaths::Get().GetExecutablePath().c_str() );
+}
+
///////////////////////////////////////////////////////////
// //
diff --git a/src/saga_core/saga_api/api_core.cpp b/src/saga_core/saga_api/api_core.cpp
index 3031df5..ad6ef31 100644
--- a/src/saga_core/saga_api/api_core.cpp
+++ b/src/saga_core/saga_api/api_core.cpp
@@ -89,10 +89,71 @@ const SG_Char * SG_Data_Type_Get_Name (TSG_Data_Type Type)
case SG_DATATYPE_String: return( LNG("string") );
case SG_DATATYPE_Date: return( LNG("date") );
case SG_DATATYPE_Color: return( LNG("color") );
+ case SG_DATATYPE_Binary: return( LNG("binary") );
}
};
+//---------------------------------------------------------
+bool SG_Data_Type_is_Numeric(TSG_Data_Type Type)
+{
+ switch( Type )
+ {
+ case SG_DATATYPE_Bit:
+ case SG_DATATYPE_Byte:
+ case SG_DATATYPE_Char:
+ case SG_DATATYPE_Word:
+ case SG_DATATYPE_Short:
+ case SG_DATATYPE_DWord:
+ case SG_DATATYPE_Int:
+ case SG_DATATYPE_ULong:
+ case SG_DATATYPE_Long:
+ case SG_DATATYPE_Float:
+ case SG_DATATYPE_Double:
+ return( true );
+
+ default:
+ case SG_DATATYPE_String:
+ case SG_DATATYPE_Date:
+ case SG_DATATYPE_Color:
+ case SG_DATATYPE_Binary:
+ return( false );
+ }
+}
+
+//---------------------------------------------------------
+bool SG_DataType_Range_Check(TSG_Data_Type Type, double &Value)
+{
+ double min, max;
+
+ switch( Type )
+ {
+ default:
+ case SG_DATATYPE_Double: Value = (double)Value; return( true );
+ case SG_DATATYPE_Float: Value = (float )Value; return( true );
+
+ case SG_DATATYPE_Bit: min = 0.0; max = 1.0; break;
+ case SG_DATATYPE_Byte: min = 0.0; max = 255.0; break;
+ case SG_DATATYPE_Char: min = -128.0; max = 127.0; break;
+ case SG_DATATYPE_Word: min = 0.0; max = 65535.0; break;
+ case SG_DATATYPE_Short: min = -32768.0; max = 32767.0; break;
+ case SG_DATATYPE_DWord: min = 0.0; max = 4294967295.0; break;
+ case SG_DATATYPE_Int: min = -2147483648.0; max = 2147483647.0; break;
+ }
+
+ if( Value < min )
+ {
+ Value = min;
+ }
+ else if( Value > max )
+ {
+ Value = max;
+ }
+
+ return( true );
+}
+
+
///////////////////////////////////////////////////////////
// //
// //
diff --git a/src/saga_core/saga_api/api_core.h b/src/saga_core/saga_api/api_core.h
index 6472786..51129a8 100644
--- a/src/saga_core/saga_api/api_core.h
+++ b/src/saga_core/saga_api/api_core.h
@@ -96,6 +96,12 @@
//---------------------------------------------------------
#ifndef SWIG
+#if !defined(__APPLE__)
+#include <malloc.h>
+#endif
+
+#include <math.h>
+#include <memory.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -181,9 +187,10 @@ SAGA_API_DLL_EXPORT void SG_Mem_Set_Double (char *Buffer, double Value , bool
//---------------------------------------------------------
#ifndef _SAGA_UNICODE
- #define SG_Char char
- #define SG_T(s) s
+ #define SG_Char char
+ #define SG_T(s) s
#define SG_PRINTF printf
+ #define SG_FPRINTF fprintf
#define SG_SSCANF sscanf
#define SG_STR_CMP strcmp
#define SG_STR_CPY strcpy
@@ -195,6 +202,7 @@ SAGA_API_DLL_EXPORT void SG_Mem_Set_Double (char *Buffer, double Value , bool
#define SG_Char wchar_t
#define SG_T(s) L ## s
#define SG_PRINTF SG_Printf
+ #define SG_FPRINTF SG_FPrintf
#define SG_SSCANF swscanf
#define SG_STR_CMP wcscmp
#define SG_STR_CPY wcscpy
@@ -332,6 +340,7 @@ protected:
//---------------------------------------------------------
SAGA_API_DLL_EXPORT int SG_Printf (const SG_Char *Format, ...);
+SAGA_API_DLL_EXPORT int SG_FPrintf (FILE* stream,const SG_Char *Format, ...);
SAGA_API_DLL_EXPORT int SG_Sscanf (const SG_Char *Buffer, const SG_Char *Format, ...);
SAGA_API_DLL_EXPORT CSG_String SG_Get_CurrentTimeStr (bool bWithDate = true);
@@ -342,8 +351,9 @@ SAGA_API_DLL_EXPORT CSG_String SG_String_To_UTF8 (const SG_Char *String);
SAGA_API_DLL_EXPORT double SG_Degree_To_Double (const SG_Char *String);
SAGA_API_DLL_EXPORT CSG_String SG_Double_To_Degree (double Value);
-SAGA_API_DLL_EXPORT double SG_Date_To_Double (const SG_Char *String);
-SAGA_API_DLL_EXPORT CSG_String SG_Double_To_Date (double Value);
+SAGA_API_DLL_EXPORT int SG_Date_To_Number (const SG_Char *Value);
+SAGA_API_DLL_EXPORT CSG_String SG_Number_To_Date (int Value);
+SAGA_API_DLL_EXPORT CSG_String SG_Number_To_Date (double Value);
SAGA_API_DLL_EXPORT int SG_Get_Significant_Decimals (double Value, int maxDecimals = 6);
@@ -354,6 +364,317 @@ SAGA_API_DLL_EXPORT CSG_String SG_Get_String (double Value, int Precision =
///////////////////////////////////////////////////////////
// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+typedef enum ESG_Array_Growth
+{
+ SG_ARRAY_GROWTH_0 = 0,
+ SG_ARRAY_GROWTH_1,
+ SG_ARRAY_GROWTH_2,
+ SG_ARRAY_GROWTH_3
+}
+TSG_Array_Growth;
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Array
+{
+public:
+ CSG_Array(void);
+ ~CSG_Array(void);
+
+ CSG_Array (size_t Value_Size, size_t nValues = 0, TSG_Array_Growth Growth = SG_ARRAY_GROWTH_0);
+ void * Create (size_t Value_Size, size_t nValues = 0, TSG_Array_Growth Growth = SG_ARRAY_GROWTH_0);
+
+ void Destroy (void);
+
+ bool Set_Growth (TSG_Array_Growth Growth);
+ int Get_Growth (void) const { return( m_Growth ); }
+
+ size_t Get_Size (void) const { return( m_nValues ); }
+
+ void * Get_Array (void) const { return( m_Values ); }
+ void * Get_Array (size_t nValues) { Set_Array(nValues); return( m_Values ); }
+
+ bool Set_Array (size_t nValues);
+ bool Set_Array (size_t nValues, void **pArray);
+
+
+private:
+
+ TSG_Array_Growth m_Growth;
+
+ size_t m_nValues, m_nBuffer, m_Value_Size;
+
+ void *m_Values;
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Buffer
+{
+public:
+
+ CSG_Buffer (void);
+ bool Create (void);
+
+ CSG_Buffer (const CSG_Buffer &Buffer);
+ bool Create (const CSG_Buffer &Buffer);
+
+ CSG_Buffer (size_t Size);
+ bool Create (size_t Size);
+
+ virtual ~CSG_Buffer (void);
+ void Destroy (void);
+
+ bool Set_Size (size_t Size, bool bShrink = true);
+ bool Inc_Size (size_t Size) { return( Set_Size(m_Size + Size) ); }
+ size_t Get_Size (void) const { return( m_Size ); }
+
+ bool Set_Data (const char *Buffer, size_t Size, bool bShrink = true);
+ char * Get_Data (int Offset = 0) const { return( m_pData + Offset ); }
+ char operator [] (int Position) const { return( m_pData[Position] ); }
+
+ void Add_Value (char Value, bool bBigEndian = false) { if( Inc_Size(sizeof(Value)) ) Set_Value(m_Size - sizeof(Value), Value, bBigEndian); }
+ void Add_Value (short Value, bool bBigEndian = false) { if( Inc_Size(sizeof(Value)) ) Set_Value(m_Size - sizeof(Value), Value, bBigEndian); }
+ void Add_Value (int Value, bool bBigEndian = false) { if( Inc_Size(sizeof(Value)) ) Set_Value(m_Size - sizeof(Value), Value, bBigEndian); }
+ void Add_Value (float Value, bool bBigEndian = false) { if( Inc_Size(sizeof(Value)) ) Set_Value(m_Size - sizeof(Value), Value, bBigEndian); }
+ void Add_Value (double Value, bool bBigEndian = false) { if( Inc_Size(sizeof(Value)) ) Set_Value(m_Size - sizeof(Value), Value, bBigEndian); }
+
+ CSG_Buffer & operator += (char Value) { Add_Value(Value); return( *this ); }
+ CSG_Buffer & operator += (short Value) { Add_Value(Value); return( *this ); }
+ CSG_Buffer & operator += (int Value) { Add_Value(Value); return( *this ); }
+ CSG_Buffer & operator += (float Value) { Add_Value(Value); return( *this ); }
+ CSG_Buffer & operator += (double Value) { Add_Value(Value); return( *this ); }
+
+ void Set_Value (int Offset, char Value, bool bBigEndian = false) { m_pData[Offset] = Value; }
+ void Set_Value (int Offset, short Value, bool bBigEndian = false) { if( bBigEndian ) SG_Swap_Bytes(&Value, sizeof(Value)); *(short *)(m_pData + Offset) = Value; }
+ void Set_Value (int Offset, int Value, bool bBigEndian = false) { if( bBigEndian ) SG_Swap_Bytes(&Value, sizeof(Value)); *(int *)(m_pData + Offset) = Value; }
+ void Set_Value (int Offset, float Value, bool bBigEndian = false) { if( bBigEndian ) SG_Swap_Bytes(&Value, sizeof(Value)); *(float *)(m_pData + Offset) = Value; }
+ void Set_Value (int Offset, double Value, bool bBigEndian = false) { if( bBigEndian ) SG_Swap_Bytes(&Value, sizeof(Value)); *(double *)(m_pData + Offset) = Value; }
+
+ short asShort (int Offset, bool bBigEndian = false) const { short Value = *(short *)(m_pData + Offset); if( bBigEndian ) SG_Swap_Bytes(&Value, sizeof(Value)); return( Value ); }
+ int asInt (int Offset, bool bBigEndian = false) const { int Value = *(int *)(m_pData + Offset); if( bBigEndian ) SG_Swap_Bytes(&Value, sizeof(Value)); return( Value ); }
+ float asFloat (int Offset, bool bBigEndian = false) const { float Value = *(float *)(m_pData + Offset); if( bBigEndian ) SG_Swap_Bytes(&Value, sizeof(Value)); return( Value ); }
+ double asDouble (int Offset, bool bBigEndian = false) const { double Value = *(double *)(m_pData + Offset); if( bBigEndian ) SG_Swap_Bytes(&Value, sizeof(Value)); return( Value ); }
+
+
+private:
+
+ char *m_pData;
+
+ size_t m_Size;
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Bytes
+{
+public:
+ CSG_Bytes (void);
+ bool Create (void);
+
+ CSG_Bytes (const CSG_Bytes &Bytes);
+ bool Create (const CSG_Bytes &Bytes);
+
+ CSG_Bytes (const BYTE *Bytes, int nBytes);
+ bool Create (const BYTE *Bytes, int nBytes);
+
+ CSG_Bytes (const SG_Char *Bytes);
+ bool Create (const SG_Char *Bytes);
+
+ virtual ~CSG_Bytes(void);
+
+ bool Destroy (void);
+ bool Clear (void);
+
+ void Rewind (void) { m_Cursor = 0; }
+ bool is_EOF (void) { return( m_Cursor >= m_nBytes ); }
+
+ int Get_Count (void) const { return( m_nBytes ); }
+ BYTE * Get_Bytes (void) const { return( m_Bytes ); }
+
+ CSG_Bytes Get_Bytes (int i) const { if( i < 0 || i >= m_nBytes ) i = 0; return( CSG_Bytes(m_Bytes + i, m_nBytes - i) ); }
+ CSG_Bytes operator + (int i) const { return( Get_Bytes(i) ); }
+
+ BYTE Get_Byte (int i) const { return( i >= 0 && i < m_nBytes ? m_Bytes[i] : 0 ); }
+ BYTE operator [] (int i) const { return( Get_Byte(i) ); }
+
+ bool Assign (const CSG_Bytes &Bytes);
+ CSG_Bytes & operator = (const CSG_Bytes &Bytes) { Assign(Bytes); return( *this ); }
+
+ bool Add (const CSG_Bytes &Bytes);
+ CSG_Bytes & operator += (const CSG_Bytes &Bytes) { Add(Bytes); return( *this ); }
+
+ bool Add (void *Bytes, int nBytes, bool bSwapBytes);
+
+ bool Add (BYTE Value) { return( Add(&Value, sizeof(Value), false) ); }
+ CSG_Bytes & operator += (BYTE Value) { Add(Value); return( *this ); }
+ bool Add (char Value) { return( Add(&Value, sizeof(Value), false) ); }
+ CSG_Bytes & operator += (char Value) { Add(Value); return( *this ); }
+ bool Add (short Value, bool bSwapBytes = false) { return( Add(&Value, sizeof(Value), bSwapBytes) ); }
+ CSG_Bytes & operator += (short Value) { Add(Value); return( *this ); }
+ bool Add (WORD Value, bool bSwapBytes = false) { return( Add(&Value, sizeof(Value), bSwapBytes) ); }
+ CSG_Bytes & operator += (WORD Value) { Add(Value); return( *this ); }
+ bool Add (int Value, bool bSwapBytes = false) { return( Add(&Value, sizeof(Value), bSwapBytes) ); }
+ CSG_Bytes & operator += (int Value) { Add(Value); return( *this ); }
+ bool Add (DWORD Value, bool bSwapBytes = false) { return( Add(&Value, sizeof(Value), bSwapBytes) ); }
+ CSG_Bytes & operator += (DWORD Value) { Add(Value); return( *this ); }
+ bool Add (float Value, bool bSwapBytes = false) { return( Add(&Value, sizeof(Value), bSwapBytes) ); }
+ CSG_Bytes & operator += (float Value) { Add(Value); return( *this ); }
+ bool Add (double Value, bool bSwapBytes = false) { return( Add(&Value, sizeof(Value), bSwapBytes) ); }
+ CSG_Bytes & operator += (double Value) { Add(Value); return( *this ); }
+
+ BYTE asByte (int i) const { return( Get_Byte (i) ); }
+ char asChar (int i) const { return( (char)Get_Byte (i) ); }
+ short asShort (int i, bool bSwapBytes = false) const { short v = *((short *)(m_Bytes + i)); if( bSwapBytes ) SG_Swap_Bytes(&v, sizeof(v)); return( v ); }
+ WORD asWord (int i, bool bSwapBytes = false) const { WORD v = *((WORD *)(m_Bytes + i)); if( bSwapBytes ) SG_Swap_Bytes(&v, sizeof(v)); return( v ); }
+ int asInt (int i, bool bSwapBytes = false) const { int v = *((int *)(m_Bytes + i)); if( bSwapBytes ) SG_Swap_Bytes(&v, sizeof(v)); return( v ); }
+ DWORD asDWord (int i, bool bSwapBytes = false) const { DWORD v = *((DWORD *)(m_Bytes + i)); if( bSwapBytes ) SG_Swap_Bytes(&v, sizeof(v)); return( v ); }
+ float asFloat (int i, bool bSwapBytes = false) const { float v = *((float *)(m_Bytes + i)); if( bSwapBytes ) SG_Swap_Bytes(&v, sizeof(v)); return( v ); }
+ double asDouble (int i, bool bSwapBytes = false) const { double v = *((double *)(m_Bytes + i)); if( bSwapBytes ) SG_Swap_Bytes(&v, sizeof(v)); return( v ); }
+
+ BYTE Read_Byte (void) { BYTE v = asByte (m_Cursor); m_Cursor += sizeof(v); return( v ); }
+ char Read_Char (void) { char v = asByte (m_Cursor); m_Cursor += sizeof(v); return( v ); }
+ short Read_Short (bool bSwapBytes = false) { short v = asShort (m_Cursor, bSwapBytes); m_Cursor += sizeof(v); return( v ); }
+ WORD Read_Word (bool bSwapBytes = false) { WORD v = asWord (m_Cursor, bSwapBytes); m_Cursor += sizeof(v); return( v ); }
+ int Read_Int (bool bSwapBytes = false) { int v = asInt (m_Cursor, bSwapBytes); m_Cursor += sizeof(v); return( v ); }
+ DWORD Read_DWord (bool bSwapBytes = false) { DWORD v = asDWord (m_Cursor, bSwapBytes); m_Cursor += sizeof(v); return( v ); }
+ float Read_Float (bool bSwapBytes = false) { float v = asFloat (m_Cursor, bSwapBytes); m_Cursor += sizeof(v); return( v ); }
+ double Read_Double (bool bSwapBytes = false) { double v = asDouble(m_Cursor, bSwapBytes); m_Cursor += sizeof(v); return( v ); }
+
+ CSG_String toHexString (void) const;
+ bool fromHexString (const CSG_String &HexString);
+
+
+private:
+
+ int m_nBytes, m_nBuffer, m_Cursor;
+
+ BYTE *m_Bytes;
+
+
+ bool _Inc_Array (int nBytes);
+
+};
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Bytes_Array
+{
+public:
+ CSG_Bytes_Array(void);
+ virtual ~CSG_Bytes_Array(void);
+
+ bool Destroy (void);
+
+ int Get_Count (void) const { return( m_nBytes ); }
+ CSG_Bytes * Get_Bytes (int i) { return( i >= 0 && i < m_nBytes ? m_pBytes[i] : NULL ); }
+ CSG_Bytes & operator [] (int i) { return( *Get_Bytes(i) ); }
+
+ CSG_Bytes * Add (void);
+
+
+private:
+
+ int m_nBytes, m_nBuffer;
+
+ CSG_Bytes **m_pBytes;
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CSG_Stack
+{
+public:
+ CSG_Stack(size_t RecordSize) : m_Size(0), m_Buffer(0), m_RecordSize(RecordSize), m_Stack(NULL) {}
+ virtual ~CSG_Stack(void) { Destroy(); }
+
+ size_t Get_RecordSize (void) { return( m_RecordSize ); }
+ size_t Get_Size (void) { return( m_Size ); }
+ void Clear (void) { m_Size = 0; }
+
+ void Destroy (void)
+ {
+ if( m_Stack )
+ {
+ SG_Free(m_Stack);
+ }
+
+ m_Size = 0;
+ m_Buffer = 0;
+ m_Stack = NULL;
+ }
+
+
+protected:
+
+ void * Get_Record_Push (void)
+ {
+ if( m_Size < m_Buffer || _Grow() )
+ {
+ m_Size++;
+
+ return( (void *)(((char *)m_Stack) + m_RecordSize * (m_Size - 1)) );
+ }
+
+ return( NULL );
+ }
+
+ void * Get_Record_Pop (void)
+ {
+ if( m_Size > 0 )
+ {
+ m_Size--;
+
+ return( (void *)(((char *)m_Stack) + m_RecordSize * (m_Size)) );
+ }
+
+ return( NULL );
+ }
+
+
+private:
+
+ size_t m_Size, m_Buffer, m_RecordSize;
+
+ void *m_Stack;
+
+
+ virtual bool _Grow (void)
+ {
+ void *Stack = SG_Realloc(m_Stack, (m_Buffer + 256) * m_RecordSize);
+
+ if( Stack )
+ {
+ m_Stack = Stack;
+ m_Buffer += 256;
+
+ return( true );
+ }
+
+ return( false );
+ }
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
// Data Types //
// //
///////////////////////////////////////////////////////////
@@ -375,6 +696,7 @@ typedef enum ESG_Data_Type
SG_DATATYPE_String,
SG_DATATYPE_Date,
SG_DATATYPE_Color,
+ SG_DATATYPE_Binary,
SG_DATATYPE_Undefined
}
TSG_Data_Type;
@@ -396,6 +718,7 @@ const SG_Char gSG_Data_Type_Identifier[][32] =
SG_T("STRING"),
SG_T("DATE"),
SG_T("COLOR"),
+ SG_T("BINARY"),
SG_T("UNDEFINED")
};
@@ -419,11 +742,14 @@ inline size_t SG_Data_Type_Get_Size (TSG_Data_Type Type)
case SG_DATATYPE_String: return( 0 );
case SG_DATATYPE_Date: return( 0 );
case SG_DATATYPE_Color: return( sizeof(unsigned int) );
+ case SG_DATATYPE_Binary: return( 0 );
}
}
//---------------------------------------------------------
SAGA_API_DLL_EXPORT const SG_Char * SG_Data_Type_Get_Name (TSG_Data_Type Type);
+SAGA_API_DLL_EXPORT bool SG_Data_Type_is_Numeric (TSG_Data_Type Type);
+SAGA_API_DLL_EXPORT bool SG_DataType_Range_Check (TSG_Data_Type Type, double &Value);
///////////////////////////////////////////////////////////
@@ -450,7 +776,7 @@ SAGA_API_DLL_EXPORT const SG_Char * SG_Data_Type_Get_Name (TSG_Data_Type Type);
#endif
//---------------------------------------------------------
-enum
+enum ESG_File_Flags_Open
{
SG_FILE_R,
SG_FILE_W,
@@ -460,7 +786,7 @@ enum
};
//---------------------------------------------------------
-enum
+enum ESG_File_Flags_Seek
{
SG_FILE_START,
SG_FILE_CURRENT,
@@ -473,15 +799,17 @@ class SAGA_API_DLL_EXPORT CSG_File
public:
CSG_File(void);
- CSG_File(const CSG_String &File_Name, int Mode = SG_FILE_R, bool bBinary = true);
+ CSG_File(const CSG_String &File_Name, int Mode = SG_FILE_R, bool bBinary = true, bool bUnicode = false);
virtual ~CSG_File(void);
bool Attach (FILE *Stream);
bool Detach (void);
FILE * Get_Stream (void) const { return( m_pStream ); }
+ bool Get_UnicodeFlag (void) const { return( m_bUnicode ); }
+ bool Set_UnicodeFlag (bool bOn);
- bool Open (const CSG_String &FileName, int Mode = SG_FILE_R, bool bBinary = true);
+ bool Open (const CSG_String &FileName, int Mode = SG_FILE_R, bool bBinary = true, bool bUnicode = false);
bool Close (void);
bool is_Open (void) const { return( m_pStream != NULL ); }
@@ -500,20 +828,32 @@ public:
int Printf (const SG_Char *Format, ...);
int Scanf (const SG_Char *Format, ...) const;
+ int Get_Character (void) const;
+
size_t Read (void *Buffer, size_t Size, size_t Count = 1) const;
size_t Write (void *Buffer, size_t Size, size_t Count = 1) const;
size_t Read (CSG_String &Buffer, size_t Size) const;
size_t Write (CSG_String &Buffer) const;
- bool Read_Line (CSG_String &sLine);
+ bool Read_Line (CSG_String &sLine) const;
- int Read_Int ( bool bByteOrderBig);
- bool Write_Int (int Value, bool bByteOrderBig);
- double Read_Double ( bool bByteOrderBig);
- bool Write_Double (double Value, bool bByteOrderBig);
+ int Read_Int ( bool bBigEndian = false) const;
+ bool Write_Int (int Value, bool bBigEndian = false);
+ double Read_Double ( bool bBigEndian = false) const;
+ bool Write_Double (double Value, bool bBigEndian = false);
+ bool Scan (int &Value) const;
+ bool Scan (double &Value) const;
+ bool Scan (CSG_String &Value, SG_Char Separator) const;
-protected:
+ int Scan_Int (void) const;
+ double Scan_Double (void) const;
+ CSG_String Scan_String (SG_Char Separator) const;
+
+
+private:
+
+ bool m_bUnicode;
FILE *m_pStream;
@@ -531,6 +871,7 @@ SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Name (const SG_Char *full_Path, boo
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Path (const SG_Char *full_Path);
SAGA_API_DLL_EXPORT CSG_String SG_File_Make_Path (const SG_Char *Directory, const SG_Char *Name, const SG_Char *Extension = NULL);
SAGA_API_DLL_EXPORT bool SG_File_Cmp_Extension (const SG_Char *File_Name, const SG_Char *Extension);
+SAGA_API_DLL_EXPORT bool SG_File_Set_Extension (const SG_Char *File_Name, const SG_Char *Extension);
SAGA_API_DLL_EXPORT CSG_String SG_File_Get_Extension (const SG_Char *File_Name);
SAGA_API_DLL_EXPORT bool SG_Read_Line (FILE *Stream, CSG_String &Line);
@@ -543,8 +884,8 @@ SAGA_API_DLL_EXPORT bool SG_Read_Line (FILE *Stream, CSG_String &Line);
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define SG_GET_RGB(r, g, b) ((DWORD) (((BYTE)(r) | ((WORD)(g) << 8)) | (((DWORD)(BYTE)(b)) << 16)))
-#define SG_GET_RGBA(r, g, b, a) ((DWORD) (((BYTE)(r) | ((WORD)(g) << 8)) | (((DWORD)(BYTE)(b)) << 16) | (((DWORD)(BYTE)(a)) << 24)))
+#define SG_GET_RGB(r, g, b) ((DWORD) (((BYTE)(r) | ((WORD)(g) << 8)) | (((DWORD)(BYTE)(b)) << 16)))
+#define SG_GET_RGBA(r, g, b, a) ((DWORD) (((BYTE)(r) | ((WORD)(g) << 8)) | (((DWORD)(BYTE)(b)) << 16) | (((DWORD)(BYTE)(a)) << 24)))
#define SG_GET_R(rgb) ((BYTE) ((rgb) ))
#define SG_GET_G(rgb) ((BYTE) ((rgb) >> 8))
@@ -554,23 +895,23 @@ SAGA_API_DLL_EXPORT bool SG_Read_Line (FILE *Stream, CSG_String &Line);
//---------------------------------------------------------
#define SG_COLOR_BLACK SG_GET_RGB( 0, 0, 0)
#define SG_COLOR_GREY SG_GET_RGB(128, 128, 128)
-#define SG_COLOR_GREY_LIGHT SG_GET_RGB(192, 192, 192)
+#define SG_COLOR_GREY_LIGHT SG_GET_RGB(192, 192, 192)
#define SG_COLOR_WHITE SG_GET_RGB(255, 255, 255)
#define SG_COLOR_RED SG_GET_RGB(255, 0, 0)
#define SG_COLOR_RED_DARK SG_GET_RGB(128, 0, 0)
-#define SG_COLOR_YELLOW SG_GET_RGB(255, 255, 0)
+#define SG_COLOR_YELLOW SG_GET_RGB(255, 255, 0)
#define SG_COLOR_YELLOW_DARK SG_GET_RGB(128, 128, 0)
#define SG_COLOR_GREEN SG_GET_RGB( 0, 255, 0)
-#define SG_COLOR_GREEN_DARK SG_GET_RGB( 0, 128, 0)
+#define SG_COLOR_GREEN_DARK SG_GET_RGB( 0, 128, 0)
#define SG_COLOR_GREEN_LIGHT SG_GET_RGB( 0, 255, 0)
#define SG_COLOR_BLUE SG_GET_RGB( 0, 0, 255)
#define SG_COLOR_BLUE_DARK SG_GET_RGB( 0, 0, 128)
-#define SG_COLOR_BLUE_LIGHT SG_GET_RGB( 0, 255, 255)
-#define SG_COLOR_BLUE_GREEN SG_GET_RGB( 0, 128, 128)
-#define SG_COLOR_PURPLE SG_GET_RGB(128, 0, 128)
+#define SG_COLOR_BLUE_LIGHT SG_GET_RGB( 0, 255, 255)
+#define SG_COLOR_BLUE_GREEN SG_GET_RGB( 0, 128, 128)
+#define SG_COLOR_PURPLE SG_GET_RGB(128, 0, 128)
#define SG_COLOR_PINK SG_GET_RGB(255, 0, 255)
#define SG_COLOR_NONE -1
-#define SG_COLOR_RANDOM -2
+#define SG_COLOR_RANDOM -2
//---------------------------------------------------------
enum ESG_Colors
@@ -768,6 +1109,8 @@ typedef enum ESG_UI_Callback_ID
CALLBACK_PROCESS_SET_READY,
CALLBACK_PROCESS_SET_TEXT,
+ CALLBACK_STOP_EXECUTION,
+
CALLBACK_DLG_MESSAGE,
CALLBACK_DLG_CONTINUE,
CALLBACK_DLG_ERROR,
@@ -792,7 +1135,8 @@ typedef enum ESG_UI_Callback_ID
CALLBACK_DATAOBJECT_GET_ALL,
- CALLBACK_GUI_GET_WINDOW
+ CALLBACK_GUI_GET_WINDOW,
+ CALLBACK_GET_APP_PATH
}
TSG_UI_Callback_ID;
@@ -811,6 +1155,8 @@ SAGA_API_DLL_EXPORT bool SG_UI_Process_Set_Progress (double Position, double
SAGA_API_DLL_EXPORT bool SG_UI_Process_Set_Ready (void);
SAGA_API_DLL_EXPORT void SG_UI_Process_Set_Text (const SG_Char *Text);
+SAGA_API_DLL_EXPORT bool SG_UI_Stop_Execution (void);
+
SAGA_API_DLL_EXPORT void SG_UI_Dlg_Message (const SG_Char *Message, const SG_Char *Caption);
SAGA_API_DLL_EXPORT bool SG_UI_Dlg_Continue (const SG_Char *Message, const SG_Char *Caption);
SAGA_API_DLL_EXPORT int SG_UI_Dlg_Error (const SG_Char *Message, const SG_Char *Caption);
@@ -836,6 +1182,7 @@ SAGA_API_DLL_EXPORT bool SG_UI_DataObject_Params_Set (class CSG_Data_Object
SAGA_API_DLL_EXPORT bool SG_UI_DataObject_Get_All (class CSG_Parameters *pParameters);
SAGA_API_DLL_EXPORT void * SG_UI_Get_Window_Main (void);
+SAGA_API_DLL_EXPORT CSG_String SG_UI_Get_Application_Path (void);
///////////////////////////////////////////////////////////
diff --git a/src/saga_core/saga_api/api_file.cpp b/src/saga_core/saga_api/api_file.cpp
index 7237b48..64ed51d 100644
--- a/src/saga_core/saga_api/api_file.cpp
+++ b/src/saga_core/saga_api/api_file.cpp
@@ -76,14 +76,15 @@
CSG_File::CSG_File(void)
{
m_pStream = NULL;
+ m_bUnicode = false;
}
//---------------------------------------------------------
-CSG_File::CSG_File(const CSG_String &FileName, int Mode, bool bBinary)
+CSG_File::CSG_File(const CSG_String &FileName, int Mode, bool bBinary, bool bUnicode)
{
m_pStream = NULL;
- Open(FileName, Mode, bBinary);
+ Open(FileName, Mode, bBinary, bUnicode);
}
//---------------------------------------------------------
@@ -111,14 +112,17 @@ bool CSG_File::Detach(void)
}
//---------------------------------------------------------
-bool CSG_File::Open(const CSG_String &File_Name, int Mode, bool bBinary)
+bool CSG_File::Open(const CSG_String &File_Name, int Mode, bool bBinary, bool bUnicode)
{
Close();
+ m_bUnicode = bUnicode;
+
const SG_Char *sMode;
switch( Mode )
{
+ default: return( false );
case SG_FILE_R: sMode = bBinary ? SG_T("rb" ) : SG_T("r" ); break;
case SG_FILE_W: sMode = bBinary ? SG_T("wb" ) : SG_T("w" ); break;
case SG_FILE_RW: sMode = bBinary ? SG_T("wb+") : SG_T("w+"); break;
@@ -149,6 +153,19 @@ bool CSG_File::Close(void)
}
//---------------------------------------------------------
+bool CSG_File::Set_UnicodeFlag(bool bOn)
+{
+ if( m_bUnicode != bOn )
+ {
+ m_bUnicode = bOn;
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
int CSG_File::Length(void) const
{
if( m_pStream )
@@ -249,6 +266,17 @@ int CSG_File::Scanf(const SG_Char *Format, ...) const
}
//---------------------------------------------------------
+int CSG_File::Get_Character(void) const
+{
+ if( m_pStream )
+ {
+ return( getc(m_pStream) );
+ }
+
+ return( 0 );
+}
+
+//---------------------------------------------------------
size_t CSG_File::Read(void *Buffer, size_t Size, size_t Count) const
{
return( m_pStream ? fread(Buffer, Size, Count, m_pStream) : 0 );
@@ -281,17 +309,20 @@ size_t CSG_File::Write(CSG_String &Buffer) const
}
//---------------------------------------------------------
-bool CSG_File::Read_Line(CSG_String &sLine)
+bool CSG_File::Read_Line(CSG_String &sLine) const
{
- char c;
+ int c;
if( m_pStream && !feof(m_pStream) )
{
sLine.Clear();
- while( !feof(m_pStream) && (c = fgetc(m_pStream)) != 0x0A && c != 0x0D && c != EOF )
+ while( !feof(m_pStream) && (c = fgetc(m_pStream)) != 0x0A && c != EOF )
{
- sLine.Append(SG_STR_MBTOSG(c));
+ if( c != 0x0D )
+ {
+ sLine.Append(SG_STR_MBTOSG(c));
+ }
}
return( true );
@@ -301,11 +332,11 @@ bool CSG_File::Read_Line(CSG_String &sLine)
}
//---------------------------------------------------------
-int CSG_File::Read_Int(bool bByteOrderBig)
+int CSG_File::Read_Int(bool bByteOrderBig) const
{
int Value = 0;
- if( Read(&Value, sizeof(Value)) == sizeof(Value) )
+ if( Read(&Value, sizeof(Value)) == 1 )
{
if( bByteOrderBig )
{
@@ -327,11 +358,11 @@ bool CSG_File::Write_Int(int Value, bool bByteOrderBig)
}
//---------------------------------------------------------
-double CSG_File::Read_Double(bool bByteOrderBig)
+double CSG_File::Read_Double(bool bByteOrderBig) const
{
double Value = 0;
- if( Read(&Value, sizeof(Value)) == sizeof(Value) )
+ if( Read(&Value, sizeof(Value)) == 1 )
{
if( bByteOrderBig )
{
@@ -352,6 +383,60 @@ bool CSG_File::Write_Double(double Value, bool bByteOrderBig)
return( Write(&Value, sizeof(Value)) == sizeof(Value) );
}
+//---------------------------------------------------------
+bool CSG_File::Scan(int &Value) const
+{
+ return( m_pStream && fscanf(m_pStream, "%d" , &Value) == 1 );
+}
+
+bool CSG_File::Scan(double &Value) const
+{
+ return( m_pStream && fscanf(m_pStream, "%lf", &Value) == 1 );
+}
+
+bool CSG_File::Scan(CSG_String &Value, SG_Char Separator) const
+{
+ if( m_pStream && !feof(m_pStream) )
+ {
+ int c;
+
+ Value.Clear();
+
+ while( !feof(m_pStream) && (c = fgetc(m_pStream)) != Separator && c != EOF )
+ {
+ Value += c;
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+int CSG_File::Scan_Int(void) const
+{
+ int Value;
+
+ return( Scan(Value) ? Value : 0 );
+}
+
+double CSG_File::Scan_Double(void) const
+{
+ double Value;
+
+ return( Scan(Value) ? Value : 0.0 );
+}
+
+CSG_String CSG_File::Scan_String(SG_Char Separator) const
+{
+ CSG_String Value;
+
+ Scan(Value, Separator);
+
+ return( Value );
+}
+
///////////////////////////////////////////////////////////
// //
@@ -418,7 +503,7 @@ CSG_String SG_File_Get_Name(const SG_Char *full_Path, bool bExtension)
wxFileName fn(full_Path);
CSG_String s;
- s.Printf(bExtension ? fn.GetFullName().c_str() : fn.GetName().c_str());
+ s = bExtension ? fn.GetFullName().c_str() : fn.GetName().c_str();
return( s );
}
@@ -426,9 +511,14 @@ CSG_String SG_File_Get_Name(const SG_Char *full_Path, bool bExtension)
//---------------------------------------------------------
CSG_String SG_File_Get_Path(const SG_Char *full_Path)
{
- wxFileName fn(full_Path);
+ if( full_Path && *full_Path )
+ {
+ wxFileName fn(full_Path);
- return( fn.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR).c_str() );
+ return( fn.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR).c_str() );
+ }
+
+ return( SG_T("") );
}
//---------------------------------------------------------
@@ -436,7 +526,7 @@ CSG_String SG_File_Make_Path(const SG_Char *Directory, const SG_Char *Name, con
{
wxFileName fn;
- fn.AssignDir(SG_Dir_Exists(Directory) ? Directory : SG_File_Get_Path(Name).c_str());
+ fn.AssignDir(Directory && *Directory ? Directory : SG_File_Get_Path(Name).c_str());
if( Extension && *Extension )
{
@@ -460,6 +550,21 @@ bool SG_File_Cmp_Extension(const SG_Char *File_Name, const SG_Char *Extension)
}
//---------------------------------------------------------
+bool SG_File_Set_Extension(const SG_Char *File_Name, const SG_Char *Extension)
+{
+ if( File_Name && *File_Name && Extension && *Extension )
+ {
+ wxFileName fn(File_Name);
+
+ fn.SetExt(Extension);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
CSG_String SG_File_Get_Extension(const SG_Char *File_Name)
{
wxFileName fn(File_Name);
diff --git a/src/saga_core/saga_api/api_memory.cpp b/src/saga_core/saga_api/api_memory.cpp
index 532895e..2ca7154 100644
--- a/src/saga_core/saga_api/api_memory.cpp
+++ b/src/saga_core/saga_api/api_memory.cpp
@@ -60,8 +60,6 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#include "malloc.h"
-
#include "api_core.h"
@@ -239,3 +237,552 @@ void SG_Mem_Set_Double(char *Buffer, double Value, bool bSwapBytes)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+CSG_Array::CSG_Array(void)
+{
+ m_Value_Size = sizeof(char);
+ m_Growth = SG_ARRAY_GROWTH_0;
+
+ m_nBuffer = 0;
+ m_nValues = 0;
+ m_Values = NULL;
+}
+
+//---------------------------------------------------------
+CSG_Array::CSG_Array(size_t Value_Size, size_t nValues, TSG_Array_Growth Growth)
+{
+ Create(Value_Size, nValues, Growth);
+}
+
+void * CSG_Array::Create(size_t Value_Size, size_t nValues, TSG_Array_Growth Growth)
+{
+ m_Value_Size = Value_Size;
+ m_Growth = Growth;
+
+ m_nBuffer = 0;
+ m_nValues = 0;
+ m_Values = NULL;
+
+ return( Get_Array(nValues) );
+}
+
+//---------------------------------------------------------
+CSG_Array::~CSG_Array(void)
+{
+ Destroy();
+}
+
+void CSG_Array::Destroy(void)
+{
+ if( m_Values )
+ {
+ SG_Free(m_Values);
+ }
+
+ m_nBuffer = 0;
+ m_nValues = 0;
+ m_Values = NULL;
+}
+
+//---------------------------------------------------------
+bool CSG_Array::Set_Growth(TSG_Array_Growth Growth)
+{
+ m_Growth = Growth;
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Array::Set_Array(size_t nValues)
+{
+ if( nValues >= m_nValues && nValues <= m_nBuffer )
+ {
+ m_nValues = nValues;
+
+ return( true );
+ }
+
+ if( nValues == 0 )
+ {
+ Destroy();
+
+ return( true );
+ }
+
+ //-----------------------------------------------------
+ size_t nBuffer;
+
+ switch( m_Growth )
+ {
+ default:
+ case SG_ARRAY_GROWTH_0:
+ nBuffer = nValues;
+ break;
+
+ case SG_ARRAY_GROWTH_1:
+ case SG_ARRAY_GROWTH_2:
+ case SG_ARRAY_GROWTH_3:
+ nBuffer = nValues < 256 ? nValues
+ : nValues < 8192 ? (1 + nValues / 256) * 256
+ : (1 + nValues / 1024) * 1024;
+ break;
+ }
+
+ //-----------------------------------------------------
+ if( nBuffer == m_nBuffer )
+ {
+ m_nValues = nValues;
+
+ return( true );
+ }
+
+ //-----------------------------------------------------
+ void *Values = SG_Realloc(m_Values, nBuffer * m_Value_Size);
+
+ if( Values )
+ {
+ m_nBuffer = nBuffer;
+ m_nValues = nValues;
+ m_Values = Values;
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_Array::Set_Array(size_t nValues, void **pArray)
+{
+ if( Set_Array(nValues) )
+ {
+ *pArray = m_Values;
+
+ return( true );
+ }
+
+ *pArray = m_Values;
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Buffer::CSG_Buffer(void)
+{
+ m_pData = NULL;
+ m_Size = 0;
+}
+
+bool CSG_Buffer::Create(void)
+{
+ Destroy();
+
+ return( true );
+}
+
+//---------------------------------------------------------
+CSG_Buffer::CSG_Buffer(const CSG_Buffer &Buffer)
+{
+ m_pData = NULL;
+ m_Size = 0;
+
+ Create(Buffer);
+}
+
+bool CSG_Buffer::Create(const CSG_Buffer &Buffer)
+{
+ return( Set_Data(Buffer.m_pData, Buffer.m_Size) );
+}
+
+//---------------------------------------------------------
+CSG_Buffer::CSG_Buffer(size_t Size)
+{
+ m_pData = NULL;
+ m_Size = 0;
+
+ Create(Size);
+}
+
+bool CSG_Buffer::Create(size_t Size)
+{
+ return( Set_Size(Size) );
+}
+
+//---------------------------------------------------------
+CSG_Buffer::~CSG_Buffer(void)
+{
+ Destroy();
+}
+
+void CSG_Buffer::Destroy(void)
+{
+ if( m_pData )
+ {
+ SG_Free(m_pData);
+ }
+
+ m_pData = NULL;
+ m_Size = 0;
+}
+
+//---------------------------------------------------------
+bool CSG_Buffer::Set_Size(size_t Size, bool bShrink)
+{
+ if( Size > m_Size || (Size < m_Size && bShrink) )
+ {
+ char *pData = (char *)SG_Realloc(m_pData, Size * sizeof(char));
+
+ if( !pData )
+ {
+ return( false );
+ }
+
+ m_pData = pData;
+ m_Size = Size;
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Buffer::Set_Data(const char *Buffer, size_t Size, bool bShrink)
+{
+ if( !Buffer || !Size || !Set_Size(Size, bShrink) )
+ {
+ return( false );
+ }
+
+ memcpy(m_pData, Buffer, m_Size);
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Bytes::CSG_Bytes(void)
+{
+ m_Bytes = NULL;
+ m_nBytes = 0;
+ m_nBuffer = 0;
+ m_Cursor = 0;
+}
+
+//---------------------------------------------------------
+bool CSG_Bytes::Create(void)
+{
+ return( Destroy() );
+}
+
+//---------------------------------------------------------
+CSG_Bytes::CSG_Bytes(const CSG_Bytes &Bytes)
+{
+ m_Bytes = NULL;
+ m_nBytes = 0;
+ m_nBuffer = 0;
+ m_Cursor = 0;
+
+ Create(Bytes);
+}
+
+bool CSG_Bytes::Create(const CSG_Bytes &Bytes)
+{
+ return( Assign(Bytes) );
+}
+
+//---------------------------------------------------------
+CSG_Bytes::CSG_Bytes(const BYTE *Bytes, int nBytes)
+{
+ m_Bytes = NULL;
+ m_nBytes = 0;
+ m_nBuffer = 0;
+ m_Cursor = 0;
+
+ Create(Bytes, nBytes);
+}
+
+bool CSG_Bytes::Create(const BYTE *Bytes, int nBytes)
+{
+ Destroy();
+
+ return( Add((void *)Bytes, nBytes, false) );
+}
+
+//---------------------------------------------------------
+CSG_Bytes::CSG_Bytes(const SG_Char *Bytes)
+{
+ m_Bytes = NULL;
+ m_nBytes = 0;
+ m_nBuffer = 0;
+ m_Cursor = 0;
+
+ Create(Bytes);
+}
+
+bool CSG_Bytes::Create(const SG_Char *Bytes)
+{
+ Destroy();
+
+ if( Bytes == NULL ) // Reset
+ {
+ return( true );
+ }
+
+#ifndef _SAGA_UNICODE
+ int nBytes = SG_STR_LEN(Bytes);
+#else
+ int nBytes = SG_STR_LEN(Bytes) * 2;
+#endif
+
+ return( Add((void *)Bytes, nBytes, false) );
+}
+
+//---------------------------------------------------------
+CSG_Bytes::~CSG_Bytes(void)
+{
+ Destroy();
+}
+
+bool CSG_Bytes::Destroy(void)
+{
+ if( m_Bytes )
+ {
+ SG_Free(m_Bytes);
+ }
+
+ m_Bytes = NULL;
+ m_nBytes = 0;
+ m_nBuffer = 0;
+ m_Cursor = 0;
+
+ return( true );
+}
+
+bool CSG_Bytes::Clear(void)
+{
+ m_nBytes = 0;
+ m_Cursor = 0;
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Bytes::_Inc_Array(int nBytes)
+{
+ if( m_nBuffer < m_nBytes + nBytes )
+ {
+ int nBuffer = m_nBuffer + nBytes + 1024;
+ BYTE *Bytes = (BYTE *)SG_Realloc(m_Bytes, nBuffer * sizeof(BYTE));
+
+ if( !Bytes )
+ {
+ return( false );
+ }
+
+ m_Bytes = Bytes;
+ m_nBuffer = nBuffer;
+ }
+
+ m_nBytes += nBytes;
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Bytes::Assign(const CSG_Bytes &Bytes)
+{
+ Destroy();
+
+ if( _Inc_Array(Bytes.m_nBytes) )
+ {
+ memcpy(m_Bytes, Bytes.m_Bytes, m_nBytes);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Bytes::Add(const CSG_Bytes &Bytes)
+{
+ return( Add(Bytes.m_Bytes, Bytes.m_nBytes, false) );
+}
+
+//---------------------------------------------------------
+bool CSG_Bytes::Add(void *Bytes, int nBytes, bool bSwapBytes)
+{
+ int Offset = m_nBytes;
+
+ if( _Inc_Array(nBytes) )
+ {
+ memcpy(m_Bytes + Offset, Bytes, nBytes);
+
+ if( bSwapBytes )
+ {
+ SG_Swap_Bytes(m_Bytes + Offset, nBytes);
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+BYTE SG_Hex_to_Byte (const SG_Char Hex)
+{
+ switch( Hex )
+ {
+ case '1': return( 1 );
+ case '2': return( 2 );
+ case '3': return( 3 );
+ case '4': return( 4 );
+ case '5': return( 5 );
+ case '6': return( 6 );
+ case '7': return( 7 );
+ case '8': return( 8 );
+ case '9': return( 9 );
+ case 'a': case 'A': return( 10 );
+ case 'b': case 'B': return( 11 );
+ case 'c': case 'C': return( 12 );
+ case 'd': case 'D': return( 13 );
+ case 'e': case 'E': return( 14 );
+ case 'f': case 'F': return( 15 );
+ }
+
+ return( 0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_String CSG_Bytes::toHexString(void) const
+{
+ CSG_String HexString;
+
+ for(int i=0; i<m_nBytes; i++)
+ {
+ HexString += CSG_String::Format(SG_T("%02X"), m_Bytes[i]);
+ }
+
+ return( HexString );
+}
+
+//---------------------------------------------------------
+bool CSG_Bytes::fromHexString(const CSG_String &HexString)
+{
+ Destroy();
+
+ const SG_Char *s = HexString.c_str();
+
+ for(size_t i=0; i<HexString.Length(); i+=2)
+ {
+ Add(SG_Hex_to_Byte(*(s++)) + 16 * SG_Hex_to_Byte(*(s++)));
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Bytes_Array::CSG_Bytes_Array(void)
+{
+ m_pBytes = NULL;
+ m_nBytes = 0;
+ m_nBuffer = 0;
+}
+
+//---------------------------------------------------------
+CSG_Bytes_Array::~CSG_Bytes_Array(void)
+{
+ Destroy();
+}
+
+//---------------------------------------------------------
+bool CSG_Bytes_Array::Destroy(void)
+{
+ if( m_pBytes )
+ {
+ for(int i=0; i<m_nBytes; i++)
+ {
+ delete(m_pBytes[i]);
+ }
+
+ SG_Free(m_pBytes);
+ }
+
+ m_pBytes = NULL;
+ m_nBytes = 0;
+ m_nBuffer = 0;
+
+ return( true );
+}
+
+//---------------------------------------------------------
+CSG_Bytes * CSG_Bytes_Array::Add(void)
+{
+ if( m_nBytes >= m_nBuffer )
+ {
+ CSG_Bytes **pBytes = (CSG_Bytes **)SG_Realloc(m_pBytes, (m_nBuffer + 256) * sizeof(CSG_Bytes *));
+
+ if( !pBytes )
+ {
+ return( NULL );
+ }
+
+ m_pBytes = pBytes;
+ m_nBuffer += 256;
+ }
+
+ return( m_pBytes[m_nBytes++] = new CSG_Bytes );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_api/api_string.cpp b/src/saga_core/saga_api/api_string.cpp
index 0588d29..7b8142a 100644
--- a/src/saga_core/saga_api/api_string.cpp
+++ b/src/saga_core/saga_api/api_string.cpp
@@ -543,16 +543,12 @@ double CSG_String::asDouble(void) const
bool CSG_String::asDouble(double &Value) const
{
- double dValue = 0.0;
-
- if( m_pString->ToDouble(&dValue) || dValue != 0.0 )
- {
- Value = dValue;
-
- return( true );
- }
-
- return( false );
+ const wxChar *start = m_pString->c_str();
+ wxChar *end;
+
+ Value = wxStrtod(start, &end);
+
+ return( end > start );
}
@@ -686,6 +682,20 @@ int SG_Printf(const SG_Char *Format, ...)
}
//---------------------------------------------------------
+int SG_FPrintf(FILE* stream,const SG_Char *Format, ...)
+{
+ va_list argptr;
+
+ va_start(argptr, Format);
+
+ int ret = wxVfprintf(stream, Format, argptr);
+
+ va_end(argptr);
+
+ return( ret );
+}
+
+//---------------------------------------------------------
int SG_Sscanf(const SG_Char *Buffer, const SG_Char *Format, ...)
{
va_list argptr;
@@ -818,7 +828,12 @@ double SG_Degree_To_Double(const SG_Char *String)
}
//---------------------------------------------------------
-CSG_String SG_Double_To_Date(double Value)
+CSG_String SG_Number_To_Date(int Value)
+{
+ return( SG_Number_To_Date((double)Value) );
+}
+
+CSG_String SG_Number_To_Date(double Value)
{
int y, m, d;
@@ -830,22 +845,20 @@ CSG_String SG_Double_To_Date(double Value)
}
//---------------------------------------------------------
-double SG_Date_To_Double(const SG_Char *String)
+int SG_Date_To_Number(const SG_Char *String)
{
- int d, m, y;
-
- if( String )
+ if( String && String[0] )
{
CSG_String s(String), sValue;
sValue = s.AfterLast ('.');
- y = sValue.asInt();
+ int y = sValue.asInt();
sValue = s.BeforeLast ('.'); s = sValue;
sValue = s.AfterLast ('.');
- m = sValue.asInt();
+ int m = sValue.asInt();
sValue = s.BeforeLast ('.'); s = sValue;
- d = sValue.asInt();
+ int d = sValue.asInt();
if( d < 1 ) d = 1; else if( d > 31 ) d = 31;
if( m < 1 ) m = 1; else if( m > 12 ) m = 12;
diff --git a/src/saga_core/saga_api/dataobject.cpp b/src/saga_core/saga_api/dataobject.cpp
index 3ecd3cc..8a2ca21 100644
--- a/src/saga_core/saga_api/dataobject.cpp
+++ b/src/saga_core/saga_api/dataobject.cpp
@@ -113,21 +113,24 @@ CSG_Data_Object::CSG_Data_Object(void)
m_MetaData.Set_Name(SG_T("SAGA_METADATA"));
- m_pHistory = m_MetaData. Add_Child(SG_META_HST);
+ m_pHistory = m_MetaData. Add_Child(SG_META_HST);
- pSource = m_MetaData. Add_Child(SG_META_SRC);
- m_pFile = pSource-> Add_Child(SG_META_SRC_FILE);
- m_pMetaData_DB = pSource-> Add_Child(SG_META_SRC_DB);
- m_pProjection = pSource-> Add_Child(SG_META_SRC_PROJ);
+ pSource = m_MetaData. Add_Child(SG_META_SRC);
+ m_pFile = pSource-> Add_Child(SG_META_SRC_FILE);
+ m_pMetaData_DB = pSource-> Add_Child(SG_META_SRC_DB);
+ m_pProjection = pSource-> Add_Child(SG_META_SRC_PROJ);
//-----------------------------------------------------
- m_File_Type = 0;
- m_bModified = true;
+ m_File_Type = 0;
+ m_bModified = true;
- Set_Name (NULL);
- Set_File_Name (NULL);
+ m_NoData_Value = -99999.0;
+ m_NoData_hiValue = -999.0;
- m_bUpdate = false;
+ Set_Name (NULL);
+ Set_File_Name (NULL);
+
+ m_bUpdate = false;
}
//---------------------------------------------------------
@@ -154,7 +157,7 @@ bool CSG_Data_Object::Destroy(void)
//---------------------------------------------------------
void CSG_Data_Object::Set_Name(const SG_Char *Name)
{
- m_Name.Printf(Name ? CSG_String(Name).c_str() : LNG("[DAT] new") );
+ m_Name = Name ? CSG_String(Name).c_str() : LNG("[DAT] new");
}
const SG_Char * CSG_Data_Object::Get_Name(void) const
@@ -167,9 +170,9 @@ void CSG_Data_Object::Set_File_Name(const SG_Char *File_Name)
{
if( File_Name )
{
- m_File_Name.Printf(File_Name);
+ m_File_Name = File_Name;
- m_Name = SG_File_Get_Name(File_Name, false);
+ m_Name = SG_File_Get_Name(File_Name, false);
m_bModified = false;
}
@@ -202,6 +205,48 @@ int CSG_Data_Object::Get_File_Type(void) const
return( m_File_Type );
}
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CSG_Data_Object::Set_NoData_Value(double Value)
+{
+ Set_NoData_Value_Range(Value, Value);
+}
+
+//---------------------------------------------------------
+void CSG_Data_Object::Set_NoData_Value_Range(double loValue, double hiValue)
+{
+ if( loValue > hiValue )
+ {
+ double d = loValue;
+ loValue = hiValue;
+ hiValue = d;
+ }
+
+ if( loValue != m_NoData_Value || hiValue != m_NoData_hiValue )
+ {
+ if( !Get_Update_Flag() )
+ {
+ Set_Update_Flag();
+ }
+
+ m_NoData_Value = loValue;
+ m_NoData_hiValue = hiValue;
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
bool CSG_Data_Object::Load_MetaData(const SG_Char *File_Name)
{
@@ -228,9 +273,9 @@ bool CSG_Data_Object::Load_MetaData(const SG_Char *File_Name)
m_pProjection->Destroy();
- if( p->Get_Child(SG_META_SRC_PROJ) )
+ if( p->Get_Child(SG_META_SRC_PROJ) && m_pProjection->Assign(*p->Get_Child(SG_META_SRC_PROJ)) )
{
- m_pProjection->Assign(*p->Get_Child(SG_META_SRC_PROJ));
+ m_Projection.Load(*m_pProjection);
}
}
@@ -251,6 +296,15 @@ bool CSG_Data_Object::Load_MetaData(const SG_Char *File_Name)
//---------------------------------------------------------
bool CSG_Data_Object::Save_MetaData(const SG_Char *File_Name)
{
+ if( m_Projection.Get_Type() == SG_PROJ_TYPE_CS_Undefined )
+ {
+ m_pProjection->Destroy();
+ }
+ else
+ {
+ m_Projection.Save(*m_pProjection);
+ }
+
switch( Get_ObjectType() )
{
default: return( m_MetaData.Save(File_Name) );
diff --git a/src/saga_core/saga_api/dataobject.h b/src/saga_core/saga_api/dataobject.h
index 8533851..90c5a09 100644
--- a/src/saga_core/saga_api/dataobject.h
+++ b/src/saga_core/saga_api/dataobject.h
@@ -186,6 +186,7 @@ public:
bool is_Modified (void) const { return( m_bModified ); }
bool Update (void);
+
CSG_MetaData & Get_MetaData (void) const { return( *m_pMetaData ); }
CSG_MetaData & Get_MetaData_DB (void) { return( *m_pMetaData_DB ); }
CSG_MetaData & Get_History (void) { return( *m_pHistory ); }
@@ -198,6 +199,16 @@ public:
class CSG_PointCloud * asPointCloud (void) { return( Get_ObjectType() == DATAOBJECT_TYPE_PointCloud ? (class CSG_PointCloud *)this : NULL ); }
class CSG_Grid * asGrid (void) { return( Get_ObjectType() == DATAOBJECT_TYPE_Grid ? (class CSG_Grid *)this : NULL ); }
+ void Set_NoData_Value (double Value);
+ void Set_NoData_Value_Range (double loValue, double hiValue);
+ double Get_NoData_Value (void) const { return( m_NoData_Value ); }
+ double Get_NoData_hiValue (void) const { return( m_NoData_hiValue ); }
+
+ bool is_NoData_Value (double Value) const
+ {
+ return( m_NoData_Value < m_NoData_hiValue ? m_NoData_Value <= Value && Value <= m_NoData_hiValue : Value == m_NoData_Value );
+ }
+
protected:
@@ -218,6 +229,8 @@ private:
int m_File_Type;
+ double m_NoData_Value, m_NoData_hiValue;
+
CSG_String m_File_Name, m_Name;
CSG_MetaData m_MetaData, *m_pMetaData, *m_pHistory, *m_pFile, *m_pProjection, *m_pMetaData_DB;
diff --git a/src/saga_core/saga_api/geo_classes.cpp b/src/saga_core/saga_api/geo_classes.cpp
index 660194f..ad8a9d4 100644
--- a/src/saga_core/saga_api/geo_classes.cpp
+++ b/src/saga_core/saga_api/geo_classes.cpp
@@ -60,13 +60,23 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#include <memory.h>
+#include "parameters.h"
#include "geo_tools.h"
///////////////////////////////////////////////////////////
// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define BUFFER_SIZE_GROW(size) (size < 1024 ? 32 : 1024)
+
+
+///////////////////////////////////////////////////////////
+// //
// CSG_Point //
// //
///////////////////////////////////////////////////////////
@@ -93,77 +103,145 @@ CSG_Point::CSG_Point(double x, double y)
}
//---------------------------------------------------------
-CSG_Point::~CSG_Point(void)
+void CSG_Point::Add(const CSG_Point &Point)
+{
+ m_x += Point.m_x;
+ m_y += Point.m_y;
+}
+
+void CSG_Point::Subtract(const CSG_Point &Point)
{
+ m_x -= Point.Get_X();
+ m_y -= Point.Get_Y();
}
//---------------------------------------------------------
-bool CSG_Point::operator == (const CSG_Point &Point) const
+void CSG_Point::Assign(double x, double y)
{
- return( is_Equal(Point) );
+ m_x = x;
+ m_y = y;
}
-bool CSG_Point::operator != (const CSG_Point &Point) const
+void CSG_Point::Assign(const CSG_Point &Point)
+{
+ m_x = Point.m_x;
+ m_y = Point.m_y;
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Point_Z::CSG_Point_Z(void)
{
- return( !is_Equal(Point) );
+ Assign(0.0, 0.0, 0.0);
}
-CSG_Point & CSG_Point::operator = (const CSG_Point &Point)
+CSG_Point_Z::CSG_Point_Z(const CSG_Point_Z &Point)
{
Assign(Point);
+}
- return( *this );
+CSG_Point_Z::CSG_Point_Z(const TSG_Point_Z &Point)
+{
+ Assign(Point.x, Point.y, Point.z);
}
-void CSG_Point::operator += (const CSG_Point &Point)
+CSG_Point_Z::CSG_Point_Z(double x, double y, double z)
{
- m_point.x += Point.Get_X();
- m_point.y += Point.Get_Y();
+ Assign(x, y, z);
}
-void CSG_Point::operator -= (const CSG_Point &Point)
+//---------------------------------------------------------
+void CSG_Point_Z::Add(const CSG_Point_Z &Point)
{
- m_point.x -= Point.Get_X();
- m_point.y -= Point.Get_Y();
+ m_x += Point.m_x;
+ m_y += Point.m_y;
+ m_z += Point.m_z;
}
-CSG_Point CSG_Point::operator + (const CSG_Point &Point) const
+void CSG_Point_Z::Subtract(const CSG_Point_Z &Point)
{
- return( CSG_Point(
- m_point.x + Point.Get_X(),
- m_point.y + Point.Get_Y())
- );
+ m_x -= Point.m_x;
+ m_y -= Point.m_y;
+ m_z -= Point.m_z;
}
-CSG_Point CSG_Point::operator - (const CSG_Point &Point) const
+//---------------------------------------------------------
+void CSG_Point_Z::Assign(double x, double y, double z)
{
- return( CSG_Point(
- m_point.x - Point.Get_X(),
- m_point.y - Point.Get_Y())
- );
+ m_x = x;
+ m_y = y;
+ m_z = z;
+}
+
+void CSG_Point_Z::Assign(const CSG_Point_Z &Point)
+{
+ m_x = Point.m_x;
+ m_y = Point.m_y;
+ m_z = Point.m_z;
}
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
-void CSG_Point::Assign(double x, double y)
+CSG_Point_ZM::CSG_Point_ZM(void)
{
- m_point.x = x;
- m_point.y = y;
+ Assign(0.0, 0.0, 0.0, 0.0);
}
-void CSG_Point::Assign(const CSG_Point &Point)
+CSG_Point_ZM::CSG_Point_ZM(const CSG_Point_ZM &Point)
+{
+ Assign(Point);
+}
+
+CSG_Point_ZM::CSG_Point_ZM(const TSG_Point_ZM &Point)
+{
+ Assign(Point.x, Point.y, Point.z, Point.m);
+}
+
+CSG_Point_ZM::CSG_Point_ZM(double x, double y, double z, double m)
{
- m_point = Point.m_point;
+ Assign(x, y, z, m);
}
//---------------------------------------------------------
-bool CSG_Point::is_Equal(double x, double y) const
+void CSG_Point_ZM::Add(const CSG_Point_ZM &Point)
{
- return( m_point.x == x && m_point.y == y );
+ m_x += Point.m_x;
+ m_y += Point.m_y;
+ m_z += Point.m_z;
+ m_m += Point.m_m;
}
-bool CSG_Point::is_Equal(const CSG_Point &Point) const
+void CSG_Point_ZM::Subtract(const CSG_Point_ZM &Point)
{
- return( is_Equal(Point.Get_X(), Point.Get_Y()) );
+ m_x -= Point.m_x;
+ m_y -= Point.m_y;
+ m_z -= Point.m_z;
+ m_m -= Point.m_m;
+}
+
+//---------------------------------------------------------
+void CSG_Point_ZM::Assign(double x, double y, double z, double m)
+{
+ m_x = x;
+ m_y = y;
+ m_z = z;
+ m_m = m;
+}
+
+void CSG_Point_ZM::Assign(const CSG_Point_ZM &Point)
+{
+ m_x = Point.m_x;
+ m_y = Point.m_y;
+ m_z = Point.m_z;
+ m_m = Point.m_m;
}
@@ -176,6 +254,7 @@ bool CSG_Point::is_Equal(const CSG_Point &Point) const
//---------------------------------------------------------
CSG_Points::CSG_Points(void)
{
+ m_nBuffer = 0;
m_nPoints = 0;
m_Points = NULL;
}
@@ -194,6 +273,7 @@ void CSG_Points::Clear(void)
SG_Free(m_Points);
}
+ m_nBuffer = 0;
m_nPoints = 0;
m_Points = NULL;
}
@@ -222,16 +302,48 @@ CSG_Points & CSG_Points::operator = (const CSG_Points &Points)
//---------------------------------------------------------
bool CSG_Points::Set_Count(int nPoints)
{
- m_nPoints = nPoints;
- m_Points = (TSG_Point *)SG_Realloc(m_Points, m_nPoints * sizeof(TSG_Point));
+ if( m_nPoints == nPoints )
+ {
+ return( true );
+ }
- return( true );
+ if( nPoints <= 0 )
+ {
+ Clear();
+
+ return( true );
+ }
+
+ TSG_Point *Points = (TSG_Point *)SG_Realloc(m_Points, nPoints * sizeof(TSG_Point));
+
+ if( Points )
+ {
+ m_Points = Points;
+ m_nPoints = nPoints;
+ m_nBuffer = nPoints;
+
+ return( true );
+ }
+
+ return( false );
}
//---------------------------------------------------------
bool CSG_Points::Add(double x, double y)
{
- m_Points = (TSG_Point *)SG_Realloc(m_Points, (m_nPoints + 1) * sizeof(TSG_Point));
+ if( m_nPoints >= m_nBuffer - 1 )
+ {
+ TSG_Point *Points = (TSG_Point *)SG_Realloc(m_Points, (m_nBuffer + BUFFER_SIZE_GROW(m_nBuffer)) * sizeof(TSG_Point));
+
+ if( Points == NULL )
+ {
+ return( false );
+ }
+
+ m_Points = Points;
+ m_nBuffer += BUFFER_SIZE_GROW(m_nBuffer);
+ }
+
m_Points[m_nPoints].x = x;
m_Points[m_nPoints].y = y;
m_nPoints++;
@@ -282,6 +394,7 @@ bool CSG_Points::Del(int Index)
//---------------------------------------------------------
CSG_Points_Int::CSG_Points_Int(void)
{
+ m_nBuffer = 0;
m_nPoints = 0;
m_Points = NULL;
}
@@ -300,6 +413,7 @@ void CSG_Points_Int::Clear(void)
SG_Free(m_Points);
}
+ m_nBuffer = 0;
m_nPoints = 0;
m_Points = NULL;
}
@@ -328,16 +442,48 @@ CSG_Points_Int & CSG_Points_Int::operator = (const CSG_Points_Int &Points)
//---------------------------------------------------------
bool CSG_Points_Int::Set_Count(int nPoints)
{
- m_nPoints = nPoints;
- m_Points = (TSG_Point_Int *)SG_Realloc(m_Points, m_nPoints * sizeof(TSG_Point_Int));
+ if( m_nPoints == nPoints )
+ {
+ return( true );
+ }
- return( true );
+ if( nPoints <= 0 )
+ {
+ Clear();
+
+ return( true );
+ }
+
+ TSG_Point_Int *Points = (TSG_Point_Int *)SG_Realloc(m_Points, nPoints * sizeof(TSG_Point_Int));
+
+ if( Points )
+ {
+ m_Points = Points;
+ m_nPoints = nPoints;
+ m_nBuffer = nPoints;
+
+ return( true );
+ }
+
+ return( false );
}
//---------------------------------------------------------
bool CSG_Points_Int::Add(int x, int y)
{
- m_Points = (TSG_Point_Int *)SG_Realloc(m_Points, (m_nPoints + 1) * sizeof(TSG_Point_Int));
+ if( m_nPoints >= m_nBuffer - 1 )
+ {
+ TSG_Point_Int *Points = (TSG_Point_Int *)SG_Realloc(m_Points, (m_nBuffer + BUFFER_SIZE_GROW(m_nBuffer)) * sizeof(TSG_Point_Int));
+
+ if( Points == NULL )
+ {
+ return( false );
+ }
+
+ m_Points = Points;
+ m_nBuffer += BUFFER_SIZE_GROW(m_nBuffer);
+ }
+
m_Points[m_nPoints].x = x;
m_Points[m_nPoints].y = y;
m_nPoints++;
@@ -386,45 +532,47 @@ bool CSG_Points_Int::Del(int Index)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-CSG_Points_3D::CSG_Points_3D(void)
+CSG_Points_Z::CSG_Points_Z(void)
{
+ m_nBuffer = 0;
m_nPoints = 0;
m_Points = NULL;
}
//---------------------------------------------------------
-CSG_Points_3D::~CSG_Points_3D(void)
+CSG_Points_Z::~CSG_Points_Z(void)
{
Clear();
}
//---------------------------------------------------------
-void CSG_Points_3D::Clear(void)
+void CSG_Points_Z::Clear(void)
{
if( m_Points )
{
SG_Free(m_Points);
}
+ m_nBuffer = 0;
m_nPoints = 0;
m_Points = NULL;
}
//---------------------------------------------------------
-bool CSG_Points_3D::Assign(const CSG_Points_3D &Points)
+bool CSG_Points_Z::Assign(const CSG_Points_Z &Points)
{
Set_Count(Points.m_nPoints);
if( m_nPoints > 0 )
{
- memcpy(m_Points, Points.m_Points, m_nPoints * sizeof(TSG_Point_3D));
+ memcpy(m_Points, Points.m_Points, m_nPoints * sizeof(TSG_Point_Z));
}
return( true );
}
//---------------------------------------------------------
-CSG_Points_3D & CSG_Points_3D::operator = (const CSG_Points_3D &Points)
+CSG_Points_Z & CSG_Points_Z::operator = (const CSG_Points_Z &Points)
{
Assign(Points);
@@ -432,18 +580,50 @@ CSG_Points_3D & CSG_Points_3D::operator = (const CSG_Points_3D &Points)
}
//---------------------------------------------------------
-bool CSG_Points_3D::Set_Count(int nPoints)
+bool CSG_Points_Z::Set_Count(int nPoints)
{
- m_nPoints = nPoints;
- m_Points = (TSG_Point_3D *)SG_Realloc(m_Points, m_nPoints * sizeof(TSG_Point_3D));
+ if( m_nPoints == nPoints )
+ {
+ return( true );
+ }
- return( true );
+ if( nPoints <= 0 )
+ {
+ Clear();
+
+ return( true );
+ }
+
+ TSG_Point_Z *Points = (TSG_Point_Z *)SG_Realloc(m_Points, nPoints * sizeof(TSG_Point_Z));
+
+ if( Points )
+ {
+ m_Points = Points;
+ m_nPoints = nPoints;
+ m_nBuffer = nPoints;
+
+ return( true );
+ }
+
+ return( false );
}
//---------------------------------------------------------
-bool CSG_Points_3D::Add(double x, double y, double z)
+bool CSG_Points_Z::Add(double x, double y, double z)
{
- m_Points = (TSG_Point_3D *)SG_Realloc(m_Points, (m_nPoints + 1) * sizeof(TSG_Point_3D));
+ if( m_nPoints >= m_nBuffer - 1 )
+ {
+ TSG_Point_Z *Points = (TSG_Point_Z *)SG_Realloc(m_Points, (m_nBuffer + BUFFER_SIZE_GROW(m_nBuffer)) * sizeof(TSG_Point_Z));
+
+ if( Points == NULL )
+ {
+ return( false );
+ }
+
+ m_Points = Points;
+ m_nBuffer += BUFFER_SIZE_GROW(m_nBuffer);
+ }
+
m_Points[m_nPoints].x = x;
m_Points[m_nPoints].y = y;
m_Points[m_nPoints].z = z;
@@ -453,13 +633,13 @@ bool CSG_Points_3D::Add(double x, double y, double z)
}
//---------------------------------------------------------
-bool CSG_Points_3D::Add(const TSG_Point_3D &Point)
+bool CSG_Points_Z::Add(const TSG_Point_Z &Point)
{
return( Add(Point.x, Point.y, Point.z) );
}
//---------------------------------------------------------
-bool CSG_Points_3D::Del(int Index)
+bool CSG_Points_Z::Del(int Index)
{
if( Index >= 0 && Index < m_nPoints )
{
@@ -467,12 +647,12 @@ bool CSG_Points_3D::Del(int Index)
if( m_nPoints > 0 )
{
- for(TSG_Point_3D *A=m_Points+Index, *B=m_Points+Index+1; Index<m_nPoints; Index++, A++, B++)
+ for(TSG_Point_Z *A=m_Points+Index, *B=m_Points+Index+1; Index<m_nPoints; Index++, A++, B++)
{
*A = *B;
}
- m_Points = (TSG_Point_3D *)SG_Realloc(m_Points, m_nPoints * sizeof(TSG_Point_3D));
+ m_Points = (TSG_Point_Z *)SG_Realloc(m_Points, m_nPoints * sizeof(TSG_Point_Z));
}
else
{
@@ -858,3 +1038,126 @@ bool CSG_Rects::Add(const CSG_Rect &Rect)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+CSG_Distance_Weighting::CSG_Distance_Weighting(void)
+{
+ m_Weighting = SG_DISTWGHT_None;
+ m_IDW_Power = 1.0;
+ m_IDW_bOffset = true;
+ m_Bandwidth = 1.0;
+
+ m_pParameters = new CSG_Parameters(NULL, LNG("Distance Weighting"), LNG(""), SG_T("DISTANCE_WEIGHTING"));
+
+ m_pParameters->Add_Choice(
+ NULL, "WEIGHTING" , LNG("Distance Weighting"),
+ LNG(""),
+ CSG_String::Format(SG_T("%s|%s|%s|%s|"),
+ LNG("no distance weighting"),
+ LNG("inverse distance to a power"),
+ LNG("exponential"),
+ LNG("gaussian weighting")
+ ), m_Weighting
+ );
+
+ m_pParameters->Add_Value(
+ NULL, "IDW_POWER" , LNG("Inverse Distance Weighting Power"),
+ LNG(""),
+ PARAMETER_TYPE_Double, m_IDW_Power, 0.0, true
+ );
+
+ m_pParameters->Add_Value(
+ NULL, "IDW_OFFSET" , LNG("Inverse Distance Offset"),
+ LNG("Calculates weights for distance plus one, avoiding division by zero for zero distances"),
+ PARAMETER_TYPE_Bool, m_IDW_bOffset
+ );
+
+ m_pParameters->Add_Value(
+ NULL, "BANDWIDTH" , LNG("Gaussian and Exponential Weighting Bandwidth"),
+ LNG(""),
+ PARAMETER_TYPE_Double, m_Bandwidth, 0.0, true
+ );
+}
+
+//---------------------------------------------------------
+CSG_Distance_Weighting::~CSG_Distance_Weighting(void)
+{
+ delete(m_pParameters);
+}
+
+//---------------------------------------------------------
+bool CSG_Distance_Weighting::Set_Parameters(CSG_Parameters *pParameters)
+{
+ m_pParameters->Assign_Values(pParameters);
+
+ switch( m_pParameters->Get_Parameter("WEIGHTING")->asInt() )
+ {
+ default:
+ case 0: Set_Weighting(SG_DISTWGHT_None); break;
+ case 1: Set_Weighting(SG_DISTWGHT_IDW); break;
+ case 3: Set_Weighting(SG_DISTWGHT_EXP); break;
+ case 4: Set_Weighting(SG_DISTWGHT_GAUSS); break;
+ }
+
+ Set_IDW_Offset (m_pParameters->Get_Parameter("IDW_OFFSET") ->asBool());
+ Set_IDW_Power (m_pParameters->Get_Parameter("IDW_POWER") ->asDouble());
+ Set_BandWidth (m_pParameters->Get_Parameter("BANDWIDTH") ->asDouble());
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Distance_Weighting::Set_Weighting(TSG_Distance_Weighting Weighting)
+{
+ m_pParameters->Get_Parameter("WEIGHTING")->Set_Value((int)(m_Weighting = Weighting));
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Distance_Weighting::Set_IDW_Power(double Value)
+{
+ if( Value <= 0.0 )
+ {
+ return( false );
+ }
+
+ m_pParameters->Get_Parameter("IDW_POWER")->Set_Value((int)(m_IDW_Power = Value));
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Distance_Weighting::Set_IDW_Offset(bool bOn)
+{
+ m_pParameters->Get_Parameter("IDW_OFFSET")->Set_Value((int)(m_IDW_bOffset = bOn));
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Distance_Weighting::Set_BandWidth(double Value)
+{
+ if( Value <= 0.0 )
+ {
+ return( false );
+ }
+
+ m_pParameters->Get_Parameter("BANDWIDTH")->Set_Value(m_Bandwidth = Value);
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_api/geo_tools.h b/src/saga_core/saga_api/geo_tools.h
index f6d6646..1ca9a1e 100644
--- a/src/saga_core/saga_api/geo_tools.h
+++ b/src/saga_core/saga_api/geo_tools.h
@@ -72,6 +72,7 @@
//---------------------------------------------------------
#include "api_core.h"
+#include "metadata.h"
///////////////////////////////////////////////////////////
@@ -101,6 +102,16 @@ typedef enum ESG_Intersection
}
TSG_Intersection;
+//---------------------------------------------------------
+typedef enum ESG_Point_Type
+{
+ SG_POINT_TYPE_XY = 0,
+ SG_POINT_TYPE_XYZ,
+ SG_POINT_TYPE_XYZM,
+ SG_POINT_TYPE_XY_Int
+}
+TSG_Point_Type;
+
///////////////////////////////////////////////////////////
// //
@@ -116,18 +127,25 @@ typedef struct SSG_Point
TSG_Point;
//---------------------------------------------------------
-typedef struct SSG_Point_Int
+typedef struct SSG_Point_Z
{
- int x, y;
+ double x, y, z;
}
-TSG_Point_Int;
+TSG_Point_Z;
//---------------------------------------------------------
-typedef struct SSG_Point_3D
+typedef struct SSG_Point_ZM
{
- double x, y, z;
+ double x, y, z, m;
+}
+TSG_Point_ZM;
+
+//---------------------------------------------------------
+typedef struct SSG_Point_Int
+{
+ int x, y;
}
-TSG_Point_3D;
+TSG_Point_Int;
//---------------------------------------------------------
typedef struct SSG_Rect
@@ -152,32 +170,125 @@ public:
CSG_Point(const TSG_Point &Point);
CSG_Point(double x, double y);
- ~CSG_Point(void);
+ virtual ~CSG_Point(void) {}
- operator TSG_Point & (void) { return( m_point ); }
+ virtual TSG_Point_Type Get_Type (void) const { return( SG_POINT_TYPE_XY ); }
- double Get_X (void) const { return( m_point.x ); }
- double Get_Y (void) const { return( m_point.y ); }
+ operator TSG_Point (void) const { TSG_Point p; p.x = m_x; p.y = m_y; return( p ); }
- bool operator == (const CSG_Point &Point) const;
- bool operator != (const CSG_Point &Point) const;
+ double Get_X (void) const { return( m_x ); }
+ void Set_X (double x) { m_x = x; }
+ double Get_Y (void) const { return( m_y ); }
+ void Set_Y (double y) { m_y = y; }
- CSG_Point & operator = (const CSG_Point &Point);
- void operator += (const CSG_Point &Point);
- void operator -= (const CSG_Point &Point);
+ virtual bool operator == (const CSG_Point &Point) const { return( is_Equal(Point) ); }
+ virtual bool operator != (const CSG_Point &Point) const { return( !is_Equal(Point) ); }
- CSG_Point operator + (const CSG_Point &Point) const;
- CSG_Point operator - (const CSG_Point &Point) const;
+ virtual CSG_Point operator + (const CSG_Point &Point) const { return( CSG_Point(m_x + Point.m_x, m_y + Point.m_y) ); }
+ virtual CSG_Point operator - (const CSG_Point &Point) const { return( CSG_Point(m_x - Point.m_x, m_y - Point.m_y) ); }
- void Assign (double x, double y);
- void Assign (const CSG_Point &Point);
+ virtual CSG_Point & operator = (const CSG_Point &Point) { Assign (Point); return( *this ); }
+ virtual CSG_Point & operator += (const CSG_Point &Point) { Add (Point); return( *this ); }
+ virtual CSG_Point & operator -= (const CSG_Point &Point) { Subtract(Point); return( *this ); }
- bool is_Equal (double x, double y) const;
- bool is_Equal (const CSG_Point &Point) const;
+ virtual void Assign (double x, double y);
+ virtual void Assign (const CSG_Point &Point);
+ virtual void Add (const CSG_Point &Point);
+ virtual void Subtract (const CSG_Point &Point);
+ virtual bool is_Equal (double x, double y) const { return( m_x == x && m_y == y ); }
+ virtual bool is_Equal (const CSG_Point &Point) const { return( m_x == Point.m_x && m_y == Point.m_y ); }
+
+
+protected:
+
+ double m_x, m_y;
+
+};
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Point_Z : public CSG_Point
+{
+public:
+ CSG_Point_Z(void);
+ CSG_Point_Z(const CSG_Point_Z &Point);
+ CSG_Point_Z(const TSG_Point_Z &Point);
+ CSG_Point_Z(double x, double y, double z);
+
+ virtual ~CSG_Point_Z(void) {}
+
+ virtual TSG_Point_Type Get_Type (void) const { return( SG_POINT_TYPE_XYZ ); }
+
+ operator TSG_Point_Z (void) const { TSG_Point_Z p; p.x = m_x; p.y = m_y; p.z = m_z; return( p ); }
+
+ double Get_Z (void) const { return( m_z ); }
+ void Set_Z (double z) { m_z = z; }
+
+ virtual bool operator == (const CSG_Point_Z &Point) const { return( is_Equal(Point) ); }
+ virtual bool operator != (const CSG_Point_Z &Point) const { return( !is_Equal(Point) ); }
+
+ virtual CSG_Point_Z operator + (const CSG_Point_Z &Point) const { return( CSG_Point_Z(m_x + Point.m_x, m_y + Point.m_y, m_z + Point.m_z) ); }
+ virtual CSG_Point_Z operator - (const CSG_Point_Z &Point) const { return( CSG_Point_Z(m_x - Point.m_x, m_y - Point.m_y, m_z - Point.m_z) ); }
+
+ virtual CSG_Point_Z & operator = (const CSG_Point_Z &Point) { Assign (Point); return( *this ); }
+ virtual CSG_Point_Z & operator += (const CSG_Point_Z &Point) { Add (Point); return( *this ); }
+ virtual CSG_Point_Z & operator -= (const CSG_Point_Z &Point) { Subtract(Point); return( *this ); }
+
+ virtual void Assign (double x, double y, double z);
+ virtual void Assign (const CSG_Point_Z &Point);
+ virtual void Add (const CSG_Point_Z &Point);
+ virtual void Subtract (const CSG_Point_Z &Point);
+
+ virtual bool is_Equal (double x, double y, double z) const { return( m_x == x && m_y == y && m_z == z ); }
+ virtual bool is_Equal (const CSG_Point_Z &Point) const { return( m_x == Point.m_x && m_y == Point.m_y && m_z == Point.m_z ); }
+
+
+protected:
+
+ double m_z;
+
+};
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Point_ZM : public CSG_Point_Z
+{
+public:
+ CSG_Point_ZM(void);
+ CSG_Point_ZM(const CSG_Point_ZM &Point);
+ CSG_Point_ZM(const TSG_Point_ZM &Point);
+ CSG_Point_ZM(double x, double y, double z, double m);
+
+ virtual ~CSG_Point_ZM(void) {}
+
+ virtual TSG_Point_Type Get_Type (void) const { return( SG_POINT_TYPE_XYZM ); }
+
+ operator TSG_Point_ZM (void) const { TSG_Point_ZM p; p.x = m_x; p.y = m_y; p.z = m_z; p.m = m_m; return( p ); }
+
+ double Get_M (void) const { return( m_m ); }
+ void Set_M (double m) { m_m = m; }
+
+ virtual bool operator == (const CSG_Point_ZM &Point) const { return( is_Equal(Point) ); }
+ virtual bool operator != (const CSG_Point_ZM &Point) const { return( !is_Equal(Point) ); }
+
+ virtual CSG_Point_ZM operator + (const CSG_Point_ZM &Point) const { return( CSG_Point_ZM(m_x + Point.m_x, m_y + Point.m_y, m_z + Point.m_z, m_m + Point.m_m) ); }
+ virtual CSG_Point_ZM operator - (const CSG_Point_ZM &Point) const { return( CSG_Point_ZM(m_x - Point.m_x, m_y - Point.m_y, m_z - Point.m_z, m_m - Point.m_m) ); }
+
+ virtual CSG_Point_ZM & operator = (const CSG_Point_ZM &Point) { Assign (Point); return( *this ); }
+ virtual CSG_Point_ZM & operator += (const CSG_Point_ZM &Point) { Add (Point); return( *this ); }
+ virtual CSG_Point_ZM & operator -= (const CSG_Point_ZM &Point) { Subtract(Point); return( *this ); }
+
+ virtual void Assign (double x, double y, double z, double m);
+ virtual void Assign (const CSG_Point_ZM &Point);
+ virtual void Add (const CSG_Point_ZM &Point);
+ virtual void Subtract (const CSG_Point_ZM &Point);
+
+ virtual bool is_Equal (double x, double y, double z, double m) const { return( m_x == x && m_y == y && m_z == z && m_m == m ); }
+ virtual bool is_Equal (const CSG_Point_ZM &Point) const { return( m_x == Point.m_x && m_y == Point.m_y && m_z == Point.m_z && m_m == Point.m_m ); }
- //-----------------------------------------------------
- TSG_Point m_point;
+
+protected:
+
+ double m_m;
};
@@ -215,7 +326,7 @@ public:
private:
- int m_nPoints;
+ int m_nPoints, m_nBuffer;
TSG_Point *m_Points;
@@ -248,33 +359,33 @@ public:
private:
- int m_nPoints;
+ int m_nPoints, m_nBuffer;
TSG_Point_Int *m_Points;
};
//---------------------------------------------------------
-class SAGA_API_DLL_EXPORT CSG_Points_3D
+class SAGA_API_DLL_EXPORT CSG_Points_Z
{
public:
- CSG_Points_3D(void);
- virtual ~CSG_Points_3D(void);
+ CSG_Points_Z(void);
+ virtual ~CSG_Points_Z(void);
void Clear (void);
- CSG_Points_3D & operator = (const CSG_Points_3D &Points);
- bool Assign (const CSG_Points_3D &Points);
+ CSG_Points_Z & operator = (const CSG_Points_Z &Points);
+ bool Assign (const CSG_Points_Z &Points);
bool Add (double x, double y, double z);
- bool Add (const TSG_Point_3D &Point);
+ bool Add (const TSG_Point_Z &Point);
bool Del (int Index);
bool Set_Count (int nPoints);
int Get_Count (void) const { return( m_nPoints ); }
- TSG_Point_3D & operator [] (int Index) { return( m_Points[Index] ); }
- TSG_Point_3D & Get_Point (int Index) { return( m_Points[Index] ); }
+ TSG_Point_Z & operator [] (int Index) { return( m_Points[Index] ); }
+ TSG_Point_Z & Get_Point (int Index) { return( m_Points[Index] ); }
double Get_X (int Index) const { return( m_Points[Index].x ); }
double Get_Y (int Index) const { return( m_Points[Index].y ); }
double Get_Z (int Index) const { return( m_Points[Index].z ); }
@@ -282,9 +393,9 @@ public:
private:
- int m_nPoints;
+ int m_nPoints, m_nBuffer;
- TSG_Point_3D *m_Points;
+ TSG_Point_Z *m_Points;
};
@@ -403,6 +514,101 @@ private:
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+typedef enum ESG_Distance_Weighting
+{
+ SG_DISTWGHT_None = 0,
+ SG_DISTWGHT_IDW,
+ SG_DISTWGHT_EXP,
+ SG_DISTWGHT_GAUSS
+}
+TSG_Distance_Weighting;
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Distance_Weighting
+{
+public:
+ CSG_Distance_Weighting(void);
+ virtual ~CSG_Distance_Weighting(void);
+
+ class CSG_Parameters * Get_Parameters (void) const { return( m_pParameters ); }
+ bool Set_Parameters (class CSG_Parameters *pParameters);
+
+ TSG_Distance_Weighting Get_Weighting (void) const { return( m_Weighting ); }
+ bool Set_Weighting (TSG_Distance_Weighting Weighting);
+
+ double Get_IDW_Power (void) const { return( m_IDW_Power ); }
+ bool Set_IDW_Power (double Value);
+
+ bool Get_IDW_Offset (void) const { return( m_IDW_bOffset ); }
+ bool Set_IDW_Offset (bool bOn = true);
+
+ double Get_BandWidth (void) const { return( m_Bandwidth ); }
+ bool Set_BandWidth (double Value);
+
+ //-----------------------------------------------------
+ double Get_Weight (double Distance) const
+ {
+ if( Distance < 0.0 )
+ {
+ return( 0.0 );
+ }
+
+ switch( m_Weighting )
+ {
+ case SG_DISTWGHT_None: default:
+ return( 1.0 );
+
+ case SG_DISTWGHT_IDW:
+ if( m_IDW_bOffset )
+ return( pow(1.0 + Distance, -m_IDW_Power) );
+ else
+ return( Distance > 0.0 ? pow(Distance, -m_IDW_Power) : 0.0 );
+
+ case SG_DISTWGHT_EXP:
+ return( exp(-Distance / m_Bandwidth) );
+
+ case SG_DISTWGHT_GAUSS:
+ Distance /= m_Bandwidth;
+ return( exp(-0.5 * Distance*Distance) );
+ }
+ }
+
+
+private:
+
+ bool m_IDW_bOffset;
+
+ double m_IDW_Power, m_Bandwidth;
+
+ TSG_Distance_Weighting m_Weighting;
+
+ class CSG_Parameters *m_pParameters;
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+typedef enum ESG_Projection_Format
+{
+ SG_PROJ_FMT_WKT,
+ SG_PROJ_FMT_Proj4,
+ SG_PROJ_FMT_EPSG,
+ SG_PROJ_FMT_Undefined
+}
+TSG_Projection_Format;
+
+//---------------------------------------------------------
typedef enum ESG_Projection_Type
{
SG_PROJ_TYPE_CS_Undefined = 0,
@@ -433,49 +639,57 @@ public:
CSG_Projection (const CSG_Projection &Projection);
bool Create (const CSG_Projection &Projection);
+ bool Assign (const CSG_Projection &Projection);
+ CSG_Projection & operator = (const CSG_Projection &Projection) { Assign(Projection); return( *this ); }
- CSG_Projection (int SRID, const SG_Char *Authority, const SG_Char *OpenGIS, const SG_Char *Proj4);
- bool Create (int SRID, const SG_Char *Authority, const SG_Char *OpenGIS, const SG_Char *Proj4);
+ CSG_Projection (int EPSG_SRID);
+ bool Create (int EPSG_SRID);
+ bool Assign (int EPSG_SRID);
+ CSG_Projection & operator = (int EPSG_SRID) { Assign(EPSG_SRID); return( *this ); }
- bool Assign (int SRID, const SG_Char *Authority, const SG_Char *OpenGIS, const SG_Char *Proj4);
- bool Assign (const CSG_Projection &Projection);
- CSG_Projection & operator = (const CSG_Projection &Projection) { Assign(Projection); return( *this ); }
+ CSG_Projection (const CSG_String &Projection, TSG_Projection_Format Format = SG_PROJ_FMT_WKT);
+ bool Create (const CSG_String &Projection, TSG_Projection_Format Format = SG_PROJ_FMT_WKT);
+ bool Assign (const CSG_String &Projection, TSG_Projection_Format Format = SG_PROJ_FMT_WKT);
+ CSG_Projection & operator = (const CSG_String &Projection) { Assign(Projection); return( *this ); }
+ bool is_Okay (void) const { return( m_Type != SG_PROJ_TYPE_CS_Undefined ); }
bool is_Equal (const CSG_Projection &Projection) const;
bool operator == (const CSG_Projection &Projection) const { return( is_Equal(Projection) ); }
- int Get_SRID (void) const { return( m_SRID ); }
- TSG_Projection_Type Get_Type (void) const { return( m_Type ); }
- const CSG_String & Get_Name (void) const { return( m_Name ); }
- const CSG_String & Get_OpenGIS (void) const { return( m_OpenGIS ); }
- const CSG_String & Get_Proj4 (void) const { return( m_Proj4 ); }
- const CSG_String & Get_Authority (void) const { return( m_Authority ); }
- CSG_String Get_Type_Name (void) const { return( gSG_Projection_Type_Identifier[m_Type] ); }
- CSG_String Get_Type_Identifier (void) const { return( SG_Get_Projection_Type_Name(m_Type) ); }
+ bool Load (const CSG_String &File_Name, TSG_Projection_Format Format);
+ bool Save (const CSG_String &File_Name, TSG_Projection_Format Format) const;
- CSG_String asString (void) const;
+ bool Load (const CSG_MetaData &Projection);
+ bool Save ( CSG_MetaData &Projection) const;
- bool from_ESRI (const CSG_String &ESRI_PRJ);
- bool to_ESRI (CSG_String &ESRI_PRJ) const;
+ const CSG_String & Get_Name (void) const { return( m_Name ); }
+ const CSG_String & Get_WKT (void) const { return( m_WKT ); }
+ const CSG_String & Get_Proj4 (void) const { return( m_Proj4 ); }
+ int Get_EPSG (void) const { return( m_EPSG ); }
+
+ TSG_Projection_Type Get_Type (void) const { return( m_Type ); }
+ CSG_String Get_Type_Name (void) const { return( gSG_Projection_Type_Identifier[m_Type] ); }
+ CSG_String Get_Type_Identifier (void) const { return( SG_Get_Projection_Type_Name(m_Type) ); }
private:
- int m_SRID;
+ int m_EPSG;
TSG_Projection_Type m_Type;
- CSG_String m_Name, m_Authority, m_OpenGIS, m_Proj4;
+ CSG_String m_Name, m_WKT, m_Proj4;
void _Reset (void);
- bool _Get_OpenGIS_from_Proj4 (const SG_Char *Text);
- bool _Get_Proj4_from_OpenGIS (const SG_Char *Text);
-
};
//---------------------------------------------------------
+/** CSG_Projections is a projections dictionary and translator
+ * for EPSG codes, OpenGIS Well-Known-Text, ESRI and Proj.4.
+*/
+//---------------------------------------------------------
class SAGA_API_DLL_EXPORT CSG_Projections
{
public:
@@ -494,32 +708,27 @@ public:
bool Save (const CSG_String &File_Name);
bool Add (const CSG_Projection &Projection);
- bool Add (int SRID, const SG_Char *Authority, const SG_Char *OpenGIS, const SG_Char *Proj4);
+ bool Add (int SRID, const SG_Char *Authority, const SG_Char *WKT, const SG_Char *Proj4);
- int Get_Count (void) const { return( m_nProjections ); }
- const CSG_Projection & Get_Projection (int i) const { return( i >= 0 && i < m_nProjections ? *(m_pProjections[i]) : m_Undefined ); }
- const CSG_Projection & operator [] (int i) const { return( i >= 0 && i < m_nProjections ? *(m_pProjections[i]) : m_Undefined ); }
+ int Get_Count (void) const;
+ const CSG_Projection & Get_Projection (int i) const;
+ const CSG_Projection & operator [] (int i) const;
+
+ bool Get_Projection (int EPSG, CSG_Projection &Projection) const;
CSG_String Get_Names (void) const;
int Get_SRID_byNamesIndex (int i) const;
+ static bool WKT_to_Proj4 (CSG_String &Proj4, const CSG_String &WKT );
+ static bool WKT_from_Proj4 (CSG_String &WKT , const CSG_String &Proj4);
-private:
-
- int m_nProjections, m_nBuffer;
-
- CSG_Projection **m_pProjections, m_Undefined;
- static CSG_Projections *s_pProjections;
+private:
- class CSG_Index *m_pIdx_Names, *m_pIdx_SRIDs;
+ class CSG_Table *m_pProjections;
void _On_Construction (void);
- CSG_Projection * _Add (void);
-
- static int _Cmp_Names (const int iElement_1, const int iElement_2);
- static int _Cmp_SRIDs (const int iElement_1, const int iElement_2);
};
diff --git a/src/saga_core/saga_api/grid.cpp b/src/saga_core/saga_api/grid.cpp
index 3d45403..fcbe906 100644
--- a/src/saga_core/saga_api/grid.cpp
+++ b/src/saga_core/saga_api/grid.cpp
@@ -223,8 +223,6 @@ void CSG_Grid::_On_Construction(void)
LineBuffer_Count = 5;
m_zFactor = 1.0;
- m_NoData_Value = -99999.0;
- m_NoData_hiValue = -999.0;
m_bIndexed = false;
m_Index = NULL;
@@ -335,20 +333,21 @@ void CSG_Grid::_Set_Properties(TSG_Data_Type Type, int NX, int NY, double Cellsi
switch( m_Type )
{
- case SG_DATATYPE_Bit: m_NoData_Value = m_NoData_hiValue = 0.0; break;
- case SG_DATATYPE_Byte: m_NoData_Value = m_NoData_hiValue = 255.0; break;
- case SG_DATATYPE_Char: m_NoData_Value = m_NoData_hiValue = -127.0; break;
- case SG_DATATYPE_Word: m_NoData_Value = m_NoData_hiValue = 65535.0; break;
- case SG_DATATYPE_Short: m_NoData_Value = m_NoData_hiValue = -32767.0; break;
- case SG_DATATYPE_DWord: m_NoData_Value = m_NoData_hiValue = 4294967295.0; break;
- case SG_DATATYPE_Int: m_NoData_Value = m_NoData_hiValue = -2147483647.0; break;
- case SG_DATATYPE_ULong: m_NoData_Value = m_NoData_hiValue = 4294967295.0; break;
- case SG_DATATYPE_Long: m_NoData_Value = m_NoData_hiValue = -2147483647.0; break;
- case SG_DATATYPE_Double: m_NoData_Value = m_NoData_hiValue = -99999.0; break;
- case SG_DATATYPE_Color: m_NoData_Value = m_NoData_hiValue = 4294967295.0; break;
-
- default: m_Type = SG_DATATYPE_Float;
- case SG_DATATYPE_Float: m_NoData_Value = m_NoData_hiValue = -99999.0; break;
+ case SG_DATATYPE_Bit: Set_NoData_Value( 0.0); break;
+ case SG_DATATYPE_Byte: Set_NoData_Value( 255.0); break;
+ case SG_DATATYPE_Char: Set_NoData_Value( -127.0); break;
+ case SG_DATATYPE_Word: Set_NoData_Value( 65535.0); break;
+ case SG_DATATYPE_Short: Set_NoData_Value( -32767.0); break;
+ case SG_DATATYPE_DWord: Set_NoData_Value( 4294967295.0); break;
+ case SG_DATATYPE_Int: Set_NoData_Value(-2147483647.0); break;
+ case SG_DATATYPE_ULong: Set_NoData_Value( 4294967295.0); break;
+ case SG_DATATYPE_Long: Set_NoData_Value(-2147483647.0); break;
+ case SG_DATATYPE_Float: Set_NoData_Value( -99999.0); break;
+ case SG_DATATYPE_Double: Set_NoData_Value( -99999.0); break;
+ case SG_DATATYPE_Color: Set_NoData_Value( 4294967295.0); break;
+
+ default:
+ m_Type = SG_DATATYPE_Float; Set_NoData_Value( -99999.0); break;
}
m_System.Assign(Cellsize > 0.0 ? Cellsize : 1.0, xMin, yMin, NX, NY);
@@ -360,7 +359,7 @@ void CSG_Grid::_Set_Properties(TSG_Data_Type Type, int NX, int NY, double Cellsi
//---------------------------------------------------------
void CSG_Grid::Set_Description(const SG_Char *String)
{
- m_Description.Printf(String ? String : SG_T(""));
+ m_Description = String ? String : SG_T("");
}
const SG_Char * CSG_Grid::Get_Description(void) const
@@ -371,7 +370,7 @@ const SG_Char * CSG_Grid::Get_Description(void) const
//---------------------------------------------------------
void CSG_Grid::Set_Unit(const SG_Char *String)
{
- m_Unit.Printf(String ? String : SG_T(""));
+ m_Unit = String ? String : SG_T("");
}
const SG_Char * CSG_Grid::Get_Unit(void) const
@@ -394,39 +393,6 @@ double CSG_Grid::Get_ZFactor(void) const
///////////////////////////////////////////////////////////
// //
-// No Data Values //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CSG_Grid::Set_NoData_Value(double Value)
-{
- Set_NoData_Value_Range(Value, Value);
-}
-
-void CSG_Grid::Set_NoData_Value_Range(double loValue, double hiValue)
-{
- double d;
-
- if( loValue > hiValue )
- {
- d = loValue;
- loValue = hiValue;
- hiValue = d;
- }
-
- if( !Get_Update_Flag() && (loValue != m_NoData_Value || hiValue != m_NoData_hiValue) )
- {
- Set_Update_Flag();
- }
-
- m_NoData_Value = loValue;
- m_NoData_hiValue = hiValue;
-}
-
-
-///////////////////////////////////////////////////////////
-// //
// Checks //
// //
///////////////////////////////////////////////////////////
@@ -493,14 +459,14 @@ double CSG_Grid::Get_Value(TSG_Point Position, int Interpolation, bool bZFactor,
{
double Value;
- return( Get_Value(Position.x, Position.y, Value, Interpolation, bZFactor, bByteWise, bOnlyValidCells) ? Value : m_NoData_Value );
+ return( Get_Value(Position.x, Position.y, Value, Interpolation, bZFactor, bByteWise, bOnlyValidCells) ? Value : Get_NoData_Value() );
}
double CSG_Grid::Get_Value(double xPosition, double yPosition, int Interpolation, bool bZFactor, bool bByteWise, bool bOnlyValidCells) const
{
double Value;
- return( Get_Value(xPosition, yPosition, Value, Interpolation, bZFactor, bByteWise, bOnlyValidCells) ? Value : m_NoData_Value );
+ return( Get_Value(xPosition, yPosition, Value, Interpolation, bZFactor, bByteWise, bOnlyValidCells) ? Value : Get_NoData_Value() );
}
bool CSG_Grid::Get_Value(TSG_Point Position, double &Value, int Interpolation, bool bZFactor, bool bByteWise, bool bOnlyValidCells) const
@@ -545,7 +511,7 @@ bool CSG_Grid::Get_Value(double xPosition, double yPosition, double &Value, int
break;
}
- if( Value != m_NoData_Value )
+ if( !is_NoData_Value(Value) )
{
if( bZFactor )
{
@@ -571,7 +537,7 @@ inline double CSG_Grid::_Get_ValAtPos_NearestNeighbour(int x, int y, double dx,
return( asDouble(x, y) );
}
- return( m_NoData_Value );
+ return( Get_NoData_Value() );
}
//---------------------------------------------------------
@@ -623,7 +589,7 @@ inline double CSG_Grid::_Get_ValAtPos_BiLinear(int x, int y, double dx, double d
}
}
- return( m_NoData_Value );
+ return( Get_NoData_Value() );
}
//---------------------------------------------------------
@@ -682,7 +648,7 @@ inline double CSG_Grid::_Get_ValAtPos_InverseDistance(int x, int y, double dx, d
return( asDouble(x, y) );
}
- return( m_NoData_Value );
+ return( Get_NoData_Value() );
}
//---------------------------------------------------------
@@ -740,7 +706,7 @@ inline double CSG_Grid::_Get_ValAtPos_BiCubicSpline(int x, int y, double dx, dou
}
}
- return( m_NoData_Value );
+ return( Get_NoData_Value() );
}
//---------------------------------------------------------
@@ -812,7 +778,7 @@ inline double CSG_Grid::_Get_ValAtPos_BSpline(int x, int y, double dx, double dy
}
}
- return( m_NoData_Value );
+ return( Get_NoData_Value() );
}
//---------------------------------------------------------
@@ -830,7 +796,7 @@ inline bool CSG_Grid::_Get_ValAtPos_Fill4x4Submatrix(int x, int y, double z_xy[4
}
else
{
- z_xy[ix][iy] = m_NoData_Value;
+ z_xy[ix][iy] = Get_NoData_Value();
nNoData++;
}
@@ -861,7 +827,7 @@ inline bool CSG_Grid::_Get_ValAtPos_Fill4x4Submatrix(int x, int y, double z_xy[4
{
for(ix=0; ix<4; ix++)
{
- if( z_xy[ix][iy] == m_NoData_Value )
+ if( is_NoData_Value(z_xy[ix][iy]) )
{
int n = 0;
@@ -871,7 +837,7 @@ inline bool CSG_Grid::_Get_ValAtPos_Fill4x4Submatrix(int x, int y, double z_xy[4
{
for(jx=ix-1; jx<=ix+1; jx++)
{
- if( jx >= 0 && jx < 4 && !(jx == ix && jy == iy) && z_xy[jx][jy] != m_NoData_Value )
+ if( jx >= 0 && jx < 4 && !(jx == ix && jy == iy) && !is_NoData_Value(z_xy[jx][jy]) )
{
if( n == 0 )
{
@@ -938,7 +904,7 @@ inline bool CSG_Grid::_Get_ValAtPos_Fill4x4Submatrix(int x, int y, double z_xy[4
}
else
{
- z_xy[0][ix][iy] = m_NoData_Value;
+ z_xy[0][ix][iy] = Get_NoData_Value();
nNoData++;
}
@@ -972,7 +938,7 @@ inline bool CSG_Grid::_Get_ValAtPos_Fill4x4Submatrix(int x, int y, double z_xy[4
{
for(ix=0; ix<4; ix++)
{
- if( z_xy[0][ix][iy] == m_NoData_Value )
+ if( is_NoData_Value(z_xy[0][ix][iy]) )
{
int n = 0;
@@ -982,7 +948,7 @@ inline bool CSG_Grid::_Get_ValAtPos_Fill4x4Submatrix(int x, int y, double z_xy[4
{
for(jx=ix-1; jx<=ix+1; jx++)
{
- if( jx >= 0 && jx < 4 && !(jx == ix && jy == iy) && z_xy[0][jx][jy] != m_NoData_Value )
+ if( jx >= 0 && jx < 4 && !(jx == ix && jy == iy) && !is_NoData_Value(z_xy[0][jx][jy]) )
{
if( n == 0 )
{
@@ -1079,6 +1045,11 @@ double CSG_Grid::Get_Variance(void)
Update(); return( m_zStats.Get_Variance() );
}
+int CSG_Grid::Get_NoData_Count(void)
+{
+ Update(); return( Get_NCells() - m_zStats.Get_Count() );
+}
+
//---------------------------------------------------------
bool CSG_Grid::On_Update(void)
{
@@ -1208,7 +1179,7 @@ double CSG_Grid::Get_Percentile(double Percent, bool bZFactor)
//---------------------------------------------------------
bool CSG_Grid::Set_Index(bool bOn)
{
- if( bOn && !m_bIndexed )
+ if( bOn && !m_bIndexed && Get_NoData_Count() < Get_NCells() )
{
m_bIndexed = true;
@@ -1219,7 +1190,7 @@ bool CSG_Grid::Set_Index(bool bOn)
return( false );
}
}
- else if( !bOn )
+ else if( !bOn || Get_NoData_Count() >= Get_NCells() )
{
m_bIndexed = false;
@@ -1230,7 +1201,7 @@ bool CSG_Grid::Set_Index(bool bOn)
}
}
- return( true );
+ return( m_bIndexed );
}
//---------------------------------------------------------
@@ -1252,6 +1223,8 @@ bool CSG_Grid::_Set_Index(void)
if( m_Index == NULL )
{
+ SG_UI_Msg_Add_Error(LNG("could not create index: insufficient memory"));
+
SG_UI_Process_Set_Ready();
return( false );
diff --git a/src/saga_core/saga_api/grid.h b/src/saga_core/saga_api/grid.h
index c8cbbd1..046e7ed 100644
--- a/src/saga_core/saga_api/grid.h
+++ b/src/saga_core/saga_api/grid.h
@@ -72,7 +72,7 @@
//---------------------------------------------------------
#include "dataobject.h"
-
+#include "table.h"
#include "grid_pyramid.h"
@@ -414,6 +414,7 @@ public: ///////////////////////////////////////////////
TSG_Data_Type Get_Type (void) const { return( m_Type ); }
int Get_nValueBytes (void) const { return( SG_Data_Type_Get_Size(m_Type) ); }
+ int Get_nLineBytes (void) const { return( m_Type != SG_DATATYPE_Bit ? SG_Data_Type_Get_Size(m_Type) * Get_NX() : 1 + Get_NX() / 8 ); }
void Set_Description (const SG_Char *String);
const SG_Char * Get_Description (void) const;
@@ -451,10 +452,7 @@ public: ///////////////////////////////////////////////
double Get_StdDev (bool bZFactor = false);
double Get_Variance (void);
- void Set_NoData_Value (double Value);
- void Set_NoData_Value_Range (double loValue, double hiValue);
- double Get_NoData_Value (void) const { return( m_NoData_Value ); }
- double Get_NoData_hiValue (void) const { return( m_NoData_hiValue ); }
+ int Get_NoData_Count (void);
virtual bool Save (const CSG_String &File_Name, int Format = GRID_FILE_FORMAT_Binary);
virtual bool Save (const CSG_String &File_Name, int Format, int xA, int yA, int xN, int yN);
@@ -481,7 +479,7 @@ public: ///////////////////////////////////////////////
//-----------------------------------------------------
// Memory...
- int Get_Buffer_Size (void) { return( LineBuffer_Count * _LineBuffer_Get_nBytes() ); }
+ int Get_Buffer_Size (void) { return( LineBuffer_Count * Get_nLineBytes() ); }
bool Set_Buffer_Size (int Size);
bool Set_Cache (bool bOn);
@@ -572,16 +570,11 @@ public: ///////////////////////////////////////////////
//-----------------------------------------------------
// No Data Value...
- virtual bool is_NoData_Value (double Value) const
- {
- return( m_NoData_Value < m_NoData_hiValue ? m_NoData_Value <= Value && Value <= m_NoData_hiValue : Value == m_NoData_Value );
- }
-
virtual bool is_NoData (int x, int y) const { return( is_NoData_Value(asDouble(x, y)) ); }
virtual bool is_NoData (long n) const { return( is_NoData_Value(asDouble( n)) ); }
- virtual void Set_NoData (int x, int y) { Set_Value(x, y, m_NoData_Value ); }
- virtual void Set_NoData (long n) { Set_Value( n, m_NoData_Value ); }
+ virtual void Set_NoData (int x, int y) { Set_Value(x, y, Get_NoData_Value() ); }
+ virtual void Set_NoData (long n) { Set_Value( n, Get_NoData_Value() ); }
//-----------------------------------------------------
@@ -654,14 +647,14 @@ public: ///////////////////////////////////////////////
{
switch( m_Type )
{
- default: Result = 0.0; break;
- case SG_DATATYPE_Byte: Result = ((BYTE **)m_Values)[y][x]; break;
- case SG_DATATYPE_Char: Result = ((char **)m_Values)[y][x]; break;
- case SG_DATATYPE_Word: Result = ((WORD **)m_Values)[y][x]; break;
- case SG_DATATYPE_Short: Result = ((short **)m_Values)[y][x]; break;
- case SG_DATATYPE_DWord: Result = ((DWORD **)m_Values)[y][x]; break;
+ default: Result = 0.0; break;
+ case SG_DATATYPE_Byte: Result = ((BYTE **)m_Values)[y][x]; break;
+ case SG_DATATYPE_Char: Result = ((char **)m_Values)[y][x]; break;
+ case SG_DATATYPE_Word: Result = ((WORD **)m_Values)[y][x]; break;
+ case SG_DATATYPE_Short: Result = ((short **)m_Values)[y][x]; break;
+ case SG_DATATYPE_DWord: Result = ((DWORD **)m_Values)[y][x]; break;
case SG_DATATYPE_Int: Result = ((int **)m_Values)[y][x]; break;
- case SG_DATATYPE_Float: Result = ((float **)m_Values)[y][x]; break;
+ case SG_DATATYPE_Float: Result = ((float **)m_Values)[y][x]; break;
case SG_DATATYPE_Double: Result = ((double **)m_Values)[y][x]; break;
case SG_DATATYPE_Bit: Result =(((BYTE **)m_Values)[y][x / 8] & m_Bitmask[x % 8]) == 0 ? 0.0 : 1.0; break;
}
@@ -702,13 +695,13 @@ public: ///////////////////////////////////////////////
switch( m_Type )
{
default: break;
- case SG_DATATYPE_Byte: ((BYTE **)m_Values)[y][x] = (BYTE )Value; break;
- case SG_DATATYPE_Char: ((char **)m_Values)[y][x] = (char )Value; break;
- case SG_DATATYPE_Word: ((WORD **)m_Values)[y][x] = (WORD )Value; break;
- case SG_DATATYPE_Short: ((short **)m_Values)[y][x] = (short )Value; break;
- case SG_DATATYPE_DWord: ((DWORD **)m_Values)[y][x] = (DWORD )Value; break;
+ case SG_DATATYPE_Byte: ((BYTE **)m_Values)[y][x] = (BYTE )Value; break;
+ case SG_DATATYPE_Char: ((char **)m_Values)[y][x] = (char )Value; break;
+ case SG_DATATYPE_Word: ((WORD **)m_Values)[y][x] = (WORD )Value; break;
+ case SG_DATATYPE_Short: ((short **)m_Values)[y][x] = (short )Value; break;
+ case SG_DATATYPE_DWord: ((DWORD **)m_Values)[y][x] = (DWORD )Value; break;
case SG_DATATYPE_Int: ((int **)m_Values)[y][x] = (int )Value; break;
- case SG_DATATYPE_Float: ((float **)m_Values)[y][x] = (float )Value; break;
+ case SG_DATATYPE_Float: ((float **)m_Values)[y][x] = (float )Value; break;
case SG_DATATYPE_Double: ((double **)m_Values)[y][x] = (double)Value; break;
case SG_DATATYPE_Bit: ((BYTE **)m_Values)[y][x / 8] = Value != 0.0
? ((BYTE **)m_Values)[y][x / 8] | m_Bitmask[x % 8]
@@ -746,7 +739,7 @@ private: ///////////////////////////////////////////////
long *m_Index, Cache_Offset;
- double m_zFactor, m_NoData_Value, m_NoData_hiValue;
+ double m_zFactor;
CSG_Simple_Statistics m_zStats;
@@ -794,7 +787,6 @@ private: ///////////////////////////////////////////////
void _LineBuffer_Create (void);
void _LineBuffer_Destroy (void);
- int _LineBuffer_Get_nBytes (void) const { return( SG_Data_Type_Get_Size(m_Type) * Get_NX() ); }
void _LineBuffer_Flush (void);
TSG_Grid_Line * _LineBuffer_Get_Line (int y) const;
void _LineBuffer_Set_Value (int x, int y, double Value);
@@ -904,6 +896,108 @@ SAGA_API_DLL_EXPORT double SG_Grid_Cache_Get_Threshold_MB (void);
///////////////////////////////////////////////////////////
// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class CSG_Grid_Stack : public CSG_Stack
+{
+public:
+ CSG_Grid_Stack(void) : CSG_Stack(sizeof(TSG_Point_Int)) {}
+
+ //-----------------------------------------------------
+ virtual void Push (int x, int y)
+ {
+ TSG_Point_Int *pPoint = (TSG_Point_Int *)Get_Record_Push();
+
+ if( pPoint )
+ {
+ pPoint->x = x;
+ pPoint->y = y;
+ }
+ }
+
+ //-----------------------------------------------------
+ virtual void Pop (int &x, int &y)
+ {
+ TSG_Point_Int *pPoint = (TSG_Point_Int *)Get_Record_Pop();
+
+ if( pPoint )
+ {
+ x = pPoint->x;
+ y = pPoint->y;
+ }
+ }
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Grid_Cell_Addressor
+{
+public:
+ CSG_Grid_Cell_Addressor(void);
+
+ bool Destroy (void);
+
+ CSG_Distance_Weighting & Get_Weighting (void) { return( m_Weighting ); }
+
+ bool Set_Radius (int Radius);
+ bool Set_Sector (int Radius, double Direction, double Tolerance);
+
+ int Get_Count (void) const { return( m_Cells.Get_Count() ); }
+
+ int Get_X (int Index, int Offset = 0) const { return( Offset + (Index >= 0 && Index < Get_Count() ? m_Cells.Get_Record_byIndex(Index)->asInt(0) : 0) ); }
+ int Get_Y (int Index, int Offset = 0) const { return( Offset + (Index >= 0 && Index < Get_Count() ? m_Cells.Get_Record_byIndex(Index)->asInt(1) : 0) ); }
+
+ double Get_Distance (int Index) const { return( Index >= 0 && Index < Get_Count() ? m_Cells.Get_Record_byIndex(Index)->asDouble(2) : -1.0 ); }
+ double Get_Weight (int Index) const { return( Index >= 0 && Index < Get_Count() ? m_Cells.Get_Record_byIndex(Index)->asDouble(3) : -1.0 ); }
+
+ bool Get_Values (int Index, int &x, int &y, double &Distance, double &Weight, bool bOffset = false) const
+ {
+ if( Index >= 0 && Index < Get_Count() )
+ {
+ CSG_Table_Record *pCell = m_Cells.Get_Record_byIndex(Index);
+
+ if( bOffset )
+ {
+ x += pCell->asInt(0);
+ y += pCell->asInt(1);
+ }
+ else
+ {
+ x = pCell->asInt(0);
+ y = pCell->asInt(1);
+ }
+
+ Distance = pCell->asDouble(2);
+ Weight = pCell->asDouble(3);
+
+ return( true );
+ }
+
+ return( false );
+ }
+
+
+private:
+
+ CSG_Distance_Weighting m_Weighting;
+
+ CSG_Table m_Cells;
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
// //
// //
///////////////////////////////////////////////////////////
diff --git a/src/saga_core/saga_api/grid_io.cpp b/src/saga_core/saga_api/grid_io.cpp
index 29cdbb1..fec5c17 100644
--- a/src/saga_core/saga_api/grid_io.cpp
+++ b/src/saga_core/saga_api/grid_io.cpp
@@ -629,7 +629,7 @@ bool CSG_Grid::_Load_Native(const CSG_String &File_Name, TSG_Grid_Memory_Type Me
case GRID_FILE_KEY_POSITION_YMIN: yMin = Value.asDouble(); break;
case GRID_FILE_KEY_CELLSIZE: Cellsize = Value.asDouble(); break;
case GRID_FILE_KEY_Z_FACTOR: m_zFactor = Value.asDouble(); break;
- case GRID_FILE_KEY_NODATA_VALUE: m_NoData_Value = m_NoData_hiValue = Value.asDouble(); break;
+ case GRID_FILE_KEY_NODATA_VALUE: Set_NoData_Value(Value.asDouble()); break;
case GRID_FILE_KEY_DATAFILE_OFFSET: hdr_Offset = Value.asInt(); break;
case GRID_FILE_KEY_BYTEORDER_BIG: hdr_bSwapBytes = Value.Find(GRID_FILE_KEY_TRUE) >= 0; break;
@@ -663,12 +663,12 @@ bool CSG_Grid::_Load_Native(const CSG_String &File_Name, TSG_Grid_Memory_Type Me
//-------------------------------------------------
// Load Data...
- if( hdr_Type < SG_DATATYPE_Undefined && m_System.Assign(Cellsize, xMin, yMin, NX, NY) )
+ if( m_System.Assign(Cellsize, xMin, yMin, NX, NY) )
{
//---------------------------------------------
// ASCII...
- if( hdr_Type >= SG_DATATYPE_Undefined )
+ if( !SG_Data_Type_is_Numeric(hdr_Type) )
{
if( m_Type >= SG_DATATYPE_Undefined )
{
@@ -680,7 +680,7 @@ bool CSG_Grid::_Load_Native(const CSG_String &File_Name, TSG_Grid_Memory_Type Me
|| Stream.Open(SG_File_Make_Path(NULL, File_Name, SG_T("sdat")) , SG_FILE_R, false) )
{
Stream.Seek(hdr_Offset);
- bResult = _Load_ASCII(Stream, Memory_Type);
+ bResult = _Load_ASCII(Stream, Memory_Type, hdr_bFlip);
}
}
@@ -748,7 +748,7 @@ bool CSG_Grid::_Save_Native(const CSG_String &File_Name, int xA, int yA, int xN,
Stream.Printf(SG_T("%s\t= %d\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_CELLCOUNT_Y ], yN );
Stream.Printf(SG_T("%s\t= %.10f\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_CELLSIZE ], Get_Cellsize() );
Stream.Printf(SG_T("%s\t= %f\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_Z_FACTOR ], m_zFactor );
- Stream.Printf(SG_T("%s\t= %f\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_NODATA_VALUE ], m_NoData_Value );
+ Stream.Printf(SG_T("%s\t= %f\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_NODATA_VALUE ], Get_NoData_Value() );
Stream.Printf(SG_T("%s\t= %s\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_TOPTOBOTTOM ], GRID_FILE_KEY_FALSE );
@@ -786,7 +786,7 @@ int CSG_Grid::_Load_Native_Get_Key(CSG_File &Stream, CSG_String &Value)
if( Stream.Read_Line(sLine) && (i = sLine.Find('=')) > 0 )
{
- Value.Printf(sLine.AfterFirst('='));
+ Value = sLine.AfterFirst('=');
Value.Trim();
sLine.Remove(i);
diff --git a/src/saga_core/saga_api/grid_memory.cpp b/src/saga_core/saga_api/grid_memory.cpp
index 7dcbc0e..f1a9a2d 100644
--- a/src/saga_core/saga_api/grid_memory.cpp
+++ b/src/saga_core/saga_api/grid_memory.cpp
@@ -84,7 +84,7 @@ void SG_Grid_Cache_Set_Directory(const SG_Char *Directory)
{
if( SG_Dir_Exists(Directory) )
{
- gSG_Grid_Cache_Directory.Printf(Directory);
+ gSG_Grid_Cache_Directory = Directory;
}
}
@@ -253,7 +253,7 @@ void CSG_Grid::_LineBuffer_Create(void)
for(int i=0; i<LineBuffer_Count; i++)
{
- LineBuffer[i].Data = (char *)SG_Malloc(_LineBuffer_Get_nBytes());
+ LineBuffer[i].Data = (char *)SG_Malloc(Get_nLineBytes());
LineBuffer[i].y = -1;
LineBuffer[i].bModified = false;
}
@@ -285,7 +285,7 @@ bool CSG_Grid::Set_Buffer_Size(int Size)
if( m_System.is_Valid() && m_Type != SG_DATATYPE_Undefined )
{
- Size /= _LineBuffer_Get_nBytes();
+ Size /= Get_nLineBytes();
if( Size < 1 )
{
@@ -306,7 +306,7 @@ bool CSG_Grid::Set_Buffer_Size(int Size)
for(i=LineBuffer_Count; i<Size; i++)
{
- LineBuffer[i].Data = (char *)SG_Malloc(_LineBuffer_Get_nBytes());
+ LineBuffer[i].Data = (char *)SG_Malloc(Get_nLineBytes());
LineBuffer[i].y = -1;
LineBuffer[i].bModified = false;
}
@@ -584,7 +584,7 @@ bool CSG_Grid::_Cache_Create(const SG_Char *FilePath, TSG_Data_Type File_Type, l
{
if( m_System.is_Valid() && m_Type != SG_DATATYPE_Undefined && m_Memory_Type == GRID_MEMORY_Normal )
{
- Cache_Path.Printf(FilePath);
+ Cache_Path = FilePath;
if( m_Type == File_Type
&& ( Cache_Stream.Open(Cache_Path, SG_FILE_RWA, true)
@@ -633,12 +633,12 @@ bool CSG_Grid::_Cache_Create(void)
if( m_Values )
{
- Line.Data = (char *)SG_Malloc(_LineBuffer_Get_nBytes());
+ Line.Data = (char *)SG_Malloc(Get_nLineBytes());
for(Line.y=0; Line.y<Get_NY() && SG_UI_Process_Set_Progress(Line.y, Get_NY()); Line.y++)
{
Line.bModified = true;
- memcpy(Line.Data, m_Values[Line.y], _LineBuffer_Get_nBytes());
+ memcpy(Line.Data, m_Values[Line.y], Get_nLineBytes());
_Cache_LineBuffer_Save(&Line);
SG_Free(m_Values[Line.y]);
}
@@ -680,7 +680,7 @@ bool CSG_Grid::_Cache_Destroy(bool bMemory_Restore)
{
if( (pLine = _LineBuffer_Get_Line(y)) != NULL )
{
- memcpy(m_Values[y], pLine->Data, _LineBuffer_Get_nBytes());
+ memcpy(m_Values[y], pLine->Data, Get_nLineBytes());
}
}
@@ -727,7 +727,7 @@ void CSG_Grid::_Cache_LineBuffer_Save(TSG_Grid_Line *pLine) const
{
y = Cache_bFlip ? Get_NY() - 1 - pLine->y : pLine->y;
- Line_Size = _LineBuffer_Get_nBytes();
+ Line_Size = Get_nLineBytes();
Line_Pos = Cache_Offset + y * Line_Size;
//-------------------------------------------------
@@ -769,7 +769,7 @@ void CSG_Grid::_Cache_LineBuffer_Load(TSG_Grid_Line *pLine, int y) const
{
y = Cache_bFlip ? Get_NY() - 1 - pLine->y : pLine->y;
- Line_Size = _LineBuffer_Get_nBytes();
+ Line_Size = Get_nLineBytes();
Line_Pos = Cache_Offset + y * Line_Size;
//-------------------------------------------------
@@ -850,7 +850,7 @@ bool CSG_Grid::_Compr_Create(void)
{
for(Line.y=0; Line.y<Get_NY() && SG_UI_Process_Set_Progress(Line.y, Get_NY()); Line.y++)
{
- memcpy(Line.Data, m_Values[Line.y], _LineBuffer_Get_nBytes());
+ memcpy(Line.Data, m_Values[Line.y], Get_nLineBytes());
Line.bModified = true;
_Compr_LineBuffer_Save(&Line);
}
@@ -861,7 +861,7 @@ bool CSG_Grid::_Compr_Create(void)
for(Line.y=0; Line.y<Get_NY() && SG_UI_Process_Set_Progress(Line.y, Get_NY()); Line.y++)
{
- m_Values[Line.y] = (void *)SG_Calloc(1, _LineBuffer_Get_nBytes());
+ m_Values[Line.y] = (void *)SG_Calloc(1, Get_nLineBytes());
Line.bModified = true;
_Compr_LineBuffer_Save(&Line);
}
@@ -899,7 +899,7 @@ bool CSG_Grid::_Compr_Destroy(bool bMemory_Restore)
{
_Compr_LineBuffer_Load(&Line, y);
m_Values[y] = (void *)SG_Realloc(m_Values[y], _Get_nLineBytes());
- memcpy(m_Values[y], Line.Data, _LineBuffer_Get_nBytes());
+ memcpy(m_Values[y], Line.Data, Get_nLineBytes());
}
SG_Free(Line.Data);
diff --git a/src/saga_core/saga_api/grid_operation.cpp b/src/saga_core/saga_api/grid_operation.cpp
index ee26d25..f6cc66b 100644
--- a/src/saga_core/saga_api/grid_operation.cpp
+++ b/src/saga_core/saga_api/grid_operation.cpp
@@ -99,11 +99,10 @@ bool CSG_Grid::Assign(double Value)
//-------------------------------------------------
Get_History().Destroy();
- Get_History().Add_Child(LNG("[HST] Value assigned to grid"), CSG_String::Format(SG_T("%f"), Value));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), Value)->Add_Property(SG_T("NAME"), LNG("Assign"));
//-------------------------------------------------
m_zStats.Invalidate();
- m_zStats.Add_Value(Value);
Set_Update_Flag(false);
@@ -179,14 +178,11 @@ bool CSG_Grid::Assign(CSG_Grid *pGrid, TSG_Grid_Interpolation Interpolation)
//-------------------------------------------------
if( bResult )
{
- m_zFactor = pGrid->m_zFactor;
-
- m_NoData_Value = pGrid->m_NoData_Value;
- m_NoData_hiValue = pGrid->m_NoData_hiValue;
-
-// Set_Name (pGrid->Get_Name());
- Set_Description (pGrid->Get_Description());
- Set_Unit (pGrid->Get_Unit());
+// Set_Name (pGrid->Get_Name());
+ Set_Description (pGrid->Get_Description());
+ Set_Unit (pGrid->Get_Unit());
+ Set_ZFactor (pGrid->Get_ZFactor());
+ Set_NoData_Value_Range (pGrid->Get_NoData_Value(), pGrid->Get_NoData_hiValue());
}
}
@@ -218,7 +214,7 @@ bool CSG_Grid::_Assign_Interpolated(CSG_Grid *pGrid, TSG_Grid_Interpolation Inte
}
Get_History() = pGrid->Get_History();
- Get_History().Add_Child(LNG("[DAT] Resampling"), CSG_String::Format(SG_T("%f -> %f"), pGrid->Get_Cellsize(), Get_Cellsize()));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), CSG_String::Format(SG_T("%f -> %f"), pGrid->Get_Cellsize(), Get_Cellsize()))->Add_Property(SG_T("NAME"), LNG("Resampling"));
SG_UI_Process_Set_Ready();
@@ -271,7 +267,7 @@ bool CSG_Grid::_Assign_ExtremeValue(CSG_Grid *pGrid, bool bMaximum)
//-----------------------------------------------------
Get_History() = pGrid->Get_History();
- Get_History().Add_Child(LNG("[DAT] Resampling"), CSG_String::Format(SG_T("%f -> %f"), pGrid->Get_Cellsize(), Get_Cellsize()));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), CSG_String::Format(SG_T("%f -> %f"), pGrid->Get_Cellsize(), Get_Cellsize()))->Add_Property(SG_T("NAME"), LNG("Resampling"));
SG_UI_Process_Set_Ready();
@@ -400,7 +396,7 @@ bool CSG_Grid::_Assign_MeanValue(CSG_Grid *pGrid, bool bAreaProportional)
//-----------------------------------------------------
Get_History() = pGrid->Get_History();
- Get_History().Add_Child(LNG("[DAT] Resampling"), CSG_String::Format(SG_T("%f -> %f"), pGrid->Get_Cellsize(), Get_Cellsize()));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), CSG_String::Format(SG_T("%f -> %f"), pGrid->Get_Cellsize(), Get_Cellsize()))->Add_Property(SG_T("NAME"), LNG("Resampling"));
SG_UI_Process_Set_Ready();
@@ -632,19 +628,19 @@ CSG_Grid & CSG_Grid::_Operation_Arithmetic(const CSG_Grid &Grid, TSG_Grid_Operat
switch( Operation )
{
case GRID_OPERATION_Addition:
- Get_History().Add_Child(LNG("[HST] Grid addition") , Grid.Get_Name());
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), Grid.Get_Name())->Add_Property(SG_T("NAME"), LNG("Addition"));
break;
case GRID_OPERATION_Subtraction:
- Get_History().Add_Child(LNG("[HST] Grid subtraction") , Grid.Get_Name());
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), Grid.Get_Name())->Add_Property(SG_T("NAME"), LNG("Subtraction"));
break;
case GRID_OPERATION_Multiplication:
- Get_History().Add_Child(LNG("[HST] Grid multiplication"), Grid.Get_Name());
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), Grid.Get_Name())->Add_Property(SG_T("NAME"), LNG("Multiplication"));
break;
case GRID_OPERATION_Division:
- Get_History().Add_Child(LNG("[HST] Grid division") , Grid.Get_Name());
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), Grid.Get_Name())->Add_Property(SG_T("NAME"), LNG("Division"));
break;
}
@@ -661,23 +657,23 @@ CSG_Grid & CSG_Grid::_Operation_Arithmetic(double Value, TSG_Grid_Operation Oper
switch( Operation )
{
case GRID_OPERATION_Addition:
- Get_History().Add_Child(LNG("[HST] Value addition") , CSG_String::Format(SG_T("%f"), Value));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), Value)->Add_Property(SG_T("NAME"), LNG("Addition"));
break;
case GRID_OPERATION_Subtraction:
- Get_History().Add_Child(LNG("[HST] Value subtraction") , CSG_String::Format(SG_T("%f"), Value));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), Value)->Add_Property(SG_T("NAME"), LNG("Subtraction"));
Value = -Value;
break;
case GRID_OPERATION_Multiplication:
- Get_History().Add_Child(LNG("[HST] Value multiplication") , CSG_String::Format(SG_T("%f"), Value));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), Value)->Add_Property(SG_T("NAME"), LNG("Multiplication"));
break;
case GRID_OPERATION_Division:
if( Value == 0.0 )
return( *this );
- Get_History().Add_Child(LNG("[HST] Value division") , CSG_String::Format(SG_T("%f"), Value));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), Value)->Add_Property(SG_T("NAME"), LNG("Division"));
Value = 1.0 / Value;
break;
}
@@ -741,7 +737,7 @@ void CSG_Grid::Invert(void)
SG_UI_Process_Set_Ready();
- Get_History().Add_Child(LNG("[HST] Grid operation"), LNG("[HST] Inversion"));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), LNG("Inversion"));
}
}
@@ -779,7 +775,7 @@ void CSG_Grid::Flip(void)
SG_Free(Line);
- Get_History().Add_Child(LNG("[HST] Grid operation"), LNG("[HST] Vertically mirrored"));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), LNG("Vertically mirrored"));
}
}
@@ -803,7 +799,7 @@ void CSG_Grid::Mirror(void)
SG_UI_Process_Set_Ready();
- Get_History().Add_Child(LNG("[HST] Grid operation"), LNG("[HST] Horizontally mirrored"));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), LNG("Horizontally mirrored"));
}
}
@@ -858,7 +854,7 @@ void CSG_Grid::Normalise(void)
SG_UI_Process_Set_Ready();
- Get_History().Add_Child(LNG("[HST] Grid normalisation"), CSG_String::Format(SG_T("%f / %f"), m_zStats.Get_Mean(), m_zStats.Get_StdDev()));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), LNG("Normalisation"));
}
}
}
@@ -885,7 +881,7 @@ void CSG_Grid::DeNormalise(double ArithMean, double Variance)
SG_UI_Process_Set_Ready();
- Get_History().Add_Child(LNG("[HST] Grid denormalisation"), CSG_String::Format(SG_T("%f / %f"), ArithMean, Variance));
+ Get_History().Add_Child(SG_T("GRID_OPERATION"), LNG("Denormalisation"));
}
}
diff --git a/src/saga_core/saga_api/grid_system.cpp b/src/saga_core/saga_api/grid_system.cpp
index 0ceaffc..2962f57 100644
--- a/src/saga_core/saga_api/grid_system.cpp
+++ b/src/saga_core/saga_api/grid_system.cpp
@@ -41,9 +41,7 @@
// //
// contact: Olaf Conrad //
// Institute of Geography //
-// Universit??? G???tingen //
-// Goldschmidtstr. 5 //
-// 37077 G???tingen //
+// University Hamburg //
// Germany //
// //
// e-mail: oconrad at saga-gis.org //
@@ -61,6 +59,7 @@
//---------------------------------------------------------
#include "grid.h"
+#include "shapes.h"
///////////////////////////////////////////////////////////
@@ -277,3 +276,136 @@ bool CSG_Grid_System::is_Equal(double Cellsize, const TSG_Rect &Extent) const
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+CSG_Grid_Cell_Addressor::CSG_Grid_Cell_Addressor(void)
+{
+ m_Cells.Add_Field(SG_T("X"), SG_DATATYPE_Int);
+ m_Cells.Add_Field(SG_T("Y"), SG_DATATYPE_Int);
+ m_Cells.Add_Field(SG_T("D"), SG_DATATYPE_Double);
+ m_Cells.Add_Field(SG_T("W"), SG_DATATYPE_Double);
+}
+
+//---------------------------------------------------------
+bool CSG_Grid_Cell_Addressor::Destroy(void)
+{
+ m_Cells.Del_Records();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Grid_Cell_Addressor::Set_Radius(int Radius)
+{
+ Destroy();
+
+ //-----------------------------------------------------
+ for(int y=-Radius; y<=Radius; y++)
+ {
+ for(int x=-Radius; x<=Radius; x++)
+ {
+ double d = SG_Get_Length(x, y);
+
+ if( d <= Radius )
+ {
+ CSG_Table_Record *pRecord = m_Cells.Add_Record();
+
+ pRecord->Set_Value(0, x);
+ pRecord->Set_Value(1, y);
+ pRecord->Set_Value(2, d);
+ pRecord->Set_Value(3, m_Weighting.Get_Weight(d));
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ if( m_Cells.Get_Count() > 0 )
+ {
+ m_Cells.Set_Index(2, TABLE_INDEX_Ascending);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_Grid_Cell_Addressor::Set_Sector(int Radius, double Direction, double Tolerance)
+{
+ Destroy();
+
+ //-----------------------------------------------------
+ TSG_Point a, b;
+ CSG_Shapes Polygons(SHAPE_TYPE_Polygon); // Polygons.Add_Field(SG_T("ID"), SG_DATATYPE_Int);
+ CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)Polygons.Add_Shape();
+
+ Direction = fmod(Direction, M_PI_360); if( Direction < 0.0 ) Direction += M_PI_360;
+
+ if( Direction < M_PI_090 )
+ {
+ a.x = -0.5; b.x = 0.5;
+ a.y = 0.5; b.y = -0.5;
+ }
+ else if( Direction < M_PI_180 )
+ {
+ a.x = 0.5; b.x = -0.5;
+ a.y = 0.5; b.y = -0.5;
+ }
+ else if( Direction < M_PI_270 )
+ {
+ a.x = 0.5; b.x = -0.5;
+ a.y = -0.5; b.y = 0.5;
+ }
+ else // if( Direction < M_PI_360 )
+ {
+ a.x = -0.5; b.x = 0.5;
+ a.y = -0.5; b.y = 0.5;
+ }
+
+ double d = 10.0 * SG_Get_Length(Radius, Radius);
+
+ pPolygon->Add_Point(b.x, b.y);
+ pPolygon->Add_Point(a.x, a.y);
+ pPolygon->Add_Point(a.x + d * sin(Direction - Tolerance), a.y + d * cos(Direction - Tolerance));
+ pPolygon->Add_Point( d * sin(Direction) , d * cos(Direction));
+ pPolygon->Add_Point(b.x + d * sin(Direction + Tolerance), a.y + d * cos(Direction + Tolerance));
+
+ //-----------------------------------------------------
+ for(int y=-Radius; y<=Radius; y++)
+ {
+ for(int x=-Radius; x<=Radius; x++)
+ {
+ if( (d = SG_Get_Length(x, y)) <= Radius && pPolygon->is_Containing(x, y) )
+ {
+ CSG_Table_Record *pRecord = m_Cells.Add_Record();
+
+ pRecord->Set_Value(0, x);
+ pRecord->Set_Value(1, y);
+ pRecord->Set_Value(2, d);
+ pRecord->Set_Value(3, m_Weighting.Get_Weight(d));
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ if( m_Cells.Get_Count() > 0 )
+ {
+ m_Cells.Set_Index(2, TABLE_INDEX_Ascending);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_api/mat_formula.cpp b/src/saga_core/saga_api/mat_formula.cpp
index d625dd1..0d77ce2 100644
--- a/src/saga_core/saga_api/mat_formula.cpp
+++ b/src/saga_core/saga_api/mat_formula.cpp
@@ -273,7 +273,7 @@ CSG_String CSG_Formula::Get_Help_Usage(void)
//---------------------------------------------------------
bool CSG_Formula::Get_Error(int *pPosition, CSG_String *pMessage)
{
- if( m_Formula.code )
+ if( m_bError )
{
if( pPosition )
{
@@ -1177,7 +1177,7 @@ SG_Char *CSG_Formula::i_trans(SG_Char *function, SG_Char *begin, SG_Char *end)
{ /*function with parameters*/
tempch = *(end - 1);
*(end - 1) = SG_T('\0');
- par_buf =(SG_Char *) SG_Malloc(SG_STR_LEN(endf + 1) + 1);
+ par_buf =(SG_Char *) SG_Malloc(sizeof(SG_Char) * (SG_STR_LEN(endf + 1) + 1));
if (!par_buf)
{
diff --git a/src/saga_core/saga_api/mat_regression_multiple.cpp b/src/saga_core/saga_api/mat_regression_multiple.cpp
index 2d41e79..32c3190 100644
--- a/src/saga_core/saga_api/mat_regression_multiple.cpp
+++ b/src/saga_core/saga_api/mat_regression_multiple.cpp
@@ -130,26 +130,26 @@ void CSG_Regression_Multiple::Destroy(void)
//---------------------------------------------------------
bool CSG_Regression_Multiple::Calculate(const CSG_Table &Values)
{
- int i, nVariables, nValues;
- CSG_Table_Record *pRecord;
-
- //-----------------------------------------------------
Destroy();
+ int nVariables, nValues;
+
if( (nVariables = Values.Get_Field_Count() - 1) > 0
&& (nValues = Values.Get_Record_Count()) > nVariables )
{
- for(i=0; i<=nVariables; i++)
+ for(int i=0; i<=nVariables; i++)
{
- pRecord = m_pResult->Add_Record();
+ CSG_Table_Record *pRecord = m_pResult->Add_Record();
+
pRecord->Set_Value(MRFIELD_NR , i);
pRecord->Set_Value(MRFIELD_NAME , Values.Get_Field_Name(i));
}
- //-------------------------------------------------
_Get_Regression (Values);
_Get_Correlation(Values);
+ m_pResult->Set_Index(MRFIELD_ORDER, TABLE_INDEX_Ascending);
+
return( true );
}
@@ -353,79 +353,104 @@ bool CSG_Regression_Multiple::_Eliminate(int nValues, double *X, double *Y)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-int CSG_Regression_Multiple::Get_Ordered(int iOrder)
+int CSG_Regression_Multiple::Get_Count(void)
+{
+ return( m_pResult->Get_Count() - 1 );
+}
+
+//---------------------------------------------------------
+double CSG_Regression_Multiple::Get_RConst(void)
{
- for(int i=0; i<m_pResult->Get_Record_Count(); i++)
+ if( Get_Count() > 0 )
{
- if( iOrder == m_pResult->Get_Record(i)->asInt(MRFIELD_ORDER) )
- {
- return( i - 1 );
- }
+ return( m_pResult->Get_Record(0)->asDouble(MRFIELD_RCOEFF) );
}
- return( -1 );
+ return( -1.0 );
}
//---------------------------------------------------------
-int CSG_Regression_Multiple::Get_Order(int iVariable)
+int CSG_Regression_Multiple::Get_Index(int iVariable)
{
- if( ++iVariable > 0 && iVariable < m_pResult->Get_Record_Count() )
+ if( iVariable >= 0 && iVariable < Get_Count() )
{
- return( m_pResult->Get_Record(iVariable)->asInt(MRFIELD_ORDER) );
+ return( m_pResult->Get_Record_byIndex(1 + iVariable)->asInt(MRFIELD_NR) );
}
return( -1 );
}
//---------------------------------------------------------
-double CSG_Regression_Multiple::Get_R2(int iVariable)
+int CSG_Regression_Multiple::Get_Order(int iVariable)
{
- if( ++iVariable > 0 && iVariable < m_pResult->Get_Record_Count() )
+ if( iVariable >= 0 && iVariable < Get_Count() )
{
- return( m_pResult->Get_Record(iVariable)->asDouble(MRFIELD_DCOEFF) );
+ return( m_pResult->Get_Record(1 + iVariable)->asInt(MRFIELD_ORDER) );
}
- return( 0.0 );
+ return( -1 );
}
//---------------------------------------------------------
-double CSG_Regression_Multiple::Get_R2_Change(int iVariable)
+double CSG_Regression_Multiple::Get_RCoeff(int iVariable, bool bOrdered)
{
- int iOrder = Get_Order(iVariable);
-
- if( iOrder > 0 )
+ if( iVariable >= 0 && iVariable < Get_Count() )
{
- return( Get_R2(iVariable) - Get_R2(Get_Ordered(iOrder - 1)) );
+ iVariable = bOrdered ? Get_Index(iVariable) : iVariable + 1;
+
+ return( m_pResult->Get_Record(iVariable)->asDouble(MRFIELD_RCOEFF) );
}
- if( iOrder == 0 )
+ return( -1.0 );
+}
+
+//---------------------------------------------------------
+double CSG_Regression_Multiple::Get_R2(int iVariable, bool bOrdered)
+{
+ if( iVariable >= 0 && iVariable < Get_Count() )
{
- return( Get_R2(iVariable) );
+ iVariable = bOrdered ? Get_Index(iVariable) : iVariable + 1;
+
+ return( m_pResult->Get_Record(iVariable)->asDouble(MRFIELD_DCOEFF) );
}
- return( 0.0 );
+ return( -1.0 );
}
//---------------------------------------------------------
-double CSG_Regression_Multiple::Get_RConst(void)
+double CSG_Regression_Multiple::Get_R2_Change(int iVariable, bool bOrdered)
{
- if( m_pResult->Get_Record_Count() > 1 )
+ if( iVariable >= 0 && iVariable < Get_Count() )
{
- return( m_pResult->Get_Record(0)->asDouble(MRFIELD_RCOEFF) );
+ if( !bOrdered )
+ {
+ iVariable = Get_Order(iVariable);
+ }
+
+ if( iVariable == 0 )
+ {
+ return( Get_R2(iVariable, true) );
+ }
+ else if( iVariable > 0 )
+ {
+ return( Get_R2(iVariable, true) - Get_R2(iVariable - 1, true) );
+ }
}
- return( 0.0 );
+ return( -1.0 );
}
//---------------------------------------------------------
-double CSG_Regression_Multiple::Get_RCoeff(int iVariable)
+const SG_Char * CSG_Regression_Multiple::Get_Name(int iVariable, bool bOrdered)
{
- if( ++iVariable > 0 && iVariable < m_pResult->Get_Record_Count() )
+ if( iVariable >= 0 && iVariable < Get_Count() )
{
- return( m_pResult->Get_Record(iVariable)->asDouble(MRFIELD_RCOEFF) );
+ iVariable = bOrdered ? Get_Index(iVariable) : iVariable + 1;
+
+ return( m_pResult->Get_Record(iVariable)->asString(MRFIELD_NAME) );
}
- return( 0.0 );
+ return( SG_T("") );
}
diff --git a/src/saga_core/saga_api/mat_spline.cpp b/src/saga_core/saga_api/mat_spline.cpp
index 5de02cb..1807cc6 100644
--- a/src/saga_core/saga_api/mat_spline.cpp
+++ b/src/saga_core/saga_api/mat_spline.cpp
@@ -87,8 +87,6 @@ CSG_Spline::~CSG_Spline(void)
///////////////////////////////////////////////////////////
// //
-// //
-// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
@@ -127,8 +125,6 @@ bool CSG_Spline::Create(double yA, double yB)
///////////////////////////////////////////////////////////
// //
-// //
-// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
@@ -140,7 +136,7 @@ void CSG_Spline::Add(double x, double y)
if( m_nValues >= m_nBuffer )
{
m_nBuffer += 64;
- m_Values = (TSG_Point_3D *)SG_Realloc(m_Values, m_nValues * sizeof(TSG_Point_3D));
+ m_Values = (TSG_Point_Z *)SG_Realloc(m_Values, m_nValues * sizeof(TSG_Point_Z));
}
m_nValues++;
@@ -170,8 +166,6 @@ void CSG_Spline::Add(double x, double y)
///////////////////////////////////////////////////////////
// //
-// //
-// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
@@ -236,8 +230,6 @@ bool CSG_Spline::_Create(double yA, double yB)
///////////////////////////////////////////////////////////
// //
-// //
-// //
///////////////////////////////////////////////////////////
//---------------------------------------------------------
@@ -298,3 +290,214 @@ double CSG_Spline::Get_Value(double x)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+//
+// Based on:
+//
+// Thin Plate Spline demo/example in C++
+// Copyright (C) 2003, 2005 by Jarno Elonen
+//
+// Permission to use, copy, modify, distribute and sell this software
+// and its documentation for any purpose is hereby granted without fee,
+// provided that the above copyright notice appear in all copies and
+// that both that copyright notice and this permission notice appear
+// in supporting documentation. The authors make no representations
+// about the suitability of this software for any purpose.
+// It is provided "as is" without express or implied warranty.
+//
+// Reference:
+// - Donato, G., Belongie, S. (2002):
+// 'Approximation Methods for Thin Plate Spline Mappings and Principal Warps'
+//
+//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Thin_Plate_Spline::CSG_Thin_Plate_Spline(void)
+{
+}
+
+//---------------------------------------------------------
+CSG_Thin_Plate_Spline::~CSG_Thin_Plate_Spline(void)
+{
+ Destroy();
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Thin_Plate_Spline::Destroy(void)
+{
+ m_Points.Clear();
+ m_V.Destroy();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+double CSG_Thin_Plate_Spline::_Get_hDistance(TSG_Point_Z A, TSG_Point_Z B)
+{
+ A.x -= B.x;
+ A.y -= B.y;
+
+ return( sqrt(A.x*A.x + A.y*A.y) );
+}
+
+//---------------------------------------------------------
+double CSG_Thin_Plate_Spline::_Get_Base_Funtion(double x)
+{
+ return( x > 0.0 ? x*x * log(x) : 0.0 );
+}
+
+//---------------------------------------------------------
+double CSG_Thin_Plate_Spline::_Get_Base_Funtion(TSG_Point_Z A, double x, double y)
+{
+ x -= A.x;
+ y -= A.y;
+ x = sqrt(x*x + y*y);
+
+ return( x > 0.0 ? x*x * log(x) : 0.0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+// Calculate Thin Plate Spline (TPS) weights from control points.
+//
+bool CSG_Thin_Plate_Spline::Create(double Regularization, bool bSilent)
+{
+ bool bResult = false;
+ int n;
+
+ //-----------------------------------------------------
+ // You We need at least 3 points to define a plane
+ if( (n = m_Points.Get_Count()) >= 3 )
+ {
+ int i, j;
+ double a, b;
+ TSG_Point_Z Point;
+ CSG_Matrix M;
+
+ //-------------------------------------------------
+ // Allocate the matrix and vector
+ M .Create(n + 3, n + 3);
+ m_V .Create(n + 3);
+
+ //-------------------------------------------------
+ // Fill K (n x n, upper left of L) and calculate
+ // mean edge length from control points
+ //
+ // K is symmetrical so we really have to
+ // calculate only about half of the coefficients.
+ for(i=0, a=0.0; i<n && (bSilent || SG_UI_Process_Set_Progress(i, n)); ++i )
+ {
+ Point = m_Points[i];
+
+ for(j=i+1; j<n; ++j)
+ {
+ b = _Get_hDistance(Point, m_Points[j]);
+ a += b * 2.0; // same for upper & lower tri
+ M[i][j] = (M[j][i] = _Get_Base_Funtion(b));
+ }
+ }
+
+ a /= (double)(n*n);
+
+ //-------------------------------------------------
+ // Fill the rest of L
+ for(i=0; i<n; ++i)
+ {
+ // diagonal: reqularization parameters (lambda * a^2)
+ M[i][i] = Regularization * (a*a);
+
+ // P (n x 3, upper right)
+ M[i][n + 0] = 1.0;
+ M[i][n + 1] = m_Points[i].x;
+ M[i][n + 2] = m_Points[i].y;
+
+ // P transposed (3 x n, bottom left)
+ M[n + 0][i] = 1.0;
+ M[n + 1][i] = m_Points[i].x;
+ M[n + 2][i] = m_Points[i].y;
+ }
+
+ //-------------------------------------------------
+ // O (3 x 3, lower right)
+ for(i=n; i<n+3; ++i)
+ {
+ for(j=n; j<n+3; ++j)
+ {
+ M[i][j] = 0.0;
+ }
+ }
+
+ //-------------------------------------------------
+ // Fill the right hand vector m_V
+ for(i=0; i<n; ++i)
+ {
+ m_V[i] = m_Points[i].z;
+ }
+
+ m_V[n + 0] = m_V[n + 1] = m_V[n + 2] = 0.0;
+
+ //-------------------------------------------------
+ // Solve the linear system "inplace"
+ if( !bSilent )
+ {
+ SG_UI_Process_Set_Text(LNG("Thin Plate Spline: solving matrix"));
+ }
+
+ bResult = SG_Matrix_Solve(M, m_V, bSilent);
+ }
+
+ //-----------------------------------------------------
+ if( !bResult )
+ {
+ Destroy();
+ }
+
+ return( bResult );
+}
+
+//---------------------------------------------------------
+double CSG_Thin_Plate_Spline::Get_Value(double x, double y)
+{
+ if( m_V.Get_N() > 0 )
+ {
+ int n = m_Points.Get_Count();
+ double z = m_V[n + 0] + m_V[n + 1] * x + m_V[n + 2] * y;
+
+ for(int i=0; i<n; i++)
+ {
+ z += m_V[i] * _Get_Base_Funtion(m_Points[i], x, y);
+ }
+
+ return( z );
+ }
+
+ return( 0.0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_api/mat_tools.cpp b/src/saga_core/saga_api/mat_tools.cpp
index 378b0ca..312d174 100644
--- a/src/saga_core/saga_api/mat_tools.cpp
+++ b/src/saga_core/saga_api/mat_tools.cpp
@@ -93,6 +93,7 @@ void CSG_Simple_Statistics::Invalidate(void)
{
m_bEvaluated = false;
m_nValues = 0;
+ m_Weights = 0.0;
m_Sum = 0.0;
m_Sum2 = 0.0;
@@ -105,14 +106,44 @@ void CSG_Simple_Statistics::Invalidate(void)
}
//---------------------------------------------------------
+void CSG_Simple_Statistics::Add_Value(double Value, double Weight)
+{
+ if( m_nValues == 0 )
+ {
+ m_Minimum = m_Maximum = Value;
+ }
+ else if( m_Minimum > Value )
+ {
+ m_Minimum = Value;
+ }
+ else if( m_Maximum < Value )
+ {
+ m_Maximum = Value;
+ }
+
+ m_nValues++;
+
+ if( Weight > 0.0 )
+ {
+ m_Weights += Weight;
+ m_Sum += Weight * Value;
+ m_Sum2 += Weight * Value*Value;
+
+ m_bEvaluated = false;
+ }
+}
+
+//---------------------------------------------------------
void CSG_Simple_Statistics::_Evaluate(void)
{
- if( m_nValues > 0 )
+ if( m_Weights > 0.0 )
{
- m_Range = m_Maximum - m_Minimum;
- m_Mean = m_Sum / m_nValues;
- m_Variance = m_Sum2 / m_nValues - m_Mean*m_Mean;
- m_StdDev = sqrt(m_Variance);
+ m_Range = m_Maximum - m_Minimum;
+ m_Mean = m_Sum / m_Weights;
+ m_Variance = m_Sum2 / m_Weights - m_Mean*m_Mean;
+ m_StdDev = m_Variance > 0.0 ? sqrt(m_Variance) : 0.0;
+
+ m_bEvaluated = true;
}
}
diff --git a/src/saga_core/saga_api/mat_tools.h b/src/saga_core/saga_api/mat_tools.h
index 31a467a..c369d06 100644
--- a/src/saga_core/saga_api/mat_tools.h
+++ b/src/saga_core/saga_api/mat_tools.h
@@ -71,13 +71,6 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#ifndef SWIG
-
-#include <math.h>
-
-#endif // #ifdef SWIG
-
-//---------------------------------------------------------
#include "geo_tools.h"
@@ -463,35 +456,17 @@ public:
bool is_Evaluated (void) { return( m_bEvaluated ); }
int Get_Count (void) { return( m_nValues ); }
+ double Get_Weights (void) { return( m_Weights ); }
- double Get_Minimum (void) { _Update(); return( m_Minimum ); }
- double Get_Maximum (void) { _Update(); return( m_Maximum ); }
- double Get_Range (void) { _Update(); return( m_Range ); }
- double Get_Mean (void) { _Update(); return( m_Mean ); }
- double Get_Variance (void) { _Update(); return( m_Variance ); }
- double Get_StdDev (void) { _Update(); return( m_StdDev ); }
-
- void Add_Value (double Value)
- {
- if( m_nValues == 0 )
- {
- m_Minimum = m_Maximum = Value;
- }
- else if( m_Minimum > Value )
- {
- m_Minimum = Value;
- }
- else if( m_Maximum < Value )
- {
- m_Maximum = Value;
- }
-
- m_nValues ++;
- m_Sum += Value;
- m_Sum2 += Value * Value;
+ double Get_Minimum (void) { if( !m_bEvaluated ) _Evaluate(); return( m_Minimum ); }
+ double Get_Maximum (void) { if( !m_bEvaluated ) _Evaluate(); return( m_Maximum ); }
+ double Get_Range (void) { if( !m_bEvaluated ) _Evaluate(); return( m_Range ); }
+ double Get_Sum (void) { if( !m_bEvaluated ) _Evaluate(); return( m_Sum ); }
+ double Get_Mean (void) { if( !m_bEvaluated ) _Evaluate(); return( m_Mean ); }
+ double Get_Variance (void) { if( !m_bEvaluated ) _Evaluate(); return( m_Variance ); }
+ double Get_StdDev (void) { if( !m_bEvaluated ) _Evaluate(); return( m_StdDev ); }
- m_bEvaluated = false;
- }
+ void Add_Value (double Value, double Weight = 1.0);
protected:
@@ -500,19 +475,11 @@ protected:
int m_nValues;
- double m_Sum, m_Sum2, m_Minimum, m_Maximum, m_Range, m_Mean, m_Variance, m_StdDev;
+ double m_Weights, m_Sum, m_Sum2, m_Minimum, m_Maximum, m_Range, m_Mean, m_Variance, m_StdDev;
void _Evaluate (void);
- void _Update (void)
- {
- if( !m_bEvaluated )
- {
- _Evaluate();
- }
- }
-
};
@@ -549,13 +516,66 @@ protected:
int m_nValues, m_nBuffer;
- TSG_Point_3D *m_Values;
+ TSG_Point_Z *m_Values;
bool _Create (double yA, double yB);
};
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Thin_Plate_Spline
+{
+public:
+ CSG_Thin_Plate_Spline(void);
+ virtual ~CSG_Thin_Plate_Spline(void);
+
+ bool Destroy (void);
+
+ bool Set_Point_Count (int Count) { return( m_Points.Set_Count(Count) ); }
+ int Get_Point_Count (void) { return( m_Points.Get_Count() ); }
+
+ CSG_Points_Z & Get_Points (void) { return( m_Points ); }
+
+ bool Add_Point (double x, double y, double z) { return( m_Points.Add( x, y, z) ); }
+ bool Add_Point (const TSG_Point &p, double z) { return( m_Points.Add(p.x, p.y, z) ); }
+
+ bool Set_Point (int Index, double x, double y, double z)
+ {
+ if( Index >= 0 && Index < m_Points.Get_Count() )
+ {
+ m_Points[Index].x = x;
+ m_Points[Index].y = y;
+ m_Points[Index].z = z;
+
+ return( true );
+ }
+
+ return( false );
+ }
+
+ bool Set_Point (int Index, const TSG_Point &p, double z) { return( Set_Point(Index, p.x, p.y, z) ); }
+
+ bool Create (double Regularization = 0.0, bool bSilent = true);
+
+ bool is_Okay (void) { return( m_V.Get_N() > 0 ); }
+
+ double Get_Value (double x, double y);
+
+
+private:
+
+ CSG_Points_Z m_Points;
+
+ CSG_Vector m_V;
+
+
+ double _Get_hDistance (TSG_Point_Z A, TSG_Point_Z B);
+ double _Get_Base_Funtion (double x);
+ double _Get_Base_Funtion (TSG_Point_Z A, double x, double y);
+
+};
+
///////////////////////////////////////////////////////////
// //
@@ -662,12 +682,16 @@ public:
class CSG_Table * Get_Result (void) { return( m_pResult ); }
- int Get_Ordered (int iOrder);
+ int Get_Count (void);
+
+ int Get_Index (int iOrder);
int Get_Order (int iVariable);
- double Get_R2 (int iVariable);
- double Get_R2_Change (int iVariable);
+
double Get_RConst (void);
- double Get_RCoeff (int iVariable);
+ double Get_RCoeff (int iVariable, bool bOrdered = false);
+ double Get_R2 (int iVariable, bool bOrdered = false);
+ double Get_R2_Change (int iVariable, bool bOrdered = false);
+ const SG_Char * Get_Name (int iVariable, bool bOrdered = false);
protected:
@@ -791,7 +815,7 @@ private:
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-enum
+enum ESG_Trend_String
{
SG_TREND_STRING_Formula = 0,
SG_TREND_STRING_Function,
diff --git a/src/saga_core/saga_api/metadata.cpp b/src/saga_core/saga_api/metadata.cpp
index 5b65552..86a3231 100644
--- a/src/saga_core/saga_api/metadata.cpp
+++ b/src/saga_core/saga_api/metadata.cpp
@@ -107,6 +107,19 @@ bool CSG_MetaData::Create(const CSG_String &File, const SG_Char *Extension)
}
//---------------------------------------------------------
+CSG_MetaData::CSG_MetaData(CSG_File &Stream)
+{
+ _On_Construction();
+
+ Create(Stream);
+}
+
+bool CSG_MetaData::Create(CSG_File &Stream)
+{
+ return( Load(Stream) );
+}
+
+//---------------------------------------------------------
CSG_MetaData::CSG_MetaData(CSG_MetaData *pParent)
{
_On_Construction();
@@ -581,3 +594,32 @@ void CSG_MetaData::_Save(wxXmlNode *pNode) const
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+bool CSG_MetaData::Load_WKT(const CSG_String &WKT)
+{
+ return( false );
+}
+
+bool CSG_MetaData::_Load_WKT(const CSG_String &WKT)
+{
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_MetaData::Save_WKT(CSG_String &WKT) const
+{
+ return( false );
+}
+
+bool CSG_MetaData::_Save_WKT(CSG_String &WKT) const
+{
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_api/metadata.h b/src/saga_core/saga_api/metadata.h
index 675fa8a..8989ddc 100644
--- a/src/saga_core/saga_api/metadata.h
+++ b/src/saga_core/saga_api/metadata.h
@@ -103,6 +103,9 @@ public:
bool Load (CSG_File &Stream);
bool Save (CSG_File &Stream) const;
+ bool Load_WKT (const CSG_String &WKT);
+ bool Save_WKT ( CSG_String &WKT) const;
+
bool Assign (const CSG_MetaData &MetaData, bool bAppend = false);
CSG_MetaData & operator = (const CSG_MetaData &MetaData) { Assign(MetaData, false); return( *this ); }
CSG_MetaData & operator += (const CSG_MetaData &MetaData) { Assign(MetaData, true ); return( *this ); }
@@ -163,6 +166,9 @@ private:
void _Load (class wxXmlNode *pNode);
void _Save (class wxXmlNode *pNode) const;
+ bool _Load_WKT (const CSG_String &WKT);
+ bool _Save_WKT ( CSG_String &WKT) const;
+
};
diff --git a/src/saga_core/saga_api/module.cpp b/src/saga_core/saga_api/module.cpp
index 6b09b46..ae82dab 100644
--- a/src/saga_core/saga_api/module.cpp
+++ b/src/saga_core/saga_api/module.cpp
@@ -160,7 +160,7 @@ void CSG_Module::Set_Author(const SG_Char *String)
{
if( String )
{
- m_Author.Printf(String);
+ m_Author = String;
}
else
{
@@ -195,6 +195,7 @@ void CSG_Module::Set_Translation(CSG_Translator &Translator)
bool CSG_Module::Execute(void)
{
bool bResult = false;
+ int i;
if( m_bExecutes == false )
{
@@ -202,6 +203,11 @@ bool CSG_Module::Execute(void)
if( Parameters.DataObjects_Check() )
{
+ for(i=0; i<m_npParameters; i++)
+ {
+ m_pParameters[i]->DataObjects_Check();
+ }
+
Destroy();
Parameters.DataObjects_Create();
@@ -240,6 +246,11 @@ __except(1)
Destroy();
Parameters.DataObjects_Synchronize();
+
+ for(i=0; i<m_npParameters; i++)
+ {
+ m_pParameters[i]->DataObjects_Synchronize();
+ }
}
m_bExecutes = false;
@@ -351,7 +362,7 @@ bool CSG_Module::Dlg_Parameters(const SG_Char *Identifier)
//---------------------------------------------------------
bool CSG_Module::Dlg_Parameters(CSG_Parameters *pParameters, const SG_Char *Caption)
{
- return( SG_UI_Dlg_Parameters(pParameters, Caption) );
+ return( pParameters ? SG_UI_Dlg_Parameters(pParameters, Caption) : false );
}
//---------------------------------------------------------
@@ -399,6 +410,12 @@ bool CSG_Module::Set_Progress(double Position, double Range)
return( m_bShow_Progress ? SG_UI_Process_Set_Progress(Position, Range) : Process_Get_Okay(false) );
}
+//---------------------------------------------------------
+bool CSG_Module::Stop_Execution(void)
+{
+ return( SG_UI_Stop_Execution() );
+}
+
///////////////////////////////////////////////////////////
// //
@@ -469,7 +486,7 @@ bool CSG_Module::Error_Set(const SG_Char *Error_Text)
//---------------------------------------------------------
bool CSG_Module::_Garbage_Add_Item(CSG_Data_Object *pDataObject)
{
- if( pDataObject )
+ if( pDataObject && !SG_UI_DataObject_Check(pDataObject, DATAOBJECT_TYPE_Undefined) )
{
for(int i=0; i<m_nGarbage; i++)
{
@@ -634,6 +651,83 @@ bool CSG_Module::DataObject_Set_Parameters(CSG_Data_Object *pDataObject, CSG_Par
return( SG_UI_DataObject_Params_Set(pDataObject, &Parameters) );
}
+//---------------------------------------------------------
+CSG_Parameter * CSG_Module::DataObject_Get_Parameter(CSG_Data_Object *pDataObject, const CSG_String &ID)
+{
+ static CSG_Parameters sParameters;
+
+ return( DataObject_Get_Parameters(pDataObject, sParameters) ? sParameters(ID) : NULL );
+}
+
+bool CSG_Module::DataObject_Set_Parameter(CSG_Data_Object *pDataObject, CSG_Parameter *pParameter)
+{
+ CSG_Parameters P;
+
+ P._Add(pParameter);
+
+ return( DataObject_Set_Parameters(pDataObject, P) );
+}
+
+bool CSG_Module::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, int Value)
+{
+ CSG_Parameters Parameters;
+
+ if( DataObject_Get_Parameters(pDataObject, Parameters) && Parameters(ID) )
+ {
+ return( Parameters(ID)->Set_Value(Value) && DataObject_Set_Parameters(pDataObject, Parameters) );
+ }
+
+ return( false );
+}
+
+bool CSG_Module::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, double Value)
+{
+ CSG_Parameters Parameters;
+
+ if( DataObject_Get_Parameters(pDataObject, Parameters) && Parameters(ID) )
+ {
+ return( Parameters(ID)->Set_Value(Value) && DataObject_Set_Parameters(pDataObject, Parameters) );
+ }
+
+ return( false );
+}
+
+bool CSG_Module::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, void *Value)
+{
+ CSG_Parameters Parameters;
+
+ if( DataObject_Get_Parameters(pDataObject, Parameters) && Parameters(ID) )
+ {
+ return( Parameters(ID)->Set_Value(Value) && DataObject_Set_Parameters(pDataObject, Parameters) );
+ }
+
+ return( false );
+}
+
+bool CSG_Module::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, const SG_Char *Value)
+{
+ CSG_Parameters Parameters;
+
+ if( DataObject_Get_Parameters(pDataObject, Parameters) && Parameters(ID) )
+ {
+ return( Parameters(ID)->Set_Value(Value) && DataObject_Set_Parameters(pDataObject, Parameters) );
+ }
+
+ return( false );
+}
+
+bool CSG_Module::DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, double loVal, double hiVal) // Range Parameter
+{
+ CSG_Parameters Parameters;
+
+ if( DataObject_Get_Parameters(pDataObject, Parameters) && Parameters(ID) && Parameters(ID)->Get_Type() == PARAMETER_TYPE_Range )
+ {
+ return( Parameters(ID)->asRange()->Set_Range(loVal, hiVal) && DataObject_Set_Parameters(pDataObject, Parameters) );
+ }
+
+ return( false );
+}
+
///////////////////////////////////////////////////////////
// //
diff --git a/src/saga_core/saga_api/module.h b/src/saga_core/saga_api/module.h
index 1078481..d77e982 100644
--- a/src/saga_core/saga_api/module.h
+++ b/src/saga_core/saga_api/module.h
@@ -162,6 +162,7 @@ public:
void Set_Show_Progress (bool bOn = true);
virtual bool On_Before_Execution (void) { return( true ); }
+ virtual bool On_After_Execution (void) { return( true ); }
bool Execute (void);
@@ -201,6 +202,8 @@ protected:
virtual bool Set_Progress (int Position);
virtual bool Set_Progress (double Position, double Range);
+ bool Stop_Execution (void);
+
void Message_Add (const SG_Char *Text, bool bNewLine = true);
void Message_Dlg (const SG_Char *Text, const SG_Char *Caption = NULL);
bool Message_Dlg_Confirm (const SG_Char *Text, const SG_Char *Caption = NULL);
@@ -223,6 +226,14 @@ protected:
bool DataObject_Get_Parameters (CSG_Data_Object *pDataObject, CSG_Parameters &Parameters);
bool DataObject_Set_Parameters (CSG_Data_Object *pDataObject, CSG_Parameters &Parameters);
+ CSG_Parameter * DataObject_Get_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID);
+ bool DataObject_Set_Parameter (CSG_Data_Object *pDataObject, CSG_Parameter *pParameter);
+ bool DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, int Value);
+ bool DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, double Value);
+ bool DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, void *Value);
+ bool DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, const SG_Char *Value);
+ bool DataObject_Set_Parameter (CSG_Data_Object *pDataObject, const CSG_String &ID, double loVal, double hiVal); // Range Parameter
+
private:
@@ -384,13 +395,13 @@ protected:
virtual bool On_Execute_Keyboard (int Character);
virtual bool On_Execute_Finish (void);
- CSG_Point & Get_Position (void) { return( m_Point ); }
- double Get_xPosition (void) { return( m_Point.m_point.x ); }
- double Get_yPosition (void) { return( m_Point.m_point.y ); }
+ CSG_Point & Get_Position (void) { return( m_Point ); }
+ double Get_xPosition (void) { return( m_Point.Get_X() ); }
+ double Get_yPosition (void) { return( m_Point.Get_Y() ); }
- CSG_Point & Get_Position_Last (void) { return( m_Point_Last ); }
- double Get_xPosition_Last (void) { return( m_Point_Last.m_point.x ); }
- double Get_yPosition_Last (void) { return( m_Point_Last.m_point.y ); }
+ CSG_Point & Get_Position_Last (void) { return( m_Point_Last ); }
+ double Get_xPosition_Last (void) { return( m_Point_Last.Get_X() ); }
+ double Get_yPosition_Last (void) { return( m_Point_Last.Get_Y() ); }
bool is_Shift (void) { return( (m_Keys & MODULE_INTERACTIVE_KEY_SHIFT) != 0 ); }
bool is_Alt (void) { return( (m_Keys & MODULE_INTERACTIVE_KEY_ALT) != 0 ); }
@@ -523,14 +534,27 @@ private:
#define SYMBOL_MLB_Initialize SG_T("MLB_Initialize")
typedef bool (* TSG_PFNC_MLB_Initialize) (const SG_Char *);
-//---------------------------------------------------------
+#define SYMBOL_MLB_Finalize SG_T("MLB_Finalize")
+typedef bool (* TSG_PFNC_MLB_Finalize) (void);
+
#define SYMBOL_MLB_Get_Interface SG_T("MLB_Get_Interface")
typedef CSG_Module_Library_Interface * (* TSG_PFNC_MLB_Get_Interface) (void);
//---------------------------------------------------------
-#define MLB_INTERFACE CSG_Module_Library_Interface MLB_Interface;\
+#define MLB_INTERFACE_CORE CSG_Module_Library_Interface MLB_Interface;\
+\
+extern "C" _SAGA_DLL_EXPORT CSG_Module_Library_Interface * MLB_Get_Interface (void)\
+{\
+ return( &MLB_Interface );\
+}\
\
-extern "C" _SAGA_DLL_EXPORT bool MLB_Initialize (const SG_Char *File_Name)\
+extern "C" _SAGA_DLL_EXPORT const SG_Char * Get_API_Version (void)\
+{\
+ return( SAGA_API_VERSION );\
+}\
+
+//---------------------------------------------------------
+#define MLB_INTERFACE_INITIALIZE extern "C" _SAGA_DLL_EXPORT bool MLB_Initialize (const SG_Char *File_Name)\
{\
MLB_Interface.Set_File_Name(File_Name);\
\
@@ -545,18 +569,17 @@ extern "C" _SAGA_DLL_EXPORT bool MLB_Initialize (const SG_Char *File_Name
\
return( MLB_Interface.Get_Count() > 0 );\
}\
-\
-extern "C" _SAGA_DLL_EXPORT CSG_Module_Library_Interface * MLB_Get_Interface (void)\
-{\
- return( &MLB_Interface );\
-}\
-\
-extern "C" _SAGA_DLL_EXPORT const SG_Char * Get_API_Version (void)\
+
+//---------------------------------------------------------
+#define MLB_INTERFACE_FINALIZE extern "C" _SAGA_DLL_EXPORT bool MLB_Finalize (void)\
{\
- return( SAGA_API_VERSION );\
+ return( true );\
}\
//---------------------------------------------------------
+#define MLB_INTERFACE MLB_INTERFACE_CORE MLB_INTERFACE_INITIALIZE MLB_INTERFACE_FINALIZE
+
+//---------------------------------------------------------
#ifndef SWIG
extern CSG_Module_Library_Interface MLB_Interface;
diff --git a/src/saga_core/saga_api/module_interactive_base.cpp b/src/saga_core/saga_api/module_interactive_base.cpp
index 1fe8ce2..99603cc 100644
--- a/src/saga_core/saga_api/module_interactive_base.cpp
+++ b/src/saga_core/saga_api/module_interactive_base.cpp
@@ -72,19 +72,18 @@
//---------------------------------------------------------
CSG_Module_Interactive_Base::CSG_Module_Interactive_Base(void)
{
- m_pModule = NULL;
+ m_pModule = NULL;
- m_Keys = 0;
- m_Drag_Mode = MODULE_INTERACTIVE_DRAG_BOX;
+ m_Keys = 0;
+ m_Drag_Mode = MODULE_INTERACTIVE_DRAG_BOX;
- m_Point.m_point.x = m_Point_Last.m_point.x = 0.0;
- m_Point.m_point.y = m_Point_Last.m_point.y = 0.0;
+ m_Point .Assign(0.0, 0.0);
+ m_Point_Last .Assign(0.0, 0.0);
}
//---------------------------------------------------------
CSG_Module_Interactive_Base::~CSG_Module_Interactive_Base(void)
-{
-}
+{}
///////////////////////////////////////////////////////////
diff --git a/src/saga_core/saga_api/module_library.cpp b/src/saga_core/saga_api/module_library.cpp
index 31a7bb5..2457ab4 100644
--- a/src/saga_core/saga_api/module_library.cpp
+++ b/src/saga_core/saga_api/module_library.cpp
@@ -197,6 +197,13 @@ bool CSG_Module_Library::Destroy(void)
{
if( m_pLibrary->IsLoaded() )
{
+ TSG_PFNC_MLB_Finalize MLB_Finalize = (TSG_PFNC_MLB_Finalize)m_pLibrary->GetSymbol(SYMBOL_MLB_Finalize);
+
+ if( MLB_Finalize )
+ {
+ MLB_Finalize();
+ }
+
m_pLibrary->Unload();
}
diff --git a/src/saga_core/saga_api/parameter.cpp b/src/saga_core/saga_api/parameter.cpp
index 7118574..d27b338 100644
--- a/src/saga_core/saga_api/parameter.cpp
+++ b/src/saga_core/saga_api/parameter.cpp
@@ -574,3 +574,292 @@ CSG_MetaData * CSG_Parameter::Serialize(CSG_MetaData &Entry, bool bSave)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+CSG_Parameters_Grid_Target::CSG_Parameters_Grid_Target(void)
+{
+ Create();
+}
+
+//---------------------------------------------------------
+void CSG_Parameters_Grid_Target::Create(void)
+{
+ m_pUser = NULL;
+ m_pGrid = NULL;
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Parameters_Grid_Target::Add_Parameters_User(CSG_Parameters *pParameters, bool bAddDefaultGrid)
+{
+ if( pParameters == NULL )
+ {
+ return( false );
+ }
+
+ m_pUser = pParameters;
+
+ pParameters->Add_Value(
+ NULL, "XMIN" , LNG("Left") , LNG(""), PARAMETER_TYPE_Double
+ );
+
+ pParameters->Add_Value(
+ NULL, "XMAX" , LNG("Right") , LNG(""), PARAMETER_TYPE_Double
+ );
+
+ pParameters->Add_Value(
+ NULL, "YMIN" , LNG("Bottom") , LNG(""), PARAMETER_TYPE_Double
+ );
+
+ pParameters->Add_Value(
+ NULL, "YMAX" , LNG("Top") , LNG(""), PARAMETER_TYPE_Double
+ );
+
+ pParameters->Add_Value(
+ NULL, "SIZE" , LNG("Cellsize") , LNG(""), PARAMETER_TYPE_Double, 1.0, 0.0, true
+ );
+
+ pParameters->Add_Info_Value(
+ NULL, "COLS" , LNG("Columns") , LNG(""), PARAMETER_TYPE_Int
+ );
+
+ pParameters->Add_Info_Value(
+ NULL, "ROWS" , LNG("Rows") , LNG(""), PARAMETER_TYPE_Int
+ );
+
+ if( bAddDefaultGrid )
+ {
+ pParameters->Add_Grid_Output(
+ NULL, "GRID" , LNG("Grid") , LNG("")
+ );
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters_Grid_Target::On_User_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ if( !m_pUser || !pParameters || !pParameter || SG_STR_CMP(m_pUser->Get_Identifier(), pParameters->Get_Identifier()) )
+ {
+ return( false );
+ }
+
+ CSG_Parameter *xMin = pParameters->Get_Parameter("XMIN");
+ CSG_Parameter *xMax = pParameters->Get_Parameter("XMAX");
+ CSG_Parameter *yMin = pParameters->Get_Parameter("YMIN");
+ CSG_Parameter *yMax = pParameters->Get_Parameter("YMAX");
+ CSG_Parameter *Size = pParameters->Get_Parameter("SIZE");
+ CSG_Parameter *Rows = pParameters->Get_Parameter("ROWS");
+ CSG_Parameter *Cols = pParameters->Get_Parameter("COLS");
+
+ if( !xMin || !xMax || !yMin || !yMax || !Size || !Rows || !Cols )
+ {
+ return( false );
+ }
+
+ if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("SIZE")) )
+ {
+ xMax->Set_Value(xMin->asDouble() + ((int)((xMax->asDouble() - xMin->asDouble()) / Size->asDouble())) * Size->asDouble());
+ yMax->Set_Value(yMin->asDouble() + ((int)((yMax->asDouble() - yMin->asDouble()) / Size->asDouble())) * Size->asDouble());
+ }
+ else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("XMIN")) )
+ {
+ if( xMin->asDouble() >= xMax->asDouble() )
+ {
+ xMin->Set_Value(xMax->asDouble() - Cols->asInt() * Size->asDouble());
+ }
+
+ xMax->Set_Value(xMin->asDouble() + ((int)((xMax->asDouble() - xMin->asDouble()) / Size->asDouble())) * Size->asDouble());
+ }
+ else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("XMAX")) )
+ {
+ if( xMin->asDouble() >= xMax->asDouble() )
+ {
+ xMax->Set_Value(xMin->asDouble() + Cols->asInt() * Size->asDouble());
+ }
+
+ xMin->Set_Value(xMax->asDouble() - ((int)((xMax->asDouble() - xMin->asDouble()) / Size->asDouble())) * Size->asDouble());
+ }
+ else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("YMIN")) )
+ {
+ if( yMin->asDouble() >= yMax->asDouble() )
+ {
+ yMin->Set_Value(yMax->asDouble() - Rows->asInt() * Size->asDouble());
+ }
+
+ yMax->Set_Value(yMin->asDouble() + ((int)((yMax->asDouble() - yMin->asDouble()) / Size->asDouble())) * Size->asDouble());
+ }
+ else if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("YMAX")) )
+ {
+ if( yMin->asDouble() >= yMax->asDouble() )
+ {
+ yMax->Set_Value(yMin->asDouble() + Rows->asInt() * Size->asDouble());
+ }
+
+ yMin->Set_Value(yMax->asDouble() - ((int)((yMax->asDouble() - yMin->asDouble()) / Size->asDouble())) * Size->asDouble());
+ }
+
+ Cols->Set_Value(1 + (int)((xMax->asDouble() - xMin->asDouble()) / Size->asDouble()));
+ Rows->Set_Value(1 + (int)((yMax->asDouble() - yMin->asDouble()) / Size->asDouble()));
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters_Grid_Target::Init_User(const TSG_Rect &Extent, int Rows)
+{
+ if( !m_pUser || Extent.xMin >= Extent.xMax || Extent.yMin >= Extent.yMax || Rows < 1 )
+ {
+ return( false );
+ }
+
+ double Size = (Extent.yMax - Extent.yMin) / (double)Rows;
+
+ m_pUser->Get_Parameter("XMIN")->Set_Value(Extent.xMin);
+ m_pUser->Get_Parameter("XMAX")->Set_Value(Extent.xMax);
+ m_pUser->Get_Parameter("YMIN")->Set_Value(Extent.yMin);
+ m_pUser->Get_Parameter("YMAX")->Set_Value(Extent.yMax);
+ m_pUser->Get_Parameter("SIZE")->Set_Value(Size);
+ m_pUser->Get_Parameter("COLS")->Set_Value(1 + (int)((Extent.xMax - Extent.xMin) / Size));
+ m_pUser->Get_Parameter("ROWS")->Set_Value(1 + (int)((Extent.yMax - Extent.yMin) / Size));
+
+ return( true );
+}
+
+//---------------------------------------------------------
+CSG_Grid * CSG_Parameters_Grid_Target::Get_User(TSG_Data_Type Type)
+{
+ return( Get_User(SG_T("GRID"), Type) );
+}
+
+//---------------------------------------------------------
+CSG_Grid * CSG_Parameters_Grid_Target::Get_User(const CSG_String &Identifier, TSG_Data_Type Type)
+{
+ CSG_Grid *pGrid = NULL;
+
+ if( m_pUser )
+ {
+ if( m_pUser->Get_Parameter("SIZE")->asDouble() > 0.0
+ && m_pUser->Get_Parameter("COLS")->asInt() > 0
+ && m_pUser->Get_Parameter("ROWS")->asInt() > 0 )
+ {
+ On_User_Changed(m_pUser, m_pUser->Get_Parameter("SIZE"));
+
+ pGrid = SG_Create_Grid(Type,
+ m_pUser->Get_Parameter("COLS")->asInt(),
+ m_pUser->Get_Parameter("ROWS")->asInt(),
+ m_pUser->Get_Parameter("SIZE")->asDouble(),
+ m_pUser->Get_Parameter("XMIN")->asDouble(),
+ m_pUser->Get_Parameter("YMIN")->asDouble()
+ );
+ }
+
+ if( Identifier.Length() > 0 && m_pUser->Get_Parameter(Identifier) )
+ {
+ m_pUser->Get_Parameter(Identifier)->Set_Value(pGrid);
+ }
+ }
+
+ return( pGrid );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Parameters_Grid_Target::Add_Grid_Parameter(const CSG_String &Identifier, const CSG_String &Name, bool bOptional)
+{
+ if( Identifier.Length() == 0 )
+ {
+ return( false );
+ }
+
+ if( m_pUser && m_pUser->Get_Parameter(Identifier) == NULL )
+ {
+ m_pUser->Add_Grid_Output(NULL, Identifier, Name, LNG(""));
+ }
+
+ if( m_pGrid && m_pGrid->Get_Parameter(Identifier) == NULL )
+ {
+ CSG_Parameter *pSystem = NULL;
+
+ for(int i=0; i<m_pGrid->Get_Count() && !pSystem; i++)
+ {
+ if( m_pGrid->Get_Parameter(i)->Get_Type() == PARAMETER_TYPE_Grid_System )
+ {
+ pSystem = m_pGrid->Get_Parameter(i);
+ }
+ }
+
+ m_pGrid->Add_Grid(pSystem, Identifier, Name, LNG(""), bOptional ? PARAMETER_OUTPUT_OPTIONAL : PARAMETER_OUTPUT, false);
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Parameters_Grid_Target::Add_Parameters_Grid(CSG_Parameters *pParameters, bool bAddDefaultGrid)
+{
+ if( pParameters == NULL )
+ {
+ return( false );
+ }
+
+ m_pGrid = pParameters;
+
+ if( bAddDefaultGrid )
+ {
+ pParameters->Add_Grid(
+ NULL , "GRID" , LNG("Grid") , LNG(""), PARAMETER_OUTPUT, false
+ );
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+CSG_Grid * CSG_Parameters_Grid_Target::Get_Grid(TSG_Data_Type Type)
+{
+ return( Get_Grid(SG_T("GRID"), Type) );
+}
+
+//---------------------------------------------------------
+CSG_Grid * CSG_Parameters_Grid_Target::Get_Grid(const CSG_String &Identifier, TSG_Data_Type Type)
+{
+ CSG_Parameter *pParameter = m_pGrid && Identifier.Length() > 0 ? m_pGrid->Get_Parameter(Identifier) : NULL;
+
+ if( !pParameter || !pParameter->Get_Parent()->asGrid_System()->is_Valid() )
+ {
+ return( NULL );
+ }
+
+ CSG_Grid *pGrid = pParameter->asGrid();
+
+ if( (pGrid == DATAOBJECT_NOTSET && !pParameter->is_Optional()) || pGrid == DATAOBJECT_CREATE )
+ {
+ pParameter->Set_Value(pGrid = SG_Create_Grid(*pParameter->Get_Parent()->asGrid_System(), Type));
+
+ SG_UI_DataObject_Add(pGrid, SG_UI_DATAOBJECT_UPDATE_ONLY);
+ }
+
+ return( pGrid );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_api/parameter_data.cpp b/src/saga_core/saga_api/parameter_data.cpp
index e8b3d83..1ae80db 100644
--- a/src/saga_core/saga_api/parameter_data.cpp
+++ b/src/saga_core/saga_api/parameter_data.cpp
@@ -853,7 +853,7 @@ bool CSG_Parameter_String::Set_Value(void *Value)
{
if( m_String.Cmp((SG_Char *)Value) )
{
- m_String.Printf((SG_Char *)Value);
+ m_String = (SG_Char *)Value;
return( true );
}
@@ -877,7 +877,7 @@ const SG_Char * CSG_Parameter_String::asString(void)
//---------------------------------------------------------
void CSG_Parameter_String::On_Assign(CSG_Parameter_Data *pSource)
{
- m_String.Printf(((CSG_Parameter_String *)pSource)->m_String.c_str());
+ m_String = ((CSG_Parameter_String *)pSource)->m_String.c_str();
bPassword = ((CSG_Parameter_String *)pSource)->bPassword;
}
@@ -1113,9 +1113,9 @@ bool CSG_Parameter_Font::On_Serialize(CSG_MetaData &Entry, bool bSave)
if( (pEntry = Entry.Get_Child(SG_T("COLOR"))) != NULL )
{
m_Color = SG_GET_RGB(
- Entry.Get_Content().AfterFirst(SG_T('R')).asInt(),
- Entry.Get_Content().AfterFirst(SG_T('G')).asInt(),
- Entry.Get_Content().AfterFirst(SG_T('B')).asInt()
+ pEntry->Get_Content().AfterFirst(SG_T('R')).asInt(),
+ pEntry->Get_Content().AfterFirst(SG_T('G')).asInt(),
+ pEntry->Get_Content().AfterFirst(SG_T('B')).asInt()
);
}
@@ -1555,6 +1555,29 @@ bool CSG_Parameter_Table_Field::Set_Value(int Value)
}
//---------------------------------------------------------
+bool CSG_Parameter_Table_Field::Set_Value(void *Value)
+{
+ CSG_Table *pTable;
+
+ if( Value && *((SG_Char *)Value) && (pTable = Get_Table()) != NULL )
+ {
+ CSG_String s((SG_Char *)Value);
+
+ for(int i=0; i<pTable->Get_Field_Count(); i++)
+ {
+ if( s.CmpNoCase(pTable->Get_Field_Name(i)) == 0 )
+ {
+ m_Value = i;
+
+ return( true );
+ }
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
CSG_Table * CSG_Parameter_Table_Field::Get_Table(void)
{
CSG_Table *pTable;
@@ -1572,15 +1595,13 @@ CSG_Table * CSG_Parameter_Table_Field::Get_Table(void)
case PARAMETER_TYPE_Table:
case PARAMETER_TYPE_Shapes:
case PARAMETER_TYPE_TIN:
- pTable = pParent->asTable();
- break;
-
case PARAMETER_TYPE_PointCloud:
+ pTable = pParent->asTable();
break;
}
}
- return( pTable && pTable->Get_Field_Count() > 0 ? pTable : NULL );
+ return( pTable && pTable != DATAOBJECT_CREATE && pTable->Get_Field_Count() > 0 ? pTable : NULL );
}
@@ -1652,21 +1673,25 @@ bool CSG_Parameter_Data_Object::On_Serialize(CSG_MetaData &Entry, bool bSave)
{
Entry.Set_Content(SG_T("CREATE"));
}
- else if( m_pDataObject != DATAOBJECT_NOTSET && m_pDataObject->Get_File_Name() )
+ else if( m_pDataObject == DATAOBJECT_NOTSET || !m_pDataObject->Get_File_Name() )
{
- Entry.Set_Content(m_pDataObject->Get_File_Name());
+ Entry.Set_Content(SG_T("NOT SET"));
}
else
{
- Entry.Set_Content(SG_T("NOT SET"));
+ Entry.Set_Content(m_pDataObject->Get_File_Name());
}
}
else
{
- if( !Entry.Cmp_Content(SG_T("CREATE")) )
+ if( Entry.Cmp_Content(SG_T("CREATE")) )
{
Set_Value(DATAOBJECT_CREATE);
}
+ else if( Entry.Cmp_Content(SG_T("NOT SET")) )
+ {
+ Set_Value(DATAOBJECT_NOTSET);
+ }
else
{
Set_Value(SG_UI_DataObject_Find(Entry.Get_Content(), -1));
@@ -2255,7 +2280,7 @@ bool CSG_Parameter_Parameters::On_Serialize(CSG_MetaData &Entry, bool bSave)
if( bSave )
{
Entry.Set_Property(SG_T("id") , m_pOwner->Get_Identifier());
- Entry.Set_Property(SG_T("type"), m_pOwner->Get_Type_Name());
+ Entry.Set_Property(SG_T("type"), m_pOwner->Get_Type_Identifier());
}
return( true );
diff --git a/src/saga_core/saga_api/parameters.cpp b/src/saga_core/saga_api/parameters.cpp
index 4cce99e..907d4dc 100644
--- a/src/saga_core/saga_api/parameters.cpp
+++ b/src/saga_core/saga_api/parameters.cpp
@@ -1,1660 +1,1731 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Application Programming Interface //
-// //
-// Library: SAGA_API //
-// //
-//-------------------------------------------------------//
-// //
-// parameters.cpp //
-// //
-// Copyright (C) 2005 by Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. //
-// //
-// This library is free software; you can redistribute //
-// it and/or modify it under the terms of the GNU Lesser //
-// General Public License as published by the Free //
-// Software Foundation, version 2.1 of the License. //
-// //
-// This library is distributed in the hope that it will //
-// be useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU Lesser General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU Lesser //
-// General Public License along with this program; if //
-// not, write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "parameters.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Parameters::CSG_Parameters(void)
-{
- _On_Construction();
-}
-
-//---------------------------------------------------------
-CSG_Parameters::CSG_Parameters(void *pOwner, const SG_Char *Name, const SG_Char *Description, const SG_Char *Identifier, bool bGrid_System)
-{
- _On_Construction();
-
- Create(pOwner, Name, Description, Identifier, bGrid_System);
-}
-
-//---------------------------------------------------------
-CSG_Parameters::~CSG_Parameters(void)
-{
- Destroy();
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CSG_Parameters::_On_Construction(void)
-{
- m_pOwner = NULL;
-
- m_Parameters = NULL;
- m_nParameters = 0;
-
- m_Callback = NULL;
- m_bCallback = false;
-
- m_pGrid_System = NULL;
-
- m_bManaged = true;
-}
-
-//---------------------------------------------------------
-void CSG_Parameters::Create(void *pOwner, const SG_Char *Name, const SG_Char *Description, const SG_Char *Identifier, bool bGrid_System)
-{
- Destroy();
-
- m_pOwner = pOwner;
-
- Set_Identifier (Identifier);
- Set_Name (Name);
- Set_Description (Description);
-
- if( bGrid_System )
- {
- m_pGrid_System = Add_Grid_System(
- NULL, SG_T("PARAMETERS_GRID_SYSTEM"),
- LNG("[PRM] Grid system"),
- LNG("[PRM] Grid system")
- );
- }
-}
-
-//---------------------------------------------------------
-void CSG_Parameters::Destroy(void)
-{
- m_pOwner = NULL;
- m_pGrid_System = NULL;
-
- if( m_nParameters > 0 )
- {
- for(int i=0; i<m_nParameters; i++)
- {
- delete(m_Parameters[i]);
- }
-
- SG_Free(m_Parameters);
-
- m_Parameters = NULL;
- m_nParameters = 0;
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CSG_Parameters::Set_Identifier(const SG_Char *String)
-{
- if( String )
- {
- m_Identifier.Printf(String);
- }
- else
- {
- m_Identifier.Clear();
- }
-}
-
-const SG_Char * CSG_Parameters::Get_Identifier(void)
-{
- return( m_Identifier );
-}
-
-//---------------------------------------------------------
-void CSG_Parameters::Set_Name(const SG_Char *String)
-{
- if( String )
- {
- m_Name.Printf(String);
- }
- else
- {
- m_Name.Clear();
- }
-}
-
-const SG_Char * CSG_Parameters::Get_Name(void)
-{
- return( m_Name );
-}
-
-//---------------------------------------------------------
-void CSG_Parameters::Set_Description(const SG_Char *String)
-{
- if( String )
- {
- m_Description.Printf(String);
- }
- else
- {
- m_Description.Clear();
- }
-}
-
-const SG_Char * CSG_Parameters::Get_Description(void)
-{
- return( m_Description );
-}
-
-//---------------------------------------------------------
-void CSG_Parameters::Set_Translation(CSG_Translator &Translator)
-{
- m_Name = Translator.Get_Translation(m_Name);
- m_Description = Translator.Get_Translation(m_Description);
-
- for(int i=0; i<m_nParameters; i++)
- {
- m_Parameters[i]->m_Name = Translator.Get_Translation(m_Parameters[i]->m_Name);
- m_Parameters[i]->m_Description = Translator.Get_Translation(m_Parameters[i]->m_Description);
- }
-}
-
-//---------------------------------------------------------
-void CSG_Parameters::Set_Enabled(bool bEnabled)
-{
- for(int i=0; i<m_nParameters; i++)
- {
- m_Parameters[i]->Set_Enabled(bEnabled);
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Node(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{
- return( _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Node, PARAMETER_INFORMATION) );
-}
-
-//---------------------------------------------------------
-/**
- * Following parameter types can be used:
- * PARAMETER_TYPE_Bool
- * PARAMETER_TYPE_Int
- * PARAMETER_TYPE_Double
- * PARAMETER_TYPE_Degree
- * PARAMETER_TYPE_Color
-*/
-CSG_Parameter * CSG_Parameters::Add_Value(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
-{
- return( _Add_Value(pParent, Identifier, Name, Description, false, Type, Value, Minimum, bMinimum, Maximum, bMaximum) );
-}
-
-CSG_Parameter * CSG_Parameters::Add_Info_Value(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value)
-{
- return( _Add_Value(pParent, Identifier, Name, Description, true, Type, Value, 0.0, false, 0.0, false) );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Range(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, double Range_Min, double Range_Max, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
-{
- return( _Add_Range(pParent, Identifier, Name, Description, false, Range_Min, Range_Max, Minimum, bMinimum, Maximum, bMaximum) );
-}
-
-CSG_Parameter * CSG_Parameters::Add_Info_Range(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, double Range_Min, double Range_Max)
-{
- return( _Add_Range(pParent, Identifier, Name, Description, true, Range_Min, Range_Max, 0.0, false, 0.0, false) );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Choice(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *Items, int Default)
-{
- CSG_Parameter *pParameter;
- CSG_Parameter_Choice *m_pData;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Choice, 0);
-
- m_pData = (CSG_Parameter_Choice *)pParameter->m_pData;
- m_pData->Set_Items(Items);
-
- pParameter->Set_Value(Default);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_String(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *String, bool bLongText, bool bPassword)
-{
- return( _Add_String(pParent, Identifier, Name, Description, false, String, bLongText, bPassword) );
-}
-
-CSG_Parameter * CSG_Parameters::Add_Info_String(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *String, bool bLongText)
-{
- return( _Add_String(pParent, Identifier, Name, Description, true, String, bLongText, false) );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_FilePath(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *Filter, const SG_Char *Default, bool bSave, bool bDirectory, bool bMultiple)
-{
- CSG_Parameter *pParameter;
- CSG_Parameter_File_Name *m_pData;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_FilePath, 0);
-
- m_pData = (CSG_Parameter_File_Name *)pParameter->m_pData;
- m_pData->Set_Filter (Filter);
- m_pData->Set_Flag_Save (bSave);
- m_pData->Set_Flag_Multiple (bMultiple);
- m_pData->Set_Flag_Directory (bDirectory);
-
- pParameter->Set_Value((void *)Default);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Font(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, wxFont *pInit)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Font, 0);
-
- if( pInit )
- {
- pParameter->Set_Value(pInit);
- }
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Colors(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Colors *pInit)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Colors, 0);
-
- pParameter->asColors()->Assign(pInit);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_FixedTable(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Table *pTemplate)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_FixedTable, 0);
-
- pParameter->asTable()->Create(pTemplate);
-
- if( pTemplate )
- {
- for(int i=0; i<pTemplate->Get_Record_Count(); i++)
- {
- pParameter->asTable()->Add_Record(pTemplate->Get_Record(i));
- }
- }
-
- return( pParameter );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Grid_System(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Grid_System *pInit)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Grid_System, 0);
-
- if( pInit )
- {
- pParameter->asGrid_System()->Assign(*pInit);
- }
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Grid(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, bool bSystem_Dependent, TSG_Data_Type Preferred_Type)
-{
- CSG_Parameter *pParameter;
-
- if( !pParent || pParent->Get_Type() != PARAMETER_TYPE_Grid_System )
- {
- if( bSystem_Dependent && m_pGrid_System )
- {
- pParent = m_pGrid_System;
- }
- else
- {
- pParent = Add_Grid_System(pParent, CSG_String::Format(SG_T("%s_GRIDSYSTEM"), Identifier), LNG("[PRM] Grid system"), SG_T(""));
- }
- }
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Grid, Constraint);
-
- ((CSG_Parameter_Grid *)pParameter->m_pData)->Set_Preferred_Type(Preferred_Type);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Grid_Output(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
-
- ((CSG_Parameter_Data_Object_Output *)pParameter->Get_Data())->Set_DataObject_Type(DATAOBJECT_TYPE_Grid);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Grid_List(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, bool bSystem_Dependent)
-{
- CSG_Parameter *pParameter;
-
- if( bSystem_Dependent && (!pParent || pParent->Get_Type() != PARAMETER_TYPE_Grid_System) )
- {
- pParent = m_pGrid_System;
- }
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Grid_List, Constraint);
-
- return( pParameter );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Table_Field(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, bool bAllowNone)
-{
- if( pParent
- && ( pParent->Get_Type() == PARAMETER_TYPE_Table
- || pParent->Get_Type() == PARAMETER_TYPE_Shapes
- || pParent->Get_Type() == PARAMETER_TYPE_TIN ) )
- {
- return( _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Table_Field, bAllowNone ? PARAMETER_OPTIONAL : 0) );
- }
-
- return( NULL );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Table(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Table, Constraint);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Table_Output(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
-
- ((CSG_Parameter_Data_Object_Output *)pParameter->Get_Data())->Set_DataObject_Type(DATAOBJECT_TYPE_Table);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Table_List(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Table_List, Constraint);
-
- return( pParameter );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Shapes(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, TSG_Shape_Type Shape_Type)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Shapes, Constraint);
-
- ((CSG_Parameter_Shapes *)pParameter->m_pData)->Set_Shape_Type(Shape_Type);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Shapes_Output(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
-
- ((CSG_Parameter_Data_Object_Output *)pParameter->Get_Data())->Set_DataObject_Type(DATAOBJECT_TYPE_Shapes);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Shapes_List(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, TSG_Shape_Type Type)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Shapes_List, Constraint);
-
- ((CSG_Parameter_Shapes_List *)pParameter->m_pData)->Set_Shape_Type(Type);
-
- return( pParameter );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_TIN(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_TIN, Constraint);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_TIN_Output(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
-
- ((CSG_Parameter_Data_Object_Output *)pParameter->Get_Data())->Set_DataObject_Type(DATAOBJECT_TYPE_TIN);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_TIN_List(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_TIN_List, Constraint);
-
- return( pParameter );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_PointCloud(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_PointCloud, Constraint);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_PointCloud_Output(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
-
- ((CSG_Parameter_Data_Object_Output *)pParameter->Get_Data())->Set_DataObject_Type(DATAOBJECT_TYPE_PointCloud);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_PointCloud_List(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_PointCloud_List, Constraint);
-
- return( pParameter );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Add_Parameters(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Parameters, 0);
-
- pParameter->asParameters()->m_Callback = m_Callback;
-
- return( pParameter );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::_Add_Value(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, bool bInformation, TSG_Parameter_Type Type, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
-{
- CSG_Parameter *pParameter;
- CSG_Parameter_Value *m_pData;
-
- switch( Type ) // Check if Type is valid...
- {
- case PARAMETER_TYPE_Bool:
- case PARAMETER_TYPE_Int:
- case PARAMETER_TYPE_Double:
- case PARAMETER_TYPE_Degree:
- case PARAMETER_TYPE_Color:
- break;
-
- default:
- Type = PARAMETER_TYPE_Double; // if not valid set Type to [double]...
- break;
- }
-
- pParameter = _Add(pParent, Identifier, Name, Description, Type, bInformation ? PARAMETER_INFORMATION : 0);
-
- if( !bInformation )
- {
- switch( Type )
- {
- default:
- break;
-
- case PARAMETER_TYPE_Int:
- case PARAMETER_TYPE_Double:
- case PARAMETER_TYPE_Degree:
- m_pData = (CSG_Parameter_Value *)pParameter->m_pData;
- m_pData->Set_Minimum(Minimum, bMinimum);
- m_pData->Set_Maximum(Maximum, bMaximum);
- break;
- }
- }
-
- pParameter->Set_Value(Value);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::_Add_Range(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, bool bInformation, double Default_Min, double Default_Max, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
-{
- double d;
- CSG_Parameter *pParameter;
- CSG_Parameter_Range *m_pData;
-
- //-----------------------------------------------------
- if( Default_Min > Default_Max )
- {
- d = Default_Min;
- Default_Min = Default_Max;
- Default_Max = d;
- }
-
- //-----------------------------------------------------
- pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Range, bInformation ? PARAMETER_INFORMATION : 0);
-
- m_pData = pParameter->asRange();
-
- m_pData->Get_LoParm()->asValue()->Set_Minimum(Minimum, bMinimum);
- m_pData->Get_LoParm()->asValue()->Set_Maximum(Maximum, bMaximum);
- m_pData->Get_HiParm()->asValue()->Set_Minimum(Minimum, bMinimum);
- m_pData->Get_HiParm()->asValue()->Set_Maximum(Maximum, bMaximum);
-
- m_pData->Set_LoVal(Default_Min);
- m_pData->Set_HiVal(Default_Max);
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::_Add_String(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, bool bInformation, const SG_Char *String, bool bLongText, bool bPassword)
-{
- CSG_Parameter *pParameter;
-
- pParameter = _Add(pParent, Identifier, Name, Description, bLongText ? PARAMETER_TYPE_Text : PARAMETER_TYPE_String, bInformation ? PARAMETER_INFORMATION : 0);
-
- pParameter->Set_Value((void *)String);
-
- ((CSG_Parameter_String *)pParameter->Get_Data())->Set_Password(bPassword);
-
- return( pParameter );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::_Add(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, int Constraint)
-{
- CSG_Parameter *pParameter;
-
- if( Identifier && *Identifier )
- {
- pParameter = new CSG_Parameter(this, pParent, Identifier, Name, Description, Type, Constraint);
- }
- else
- {
- pParameter = new CSG_Parameter(this, pParent, CSG_String::Format(SG_T("%d"), m_nParameters), Name, Description, Type, Constraint);
- }
-
- m_Parameters = (CSG_Parameter **)SG_Realloc(m_Parameters, (m_nParameters + 1) * sizeof(CSG_Parameter *));
- m_Parameters[m_nParameters++] = pParameter;
-
- return( pParameter );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::_Add(CSG_Parameter *pSource)
-{
- CSG_Parameter *pParameter;
-
- if( pSource )
- {
- pParameter = _Add(
- pSource->Get_Parent() ? Get_Parameter(pSource->Get_Parent()->Get_Identifier()) : NULL,
- pSource->Get_Identifier(),
- pSource->Get_Name(),
- pSource->Get_Description(),
- pSource->Get_Type(),
- pSource->m_pData->Get_Constraint()
- );
-
- pParameter->Assign(pSource);
- }
- else
- {
- pParameter = NULL;
- }
-
- return( pParameter );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Get_Parameter(const SG_Char *Identifier)
-{
- int i;
-
- if( m_Parameters && Identifier )
- {
- for(i=0; i<m_nParameters; i++)
- {
- if( !m_Parameters[i]->m_Identifier.Cmp(Identifier) )
- {
- return( m_Parameters[i] );
- }
- }
- }
-
- return( NULL );
-}
-
-//---------------------------------------------------------
-CSG_Parameter * CSG_Parameters::Get_Parameter(int iParameter)
-{
- if( m_Parameters && iParameter >= 0 && iParameter < m_nParameters )
- {
- return( m_Parameters[iParameter] );
- }
-
- return( NULL );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// Callback //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CSG_Parameters::Set_Callback_On_Parameter_Changed(TSG_PFNC_Parameter_Changed Callback)
-{
- m_Callback = Callback;
-}
-
-//---------------------------------------------------------
-void CSG_Parameters::Set_Callback(bool bActive)
-{
- m_bCallback = bActive;
-}
-
-//---------------------------------------------------------
-bool CSG_Parameters::_On_Parameter_Changed(CSG_Parameter *pSender)
-{
- if( m_Callback && m_bCallback )
- {
- m_bCallback = false;
- m_Callback(pSender);
- m_bCallback = true;
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSG_Parameters::Set_Parameter(const SG_Char *Identifier, CSG_Parameter *pSource)
-{
- CSG_Parameter *pTarget;
-
- if( pSource != NULL && (pTarget = Get_Parameter(Identifier)) != NULL && pSource->Get_Type() == pTarget->Get_Type() )
- {
- switch( pTarget->Get_Type() )
- {
- default:
- return( pTarget->Assign(pSource) );
-
- case PARAMETER_TYPE_DataObject_Output:
- case PARAMETER_TYPE_Grid:
- case PARAMETER_TYPE_Table:
- case PARAMETER_TYPE_Shapes:
- case PARAMETER_TYPE_TIN:
- return( pTarget->Set_Value(pSource->asDataObject()) );
- }
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CSG_Parameters::Set_Parameter(const SG_Char *Identifier, int Type, int Value)
-{
- CSG_Parameter *pTarget;
-
- if( (pTarget = Get_Parameter(Identifier)) != NULL && Type == pTarget->Get_Type() )
- {
- pTarget->Set_Value(Value);
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CSG_Parameters::Set_Parameter(const SG_Char *Identifier, int Type, double Value)
-{
- CSG_Parameter *pTarget;
-
- if( (pTarget = Get_Parameter(Identifier)) != NULL && Type == pTarget->Get_Type() )
- {
- pTarget->Set_Value(Value);
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CSG_Parameters::Set_Parameter(const SG_Char *Identifier, int Type, void *Value)
-{
- CSG_Parameter *pTarget;
-
- if( (pTarget = Get_Parameter(Identifier)) != NULL && Type == pTarget->Get_Type() )
- {
- pTarget->Set_Value(Value);
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CSG_Parameters::Set_Parameter(const SG_Char *Identifier, int Type, const SG_Char *Value)
-{
- CSG_Parameter *pTarget;
-
- if( (pTarget = Get_Parameter(Identifier)) != NULL && Type == pTarget->Get_Type() )
- {
- pTarget->Set_Value(Value);
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-int CSG_Parameters::Assign(CSG_Parameters *pSource)
-{
- int i;
- CSG_Parameter *pParameter;
-
- if( pSource && pSource != this )
- {
- Destroy();
-
- m_pOwner = pSource->Get_Owner();
-
- Set_Identifier (pSource->Get_Identifier());
- Set_Name (pSource->Get_Name());
- Set_Description (pSource->Get_Description());
-
- m_Callback = pSource->m_Callback;
- m_bCallback = pSource->m_bCallback;
-
- if( pSource->Get_Count() > 0 )
- {
- for(i=0; i<pSource->Get_Count(); i++)
- {
- _Add(pSource->Get_Parameter(i));
- }
-
- for(i=0; i<pSource->Get_Count(); i++)
- {
- if( Get_Parameter(i) && (pParameter = pSource->Get_Parameter(i)->Get_Parent()) != NULL )
- {
- Get_Parameter(i)->m_pParent = Get_Parameter(pParameter->Get_Identifier());
- }
- }
-
- if( pSource->m_pGrid_System )
- {
- m_pGrid_System = Get_Parameter(pSource->m_pGrid_System->Get_Identifier());
- }
- }
-
- return( m_nParameters );
- }
-
- return( -1 );
-}
-
-//---------------------------------------------------------
-int CSG_Parameters::Assign_Values(CSG_Parameters *pSource)
-{
- if( pSource && pSource != this )
- {
- int i, n;
-
- for(i=0, n=0; i<pSource->Get_Count(); i++)
- {
- CSG_Parameter *pParameter = Get_Parameter(pSource->Get_Parameter(i)->Get_Identifier());
-
- if( pParameter && pParameter->Get_Type() == pSource->Get_Parameter(i)->Get_Type() )
- {
- pParameter->Assign(pSource->Get_Parameter(i));
- n++;
- }
- }
-
- return( n );
- }
-
- return( 0 );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSG_Parameters::DataObjects_Check(bool bSilent)
-{
- bool bInvalid, bResult = true;
- CSG_String s;
-
- //-----------------------------------------------------
- for(int i=0; i<Get_Count(); i++)
- {
- switch( m_Parameters[i]->Get_Type() )
- {
- default:
- bInvalid = false;
- break;
-
- case PARAMETER_TYPE_Parameters:
- bInvalid = m_Parameters[i]->asParameters()->DataObjects_Check(bSilent) == false;
- break;
-
- case PARAMETER_TYPE_Grid:
- case PARAMETER_TYPE_Table:
- case PARAMETER_TYPE_Shapes:
- case PARAMETER_TYPE_TIN:
- bInvalid = m_Parameters[i]->is_Input() == true
- && m_Parameters[i]->is_Optional() == false
- && m_Parameters[i]->asDataObject() == NULL;
- break;
-
- case PARAMETER_TYPE_Grid_List:
- case PARAMETER_TYPE_Table_List:
- case PARAMETER_TYPE_Shapes_List:
- case PARAMETER_TYPE_TIN_List:
- case PARAMETER_TYPE_PointCloud_List:
- bInvalid = m_Parameters[i]->is_Input() == true
- && m_Parameters[i]->is_Optional() == false
- && m_Parameters[i]->asList()->Get_Count() == 0;
- break;
- }
-
- if( bInvalid )
- {
- bResult = false;
- s.Append(CSG_String::Format(SG_T("\n%s: %s"), m_Parameters[i]->Get_Type_Name(), m_Parameters[i]->Get_Name()));
- }
- }
-
- //-----------------------------------------------------
- if( !bResult && !bSilent )
- {
- SG_UI_Dlg_Message(CSG_String::Format(SG_T("%s\n%s"), LNG("[DLG] Invalid parameters!"), s.c_str() ), Get_Name() );
- }
-
- return( bResult );
-}
-
-//---------------------------------------------------------
-bool CSG_Parameters::DataObjects_Create(void)
-{
- if( m_bManaged )
- {
- for(int i=0; i<Get_Count(); i++)
- {
- CSG_Data_Object *pDataObject;
- CSG_Grid_System *pGrid_System;
- CSG_Parameter *p = m_Parameters[i];
-
- if( p->Get_Type() == PARAMETER_TYPE_Parameters )
- {
- p->asParameters()->DataObjects_Create();
- }
- else if( p->Get_Type() == PARAMETER_TYPE_DataObject_Output )
- {
- p->Set_Value(DATAOBJECT_NOTSET);
- }
- else if( p->is_DataObject() && p->is_Output()
- && ( (p->asDataObject() == DATAOBJECT_CREATE)
- || (p->asDataObject() == NULL && !p->is_Optional()) ) )
- {
- pDataObject = NULL;
-
- switch( p->Get_Type() )
- {
- default:
- break;
-
- case PARAMETER_TYPE_Grid:
- if( p->Get_Parent() && p->Get_Parent()->Get_Type() == PARAMETER_TYPE_Grid_System
- && (pGrid_System = p->Get_Parent()->asGrid_System()) != NULL && pGrid_System->is_Valid() )
- {
- pDataObject = SG_Create_Grid(*pGrid_System, ((CSG_Parameter_Grid *)p->Get_Data())->Get_Preferred_Type());
- }
- break;
-
- case PARAMETER_TYPE_Table:
- pDataObject = SG_Create_Table();
- break;
-
- case PARAMETER_TYPE_Shapes:
- pDataObject = SG_Create_Shapes(((CSG_Parameter_Shapes *)p->Get_Data())->Get_Shape_Type());
- break;
-
- case PARAMETER_TYPE_PointCloud:
- pDataObject = SG_Create_PointCloud();
- break;
-
- case PARAMETER_TYPE_TIN:
- pDataObject = SG_Create_TIN();
- break;
- }
-
- p->Set_Value(pDataObject);
-
- if( pDataObject )
- {
- pDataObject->Set_Name(p->Get_Name());
- SG_UI_DataObject_Add(pDataObject, false);
- }
- }
- }
- }
-
- return( true );
-}
-
-//---------------------------------------------------------
-bool CSG_Parameters::DataObjects_Synchronize(void)
-{
- if( m_bManaged )
- {
- for(int i=0; i<Get_Count(); i++)
- {
- CSG_Parameter *p = m_Parameters[i];
-
- if( p->Get_Type() == PARAMETER_TYPE_Parameters )
- {
- p->asParameters()->DataObjects_Synchronize();
- }
- else
- {
- if( p->Get_Type() == PARAMETER_TYPE_Shapes && p->asShapes() && p->asShapes()->Get_Type() == SHAPE_TYPE_Undefined )
- {
- delete(p->asShapes());
- p->Set_Value(DATAOBJECT_NOTSET);
- }
-
- if( p->is_Output() )
- {
- if( p->is_DataObject() )
- {
- if( p->asDataObject() )
- {
- SG_UI_DataObject_Add (p->asDataObject(), false);
- SG_UI_DataObject_Update (p->asDataObject(), false, NULL);
- }
- }
- else if( p->is_DataObject_List() )
- {
- for(int j=0; j<p->asList()->Get_Count(); j++)
- {
- SG_UI_DataObject_Add (p->asList()->asDataObject(j), false);
- SG_UI_DataObject_Update (p->asList()->asDataObject(j), false, NULL);
- }
- }
- }
- }
- }
- }
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSG_Parameters::Get_String(CSG_String &String, bool bOptionsOnly)
-{
- bool bResult = false;
-
- if( Get_Count() > 0 )
- {
- for(int i=0; i<Get_Count(); i++)
- {
- CSG_Parameter *p = m_Parameters[i];
-
- if( (!bOptionsOnly || p->is_Option()) && !p->is_Information() && !(p->Get_Type() == PARAMETER_TYPE_String && ((CSG_Parameter_String *)p->Get_Data())->is_Password()) )
- {
- bResult = true;
-
- // String.Append(CSG_String::Format(SG_T("[%s] %s: %s\n"),
- // p->Get_Type_Name(),
- String.Append(CSG_String::Format(SG_T("%s: %s\n"),
- p->Get_Name(),
- p->asString())
- );
- }
- }
- }
-
- return( bResult );
-}
-
-//---------------------------------------------------------
-bool CSG_Parameters::Msg_String(bool bOptionsOnly)
-{
- CSG_String s;
-
- if( Get_String(s, bOptionsOnly) )
- {
- SG_UI_Msg_Add_Execution(SG_T("\n"), false);
- SG_UI_Msg_Add_Execution(bOptionsOnly ? LNG("[CAP] Options") : LNG("[CAP] Parameters"), false);
- SG_UI_Msg_Add_Execution(SG_T("\n"), false);
- SG_UI_Msg_Add_Execution(s, false, SG_UI_MSG_STYLE_01);
-
- return( true );
- }
-
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Application Programming Interface //
+// //
+// Library: SAGA_API //
+// //
+//-------------------------------------------------------//
+// //
+// parameters.cpp //
+// //
+// Copyright (C) 2005 by Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. //
+// //
+// This library is free software; you can redistribute //
+// it and/or modify it under the terms of the GNU Lesser //
+// General Public License as published by the Free //
+// Software Foundation, version 2.1 of the License. //
+// //
+// This library is distributed in the hope that it will //
+// be useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU Lesser General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU Lesser //
+// General Public License along with this program; if //
+// not, write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "parameters.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Parameters::CSG_Parameters(void)
+{
+ _On_Construction();
+}
+
+//---------------------------------------------------------
+CSG_Parameters::CSG_Parameters(void *pOwner, const SG_Char *Name, const SG_Char *Description, const SG_Char *Identifier, bool bGrid_System)
+{
+ _On_Construction();
+
+ Create(pOwner, Name, Description, Identifier, bGrid_System);
+}
+
+//---------------------------------------------------------
+CSG_Parameters::~CSG_Parameters(void)
+{
+ Destroy();
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CSG_Parameters::_On_Construction(void)
+{
+ m_pOwner = NULL;
+
+ m_Parameters = NULL;
+ m_nParameters = 0;
+
+ m_Callback = NULL;
+ m_bCallback = false;
+
+ m_pGrid_System = NULL;
+
+ m_bManaged = true;
+}
+
+//---------------------------------------------------------
+void CSG_Parameters::Create(void *pOwner, const SG_Char *Name, const SG_Char *Description, const SG_Char *Identifier, bool bGrid_System)
+{
+ Destroy();
+
+ m_pOwner = pOwner;
+
+ Set_Identifier (Identifier);
+ Set_Name (Name);
+ Set_Description (Description);
+
+ if( bGrid_System )
+ {
+ m_pGrid_System = Add_Grid_System(
+ NULL, SG_T("PARAMETERS_GRID_SYSTEM"),
+ LNG("[PRM] Grid system"),
+ LNG("[PRM] Grid system")
+ );
+ }
+}
+
+//---------------------------------------------------------
+void CSG_Parameters::Destroy(void)
+{
+ m_pOwner = NULL;
+ m_pGrid_System = NULL;
+
+ Del_Parameters();
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CSG_Parameters::Set_Identifier(const SG_Char *String)
+{
+ if( String )
+ {
+ m_Identifier = String;
+ }
+ else
+ {
+ m_Identifier.Clear();
+ }
+}
+
+const SG_Char * CSG_Parameters::Get_Identifier(void)
+{
+ return( m_Identifier );
+}
+
+//---------------------------------------------------------
+void CSG_Parameters::Set_Name(const SG_Char *String)
+{
+ if( String )
+ {
+ m_Name = String;
+ }
+ else
+ {
+ m_Name.Clear();
+ }
+}
+
+const SG_Char * CSG_Parameters::Get_Name(void)
+{
+ return( m_Name );
+}
+
+//---------------------------------------------------------
+void CSG_Parameters::Set_Description(const SG_Char *String)
+{
+ if( String )
+ {
+ m_Description = String;
+ }
+ else
+ {
+ m_Description.Clear();
+ }
+}
+
+const SG_Char * CSG_Parameters::Get_Description(void)
+{
+ return( m_Description );
+}
+
+//---------------------------------------------------------
+void CSG_Parameters::Set_Translation(CSG_Translator &Translator)
+{
+ m_Name = Translator.Get_Translation(m_Name);
+ m_Description = Translator.Get_Translation(m_Description);
+
+ for(int i=0; i<m_nParameters; i++)
+ {
+ m_Parameters[i]->m_Name = Translator.Get_Translation(m_Parameters[i]->m_Name);
+ m_Parameters[i]->m_Description = Translator.Get_Translation(m_Parameters[i]->m_Description);
+ }
+}
+
+//---------------------------------------------------------
+void CSG_Parameters::Set_Enabled(bool bEnabled)
+{
+ for(int i=0; i<m_nParameters; i++)
+ {
+ m_Parameters[i]->Set_Enabled(bEnabled);
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Node(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{
+ return( _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Node, PARAMETER_INFORMATION) );
+}
+
+//---------------------------------------------------------
+/**
+ * Following parameter types can be used:
+ * PARAMETER_TYPE_Bool
+ * PARAMETER_TYPE_Int
+ * PARAMETER_TYPE_Double
+ * PARAMETER_TYPE_Degree
+ * PARAMETER_TYPE_Color
+*/
+CSG_Parameter * CSG_Parameters::Add_Value(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
+{
+ return( _Add_Value(pParent, Identifier, Name, Description, false, Type, Value, Minimum, bMinimum, Maximum, bMaximum) );
+}
+
+CSG_Parameter * CSG_Parameters::Add_Info_Value(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value)
+{
+ return( _Add_Value(pParent, Identifier, Name, Description, true, Type, Value, 0.0, false, 0.0, false) );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Range(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, double Range_Min, double Range_Max, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
+{
+ return( _Add_Range(pParent, Identifier, Name, Description, false, Range_Min, Range_Max, Minimum, bMinimum, Maximum, bMaximum) );
+}
+
+CSG_Parameter * CSG_Parameters::Add_Info_Range(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, double Range_Min, double Range_Max)
+{
+ return( _Add_Range(pParent, Identifier, Name, Description, true, Range_Min, Range_Max, 0.0, false, 0.0, false) );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Choice(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *Items, int Default)
+{
+ CSG_Parameter *pParameter;
+ CSG_Parameter_Choice *m_pData;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Choice, 0);
+
+ m_pData = (CSG_Parameter_Choice *)pParameter->m_pData;
+ m_pData->Set_Items(Items);
+
+ pParameter->Set_Value(Default);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_String(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *String, bool bLongText, bool bPassword)
+{
+ return( _Add_String(pParent, Identifier, Name, Description, false, String, bLongText, bPassword) );
+}
+
+CSG_Parameter * CSG_Parameters::Add_Info_String(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *String, bool bLongText)
+{
+ return( _Add_String(pParent, Identifier, Name, Description, true, String, bLongText, false) );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_FilePath(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *Filter, const SG_Char *Default, bool bSave, bool bDirectory, bool bMultiple)
+{
+ CSG_Parameter *pParameter;
+ CSG_Parameter_File_Name *m_pData;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_FilePath, 0);
+
+ m_pData = (CSG_Parameter_File_Name *)pParameter->m_pData;
+ m_pData->Set_Filter (Filter);
+ m_pData->Set_Flag_Save (bSave);
+ m_pData->Set_Flag_Multiple (bMultiple);
+ m_pData->Set_Flag_Directory (bDirectory);
+
+ pParameter->Set_Value((void *)Default);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Font(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, wxFont *pInit)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Font, 0);
+
+ if( pInit )
+ {
+ pParameter->Set_Value(pInit);
+ }
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Colors(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Colors *pInit)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Colors, 0);
+
+ pParameter->asColors()->Assign(pInit);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_FixedTable(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Table *pTemplate)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_FixedTable, 0);
+
+ pParameter->asTable()->Create(pTemplate);
+
+ if( pTemplate )
+ {
+ for(int i=0; i<pTemplate->Get_Record_Count(); i++)
+ {
+ pParameter->asTable()->Add_Record(pTemplate->Get_Record(i));
+ }
+ }
+
+ return( pParameter );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Grid_System(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Grid_System *pInit)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Grid_System, 0);
+
+ if( pInit )
+ {
+ pParameter->asGrid_System()->Assign(*pInit);
+ }
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Grid(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, bool bSystem_Dependent, TSG_Data_Type Preferred_Type)
+{
+ CSG_Parameter *pParameter;
+
+ if( !pParent || pParent->Get_Type() != PARAMETER_TYPE_Grid_System )
+ {
+ if( bSystem_Dependent && m_pGrid_System )
+ {
+ pParent = m_pGrid_System;
+ }
+ else
+ {
+ pParent = Add_Grid_System(pParent, CSG_String::Format(SG_T("%s_GRIDSYSTEM"), Identifier), LNG("[PRM] Grid system"), SG_T(""));
+ }
+ }
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Grid, Constraint);
+
+ ((CSG_Parameter_Grid *)pParameter->m_pData)->Set_Preferred_Type(Preferred_Type);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Grid_Output(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
+
+ ((CSG_Parameter_Data_Object_Output *)pParameter->Get_Data())->Set_DataObject_Type(DATAOBJECT_TYPE_Grid);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Grid_List(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, bool bSystem_Dependent)
+{
+ CSG_Parameter *pParameter;
+
+ if( bSystem_Dependent && (!pParent || pParent->Get_Type() != PARAMETER_TYPE_Grid_System) )
+ {
+ pParent = m_pGrid_System;
+ }
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Grid_List, Constraint);
+
+ return( pParameter );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Table_Field(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, bool bAllowNone)
+{
+ if( pParent
+ && ( pParent->Get_Type() == PARAMETER_TYPE_Table
+ || pParent->Get_Type() == PARAMETER_TYPE_Shapes
+ || pParent->Get_Type() == PARAMETER_TYPE_TIN
+ || pParent->Get_Type() == PARAMETER_TYPE_PointCloud ) )
+ {
+ return( _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Table_Field, bAllowNone ? PARAMETER_OPTIONAL : 0) );
+ }
+
+ return( NULL );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Table(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Table, Constraint);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Table_Output(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
+
+ ((CSG_Parameter_Data_Object_Output *)pParameter->Get_Data())->Set_DataObject_Type(DATAOBJECT_TYPE_Table);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Table_List(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Table_List, Constraint);
+
+ return( pParameter );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Shapes(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, TSG_Shape_Type Shape_Type)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Shapes, Constraint);
+
+ ((CSG_Parameter_Shapes *)pParameter->m_pData)->Set_Shape_Type(Shape_Type);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Shapes_Output(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
+
+ ((CSG_Parameter_Data_Object_Output *)pParameter->Get_Data())->Set_DataObject_Type(DATAOBJECT_TYPE_Shapes);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Shapes_List(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, TSG_Shape_Type Type)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Shapes_List, Constraint);
+
+ ((CSG_Parameter_Shapes_List *)pParameter->m_pData)->Set_Shape_Type(Type);
+
+ return( pParameter );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_TIN(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_TIN, Constraint);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_TIN_Output(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
+
+ ((CSG_Parameter_Data_Object_Output *)pParameter->Get_Data())->Set_DataObject_Type(DATAOBJECT_TYPE_TIN);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_TIN_List(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_TIN_List, Constraint);
+
+ return( pParameter );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_PointCloud(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_PointCloud, Constraint);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_PointCloud_Output(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_DataObject_Output, PARAMETER_OUTPUT_OPTIONAL);
+
+ ((CSG_Parameter_Data_Object_Output *)pParameter->Get_Data())->Set_DataObject_Type(DATAOBJECT_TYPE_PointCloud);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_PointCloud_List(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_PointCloud_List, Constraint);
+
+ return( pParameter );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Add_Parameters(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Parameters, 0);
+
+ pParameter->asParameters()->m_Callback = m_Callback;
+
+ return( pParameter );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::_Add_Value(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, bool bInformation, TSG_Parameter_Type Type, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
+{
+ CSG_Parameter *pParameter;
+ CSG_Parameter_Value *m_pData;
+
+ switch( Type ) // Check if Type is valid...
+ {
+ case PARAMETER_TYPE_Bool:
+ case PARAMETER_TYPE_Int:
+ case PARAMETER_TYPE_Double:
+ case PARAMETER_TYPE_Degree:
+ case PARAMETER_TYPE_Color:
+ break;
+
+ default:
+ Type = PARAMETER_TYPE_Double; // if not valid set Type to [double]...
+ break;
+ }
+
+ pParameter = _Add(pParent, Identifier, Name, Description, Type, bInformation ? PARAMETER_INFORMATION : 0);
+
+ if( !bInformation )
+ {
+ switch( Type )
+ {
+ default:
+ break;
+
+ case PARAMETER_TYPE_Int:
+ case PARAMETER_TYPE_Double:
+ case PARAMETER_TYPE_Degree:
+ m_pData = (CSG_Parameter_Value *)pParameter->m_pData;
+ m_pData->Set_Minimum(Minimum, bMinimum);
+ m_pData->Set_Maximum(Maximum, bMaximum);
+ break;
+ }
+ }
+
+ pParameter->Set_Value(Value);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::_Add_Range(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, bool bInformation, double Default_Min, double Default_Max, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
+{
+ double d;
+ CSG_Parameter *pParameter;
+ CSG_Parameter_Range *m_pData;
+
+ //-----------------------------------------------------
+ if( Default_Min > Default_Max )
+ {
+ d = Default_Min;
+ Default_Min = Default_Max;
+ Default_Max = d;
+ }
+
+ //-----------------------------------------------------
+ pParameter = _Add(pParent, Identifier, Name, Description, PARAMETER_TYPE_Range, bInformation ? PARAMETER_INFORMATION : 0);
+
+ m_pData = pParameter->asRange();
+
+ m_pData->Get_LoParm()->asValue()->Set_Minimum(Minimum, bMinimum);
+ m_pData->Get_LoParm()->asValue()->Set_Maximum(Maximum, bMaximum);
+ m_pData->Get_HiParm()->asValue()->Set_Minimum(Minimum, bMinimum);
+ m_pData->Get_HiParm()->asValue()->Set_Maximum(Maximum, bMaximum);
+
+ m_pData->Set_LoVal(Default_Min);
+ m_pData->Set_HiVal(Default_Max);
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::_Add_String(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, bool bInformation, const SG_Char *String, bool bLongText, bool bPassword)
+{
+ CSG_Parameter *pParameter;
+
+ pParameter = _Add(pParent, Identifier, Name, Description, bLongText ? PARAMETER_TYPE_Text : PARAMETER_TYPE_String, bInformation ? PARAMETER_INFORMATION : 0);
+
+ pParameter->Set_Value((void *)String);
+
+ ((CSG_Parameter_String *)pParameter->Get_Data())->Set_Password(bPassword);
+
+ return( pParameter );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::_Add(CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, int Constraint)
+{
+ CSG_Parameter *pParameter;
+
+ if( Identifier && *Identifier )
+ {
+ pParameter = new CSG_Parameter(this, pParent, Identifier, Name, Description, Type, Constraint);
+ }
+ else
+ {
+ pParameter = new CSG_Parameter(this, pParent, CSG_String::Format(SG_T("%d"), m_nParameters), Name, Description, Type, Constraint);
+ }
+
+ m_Parameters = (CSG_Parameter **)SG_Realloc(m_Parameters, (m_nParameters + 1) * sizeof(CSG_Parameter *));
+ m_Parameters[m_nParameters++] = pParameter;
+
+ return( pParameter );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::_Add(CSG_Parameter *pSource)
+{
+ CSG_Parameter *pParameter;
+
+ if( pSource )
+ {
+ pParameter = _Add(
+ pSource->Get_Parent() ? Get_Parameter(pSource->Get_Parent()->Get_Identifier()) : NULL,
+ pSource->Get_Identifier(),
+ pSource->Get_Name(),
+ pSource->Get_Description(),
+ pSource->Get_Type(),
+ pSource->m_pData->Get_Constraint()
+ );
+
+ pParameter->Assign(pSource);
+ }
+ else
+ {
+ pParameter = NULL;
+ }
+
+ return( pParameter );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Get_Parameter(int iParameter)
+{
+ if( m_Parameters && iParameter >= 0 && iParameter < m_nParameters )
+ {
+ return( m_Parameters[iParameter] );
+ }
+
+ return( NULL );
+}
+
+//---------------------------------------------------------
+CSG_Parameter * CSG_Parameters::Get_Parameter(const SG_Char *Identifier)
+{
+ if( m_Parameters && Identifier )
+ {
+ for(int i=0; i<m_nParameters; i++)
+ {
+ if( !m_Parameters[i]->m_Identifier.Cmp(Identifier) )
+ {
+ return( m_Parameters[i] );
+ }
+ }
+ }
+
+ return( NULL );
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters::Del_Parameter(int iParameter)
+{
+ if( m_Parameters && iParameter >= 0 && iParameter < m_nParameters )
+ {
+ delete(m_Parameters[iParameter]);
+
+ m_nParameters--;
+
+ for(; iParameter<m_nParameters; iParameter++)
+ {
+ m_Parameters[iParameter] = m_Parameters[iParameter + 1];
+ }
+
+ m_Parameters = (CSG_Parameter **)SG_Realloc(m_Parameters, m_nParameters * sizeof(CSG_Parameter *));
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters::Del_Parameter(const SG_Char *Identifier)
+{
+ if( m_Parameters && Identifier )
+ {
+ for(int i=0; i<m_nParameters; i++)
+ {
+ if( !m_Parameters[i]->m_Identifier.Cmp(Identifier) )
+ {
+ return( Del_Parameter(i) );
+ }
+ }
+ }
+
return( false );
}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSG_Parameters::Set_History(CSG_MetaData &MetaData, bool bOptions, bool bDataObjects)
-{
- CSG_MetaData *pEntry;
- CSG_Data_Object *pObject;
-
- //-----------------------------------------------------
- if( bOptions )
- {
- for(int i=0; i<Get_Count(); i++) // get options...
- {
- CSG_Parameter *p = m_Parameters[i];
-
- if( p->is_Option() && !p->is_Information()
- && !(p->Get_Type() == PARAMETER_TYPE_String && ((CSG_Parameter_String *)p->Get_Data())->is_Password())
- && !(p->Get_Type() == PARAMETER_TYPE_Grid_System && p->Get_Children_Count() > 0) )
- {
- p->Serialize(MetaData, true);
- }
-
- if( p->is_Parameters() )
- {
- p->asParameters()->Set_History(MetaData, true, false);
- }
- }
- }
-
- //-----------------------------------------------------
- if( bDataObjects )
- {
- for(int i=0; i<Get_Count(); i++) // get input with history...
- {
- CSG_Parameter *p = m_Parameters[i];
-
- if( p->Get_Type() == PARAMETER_TYPE_Grid_System && p->Get_Children_Count() > 0 )
- {
- CSG_MetaData *pGrids = NULL;
-
- for(int j=0; j<p->Get_Children_Count(); j++)
- {
- CSG_Parameter *pj = p->Get_Child(j);
-
- if( pj->is_Input() && pj->is_DataObject() && (pObject = pj->asDataObject()) != NULL )
- {
- if( pGrids == NULL )
- {
- pGrids = p->Serialize(MetaData, true);
- }
-
- pEntry = pj->Serialize(*pGrids, true);
- pEntry->Assign(pObject->Get_History(), true);
- }
- }
- }
- else if( p->is_Input() )
- {
- if( p->is_DataObject() && (pObject = p->asDataObject()) != NULL )
- {
- pEntry = p->Serialize(MetaData, true);
- pEntry->Assign(pObject->Get_History(), true);
- }
-
- if( p->is_DataObject_List() && p->asList()->Get_Count() > 0 )
- {
- MetaData.Add_Child(p->Get_Name(), p->asString());
-
- for(int j=0; j<p->asList()->Get_Count(); j++)
- {
- pEntry = p->Serialize(MetaData, true);
- pEntry->Assign(p->asList()->asDataObject(j)->Get_History(), true);
- }
- }
- }
-
- if( p->is_Parameters() )
- {
- p->asParameters()->Set_History(MetaData, false, true);
- }
- }
- }
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// Serialize //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSG_Parameters::Serialize(const CSG_String &File_Name, bool bSave)
-{
- CSG_MetaData MetaData;
-
- if( bSave )
- {
- return( Serialize(MetaData, true) && MetaData.Save(File_Name) );
- }
- else
- {
- return( MetaData.Load(File_Name) && Serialize(MetaData, false) );
- }
-}
-
-//---------------------------------------------------------
-bool CSG_Parameters::Serialize(CSG_MetaData &MetaData, bool bSave)
-{
- if( bSave )
- {
- MetaData.Destroy();
-
- MetaData.Set_Name (SG_T("PARAMETERS"));
- MetaData.Set_Property(SG_T("name"), Get_Name());
-
- for(int i=0; i<Get_Count(); i++)
- {
- m_Parameters[i]->Serialize(MetaData, true);
- }
- }
- else
- {
- if( MetaData.Get_Name().Cmp(SG_T("PARAMETERS")) )
- {
- return( false );
- }
-
- MetaData.Get_Property(SG_T("name"), m_Name);
-
- for(int i=0; i<MetaData.Get_Children_Count(); i++)
- {
- CSG_String Identifier;
- CSG_Parameter *pParameter;
-
- if( MetaData.Get_Child(i)->Get_Property(SG_T("id"), Identifier)
- && (pParameter = Get_Parameter(Identifier)) != NULL )
- {
- pParameter->Serialize(*MetaData.Get_Child(i), false);
- }
- }
- }
-
- return( true );
-}
-
-//---------------------------------------------------------
-// SAGA 2.0 compatibility...
-bool CSG_Parameters::Serialize_Compatibility(CSG_File &Stream)
-{
- CSG_Parameter *pParameter;
- CSG_String sLine;
-
- if( !Stream.is_Open() )
- {
- return( false );
- }
-
- //-----------------------------------------------------
- while( Stream.Read_Line(sLine) && sLine.Cmp(SG_T("[PARAMETER_ENTRIES_BEGIN]")) );
-
- if( sLine.Cmp(SG_T("[PARAMETER_ENTRIES_BEGIN]")) )
- {
- return( false );
- }
-
- //-----------------------------------------------------
- while( Stream.Read_Line(sLine) && sLine.Cmp(SG_T("[PARAMETER_ENTRIES_END]")) )
- {
- if( !sLine.Cmp(SG_T("[PARAMETER_ENTRY_BEGIN]"))
- && Stream.Read_Line(sLine) && (pParameter = Get_Parameter(sLine)) != NULL
- && Stream.Read_Line(sLine) && pParameter ->Get_Type() == sLine.asInt() )
- {
- int i;
- double d, e;
- TSG_Rect r;
- CSG_String s;
- CSG_Table t;
-
- switch( sLine.asInt() )
- {
- case 1: // PARAMETER_TYPE_Bool:
- case 2: // PARAMETER_TYPE_Int:
- case 6: // PARAMETER_TYPE_Choice:
- case 11: // PARAMETER_TYPE_Color:
- case 15: // PARAMETER_TYPE_Table_Field:
- SG_FILE_SCANF(Stream.Get_Stream(), SG_T("%d"), &i);
- pParameter->Set_Value(i);
- break;
-
- case 3: // PARAMETER_TYPE_Double:
- case 4: // PARAMETER_TYPE_Degree:
- SG_FILE_SCANF(Stream.Get_Stream(), SG_T("%lf"), &d);
- pParameter->Set_Value(d);
- break;
-
- case 5: // PARAMETER_TYPE_Range:
- SG_FILE_SCANF(Stream.Get_Stream(), SG_T("%lf %lf"), &d, &e);
- pParameter->asRange()->Set_Range(d, e);
- break;
-
- case 7: // PARAMETER_TYPE_String:
- case 9: // PARAMETER_TYPE_FilePath:
- Stream.Read_Line(sLine);
- pParameter->Set_Value(sLine);
- break;
-
- case 8: // PARAMETER_TYPE_Text:
- s.Clear();
- while( Stream.Read_Line(sLine) && sLine.Cmp(SG_T("[TEXT_ENTRY_END]")) )
- {
- s += sLine + SG_T("\n");
- }
- pParameter->Set_Value(s);
- break;
-
- case 10: // PARAMETER_TYPE_Font:
- Stream.Read(&i, sizeof(i));
- pParameter->Set_Value(i);
- break;
-
- case 12: // PARAMETER_TYPE_Colors:
- pParameter->asColors()->Serialize(Stream, false, false);
- break;
-
- case 13: // PARAMETER_TYPE_FixedTable:
- if( t.Serialize(Stream, false) )
- {
- pParameter->asTable()->Assign_Values(&t);
- }
- break;
-
- case 14: // PARAMETER_TYPE_Grid_System:
- Stream.Read(&d, sizeof(d));
- Stream.Read(&r, sizeof(r));
- pParameter->asGrid_System()->Assign(d, r);
- break;
-
- case 16: // PARAMETER_TYPE_Grid:
- case 17: // PARAMETER_TYPE_Table:
- case 18: // PARAMETER_TYPE_Shapes:
- case 19: // PARAMETER_TYPE_TIN:
- case 24: // PARAMETER_TYPE_DataObject_Output:
- if( Stream.Read_Line(sLine) )
- {
- if( !sLine.Cmp(SG_T("[ENTRY_DATAOBJECT_CREATE]")) )
- {
- pParameter->Set_Value(DATAOBJECT_CREATE);
- }
- else
- {
- pParameter->Set_Value(SG_UI_DataObject_Find(sLine, -1));
- }
- }
- break;
-
- case 20: // PARAMETER_TYPE_Grid_List:
- case 21: // PARAMETER_TYPE_Table_List:
- case 22: // PARAMETER_TYPE_Shapes_List:
- case 23: // PARAMETER_TYPE_TIN_List:
- while( Stream.Read_Line(sLine) && sLine.Cmp(SG_T("[ENTRY_DATAOBJECTLIST_END]")) )
- {
- CSG_Data_Object *pObject = SG_UI_DataObject_Find(sLine, -1);
-
- if( pObject )
- {
- pParameter->asList()->Add_Item(pObject);
- }
- }
- break;
-
- case 25: // PARAMETER_TYPE_Parameters:
- pParameter->asParameters()->Serialize_Compatibility(Stream);
- break;
- }
- }
- }
+
+//---------------------------------------------------------
+bool CSG_Parameters::Del_Parameters(void)
+{
+ if( m_nParameters > 0 )
+ {
+ for(int i=0; i<m_nParameters; i++)
+ {
+ delete(m_Parameters[i]);
+ }
+
+ SG_Free(m_Parameters);
+
+ m_Parameters = NULL;
+ m_nParameters = 0;
+ }
return( true );
}
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#ifdef _SAGA_UNICODE
-
-CSG_Parameter * CSG_Parameters::Get_Parameter(const char *Identifier)
-{ return( Get_Parameter(SG_STR_MBTOSG(Identifier)) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Node (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{ return( Add_Node (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Value (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
-{ return( Add_Value (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Type, Value, Minimum, bMinimum, Maximum, bMaximum) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Info_Value (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value)
-{ return( Add_Info_Value (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Type, Value) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Range (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, double Range_Min, double Range_Max, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
-{ return( Add_Range (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Range_Min, Range_Max, Minimum, bMinimum, Maximum, bMaximum) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Info_Range (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, double Range_Min, double Range_Max)
-{ return( Add_Info_Range (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Range_Min, Range_Max) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Choice (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *Items, int Default)
-{ return( Add_Choice (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Items, Default) ); }
-
-CSG_Parameter * CSG_Parameters::Add_String (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *String, bool bLongText, bool bPassword)
-{ return( Add_String (pParent, SG_STR_MBTOSG(Identifier), Name, Description, String, bLongText, bPassword) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Info_String (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *String, bool bLongText)
-{ return( Add_Info_String (pParent, SG_STR_MBTOSG(Identifier), Name, Description, String, bLongText) ); }
-
-CSG_Parameter * CSG_Parameters::Add_FilePath (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *Filter, const SG_Char *Default, bool bSave, bool bDirectory, bool bMultiple)
-{ return( Add_FilePath (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Filter, Default, bSave, bDirectory, bMultiple) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Font (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, class wxFont *pInit)
-{ return( Add_Font (pParent, SG_STR_MBTOSG(Identifier), Name, Description, pInit) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Colors (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Colors *pInit)
-{ return( Add_Colors (pParent, SG_STR_MBTOSG(Identifier), Name, Description, pInit) ); }
-
-CSG_Parameter * CSG_Parameters::Add_FixedTable (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Table *pTemplate)
-{ return( Add_FixedTable (pParent, SG_STR_MBTOSG(Identifier), Name, Description, pTemplate) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Grid_System (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Grid_System *pInit)
-{ return( Add_Grid_System (pParent, SG_STR_MBTOSG(Identifier), Name, Description, pInit) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Grid (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, bool bSystem_Dependent, TSG_Data_Type Preferred_Type)
-{ return( Add_Grid (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint, bSystem_Dependent, Preferred_Type) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Grid_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{ return( Add_Grid_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Grid_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, bool bSystem_Dependent)
-{ return( Add_Grid_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint, bSystem_Dependent) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Table_Field (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, bool bAllowNone)
-{ return( Add_Table_Field (pParent, SG_STR_MBTOSG(Identifier), Name, Description, bAllowNone) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Table (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
-{ return( Add_Table (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Table_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{ return( Add_Table_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Table_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
-{ return( Add_Table_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Shapes (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, TSG_Shape_Type Shape_Type)
-{ return( Add_Shapes (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint, Shape_Type) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Shapes_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{ return( Add_Shapes_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Shapes_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, TSG_Shape_Type Shape_Type)
-{ return( Add_Shapes_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint, Shape_Type) ); }
-
-CSG_Parameter * CSG_Parameters::Add_TIN (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
-{ return( Add_TIN (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
-
-CSG_Parameter * CSG_Parameters::Add_TIN_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{ return( Add_TIN_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
-
-CSG_Parameter * CSG_Parameters::Add_TIN_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
-{ return( Add_TIN_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
-
-CSG_Parameter * CSG_Parameters::Add_PointCloud (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
-{ return( Add_PointCloud (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
-
-CSG_Parameter * CSG_Parameters::Add_PointCloud_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{ return( Add_PointCloud_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
-
-CSG_Parameter * CSG_Parameters::Add_PointCloud_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
-{ return( Add_PointCloud_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
-
-CSG_Parameter * CSG_Parameters::Add_Parameters (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
-{ return( Add_Parameters (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
-
-#endif
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// Callback //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CSG_Parameters::Set_Callback_On_Parameter_Changed(TSG_PFNC_Parameter_Changed Callback)
+{
+ m_Callback = Callback;
+}
+
+//---------------------------------------------------------
+void CSG_Parameters::Set_Callback(bool bActive)
+{
+ m_bCallback = bActive;
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters::_On_Parameter_Changed(CSG_Parameter *pSender)
+{
+ if( m_Callback && m_bCallback )
+ {
+ m_bCallback = false;
+ m_Callback(pSender);
+ m_bCallback = true;
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Parameters::Set_Parameter(const SG_Char *Identifier, CSG_Parameter *pSource)
+{
+ CSG_Parameter *pTarget;
+
+ if( pSource != NULL && (pTarget = Get_Parameter(Identifier)) != NULL && pSource->Get_Type() == pTarget->Get_Type() )
+ {
+ switch( pTarget->Get_Type() )
+ {
+ default:
+ return( pTarget->Assign(pSource) );
+
+ case PARAMETER_TYPE_DataObject_Output:
+ case PARAMETER_TYPE_Grid:
+ case PARAMETER_TYPE_Table:
+ case PARAMETER_TYPE_Shapes:
+ case PARAMETER_TYPE_TIN:
+ return( pTarget->Set_Value(pSource->asDataObject()) );
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters::Set_Parameter(const SG_Char *Identifier, int Type, int Value)
+{
+ CSG_Parameter *pTarget;
+
+ if( (pTarget = Get_Parameter(Identifier)) != NULL && Type == pTarget->Get_Type() )
+ {
+ pTarget->Set_Value(Value);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters::Set_Parameter(const SG_Char *Identifier, int Type, double Value)
+{
+ CSG_Parameter *pTarget;
+
+ if( (pTarget = Get_Parameter(Identifier)) != NULL && Type == pTarget->Get_Type() )
+ {
+ pTarget->Set_Value(Value);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters::Set_Parameter(const SG_Char *Identifier, int Type, void *Value)
+{
+ CSG_Parameter *pTarget;
+
+ if( (pTarget = Get_Parameter(Identifier)) != NULL && Type == pTarget->Get_Type() )
+ {
+ pTarget->Set_Value(Value);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters::Set_Parameter(const SG_Char *Identifier, int Type, const SG_Char *Value)
+{
+ CSG_Parameter *pTarget;
+
+ if( (pTarget = Get_Parameter(Identifier)) != NULL && Type == pTarget->Get_Type() )
+ {
+ pTarget->Set_Value(Value);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int CSG_Parameters::Assign(CSG_Parameters *pSource)
+{
+ int i;
+ CSG_Parameter *pParameter;
+
+ if( pSource && pSource != this )
+ {
+ Destroy();
+
+ m_pOwner = pSource->Get_Owner();
+
+ Set_Identifier (pSource->Get_Identifier());
+ Set_Name (pSource->Get_Name());
+ Set_Description (pSource->Get_Description());
+
+ m_Callback = pSource->m_Callback;
+ m_bCallback = pSource->m_bCallback;
+
+ if( pSource->Get_Count() > 0 )
+ {
+ for(i=0; i<pSource->Get_Count(); i++)
+ {
+ _Add(pSource->Get_Parameter(i));
+ }
+
+ for(i=0; i<pSource->Get_Count(); i++)
+ {
+ if( Get_Parameter(i) && (pParameter = pSource->Get_Parameter(i)->Get_Parent()) != NULL )
+ {
+ Get_Parameter(i)->m_pParent = Get_Parameter(pParameter->Get_Identifier());
+ }
+ }
+
+ if( pSource->m_pGrid_System )
+ {
+ m_pGrid_System = Get_Parameter(pSource->m_pGrid_System->Get_Identifier());
+ }
+ }
+
+ return( m_nParameters );
+ }
+
+ return( -1 );
+}
+
+//---------------------------------------------------------
+int CSG_Parameters::Assign_Values(CSG_Parameters *pSource)
+{
+ if( pSource && pSource != this )
+ {
+ int i, n;
+
+ for(i=0, n=0; i<pSource->Get_Count(); i++)
+ {
+ CSG_Parameter *pParameter = Get_Parameter(pSource->Get_Parameter(i)->Get_Identifier());
+
+ if( pParameter && pParameter->Get_Type() == pSource->Get_Parameter(i)->Get_Type() )
+ {
+ pParameter->Assign(pSource->Get_Parameter(i));
+ n++;
+ }
+ }
+
+ return( n );
+ }
+
+ return( 0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Parameters::DataObjects_Check(bool bSilent)
+{
+ bool bInvalid, bResult = true;
+ CSG_String s;
+
+ //-----------------------------------------------------
+ for(int i=0; i<Get_Count(); i++)
+ {
+ switch( m_Parameters[i]->Get_Type() )
+ {
+ default:
+ bInvalid = false;
+ break;
+
+ case PARAMETER_TYPE_Parameters:
+ bInvalid = m_Parameters[i]->asParameters()->DataObjects_Check(bSilent) == false;
+ break;
+
+ case PARAMETER_TYPE_Grid:
+ case PARAMETER_TYPE_Table:
+ case PARAMETER_TYPE_Shapes:
+ case PARAMETER_TYPE_TIN:
+ bInvalid = m_Parameters[i]->is_Input() == true
+ && m_Parameters[i]->is_Optional() == false
+ && m_Parameters[i]->asDataObject() == NULL;
+ break;
+
+ case PARAMETER_TYPE_Grid_List:
+ case PARAMETER_TYPE_Table_List:
+ case PARAMETER_TYPE_Shapes_List:
+ case PARAMETER_TYPE_TIN_List:
+ case PARAMETER_TYPE_PointCloud_List:
+ bInvalid = m_Parameters[i]->is_Input() == true
+ && m_Parameters[i]->is_Optional() == false
+ && m_Parameters[i]->asList()->Get_Count() == 0;
+ break;
+ }
+
+ if( bInvalid )
+ {
+ bResult = false;
+ s.Append(CSG_String::Format(SG_T("\n%s: %s"), m_Parameters[i]->Get_Type_Name(), m_Parameters[i]->Get_Name()));
+ }
+ }
+
+ //-----------------------------------------------------
+ if( !bResult && !bSilent )
+ {
+ SG_UI_Dlg_Message(CSG_String::Format(SG_T("%s\n%s"), LNG("[DLG] Invalid parameters!"), s.c_str() ), Get_Name() );
+ }
+
+ return( bResult );
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters::DataObjects_Create(void)
+{
+ if( m_bManaged )
+ {
+ for(int i=0; i<Get_Count(); i++)
+ {
+ CSG_Data_Object *pDataObject;
+ CSG_Grid_System *pGrid_System;
+ CSG_Parameter *p = m_Parameters[i];
+
+ if( p->Get_Type() == PARAMETER_TYPE_Parameters )
+ {
+ p->asParameters()->DataObjects_Create();
+ }
+ else if( p->Get_Type() == PARAMETER_TYPE_DataObject_Output )
+ {
+ p->Set_Value(DATAOBJECT_NOTSET);
+ }
+ else if( p->is_DataObject() && p->is_Output() )
+ {
+ if( (p->asDataObject() == DATAOBJECT_CREATE)
+ || (p->asDataObject() == DATAOBJECT_NOTSET && !p->is_Optional()) )
+ {
+ pDataObject = NULL;
+
+ switch( p->Get_Type() )
+ {
+ default:
+ break;
+
+ case PARAMETER_TYPE_Grid:
+ if( p->Get_Parent() && p->Get_Parent()->Get_Type() == PARAMETER_TYPE_Grid_System
+ && (pGrid_System = p->Get_Parent()->asGrid_System()) != NULL && pGrid_System->is_Valid() )
+ {
+ pDataObject = SG_Create_Grid(*pGrid_System, ((CSG_Parameter_Grid *)p->Get_Data())->Get_Preferred_Type());
+ }
+ break;
+
+ case PARAMETER_TYPE_Table:
+ pDataObject = SG_Create_Table();
+ break;
+
+ case PARAMETER_TYPE_Shapes:
+ pDataObject = SG_Create_Shapes(((CSG_Parameter_Shapes *)p->Get_Data())->Get_Shape_Type());
+ break;
+
+ case PARAMETER_TYPE_PointCloud:
+ pDataObject = SG_Create_PointCloud();
+ break;
+
+ case PARAMETER_TYPE_TIN:
+ pDataObject = SG_Create_TIN();
+ break;
+ }
+
+ p->Set_Value(pDataObject);
+
+ if( pDataObject )
+ {
+ pDataObject->Set_Name(p->Get_Name());
+ SG_UI_DataObject_Add(pDataObject, false);
+ }
+ }
+ else if( p->Get_Type() == PARAMETER_TYPE_Shapes && p->asShapes() )
+ {
+ if( ((CSG_Parameter_Shapes *)p->Get_Data())->Get_Shape_Type() != SHAPE_TYPE_Undefined
+ && ((CSG_Parameter_Shapes *)p->Get_Data())->Get_Shape_Type() != p->asShapes()->Get_Type() )
+ {
+ pDataObject = SG_Create_Shapes(((CSG_Parameter_Shapes *)p->Get_Data())->Get_Shape_Type());
+ pDataObject->Set_Name(p->Get_Name());
+ p->Set_Value(pDataObject);
+ SG_UI_DataObject_Add(pDataObject, false);
+ }
+ }
+ }
+ }
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters::DataObjects_Synchronize(void)
+{
+ if( m_bManaged )
+ {
+ for(int i=0; i<Get_Count(); i++)
+ {
+ CSG_Parameter *p = m_Parameters[i];
+
+ if( p->Get_Type() == PARAMETER_TYPE_Parameters )
+ {
+ p->asParameters()->DataObjects_Synchronize();
+ }
+ else
+ {
+ if( p->Get_Type() == PARAMETER_TYPE_Shapes && p->asShapes() && p->asShapes()->Get_Type() == SHAPE_TYPE_Undefined )
+ {
+ delete(p->asShapes());
+ p->Set_Value(DATAOBJECT_NOTSET);
+ }
+
+ if( p->is_Output() )
+ {
+ if( p->is_DataObject() )
+ {
+ if( p->asDataObject() )
+ {
+ SG_UI_DataObject_Add (p->asDataObject(), false);
+ SG_UI_DataObject_Update (p->asDataObject(), false, NULL);
+ }
+ }
+ else if( p->is_DataObject_List() )
+ {
+ for(int j=0; j<p->asList()->Get_Count(); j++)
+ {
+ SG_UI_DataObject_Add (p->asList()->asDataObject(j), false);
+ SG_UI_DataObject_Update (p->asList()->asDataObject(j), false, NULL);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Parameters::Get_String(CSG_String &String, bool bOptionsOnly)
+{
+ bool bResult = false;
+
+ if( Get_Count() > 0 )
+ {
+ for(int i=0; i<Get_Count(); i++)
+ {
+ CSG_Parameter *p = m_Parameters[i];
+
+ if( (!bOptionsOnly || p->is_Option()) && !p->is_Information() && !(p->Get_Type() == PARAMETER_TYPE_String && ((CSG_Parameter_String *)p->Get_Data())->is_Password()) )
+ {
+ bResult = true;
+
+ // String.Append(CSG_String::Format(SG_T("[%s] %s: %s\n"),
+ // p->Get_Type_Name(),
+ String.Append(CSG_String::Format(SG_T("%s: %s\n"),
+ p->Get_Name(),
+ p->asString())
+ );
+ }
+ }
+ }
+
+ return( bResult );
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters::Msg_String(bool bOptionsOnly)
+{
+ CSG_String s;
+
+ if( Get_String(s, bOptionsOnly) )
+ {
+ SG_UI_Msg_Add_Execution(SG_T("\n"), false);
+ SG_UI_Msg_Add_Execution(bOptionsOnly ? LNG("[CAP] Options") : LNG("[CAP] Parameters"), false);
+ SG_UI_Msg_Add_Execution(SG_T("\n"), false);
+ SG_UI_Msg_Add_Execution(s, false, SG_UI_MSG_STYLE_01);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Parameters::Set_History(CSG_MetaData &MetaData, bool bOptions, bool bDataObjects)
+{
+ CSG_MetaData *pEntry;
+ CSG_Data_Object *pObject;
+
+ //-----------------------------------------------------
+ if( bOptions )
+ {
+ for(int i=0; i<Get_Count(); i++) // get options...
+ {
+ CSG_Parameter *p = m_Parameters[i];
+
+ if( p->is_Option() && !p->is_Information()
+ && !(p->Get_Type() == PARAMETER_TYPE_String && ((CSG_Parameter_String *)p->Get_Data())->is_Password())
+ && !(p->Get_Type() == PARAMETER_TYPE_Grid_System && p->Get_Children_Count() > 0) )
+ {
+ p->Serialize(MetaData, true);
+ }
+
+ //---------------------------------------------
+ else if( p->is_Parameters() )
+ {
+ p->asParameters()->Set_History(MetaData, true, false);
+ }
+ }
+ }
+
+ //-----------------------------------------------------
+ if( bDataObjects )
+ {
+ for(int i=0; i<Get_Count(); i++) // get input with history...
+ {
+ CSG_Parameter *p = m_Parameters[i];
+
+ //---------------------------------------------
+ if( p->Get_Type() == PARAMETER_TYPE_Grid_System && p->Get_Children_Count() > 0 )
+ {
+ CSG_Parameter *pSystem = p;
+ CSG_MetaData *pGrids = NULL;
+
+ for(int j=0; j<pSystem->Get_Children_Count(); j++)
+ {
+ p = pSystem->Get_Child(j);
+
+ if( p->is_Input() && p->is_DataObject() && (pObject = p->asDataObject()) != NULL )
+ {
+ if( pGrids == NULL )
+ {
+ pGrids = pSystem->Serialize(MetaData, true);
+ }
+
+ pEntry = p->Serialize(*pGrids, true);
+ pEntry->Assign(pObject->Get_History(), true);
+ }
+ }
+ }
+
+ //---------------------------------------------
+ else if( p->is_Input() )
+ {
+ if( p->is_DataObject() && (pObject = p->asDataObject()) != NULL )
+ {
+ pEntry = p->Serialize(MetaData, true);
+ pEntry->Assign(pObject->Get_History(), true);
+ }
+
+ else if( p->is_DataObject_List() && p->asList()->Get_Count() > 0 )
+ {
+ CSG_MetaData *pList = MetaData.Add_Child(SG_T("DATA_LIST"));
+ pList->Add_Property(SG_T("type"), p->Get_Type_Identifier());
+ pList->Add_Property(SG_T("id") , p->Get_Identifier());
+ pList->Add_Property(SG_T("name"), p->Get_Name());
+
+ for(int j=0; j<p->asList()->Get_Count(); j++)
+ {
+ pEntry = pList->Add_Child(SG_T("DATA"));
+ pEntry->Assign(p->asList()->asDataObject(j)->Get_History(), true);
+ }
+ }
+ }
+
+ //---------------------------------------------
+ else if( p->is_Parameters() )
+ {
+ p->asParameters()->Set_History(MetaData, false, true);
+ }
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Serialize //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Parameters::Serialize(const CSG_String &File_Name, bool bSave)
+{
+ CSG_MetaData MetaData;
+
+ if( bSave )
+ {
+ return( Serialize(MetaData, true) && MetaData.Save(File_Name) );
+ }
+ else
+ {
+ return( MetaData.Load(File_Name) && Serialize(MetaData, false) );
+ }
+}
+
+//---------------------------------------------------------
+bool CSG_Parameters::Serialize(CSG_MetaData &MetaData, bool bSave)
+{
+ if( bSave )
+ {
+ MetaData.Destroy();
+
+ MetaData.Set_Name (SG_T("PARAMETERS"));
+ MetaData.Set_Property(SG_T("name"), Get_Name());
+
+ for(int i=0; i<Get_Count(); i++)
+ {
+ m_Parameters[i]->Serialize(MetaData, true);
+ }
+ }
+ else
+ {
+ if( MetaData.Get_Name().Cmp(SG_T("PARAMETERS")) )
+ {
+ return( false );
+ }
+
+ MetaData.Get_Property(SG_T("name"), m_Name);
+
+ for(int i=0; i<MetaData.Get_Children_Count(); i++)
+ {
+ CSG_String Identifier;
+ CSG_Parameter *pParameter;
+
+ if( MetaData.Get_Child(i)->Get_Property(SG_T("id"), Identifier)
+ && (pParameter = Get_Parameter(Identifier)) != NULL )
+ {
+ pParameter->Serialize(*MetaData.Get_Child(i), false);
+ }
+ }
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+// SAGA 2.0 compatibility...
+bool CSG_Parameters::Serialize_Compatibility(CSG_File &Stream)
+{
+ CSG_Parameter *pParameter;
+ CSG_String sLine;
+
+ if( !Stream.is_Open() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ while( Stream.Read_Line(sLine) && sLine.Cmp(SG_T("[PARAMETER_ENTRIES_BEGIN]")) );
+
+ if( sLine.Cmp(SG_T("[PARAMETER_ENTRIES_BEGIN]")) )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ while( Stream.Read_Line(sLine) && sLine.Cmp(SG_T("[PARAMETER_ENTRIES_END]")) )
+ {
+ if( !sLine.Cmp(SG_T("[PARAMETER_ENTRY_BEGIN]"))
+ && Stream.Read_Line(sLine) && (pParameter = Get_Parameter(sLine)) != NULL
+ && Stream.Read_Line(sLine) )
+ {
+ int i;
+ double d, e;
+ TSG_Rect r;
+ CSG_String s;
+ CSG_Table t;
+
+ switch( sLine.asInt() )
+ {
+ case 1: // PARAMETER_TYPE_Bool:
+ case 2: // PARAMETER_TYPE_Int:
+ case 6: // PARAMETER_TYPE_Choice:
+ case 11: // PARAMETER_TYPE_Color:
+ case 15: // PARAMETER_TYPE_Table_Field:
+ SG_FILE_SCANF(Stream.Get_Stream(), SG_T("%d"), &i);
+ pParameter->Set_Value(i);
+ break;
+
+ case 3: // PARAMETER_TYPE_Double:
+ case 4: // PARAMETER_TYPE_Degree:
+ SG_FILE_SCANF(Stream.Get_Stream(), SG_T("%lf"), &d);
+ pParameter->Set_Value(d);
+ break;
+
+ case 5: // PARAMETER_TYPE_Range:
+ SG_FILE_SCANF(Stream.Get_Stream(), SG_T("%lf %lf"), &d, &e);
+ pParameter->asRange()->Set_Range(d, e);
+ break;
+
+ case 7: // PARAMETER_TYPE_String:
+ case 9: // PARAMETER_TYPE_FilePath:
+ Stream.Read_Line(sLine);
+ pParameter->Set_Value(sLine);
+ break;
+
+ case 8: // PARAMETER_TYPE_Text:
+ s.Clear();
+ while( Stream.Read_Line(sLine) && sLine.Cmp(SG_T("[TEXT_ENTRY_END]")) )
+ {
+ s += sLine + SG_T("\n");
+ }
+ pParameter->Set_Value(s);
+ break;
+
+ case 10: // PARAMETER_TYPE_Font:
+ Stream.Read(&i, sizeof(i));
+ pParameter->Set_Value(i);
+ break;
+
+ case 12: // PARAMETER_TYPE_Colors:
+ pParameter->asColors()->Serialize(Stream, false, false);
+ break;
+
+ case 13: // PARAMETER_TYPE_FixedTable:
+ if( t.Serialize(Stream, false) )
+ {
+ pParameter->asTable()->Assign_Values(&t);
+ }
+ break;
+
+ case 14: // PARAMETER_TYPE_Grid_System:
+ Stream.Read(&d, sizeof(d));
+ Stream.Read(&r, sizeof(r));
+ pParameter->asGrid_System()->Assign(d, r);
+ break;
+
+ case 16: // PARAMETER_TYPE_Grid:
+ case 17: // PARAMETER_TYPE_Table:
+ case 18: // PARAMETER_TYPE_Shapes:
+ case 19: // PARAMETER_TYPE_TIN:
+ case 24: // PARAMETER_TYPE_DataObject_Output:
+ if( Stream.Read_Line(sLine) )
+ {
+ if( !sLine.Cmp(SG_T("[ENTRY_DATAOBJECT_CREATE]")) )
+ {
+ pParameter->Set_Value(DATAOBJECT_CREATE);
+ }
+ else
+ {
+ pParameter->Set_Value(SG_UI_DataObject_Find(sLine, -1));
+ }
+ }
+ break;
+
+ case 20: // PARAMETER_TYPE_Grid_List:
+ case 21: // PARAMETER_TYPE_Table_List:
+ case 22: // PARAMETER_TYPE_Shapes_List:
+ case 23: // PARAMETER_TYPE_TIN_List:
+ while( Stream.Read_Line(sLine) && sLine.Cmp(SG_T("[ENTRY_DATAOBJECTLIST_END]")) )
+ {
+ CSG_Data_Object *pObject = SG_UI_DataObject_Find(sLine, -1);
+
+ if( pObject )
+ {
+ pParameter->asList()->Add_Item(pObject);
+ }
+ }
+ break;
+
+ case 25: // PARAMETER_TYPE_Parameters:
+ pParameter->asParameters()->Serialize_Compatibility(Stream);
+ break;
+ }
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifdef _SAGA_UNICODE
+
+CSG_Parameter * CSG_Parameters::Get_Parameter(const char *Identifier)
+{ return( Get_Parameter(SG_STR_MBTOSG(Identifier)) ); }
+
+bool CSG_Parameters::Del_Parameter(const char *Identifier)
+{ return( Del_Parameter(SG_STR_MBTOSG(Identifier)) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Node (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{ return( Add_Node (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Value (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
+{ return( Add_Value (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Type, Value, Minimum, bMinimum, Maximum, bMaximum) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Info_Value (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value)
+{ return( Add_Info_Value (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Type, Value) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Range (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, double Range_Min, double Range_Max, double Minimum, bool bMinimum, double Maximum, bool bMaximum)
+{ return( Add_Range (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Range_Min, Range_Max, Minimum, bMinimum, Maximum, bMaximum) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Info_Range (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, double Range_Min, double Range_Max)
+{ return( Add_Info_Range (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Range_Min, Range_Max) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Choice (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *Items, int Default)
+{ return( Add_Choice (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Items, Default) ); }
+
+CSG_Parameter * CSG_Parameters::Add_String (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *String, bool bLongText, bool bPassword)
+{ return( Add_String (pParent, SG_STR_MBTOSG(Identifier), Name, Description, String, bLongText, bPassword) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Info_String (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *String, bool bLongText)
+{ return( Add_Info_String (pParent, SG_STR_MBTOSG(Identifier), Name, Description, String, bLongText) ); }
+
+CSG_Parameter * CSG_Parameters::Add_FilePath (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, const SG_Char *Filter, const SG_Char *Default, bool bSave, bool bDirectory, bool bMultiple)
+{ return( Add_FilePath (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Filter, Default, bSave, bDirectory, bMultiple) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Font (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, class wxFont *pInit)
+{ return( Add_Font (pParent, SG_STR_MBTOSG(Identifier), Name, Description, pInit) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Colors (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Colors *pInit)
+{ return( Add_Colors (pParent, SG_STR_MBTOSG(Identifier), Name, Description, pInit) ); }
+
+CSG_Parameter * CSG_Parameters::Add_FixedTable (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Table *pTemplate)
+{ return( Add_FixedTable (pParent, SG_STR_MBTOSG(Identifier), Name, Description, pTemplate) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Grid_System (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, CSG_Grid_System *pInit)
+{ return( Add_Grid_System (pParent, SG_STR_MBTOSG(Identifier), Name, Description, pInit) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Grid (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, bool bSystem_Dependent, TSG_Data_Type Preferred_Type)
+{ return( Add_Grid (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint, bSystem_Dependent, Preferred_Type) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Grid_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{ return( Add_Grid_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Grid_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, bool bSystem_Dependent)
+{ return( Add_Grid_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint, bSystem_Dependent) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Table_Field (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, bool bAllowNone)
+{ return( Add_Table_Field (pParent, SG_STR_MBTOSG(Identifier), Name, Description, bAllowNone) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Table (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
+{ return( Add_Table (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Table_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{ return( Add_Table_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Table_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
+{ return( Add_Table_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Shapes (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, TSG_Shape_Type Shape_Type)
+{ return( Add_Shapes (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint, Shape_Type) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Shapes_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{ return( Add_Shapes_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Shapes_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint, TSG_Shape_Type Shape_Type)
+{ return( Add_Shapes_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint, Shape_Type) ); }
+
+CSG_Parameter * CSG_Parameters::Add_TIN (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
+{ return( Add_TIN (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
+
+CSG_Parameter * CSG_Parameters::Add_TIN_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{ return( Add_TIN_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
+
+CSG_Parameter * CSG_Parameters::Add_TIN_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
+{ return( Add_TIN_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
+
+CSG_Parameter * CSG_Parameters::Add_PointCloud (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
+{ return( Add_PointCloud (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
+
+CSG_Parameter * CSG_Parameters::Add_PointCloud_Output (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{ return( Add_PointCloud_Output (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
+
+CSG_Parameter * CSG_Parameters::Add_PointCloud_List (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, int Constraint)
+{ return( Add_PointCloud_List (pParent, SG_STR_MBTOSG(Identifier), Name, Description, Constraint) ); }
+
+CSG_Parameter * CSG_Parameters::Add_Parameters (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description)
+{ return( Add_Parameters (pParent, SG_STR_MBTOSG(Identifier), Name, Description) ); }
+
+#endif
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_api/parameters.h b/src/saga_core/saga_api/parameters.h
index 41d179a..adac29d 100644
--- a/src/saga_core/saga_api/parameters.h
+++ b/src/saga_core/saga_api/parameters.h
@@ -642,7 +642,8 @@ public:
virtual const SG_Char * asString (void);
- virtual bool Set_Value (int Value);
+ virtual bool Set_Value (int Value);
+ virtual bool Set_Value (void *Value);
CSG_Table * Get_Table (void);
@@ -935,6 +936,42 @@ private:
///////////////////////////////////////////////////////////
// //
+// Grid Target Selector //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Parameters_Grid_Target
+{
+public:
+ CSG_Parameters_Grid_Target(void);
+
+ void Create (void);
+
+ bool Add_Parameters_User (CSG_Parameters *pParameters, bool bAddDefaultGrid = true);
+ bool Add_Parameters_Grid (CSG_Parameters *pParameters, bool bAddDefaultGrid = true);
+
+ bool Add_Grid_Parameter (const CSG_String &Identifier, const CSG_String &Name, bool bOptional);
+
+ bool On_User_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
+
+ bool Init_User (const TSG_Rect &Extent, int Rows = 100);
+
+ CSG_Grid * Get_User ( TSG_Data_Type Type = SG_DATATYPE_Float);
+ CSG_Grid * Get_User (const CSG_String &Identifier, TSG_Data_Type Type = SG_DATATYPE_Float);
+ CSG_Grid * Get_Grid ( TSG_Data_Type Type = SG_DATATYPE_Float);
+ CSG_Grid * Get_Grid (const CSG_String &Identifier, TSG_Data_Type Type = SG_DATATYPE_Float);
+
+
+private:
+
+ CSG_Parameters *m_pUser, *m_pGrid;
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
// CSG_Parameter //
// //
///////////////////////////////////////////////////////////
@@ -1094,12 +1131,18 @@ public:
//-----------------------------------------------------
CSG_Parameter * Get_Parameter (int iParameter);
- CSG_Parameter * operator() (int iParameter) { return( Get_Parameter(iParameter) ); }
-
CSG_Parameter * Get_Parameter (const SG_Char *Identifier);
+
+ CSG_Parameter * operator() (int iParameter) { return( Get_Parameter(iParameter) ); }
CSG_Parameter * operator() (const SG_Char *Identifier) { return( Get_Parameter(Identifier) ); }
//-----------------------------------------------------
+ bool Del_Parameter (int iParameter);
+ bool Del_Parameter (const SG_Char *Identifier);
+
+ bool Del_Parameters (void);
+
+ //-----------------------------------------------------
CSG_Parameter * Add_Node (CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description);
CSG_Parameter * Add_Value (CSG_Parameter *pParent, const SG_Char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value = 0.0, double Minimum = 0.0, bool bMinimum = false, double Maximum = 0.0, bool bMaximum = false);
@@ -1174,6 +1217,7 @@ public:
#ifdef _SAGA_UNICODE
CSG_Parameter * Get_Parameter (const char *Identifier);
CSG_Parameter * operator() (const char *Identifier) { return( Get_Parameter(Identifier) ); }
+ bool Del_Parameter (const char *Identifier);
CSG_Parameter * Add_Node (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description);
CSG_Parameter * Add_Value (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value = 0.0, double Minimum = 0.0, bool bMinimum = false, double Maximum = 0.0, bool bMaximum = false);
CSG_Parameter * Add_Info_Value (CSG_Parameter *pParent, const char *Identifier, const SG_Char *Name, const SG_Char *Description, TSG_Parameter_Type Type, double Value = 0.0);
diff --git a/src/saga_core/saga_api/pointcloud.cpp b/src/saga_core/saga_api/pointcloud.cpp
index f947483..658e9ff 100644
--- a/src/saga_core/saga_api/pointcloud.cpp
+++ b/src/saga_core/saga_api/pointcloud.cpp
@@ -1,183 +1,689 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Application Programming Interface //
-// //
-// Library: SAGA_API //
-// //
-//-------------------------------------------------------//
-// //
-// pointcloud.cpp //
-// //
-// Copyright (C) 2009 by Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. //
-// //
-// This library is free software; you can redistribute //
-// it and/or modify it under the terms of the GNU Lesser //
-// General Public License as published by the Free //
-// Software Foundation, version 2.1 of the License. //
-// //
-// This library is distributed in the hope that it will //
-// be useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU Lesser General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU Lesser //
-// General Public License along with this program; if //
-// not, write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Hamburg //
-// Germany //
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "pointcloud.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#define POINTCLOUD_FILE_VERSION "SGPC01"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_PointCloud * SG_Create_PointCloud(void)
-{
- return( new CSG_PointCloud );
-}
-
-//---------------------------------------------------------
-CSG_PointCloud * SG_Create_PointCloud(const CSG_PointCloud &PointCloud)
-{
- return( new CSG_PointCloud(PointCloud) );
-}
-
-//---------------------------------------------------------
-CSG_PointCloud * SG_Create_PointCloud(const CSG_String &File_Name)
-{
- return( new CSG_PointCloud(File_Name) );
-}
-
-//---------------------------------------------------------
-CSG_PointCloud * SG_Create_PointCloud(CSG_PointCloud *pStructure)
-{
- return( new CSG_PointCloud(pStructure) );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_PointCloud::CSG_PointCloud(void)
- : CSG_Data_Object()
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Application Programming Interface //
+// //
+// Library: SAGA_API //
+// //
+//-------------------------------------------------------//
+// //
+// pointcloud.cpp //
+// //
+// Copyright (C) 2009 by Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. //
+// //
+// This library is free software; you can redistribute //
+// it and/or modify it under the terms of the GNU Lesser //
+// General Public License as published by the Free //
+// Software Foundation, version 2.1 of the License. //
+// //
+// This library is distributed in the hope that it will //
+// be useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU Lesser General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU Lesser //
+// General Public License along with this program; if //
+// not, write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "pointcloud.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define POINTCLOUD_FILE_VERSION "SGPC01"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_PointCloud * SG_Create_PointCloud(void)
+{
+ return( new CSG_PointCloud );
+}
+
+//---------------------------------------------------------
+CSG_PointCloud * SG_Create_PointCloud(const CSG_PointCloud &PointCloud)
+{
+ return( new CSG_PointCloud(PointCloud) );
+}
+
+//---------------------------------------------------------
+CSG_PointCloud * SG_Create_PointCloud(const CSG_String &File_Name)
+{
+ return( new CSG_PointCloud(File_Name) );
+}
+
+//---------------------------------------------------------
+CSG_PointCloud * SG_Create_PointCloud(CSG_PointCloud *pStructure)
+{
+ return( new CSG_PointCloud(pStructure) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_PointCloud::CSG_PointCloud(void)
+ : CSG_Shapes()
+{
+ _On_Construction();
+}
+
+bool CSG_PointCloud::Create(void)
+{
+ Destroy();
+
+ Add_Field(SG_T(""), SG_DATATYPE_Undefined); // add x, y, z fields
+
+ return( true );
+}
+
+//---------------------------------------------------------
+CSG_PointCloud::CSG_PointCloud(const CSG_PointCloud &PointCloud)
+ : CSG_Shapes()
+{
+ _On_Construction();
+
+ Create(PointCloud);
+}
+
+bool CSG_PointCloud::Create(const CSG_PointCloud &PointCloud)
+{
+ if( Assign((CSG_Data_Object *)&PointCloud) )
+ {
+ Set_Name(PointCloud.Get_Name());
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+CSG_PointCloud::CSG_PointCloud(const CSG_String &File_Name)
+ : CSG_Shapes()
+{
+ _On_Construction();
+
+ Create(File_Name);
+}
+
+bool CSG_PointCloud::Create(const CSG_String &File_Name)
+{
+ return( _Load(File_Name) );
+}
+
+//---------------------------------------------------------
+CSG_PointCloud::CSG_PointCloud(CSG_PointCloud *pStructure)
+ : CSG_Shapes()
+{
+ _On_Construction();
+
+ Create(pStructure);
+}
+
+bool CSG_PointCloud::Create(CSG_PointCloud *pStructure)
+{
+ Destroy();
+
+ if( pStructure && pStructure->Get_Field_Count() > 0 )
+ {
+ for(int i=0; i<pStructure->Get_Field_Count(); i++)
+ {
+ _Add_Field(pStructure->Get_Field_Name(i), pStructure->Get_Field_Type(i));
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+void CSG_PointCloud::_On_Construction(void)
+{
+ m_Type = SHAPE_TYPE_Point;
+
+ m_nFields = 0;
+ m_Field_Name = NULL;
+ m_Field_Type = NULL;
+ m_Field_Stats = NULL;
+ m_Field_Offset = NULL;
+
+ m_Points = NULL;
+ m_nRecords = 0;
+ m_nPointBytes = 0;
+
+ m_Cursor = NULL;
+ m_bXYZPrecDbl = true;
+ m_NoData_Value = -999999;
+
+ m_Selected = NULL;
+ m_nSelected = 0;
+
+ Set_Update_Flag();
+
+ m_Shapes.Create(SHAPE_TYPE_Point);
+ m_Shapes.Add_Shape();
+ m_Shapes_Index = -1;
+
+ m_Array_Points .Create(sizeof(char *), 0, SG_ARRAY_GROWTH_2);
+ m_Array_Selected.Create(sizeof(int ), 0, SG_ARRAY_GROWTH_3);
+}
+
+//---------------------------------------------------------
+CSG_PointCloud::~CSG_PointCloud(void)
+{
+ Destroy();
+}
+
+bool CSG_PointCloud::Destroy(void)
+{
+ Del_Points();
+
+ if( m_nFields > 0 )
+ {
+ for(int i=0; i<m_nFields; i++)
+ {
+ delete(m_Field_Name [i]);
+ delete(m_Field_Stats[i]);
+ }
+
+ SG_Free(m_Field_Name);
+ SG_Free(m_Field_Type);
+ SG_Free(m_Field_Stats);
+ SG_Free(m_Field_Offset);
+
+ _On_Construction();
+ }
+
+ CSG_Data_Object::Destroy();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// File //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_PointCloud::_Load(const CSG_String &File_Name)
+{
+ TSG_Data_Type Type;
+
+ char ID[6];
+ int i, iBuffer, nPointBytes, nFields;
+ char Name[1024];
+ CSG_File Stream;
+
+ SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), LNG("[MSG] Load point cloud"), File_Name.c_str()), true);
+
+ //-----------------------------------------------------
+ if( !Stream.Open(File_Name, SG_FILE_R, true) )
+ {
+ SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+ SG_UI_Msg_Add_Error(LNG("[ERR] file could not be opened."));
+
+ return( false );
+ }
+
+ if( !Stream.Read(ID, 6) || strncmp(ID, POINTCLOUD_FILE_VERSION, 5) != 0 )
+ {
+ SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+ SG_UI_Msg_Add_Error(LNG("[ERR] incompatible file."));
+
+ return( false );
+ }
+
+ if( !Stream.Read(&nPointBytes, sizeof(int)) || nPointBytes < (int)(3 * sizeof(float)) )
+ {
+ SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+ SG_UI_Msg_Add_Error(LNG("[ERR] incompatible file."));
+
+ return( false );
+ }
+
+ if( !Stream.Read(&nFields, sizeof(int)) || nFields < 3 )
+ {
+ SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+ SG_UI_Msg_Add_Error(LNG("[ERR] incompatible file."));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ Destroy();
+
+ for(i=0; i<nFields; i++)
+ {
+ if( !Stream.Read(&Type , sizeof(TSG_Data_Type))
+ || !Stream.Read(&iBuffer , sizeof(int)) || !(iBuffer > 0 && iBuffer < 1024)
+ || !Stream.Read(Name , iBuffer) )
+ {
+ SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+ SG_UI_Msg_Add_Error(LNG("[ERR] incompatible file."));
+
+ return( false );
+ }
+
+ if( ID[5] == '0' ) // Data Type Definition changed!!!
+ {
+ switch( Type )
+ {
+ default: Type = SG_DATATYPE_Undefined; break;
+ case 1: Type = SG_DATATYPE_Char; break;
+ case 2: Type = SG_DATATYPE_Short; break;
+ case 3: Type = SG_DATATYPE_Int; break;
+ case 4: Type = SG_DATATYPE_Long; break;
+ case 5: Type = SG_DATATYPE_Float; break;
+ case 6: Type = SG_DATATYPE_Double; break;
+ }
+ }
+
+ Name[iBuffer] = '\0';
+
+ if( !_Add_Field(CSG_String((const char *)Name), Type) )
+ {
+ SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+ SG_UI_Msg_Add_Error(LNG("[ERR] incompatible file."));
+
+ return( false );
+ }
+ }
+
+ if( m_nPointBytes != nPointBytes + 1 )
+ {
+ SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+ SG_UI_Msg_Add_Error(LNG("[ERR] incompatible file."));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ int fLength = Stream.Length();
+
+ while( _Inc_Array() && Stream.Read(m_Cursor + 1, nPointBytes) && SG_UI_Process_Set_Progress(Stream.Tell(), fLength) )
+ {}
+
+ _Dec_Array();
+
+ Set_File_Name(File_Name);
+
+ Load_MetaData(File_Name);
+
+ if( 0 > Get_Count() )
+ {
+ SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+ SG_UI_Msg_Add_Error(LNG("[ERR] no records in file."));
+
+ return( false );
+ }
+
+ SG_UI_Msg_Add(LNG("[MSG] okay"), false, SG_UI_MSG_STYLE_SUCCESS);
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_PointCloud::_Save(const CSG_String &File_Name)
+{
+ CSG_File Stream;
+
+ SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), LNG("[MSG] Save point cloud"), File_Name.c_str()), true);
+
+ if( Stream.Open(File_Name, SG_FILE_W, true) == false )
+ {
+ SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+ SG_UI_Msg_Add_Error(LNG("[ERR] unable to create file."));
+
+ return( false );
+ }
+
+ int i, iBuffer, nPointBytes = m_nPointBytes - 1;
+
+ Stream.Write((void *)POINTCLOUD_FILE_VERSION, 6);
+ Stream.Write(&nPointBytes , sizeof(int));
+ Stream.Write(&m_nFields , sizeof(int));
+
+ for(i=0; i<m_nFields; i++)
+ {
+ Stream.Write(&m_Field_Type[i], sizeof(TSG_Data_Type));
+
+ iBuffer = m_Field_Name[i]->Length(); if( iBuffer >= 1024 - 1 ) iBuffer = 1024 - 1;
+ Stream.Write(&iBuffer, sizeof(int));
+ Stream.Write((void *)m_Field_Name[i]->b_str(), sizeof(char), iBuffer);
+ }
+
+ _Set_Shape(m_Shapes_Index);
+
+ for(i=0; i<Get_Count() && SG_UI_Process_Set_Progress(i, Get_Count()); i++)
+ {
+ Stream.Write(m_Points[i] + 1, nPointBytes);
+ }
+
+ Set_Modified(false);
+
+ Set_File_Name(SG_File_Make_Path(NULL, File_Name, SG_T("spc")));
+
+ Save_MetaData(File_Name);
+
+ SG_UI_Msg_Add(LNG("[MSG] okay"), false, SG_UI_MSG_STYLE_SUCCESS);
+
+ return( true );
+}
+
+bool CSG_PointCloud::Save(const CSG_String &File_Name, int Format)
+{
+ return( _Save(File_Name) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Assign //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_PointCloud::Assign(CSG_Data_Object *pObject)
+{
+ if( pObject && pObject->is_Valid() && pObject->Get_ObjectType() == Get_ObjectType() )
+ {
+ Destroy();
+
+ CSG_PointCloud *pPointCloud = (CSG_PointCloud *)pObject;
+
+ Get_History() = pPointCloud->Get_History();
+
+ for(int iField=0; iField<pPointCloud->m_nFields; iField++)
+ {
+ _Add_Field(pPointCloud->m_Field_Name[iField]->c_str(), pPointCloud->m_Field_Type[iField]);
+ }
+
+ for(int iPoint=0; iPoint<pPointCloud->Get_Count(); iPoint++)
+ {
+ if( _Inc_Array() )
+ {
+ memcpy(m_Points[iPoint] + 1, pPointCloud->m_Points[iPoint] + 1, m_nPointBytes - 1);
+ }
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Checks //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_PointCloud::is_Compatible(CSG_PointCloud *pPointCloud) const
+{
+ if( Get_Field_Count() == pPointCloud->Get_Field_Count() )
+ {
+ for(int i=0; i<Get_Field_Count(); i++)
+ {
+ if( Get_Field_Type(i) != pPointCloud->Get_Field_Type(i) )
+ {
+ return( false );
+ }
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Fields //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_PointCloud::_Add_Field(const SG_Char *Name, TSG_Data_Type Type, int iField)
+{
+ if( !Name || SG_Data_Type_Get_Size(Type) <= 0 )
+ {
+ return( false );
+ }
+
+ m_Field_Name = (CSG_String **)SG_Realloc(m_Field_Name , (m_nFields + 1) * sizeof(CSG_String *));
+ m_Field_Type = (TSG_Data_Type *)SG_Realloc(m_Field_Type , (m_nFields + 1) * sizeof(TSG_Data_Type));
+ m_Field_Stats = (CSG_Simple_Statistics **)SG_Realloc(m_Field_Stats , (m_nFields + 1) * sizeof(CSG_Simple_Statistics *));
+ m_Field_Offset = (int *)SG_Realloc(m_Field_Offset, (m_nFields + 1) * sizeof(int));
+
+ m_Field_Name [m_nFields] = new CSG_String(Name);
+ m_Field_Type [m_nFields] = Type;
+ m_Field_Stats [m_nFields] = new CSG_Simple_Statistics();
+ m_Field_Offset[m_nFields] = m_nFields == 0 ? 1 : m_Field_Offset[m_nFields - 1] + SG_Data_Type_Get_Size(m_Field_Type[m_nFields - 1]);
+
+ if( m_nFields == 0 )
+ {
+ m_nPointBytes = 1;
+ }
+
+ m_nPointBytes += SG_Data_Type_Get_Size(m_Field_Type[m_nFields]);
+ m_nFields ++;
+
+ m_Shapes.Add_Field(Name, Type);
+
+ for(int i=0; i<Get_Count(); i++)
+ {
+ m_Points[i] = (char *)SG_Realloc(m_Points[i], m_nPointBytes * sizeof(char));
+ }
+
+ Set_Modified();
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_PointCloud::Add_Field(const SG_Char *Name, TSG_Data_Type Type, int iField)
+{
+ if( m_nFields == 0 )
+ {
+ _Add_Field(SG_T("X"), m_bXYZPrecDbl ? SG_DATATYPE_Double : SG_DATATYPE_Float);
+ _Add_Field(SG_T("Y"), m_bXYZPrecDbl ? SG_DATATYPE_Double : SG_DATATYPE_Float);
+ _Add_Field(SG_T("Z"), m_bXYZPrecDbl ? SG_DATATYPE_Double : SG_DATATYPE_Float);
+ }
+
+ return( _Add_Field(Name, Type, iField) );
+}
+
+//---------------------------------------------------------
+#ifdef _SAGA_UNICODE
+bool CSG_PointCloud::Add_Field(const char *Name, TSG_Data_Type Type, int iField)
+{ return( Add_Field(CSG_String(Name), Type, iField) ); }
+#endif
+
+//---------------------------------------------------------
+bool CSG_PointCloud::Del_Field(int iField)
+{
+ int i;
+
+ if( iField < 3 || iField >= m_nFields )
+ {
+ return( false );
+ }
+
+ if( m_nFields == 1 )
+ {
+ return( Destroy() );
+ }
+
+ //-----------------------------------------------------
+ m_nFields --;
+ m_nPointBytes -= SG_Data_Type_Get_Size(m_Field_Type[iField]);
+
+ for(i=0; i<m_nRecords; i++)
+ {
+ if( iField < m_nFields )
+ {
+ memmove(
+ m_Points[i] + m_Field_Offset[iField],
+ m_Points[i] + m_Field_Offset[iField + 1],
+ m_Field_Offset[iField + 1] - m_Field_Offset[iField]
+ );
+ }
+
+ m_Points[i] = (char *)SG_Realloc(m_Points[i], m_nPointBytes * sizeof(char));
+ }
+
+ //-----------------------------------------------------
+ delete(m_Field_Name [iField]);
+ delete(m_Field_Stats[iField]);
+
+ for(i=iField; i<m_nFields; i++)
+ {
+ m_Field_Name [i] = m_Field_Name [i + 1];
+ m_Field_Type [i] = m_Field_Type [i + 1];
+ m_Field_Stats [i] = m_Field_Stats [i + 1];
+ m_Field_Offset[i] = m_Field_Offset[i - 1] + SG_Data_Type_Get_Size(m_Field_Type[i - 1]);
+ }
+
+ m_Field_Name = (CSG_String **)SG_Realloc(m_Field_Name , m_nFields * sizeof(CSG_String *));
+ m_Field_Type = (TSG_Data_Type *)SG_Realloc(m_Field_Type , m_nFields * sizeof(TSG_Data_Type));
+ m_Field_Stats = (CSG_Simple_Statistics **)SG_Realloc(m_Field_Stats , m_nFields * sizeof(CSG_Simple_Statistics *));
+ m_Field_Offset = (int *)SG_Realloc(m_Field_Offset, m_nFields * sizeof(int));
+
+ Set_Modified();
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_PointCloud::_Set_Field_Value(char *pPoint, int iField, double Value)
+{
+ if( pPoint && iField >= 0 && iField < m_nFields )
+ {
+ pPoint = ((char *)pPoint) + m_Field_Offset[iField];
+
+ switch( m_Field_Type[iField] )
+ {
+ default:
+ case SG_DATATYPE_Undefined: break;
+ case SG_DATATYPE_Byte: *((BYTE *)pPoint) = (BYTE )Value; break;
+ case SG_DATATYPE_Char: *((char *)pPoint) = (char )Value; break;
+ case SG_DATATYPE_Word: *((WORD *)pPoint) = (WORD )Value; break;
+ case SG_DATATYPE_Short: *((short *)pPoint) = (short )Value; break;
+ case SG_DATATYPE_DWord: *((DWORD *)pPoint) = (DWORD )Value; break;
+ case SG_DATATYPE_Int: *((int *)pPoint) = (int )Value; break;
+ case SG_DATATYPE_Long: *((long *)pPoint) = (long )Value; break;
+ case SG_DATATYPE_Float: *((float *)pPoint) = (float )Value; break;
+ case SG_DATATYPE_Double: *((double *)pPoint) = (double)Value; break;
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+double CSG_PointCloud::_Get_Field_Value(char *pPoint, int iField) const
+{
+ if( pPoint && iField >= 0 && iField < m_nFields )
+ {
+ pPoint = ((char *)pPoint) + m_Field_Offset[iField];
+
+ switch( m_Field_Type[iField] )
+ {
+ case SG_DATATYPE_Undefined: default: break;
+ case SG_DATATYPE_Byte: return( *((BYTE *)pPoint) );
+ case SG_DATATYPE_Char: return( *((char *)pPoint) );
+ case SG_DATATYPE_Word: return( *((WORD *)pPoint) );
+ case SG_DATATYPE_Short: return( *((short *)pPoint) );
+ case SG_DATATYPE_DWord: return( *((DWORD *)pPoint) );
+ case SG_DATATYPE_Int: return( *((int *)pPoint) );
+ case SG_DATATYPE_Long: return( *((long *)pPoint) );
+ case SG_DATATYPE_Float: return( *((float *)pPoint) );
+ case SG_DATATYPE_Double: return( *((double *)pPoint) );
+ }
+ }
+
+ return( 0.0 );
+}
+
+//---------------------------------------------------------
+bool CSG_PointCloud::Set_Value(int iPoint, int iField, const SG_Char *Value)
{
- _On_Construction();
-}
-
-bool CSG_PointCloud::Create(void)
-{
- Destroy();
-
- Add_Field(SG_T(""), SG_DATATYPE_Undefined); // add x, y, z fields
-
- return( true );
-}
-
-//---------------------------------------------------------
-CSG_PointCloud::CSG_PointCloud(const CSG_PointCloud &PointCloud)
- : CSG_Data_Object()
-{
- _On_Construction();
-
- Create(PointCloud);
-}
-
-bool CSG_PointCloud::Create(const CSG_PointCloud &PointCloud)
-{
- if( Assign((CSG_Data_Object *)&PointCloud) )
+ if( iPoint >= 0 && iPoint < m_nRecords && Value && *Value )
{
- Set_Name(PointCloud.Get_Name());
+ double d;
+ CSG_String s(Value);
- return( true );
+ if( s.asDouble(d) )
+ {
+ return( _Set_Field_Value(m_Points[iPoint], iField, d) );
+ }
}
return( false );
}
-
-//---------------------------------------------------------
-CSG_PointCloud::CSG_PointCloud(const CSG_String &File_Name)
- : CSG_Data_Object()
-{
- _On_Construction();
-
- Create(File_Name);
-}
-
-bool CSG_PointCloud::Create(const CSG_String &File_Name)
-{
- return( _Load(File_Name) );
-}
-
-//---------------------------------------------------------
-CSG_PointCloud::CSG_PointCloud(CSG_PointCloud *pStructure)
- : CSG_Data_Object()
+
+//---------------------------------------------------------
+bool CSG_PointCloud::Get_Value(int iPoint, int iField, CSG_String &Value) const
{
- _On_Construction();
-
- Create(pStructure);
-}
-
-bool CSG_PointCloud::Create(CSG_PointCloud *pStructure)
-{
- Destroy();
-
- if( pStructure && pStructure->Get_Field_Count() > 0 )
+ if( iPoint >= 0 && iPoint < m_nRecords && iField >= 0 && iField < m_nFields )
{
- for(int i=0; i<pStructure->Get_Field_Count(); i++)
- {
- _Add_Field(pStructure->Get_Field_Name(i), pStructure->Get_Field_Type(i));
- }
+ Value.Printf(SG_T("%f"), _Get_Field_Value(m_Points[iPoint], iField));
return( true );
}
@@ -185,694 +691,553 @@ bool CSG_PointCloud::Create(CSG_PointCloud *pStructure)
return( false );
}
-//---------------------------------------------------------
-void CSG_PointCloud::_On_Construction(void)
-{
- m_nFields = 0;
- m_Field_Name = NULL;
- m_Field_Type = NULL;
- m_Field_Stats = NULL;
- m_Field_Offset = NULL;
-
- m_Points = NULL;
- m_nPoints = 0;
- m_nBuffer = 0;
- m_nPointBytes = 0;
-
- m_Cursor = NULL;
- m_bXYZPrecDbl = true;
- m_NoData_Value = -999999;
-
- Set_Update_Flag();
-}
-
-//---------------------------------------------------------
-CSG_PointCloud::~CSG_PointCloud(void)
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+TSG_Point_Z CSG_PointCloud::Get_Point(void) const
+{
+ TSG_Point_Z p;
+
+ if( m_Cursor )
+ {
+ p.x = _Get_Field_Value(m_Cursor, 0);
+ p.y = _Get_Field_Value(m_Cursor, 1);
+ p.z = _Get_Field_Value(m_Cursor, 2);
+ }
+ else
+ {
+ p.x = p.y = p.z = 0.0;
+ }
+
+ return( p );
+}
+
+//---------------------------------------------------------
+TSG_Point_Z CSG_PointCloud::Get_Point(int iPoint) const
+{
+ TSG_Point_Z p;
+
+ if( iPoint >= 0 && iPoint < Get_Count() )
+ {
+ char *pPoint = m_Points[iPoint];
+
+ p.x = _Get_Field_Value(pPoint, 0);
+ p.y = _Get_Field_Value(pPoint, 1);
+ p.z = _Get_Field_Value(pPoint, 2);
+ }
+ else
+ {
+ p.x = p.y = p.z = 0.0;
+ }
+
+ return( p );
+}
+
+//---------------------------------------------------------
+bool CSG_PointCloud::Set_NoData_Value(double NoData_Value)
+{
+ if( NoData_Value != m_NoData_Value )
+ {
+ for(int i=3; i<m_nFields; i++)
+ {
+ m_Field_Stats[i]->Invalidate();
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_PointCloud::Add_Point(double x, double y, double z)
+{
+ if( _Inc_Array() )
+ {
+ _Set_Field_Value(m_Cursor, 0, x);
+ _Set_Field_Value(m_Cursor, 1, y);
+ _Set_Field_Value(m_Cursor, 2, z);
+
+ Set_Modified();
+ Set_Update_Flag();
+ _Stats_Invalidate();
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_PointCloud::Del_Point(int iPoint)
+{
+ if( iPoint >= 0 && iPoint < Get_Count() )
+ {
+ if( is_Selected(iPoint) )
+ {
+ Select(iPoint, true);
+ }
+
+ m_Cursor = m_Points[iPoint];
+
+ for(int i=iPoint, j=iPoint+1; j<Get_Count(); i++, j++)
+ {
+ m_Points[i] = m_Points[j];
+ }
+
+ m_Points[Get_Count() - 1] = m_Cursor;
+
+ m_Cursor = NULL;
+
+ _Dec_Array();
+
+ Set_Modified();
+ Set_Update_Flag();
+ _Stats_Invalidate();
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_PointCloud::Del_Points(void)
+{
+ for(int iPoint=0; iPoint<m_nRecords; iPoint++)
+ {
+ SG_Free(m_Points[iPoint]);
+ }
+
+ m_Array_Points .Destroy();
+ m_Array_Selected.Destroy();
+
+ m_nRecords = 0;
+ m_Points = NULL;
+ m_Cursor = NULL;
+
+ m_nSelected = 0;
+ m_Selected = NULL;
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_PointCloud::_Inc_Array(void)
+{
+ if( m_nFields > 0 && m_Array_Points.Set_Array(m_nRecords + 1, (void **)&m_Points) )
+ {
+ m_Points[m_nRecords++] = m_Cursor = (char *)SG_Calloc(m_nPointBytes, sizeof(char));
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_PointCloud::_Dec_Array(void)
+{
+ if( m_nRecords > 0 )
+ {
+ m_nRecords --;
+
+ m_Cursor = NULL;
+
+ SG_Free(m_Points[m_nRecords]);
+
+ m_Array_Points.Set_Array(m_nRecords, (void **)&m_Points);
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// Statistics //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_PointCloud::On_Update(void)
+{
+ if( m_nFields >= 2 )
+ {
+ _Stats_Update(0);
+ _Stats_Update(1);
+
+ m_Extent.Assign(
+ m_Field_Stats[0]->Get_Minimum(), m_Field_Stats[1]->Get_Minimum(),
+ m_Field_Stats[0]->Get_Maximum(), m_Field_Stats[1]->Get_Maximum()
+ );
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_PointCloud::_Stats_Update(int iField) const
+{
+ if( iField >= 0 && iField < m_nFields && Get_Count() > 0 )
+ {
+ if( !m_Field_Stats[iField]->is_Evaluated() )
+ {
+ char **pPoint = m_Points;
+
+ for(int iPoint=0; iPoint<Get_Count(); iPoint++, pPoint++)
+ {
+ double Value = _Get_Field_Value(*pPoint, iField);
+
+ if( iField < 3 || Value != m_NoData_Value )
+ {
+ m_Field_Stats[iField]->Add_Value(Value);
+ }
+ }
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Shape * CSG_PointCloud::_Set_Shape(int iPoint)
{
- Destroy();
+ CSG_Shape *pShape = m_Shapes.Get_Shape(0);
+
+ if( pShape->is_Modified() && m_Shapes_Index >= 0 && m_Shapes_Index < Get_Count() )
+ {
+ m_Cursor = m_Points[m_Shapes_Index];
+
+ for(int i=0; i<Get_Field_Count(); i++)
+ {
+ Set_Value(i, pShape->asDouble(i));
+ }
+ }
+
+ if( iPoint != m_Shapes_Index && iPoint >= 0 && iPoint < Get_Count() )
+ {
+ m_Cursor = m_Points[iPoint];
+
+ pShape->Set_Point(Get_X(), Get_Y(), 0, 0);
+
+ for(int i=0; i<Get_Field_Count(); i++)
+ {
+ pShape->Set_Value(i, Get_Value(i));
+ }
+
+ m_Shapes.Set_Modified(false);
+
+ m_Shapes_Index = iPoint;
+
+ return( pShape );
+ }
+
+ m_Shapes_Index = -1;
+
+ return( NULL );
}
-
-bool CSG_PointCloud::Destroy(void)
+
+//---------------------------------------------------------
+CSG_Table_Record * CSG_PointCloud::Get_Record(int iRecord) const
+{
+ return( ((CSG_PointCloud *)this)->_Set_Shape(iRecord) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Shape * CSG_PointCloud::Get_Shape(TSG_Point Point, double Epsilon)
+{
+ CSG_Rect r(Point.x - Epsilon, Point.y - Epsilon, Point.x + Epsilon, Point.y + Epsilon);
+
+ if( r.Intersects(Get_Extent()) != INTERSECTION_None )
+ {
+ int iPoint = -1;
+ double iDistance = -1.0;
+
+ for(int iRecord=0; iRecord<Get_Count(); iRecord++)
+ {
+ Set_Cursor(iRecord);
+
+ if( r.Contains(Get_X(), Get_Y()) )
+ {
+ if( iPoint < 0 || iDistance > SG_Get_Distance(Point.x, Point.y, Get_X(), Get_Y()) )
+ {
+ iPoint = iRecord;
+ iDistance = SG_Get_Distance(Point.x, Point.y, Get_X(), Get_Y());
+ }
+ }
+ }
+
+ if( iPoint >= 0 )
+ {
+ return( CSG_Shapes::Get_Shape(iPoint) );
+ }
+ }
+
+ return( NULL );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_PointCloud::Select(int iRecord, bool bInvert)
{
- Del_Points();
-
- if( m_nFields > 0 )
+ if( !bInvert )
{
- for(int i=0; i<m_nFields; i++)
+ for(int i=0; i<m_nSelected; i++)
{
- delete(m_Field_Name [i]);
- delete(m_Field_Stats[i]);
+ m_Points[m_Selected[i]][0] &= ~SG_TABLE_REC_FLAG_Selected;
}
- SG_Free(m_Field_Name);
- SG_Free(m_Field_Type);
- SG_Free(m_Field_Stats);
- SG_Free(m_Field_Offset);
-
- _On_Construction();
- }
-
- CSG_Data_Object::Destroy();
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// File //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSG_PointCloud::_Load(const CSG_String &File_Name)
-{
- TSG_Data_Type Type;
-
- char ID[6];
- int i, iBuffer, nPointBytes, nFields;
- char Name[1024];
- CSG_File Stream;
-
- SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), LNG("[MSG] Load point cloud"), File_Name.c_str()), true);
-
- //-----------------------------------------------------
- if( !Stream.Open(File_Name, SG_FILE_R, true) )
- {
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
- SG_UI_Msg_Add_Error(LNG("[ERR] file could not be opened."));
-
- return( false );
- }
-
- if( !Stream.Read(ID, 6) || strncmp(ID, POINTCLOUD_FILE_VERSION, 5) != 0 )
- {
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
- SG_UI_Msg_Add_Error(LNG("[ERR] incompatible file."));
-
- return( false );
- }
-
- if( !Stream.Read(&nPointBytes, sizeof(int)) || nPointBytes < 3 * sizeof(float) )
- {
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
- SG_UI_Msg_Add_Error(LNG("[ERR] incompatible file."));
-
- return( false );
- }
-
- if( !Stream.Read(&nFields, sizeof(int)) || nFields < 3 )
- {
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
- SG_UI_Msg_Add_Error(LNG("[ERR] incompatible file."));
-
- return( false );
+ m_Array_Selected.Destroy();
+ m_Selected = NULL;
+ m_nSelected = 0;
}
- //-----------------------------------------------------
- Destroy();
-
- for(i=0; i<nFields; i++)
+ if( Set_Cursor(iRecord) )
{
- if( !Stream.Read(&Type , sizeof(TSG_Data_Type))
- || !Stream.Read(&iBuffer , sizeof(int)) || !(iBuffer > 0 && iBuffer < 1024)
- || !Stream.Read(Name , iBuffer) )
+ if( (m_Cursor[0] & SG_TABLE_REC_FLAG_Selected) == 0 ) // select
{
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
- SG_UI_Msg_Add_Error(LNG("[ERR] incompatible file."));
+ if( m_Array_Selected.Set_Array(m_nSelected + 1, (void **)&m_Selected) )
+ {
+ m_Cursor[0] |= SG_TABLE_REC_FLAG_Selected;
- return( false );
- }
+ m_Selected[m_nSelected++] = iRecord;
- if( ID[5] == '0' ) // Data Type Definition changed!!!
- {
- switch( Type )
- {
- default: Type = SG_DATATYPE_Undefined; break;
- case 1: Type = SG_DATATYPE_Char; break;
- case 2: Type = SG_DATATYPE_Short; break;
- case 3: Type = SG_DATATYPE_Int; break;
- case 4: Type = SG_DATATYPE_Long; break;
- case 5: Type = SG_DATATYPE_Float; break;
- case 6: Type = SG_DATATYPE_Double; break;
+ return( true );
}
}
-
- Name[iBuffer] = '\0';
-
- if( !_Add_Field(CSG_String((const char *)Name), Type) )
+ else // deselect
{
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
- SG_UI_Msg_Add_Error(LNG("[ERR] incompatible file."));
+ m_Cursor[0] &= ~SG_TABLE_REC_FLAG_Selected;
- return( false );
- }
- }
-
- if( m_nPointBytes != nPointBytes )
- {
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
- SG_UI_Msg_Add_Error(LNG("[ERR] incompatible file."));
-
- return( false );
- }
-
- //-----------------------------------------------------
- int fLength = Stream.Length();
-
- while( _Inc_Array() && Stream.Read(m_Cursor, m_nPointBytes) && SG_UI_Process_Set_Progress(Stream.Tell(), fLength) )
- {}
-
- _Dec_Array();
-
- Set_File_Name(File_Name);
-
- Load_MetaData(File_Name);
-
- if( m_nPoints <= 0 )
- {
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
- SG_UI_Msg_Add_Error(LNG("[ERR] no records in file."));
-
- return( false );
- }
-
- SG_UI_Msg_Add(LNG("[MSG] okay"), false, SG_UI_MSG_STYLE_SUCCESS);
-
- return( true );
-}
-
-//---------------------------------------------------------
-bool CSG_PointCloud::_Save(const CSG_String &File_Name)
-{
- CSG_File Stream;
+ m_nSelected--;
- SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), LNG("[MSG] Save point cloud"), File_Name.c_str()), true);
-
- if( Stream.Open(File_Name, SG_FILE_W, true) == false )
- {
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
- SG_UI_Msg_Add_Error(LNG("[ERR] unable to create file."));
-
- return( false );
- }
-
- int i, iBuffer;
-
- Stream.Write((void *)POINTCLOUD_FILE_VERSION, 6);
- Stream.Write(&m_nPointBytes , sizeof(int));
- Stream.Write(&m_nFields , sizeof(int));
-
- for(i=0; i<m_nFields; i++)
- {
- Stream.Write(&m_Field_Type[i], sizeof(TSG_Data_Type));
-
- iBuffer = m_Field_Name[i]->Length(); if( iBuffer >= 1024 - 1 ) iBuffer = 1024 - 1;
- Stream.Write(&iBuffer, sizeof(int));
- Stream.Write((void *)m_Field_Name[i]->b_str(), sizeof(char), iBuffer);
- }
-
- for(i=0; i<m_nPoints && SG_UI_Process_Set_Progress(i, m_nPoints); i++)
- {
- Stream.Write(m_Points[i], m_nPointBytes);
- }
-
- Set_Modified(false);
-
- Set_File_Name(SG_File_Make_Path(NULL, File_Name, SG_T("spc")));
-
- Save_MetaData(File_Name);
-
- SG_UI_Msg_Add(LNG("[MSG] okay"), false, SG_UI_MSG_STYLE_SUCCESS);
-
- return( true );
-}
-
-bool CSG_PointCloud::Save(const CSG_String &File_Name, int Format)
-{
- return( _Save(File_Name) );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// Assign //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSG_PointCloud::Assign(CSG_Data_Object *pObject)
-{
- if( pObject && pObject->is_Valid() && pObject->Get_ObjectType() == Get_ObjectType() )
- {
- Destroy();
-
- CSG_PointCloud *pPointCloud = (CSG_PointCloud *)pObject;
-
- Get_History() = pPointCloud->Get_History();
-
- for(int iField=0; iField<pPointCloud->m_nFields; iField++)
- {
- _Add_Field(pPointCloud->m_Field_Name[iField]->c_str(), pPointCloud->m_Field_Type[iField]);
- }
-
- for(int iPoint=0; iPoint<pPointCloud->m_nPoints; iPoint++)
- {
- if( _Inc_Array() )
+ for(int i=0; i<m_nSelected; i++)
{
- memcpy(m_Points[iPoint], pPointCloud->m_Points[iPoint], m_nPointBytes);
+ if( m_Points[iRecord] == m_Points[m_Selected[i]] )
+ {
+ for(; i<m_nSelected; i++)
+ {
+ m_Selected[i] = m_Selected[i + 1];
+ }
+ }
}
- }
- return( true );
+ m_Array_Selected.Set_Array(m_nSelected, (void **)&m_Selected);
+
+ return( true );
+ }
}
return( false );
}
-
-///////////////////////////////////////////////////////////
-// //
-// Checks //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSG_PointCloud::is_Compatible(CSG_PointCloud *pPointCloud) const
+//---------------------------------------------------------
+bool CSG_PointCloud::Select(CSG_Shape *pShape, bool bInvert)
{
- if( Get_Field_Count() == pPointCloud->Get_Field_Count() )
- {
- for(int i=0; i<Get_Field_Count(); i++)
- {
- if( Get_Field_Type(i) != pPointCloud->Get_Field_Type(i) )
- {
- return( false );
- }
- }
-
- return( true );
- }
-
return( false );
}
-
-///////////////////////////////////////////////////////////
-// //
-// Fields //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSG_PointCloud::_Add_Field(const SG_Char *Name, TSG_Data_Type Type)
+//---------------------------------------------------------
+bool CSG_PointCloud::Select(TSG_Rect Extent, bool bInvert)
{
- if( SG_Data_Type_Get_Size(Type) <= 0 )
+ if( !bInvert ) // clear selection
{
- return( false );
+ Select(-1, false);
}
- m_Field_Name = (CSG_String **)SG_Realloc(m_Field_Name , (m_nFields + 1) * sizeof(CSG_String *));
- m_Field_Type = (TSG_Data_Type *)SG_Realloc(m_Field_Type , (m_nFields + 1) * sizeof(TSG_Data_Type));
- m_Field_Stats = (CSG_Simple_Statistics **)SG_Realloc(m_Field_Stats , (m_nFields + 1) * sizeof(CSG_Simple_Statistics *));
- m_Field_Offset = (int *)SG_Realloc(m_Field_Offset, (m_nFields + 1) * sizeof(int));
-
- m_Field_Name [m_nFields] = new CSG_String(Name);
- m_Field_Type [m_nFields] = Type;
- m_Field_Stats [m_nFields] = new CSG_Simple_Statistics();
- m_Field_Offset[m_nFields] = m_nFields == 0 ? 0 : m_Field_Offset[m_nFields - 1] + SG_Data_Type_Get_Size(m_Field_Type[m_nFields - 1]);
-
- m_nPointBytes += SG_Data_Type_Get_Size(m_Field_Type[m_nFields]);
- m_nFields ++;
-
- return( true );
-}
-
-//---------------------------------------------------------
-bool CSG_PointCloud::Add_Field(const SG_Char *Name, TSG_Data_Type Type)
-{
- if( m_nPoints == 0 )
- {
- if( m_nFields == 0 )
+ if( Get_Extent().Intersects(Extent) != INTERSECTION_None )
+ {
+ for(int i=0; i<Get_Count(); i++)
{
- _Add_Field(SG_T("X"), m_bXYZPrecDbl ? SG_DATATYPE_Double : SG_DATATYPE_Float);
- _Add_Field(SG_T("Y"), m_bXYZPrecDbl ? SG_DATATYPE_Double : SG_DATATYPE_Float);
- _Add_Field(SG_T("Z"), m_bXYZPrecDbl ? SG_DATATYPE_Double : SG_DATATYPE_Float);
- }
+ Set_Cursor(i);
- if( Name && SG_Data_Type_Get_Size(Type) > 0 )
- {
- return( _Add_Field(Name, Type) );
+ if( Extent.xMin <= Get_X() && Get_X() <= Extent.xMax
+ && Extent.yMin <= Get_Y() && Get_Y() <= Extent.yMax )
+ {
+ Select(i, true);
+ }
}
}
- return( false );
+ return( m_nSelected > 0 );
}
-//---------------------------------------------------------
-#ifdef _SAGA_UNICODE
-bool CSG_PointCloud::Add_Field(const char *Name, TSG_Data_Type Type)
-{ return( Add_Field(CSG_String(Name), Type) ); }
-#endif
-
-//---------------------------------------------------------
-bool CSG_PointCloud::_Set_Field_Value(char *pPoint, int iField, double Value)
+//---------------------------------------------------------
+bool CSG_PointCloud::Select(TSG_Point Point, bool bInvert)
{
- if( pPoint && iField >= 0 && iField < m_nFields )
- {
- pPoint = ((char *)pPoint) + m_Field_Offset[iField];
-
- switch( m_Field_Type[iField] )
- {
- default:
- case SG_DATATYPE_Undefined: break;
- case SG_DATATYPE_Byte: *((BYTE *)pPoint) = (BYTE )Value; break;
- case SG_DATATYPE_Char: *((char *)pPoint) = (char )Value; break;
- case SG_DATATYPE_Word: *((WORD *)pPoint) = (WORD )Value; break;
- case SG_DATATYPE_Short: *((short *)pPoint) = (short )Value; break;
- case SG_DATATYPE_DWord: *((DWORD *)pPoint) = (DWORD )Value; break;
- case SG_DATATYPE_Int: *((int *)pPoint) = (int )Value; break;
- case SG_DATATYPE_Long: *((long *)pPoint) = (long )Value; break;
- case SG_DATATYPE_Float: *((float *)pPoint) = (float )Value; break;
- case SG_DATATYPE_Double: *((double *)pPoint) = (double)Value; break;
- }
+ CSG_Rect r(Point.x, Point.y, Point.x, Point.y);
- return( true );
- }
-
- return( false );
+ return( Select(r.m_rect, bInvert) );
}
-
-//---------------------------------------------------------
-double CSG_PointCloud::_Get_Field_Value(char *pPoint, int iField) const
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_PointCloud::is_Selected(int iRecord) const
{
- if( pPoint && iField >= 0 && iField < m_nFields )
- {
- pPoint = ((char *)pPoint) + m_Field_Offset[iField];
-
- switch( m_Field_Type[iField] )
- {
- case SG_DATATYPE_Undefined: default: break;
- case SG_DATATYPE_Byte: return( *((BYTE *)pPoint) );
- case SG_DATATYPE_Char: return( *((char *)pPoint) );
- case SG_DATATYPE_Word: return( *((WORD *)pPoint) );
- case SG_DATATYPE_Short: return( *((short *)pPoint) );
- case SG_DATATYPE_DWord: return( *((DWORD *)pPoint) );
- case SG_DATATYPE_Int: return( *((int *)pPoint) );
- case SG_DATATYPE_Long: return( *((long *)pPoint) );
- case SG_DATATYPE_Float: return( *((float *)pPoint) );
- case SG_DATATYPE_Double: return( *((double *)pPoint) );
- }
- }
-
- return( 0.0 );
+ return( iRecord >= 0 && iRecord < Get_Count() && (m_Points[iRecord][0] & SG_TABLE_REC_FLAG_Selected) != 0 );
}
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-TSG_Point_3D CSG_PointCloud::Get_Point(void) const
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Shape * CSG_PointCloud::Get_Selection(int Index)
{
- TSG_Point_3D p;
-
- if( m_Cursor )
- {
- p.x = _Get_Field_Value(m_Cursor, 0);
- p.y = _Get_Field_Value(m_Cursor, 1);
- p.z = _Get_Field_Value(m_Cursor, 2);
- }
- else
- {
- p.x = p.y = p.z = 0.0;
- }
-
- return( p );
+ return( Index >= 0 && Index < m_nSelected ? _Set_Shape(m_Selected[Index]) : NULL );
}
-//---------------------------------------------------------
-TSG_Point_3D CSG_PointCloud::Get_Point(int iPoint) const
+//---------------------------------------------------------
+const CSG_Rect & CSG_PointCloud::Get_Selection_Extent(void)
{
- TSG_Point_3D p;
-
- if( iPoint >= 0 && iPoint < m_nPoints )
+ if( m_nSelected > 0 && Set_Cursor(m_Selected[0]) )
{
- char *pPoint = m_Points[iPoint];
+ TSG_Rect r;
- p.x = _Get_Field_Value(pPoint, 0);
- p.y = _Get_Field_Value(pPoint, 1);
- p.z = _Get_Field_Value(pPoint, 2);
- }
- else
- {
- p.x = p.y = p.z = 0.0;
- }
+ r.xMin = r.xMax = Get_X();
+ r.yMin = r.yMax = Get_Y();
- return( p );
-}
-
-//---------------------------------------------------------
-bool CSG_PointCloud::Set_NoData_Value(double NoData_Value)
-{
- if( NoData_Value != m_NoData_Value )
- {
- for(int i=3; i<m_nFields; i++)
+ for(int i=1; i<m_nSelected; i++)
{
- m_Field_Stats[i]->Invalidate();
+ if( Set_Cursor(m_Selected[i]) )
+ {
+ if( Get_X() < r.xMin ) r.xMin = Get_X(); else if( Get_X() > r.xMax ) r.xMax = Get_X();
+ if( Get_Y() < r.yMin ) r.yMin = Get_Y(); else if( Get_Y() > r.yMax ) r.yMax = Get_Y();
+ }
}
- return( true );
+ m_Extent_Selected.Assign(r);
}
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CSG_PointCloud::Add_Point(double x, double y, double z)
-{
- if( _Inc_Array() )
- {
- _Set_Field_Value(m_Cursor, 0, x);
- _Set_Field_Value(m_Cursor, 1, y);
- _Set_Field_Value(m_Cursor, 2, z);
-
- Set_Modified();
-
- Set_Update_Flag();
-
- _Stats_Invalidate();
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CSG_PointCloud::Del_Point(int iPoint)
-{
- if( iPoint >= 0 && iPoint < m_nPoints )
+ else
{
- m_Cursor = NULL;
-
- delete(m_Points[iPoint]);
-
- m_nPoints--;
-
- for(int i=iPoint, j=iPoint+1; i<m_nPoints; i++, j++)
- {
- m_Points[i] = m_Points[i + 1];
- }
-
- _Dec_Array();
-
- Set_Modified();
-
- Set_Update_Flag();
-
- return( true );
+ m_Extent_Selected.Assign(0.0, 0.0, 0.0, 0.0);
}
- return( false );
+ return( m_Extent_Selected );
}
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
-bool CSG_PointCloud::Del_Points(void)
+int CSG_PointCloud::Del_Selection(void)
{
- if( m_nBuffer > 0 )
+ if( m_nSelected <= 0 )
{
- for(int iPoint=0; iPoint<m_nPoints; iPoint++)
- {
- SG_Free(m_Points[iPoint]);
- }
-
- SG_Free(m_Points);
- m_Points = NULL;
- m_nPoints = 0;
- m_nBuffer = 0;
- m_Cursor = NULL;
-
- return( true );
+ return( 0 );
}
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
+ //-----------------------------------------------------
+ int i, n;
-//---------------------------------------------------------
-#define GET_GROW_SIZE(n) (n < 256 ? 1 : (n < 8192 ? 128 : 1024))
+ m_Array_Selected.Set_Array(0, (void **)&m_Selected);
+ m_nSelected = 0;
+ m_Cursor = NULL;
-//---------------------------------------------------------
-bool CSG_PointCloud::_Inc_Array(void)
-{
- if( m_nFields > 0 )
+ for(i=0, n=0; i<m_nRecords; i++)
{
- if( (m_nPoints + 1) >= m_nBuffer )
+ if( (m_Points[i][0] & SG_TABLE_REC_FLAG_Selected) != 0 )
{
- char **pPoints = (char **)SG_Realloc(m_Points, (m_nBuffer + GET_GROW_SIZE(m_nBuffer)) * sizeof(char *));
-
- if( pPoints )
- {
- m_Points = pPoints;
- m_nBuffer += GET_GROW_SIZE(m_nBuffer);
- }
- else
- {
- return( false );
- }
+ SG_Free(m_Points[i]);
}
-
- m_Cursor = m_Points[m_nPoints] = (char *)SG_Calloc(m_nPointBytes, sizeof(char));
- m_nPoints ++;
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CSG_PointCloud::_Dec_Array(void)
-{
- if( m_nPoints > 0 )
- {
- _Stats_Invalidate();
-
- m_Cursor = NULL;
- m_nPoints --;
-
- SG_Free(m_Points[m_nPoints]);
-
- if( (m_nPoints - 1) < m_nBuffer - GET_GROW_SIZE(m_nBuffer) )
+ else
{
- char **pPoints = (char **)SG_Realloc(m_Points, (m_nBuffer - GET_GROW_SIZE(m_nBuffer)) * sizeof(char *));
-
- if( pPoints )
+ if( n < i )
{
- m_Points = pPoints;
- m_nBuffer -= GET_GROW_SIZE(m_nBuffer);
+ m_Points[n] = m_Points[i];
}
+
+ n++;
}
}
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// Statistics //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-const CSG_Rect & CSG_PointCloud::Get_Extent(void)
-{
- if( m_nFields >= 2 )
- {
- _Stats_Update(0);
- _Stats_Update(1);
+ m_Array_Points.Set_Array(m_nRecords = n, (void **)&m_Points);
- m_Extent.Assign(
- m_Field_Stats[0]->Get_Minimum(), m_Field_Stats[1]->Get_Minimum(),
- m_Field_Stats[0]->Get_Maximum(), m_Field_Stats[1]->Get_Maximum()
- );
- }
-
- return( m_Extent );
+ return( n );
}
//---------------------------------------------------------
-bool CSG_PointCloud::_Stats_Invalidate(void) const
+int CSG_PointCloud::Inv_Selection(void)
{
- for(int iField=0; iField<m_nFields; iField++)
- {
- _Stats_Invalidate(iField);
- }
+ char **pPoint;
+ int i, n;
- return( true );
-}
+ n = m_nRecords - m_nSelected;
-//---------------------------------------------------------
-bool CSG_PointCloud::_Stats_Invalidate(int iField) const
-{
- if( iField >= 0 && iField < m_nFields )
+ if( m_Array_Selected.Set_Array(n, (void **)&m_Selected) )
{
- m_Field_Stats[iField]->Invalidate();
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CSG_PointCloud::_Stats_Update(int iField) const
-{
- if( iField >= 0 && iField < m_nFields && m_nPoints > 0 )
- {
- if( !m_Field_Stats[iField]->is_Evaluated() )
+ for(i=0, m_nSelected=0, pPoint=m_Points; i<m_nRecords; i++, pPoint++)
{
- char **pPoint = m_Points;
-
- for(int iPoint=0; iPoint<m_nPoints; iPoint++, pPoint++)
+ if( ((*pPoint)[0] & SG_TABLE_REC_FLAG_Selected) != 0 && m_nSelected < n )
{
- double Value = _Get_Field_Value(*pPoint, iField);
+ m_Selected[m_nSelected++] = i;
- if( iField < 3 || Value != m_NoData_Value )
- {
- m_Field_Stats[iField]->Add_Value(Value);
- }
+ (*pPoint)[0] |= SG_TABLE_REC_FLAG_Selected;
+ }
+ else
+ {
+ (*pPoint)[0] &= ~SG_TABLE_REC_FLAG_Selected;
}
}
-
- return( true );
}
- return( false );
+ return( m_nSelected );
}
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_api/pointcloud.h b/src/saga_core/saga_api/pointcloud.h
index 3193a1e..14ac779 100644
--- a/src/saga_core/saga_api/pointcloud.h
+++ b/src/saga_core/saga_api/pointcloud.h
@@ -69,7 +69,7 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#include "dataobject.h"
+#include "shapes.h"
///////////////////////////////////////////////////////////
@@ -79,7 +79,7 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-class SAGA_API_DLL_EXPORT CSG_PointCloud : public CSG_Data_Object
+class SAGA_API_DLL_EXPORT CSG_PointCloud : public CSG_Shapes
{
public:
@@ -105,47 +105,35 @@ public:
virtual bool Save (const CSG_String &File_Name, int Format = 0);
- const CSG_Rect & Get_Extent (void);
-
void Set_XYZ_Precision (bool bDouble) { m_bXYZPrecDbl = bDouble; }
//-----------------------------------------------------
- virtual bool is_Valid (void) const { return( m_nPoints > 0 ); }
+ virtual bool is_Valid (void) const { return( m_nFields > 0 ); }
bool is_Compatible (CSG_PointCloud *pPointCloud) const;
//-----------------------------------------------------
- bool Add_Field (const SG_Char *Name, TSG_Data_Type Type);
+ virtual bool Add_Field (const SG_Char *Name, TSG_Data_Type Type, int iField = -1);
#ifdef _SAGA_UNICODE
- bool Add_Field (const char *Name, TSG_Data_Type Type);
+ virtual bool Add_Field (const char *Name, TSG_Data_Type Type, int iField = -1);
#endif
+ virtual bool Del_Field (int iField);
- int Get_Field_Count (void) const { return( m_nFields ); }
- const SG_Char * Get_Field_Name (int iField) const { return( iField >= 0 && iField < m_nFields ? m_Field_Name[iField]->c_str() : NULL ); }
- TSG_Data_Type Get_Field_Type (int iField) const { return( iField >= 0 && iField < m_nFields ? m_Field_Type[iField] : SG_DATATYPE_Undefined ); }
-
- int Get_Attribute_Count (void) const { return( m_nFields ); }
- const SG_Char * Get_Attribute_Name (int iField) const { return( iField >= 0 && iField < m_nFields ? m_Field_Name[iField]->c_str() : NULL ); }
- TSG_Data_Type Get_Attribute_Type (int iField) const { return( iField >= 0 && iField < m_nFields ? m_Field_Type[iField] : SG_DATATYPE_Undefined ); }
-
- double Get_Minimum (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Minimum() : 0.0 ); }
- double Get_Maximum (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Maximum() : 0.0 ); }
- double Get_Range (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Range() : 0.0 ); }
- double Get_Mean (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Mean() : 0.0 ); }
- double Get_StdDev (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_StdDev() : 0.0 ); }
- double Get_Variance (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Variance() : 0.0 ); }
+ //-----------------------------------------------------
+ int Get_Attribute_Count (void) const { return( m_nFields - 3 ); }
+ const SG_Char * Get_Attribute_Name (int iField) const { iField += 3; return( iField >= 3 && iField < m_nFields ? m_Field_Name[iField]->c_str() : NULL ); }
+ TSG_Data_Type Get_Attribute_Type (int iField) const { iField += 3; return( iField >= 3 && iField < m_nFields ? m_Field_Type[iField] : SG_DATATYPE_Undefined ); }
//-----------------------------------------------------
bool Add_Point (double x, double y, double z);
bool Del_Point (int iPoint);
bool Del_Points (void);
- int Get_Point_Count (void) const { return( m_nPoints ); }
- int Get_Count (void) const { return( m_nPoints ); }
+ int Get_Point_Count (void) const { return( m_nRecords ); }
//-----------------------------------------------------
- bool Set_Cursor (int iPoint) { return( (m_Cursor = iPoint >= 0 && iPoint < m_nPoints ? m_Points[iPoint] : NULL) != NULL ); }
- bool Set_Value (int iField, double Value) { return( _Set_Field_Value(m_Cursor, iField, Value) ); }
- double Get_Value (int iField) const { return( _Get_Field_Value(m_Cursor, iField) ); }
+ bool Set_Cursor (int iPoint) { return( (m_Cursor = iPoint >= 0 && iPoint < m_nRecords ? m_Points[iPoint] : NULL) != NULL ); }
+ virtual bool Set_Value (int iField, double Value) { return( _Set_Field_Value(m_Cursor, iField, Value) ); }
+ virtual double Get_Value (int iField) const { return( _Get_Field_Value(m_Cursor, iField) ); }
double Get_X (void) const { return( _Get_Field_Value(m_Cursor, 0) ); }
double Get_Y (void) const { return( _Get_Field_Value(m_Cursor, 1) ); }
double Get_Z (void) const { return( _Get_Field_Value(m_Cursor, 2) ); }
@@ -154,50 +142,86 @@ public:
bool Set_NoData (int iField) { return( Set_Attribute(iField, m_NoData_Value) ); }
bool is_NoData (int iField) const { return( Get_Attribute(iField) == m_NoData_Value ); }
- bool Set_Value (int iPoint, int iField, double Value) { return( _Set_Field_Value(iPoint >= 0 && iPoint < m_nPoints ? m_Points[iPoint] : NULL, iField, Value) ); }
- double Get_Value (int iPoint, int iField) const { return( _Get_Field_Value(iPoint >= 0 && iPoint < m_nPoints ? m_Points[iPoint] : NULL, iField) ); }
- double Get_X (int iPoint) const { return( _Get_Field_Value(iPoint >= 0 && iPoint < m_nPoints ? m_Points[iPoint] : NULL, 0) ); }
- double Get_Y (int iPoint) const { return( _Get_Field_Value(iPoint >= 0 && iPoint < m_nPoints ? m_Points[iPoint] : NULL, 1) ); }
- double Get_Z (int iPoint) const { return( _Get_Field_Value(iPoint >= 0 && iPoint < m_nPoints ? m_Points[iPoint] : NULL, 2) ); }
+ virtual bool Set_Value (int iPoint, int iField, double Value) { return( _Set_Field_Value(iPoint >= 0 && iPoint < m_nRecords ? m_Points[iPoint] : NULL, iField, Value) ); }
+ virtual double Get_Value (int iPoint, int iField) const { return( _Get_Field_Value(iPoint >= 0 && iPoint < m_nRecords ? m_Points[iPoint] : NULL, iField) ); }
+ double Get_X (int iPoint) const { return( _Get_Field_Value(iPoint >= 0 && iPoint < m_nRecords ? m_Points[iPoint] : NULL, 0) ); }
+ double Get_Y (int iPoint) const { return( _Get_Field_Value(iPoint >= 0 && iPoint < m_nRecords ? m_Points[iPoint] : NULL, 1) ); }
+ double Get_Z (int iPoint) const { return( _Get_Field_Value(iPoint >= 0 && iPoint < m_nRecords ? m_Points[iPoint] : NULL, 2) ); }
bool Set_Attribute (int iPoint, int iField, double Value) { return( Set_Value(iPoint, iField + 3, Value) ); }
double Get_Attribute (int iPoint, int iField) const { return( Get_Value(iPoint, iField + 3) ); }
bool Set_NoData (int iPoint, int iField) { return( Set_Attribute(iPoint, iField, m_NoData_Value) ); }
bool is_NoData (int iPoint, int iField) const { return( Get_Attribute(iPoint, iField) == m_NoData_Value ); }
- TSG_Point_3D Get_Point (void) const;
- TSG_Point_3D Get_Point (int iPoint) const;
+ virtual bool Set_Value (int iPoint, int iField, const SG_Char *Value);
+ virtual bool Get_Value (int iPoint, int iField, CSG_String &Value) const;
+
+ TSG_Point_Z Get_Point (void) const;
+ TSG_Point_Z Get_Point (int iPoint) const;
double Get_NoData_Value (void) const { return( m_NoData_Value ); }
bool Set_NoData_Value (double NoData_Value);
- virtual void Set_Modified (bool bModified = true) { CSG_Data_Object::Set_Modified(bModified); }
+ virtual void Set_Modified (bool bModified = true) { CSG_Data_Object::Set_Modified(bModified); }
-protected:
+ //-----------------------------------------------------
+ // Overrides: CSG_Table, CSG_Shapes
- bool m_bXYZPrecDbl;
+ virtual CSG_Table_Record * Get_Record (int iRecord) const;
- char **m_Points, *m_Cursor;
+ virtual CSG_Shape * Get_Shape (TSG_Point Point, double Epsilon = 0.0);
- int m_nFields, m_nPoints, m_nBuffer, m_nPointBytes, *m_Field_Offset;
+ virtual bool Del_Record (int iRecord) { return( Del_Point(iRecord) ); }
+ virtual bool Del_Shape (int iShape) { return( Del_Point(iShape) ); }
+ virtual bool Del_Records (void) { return( Del_Points() ); }
+ virtual bool Del_Shapes (void) { return( Del_Points() ); }
- double m_NoData_Value;
+ virtual CSG_Table_Record * Ins_Record (int iRecord, CSG_Table_Record *pCopy = NULL) { return( NULL ); }
+ virtual CSG_Table_Record * Add_Record ( CSG_Table_Record *pCopy = NULL) { return( NULL ); }
+ virtual CSG_Shape * Add_Shape ( CSG_Table_Record *pCopy = NULL, TSG_ADD_Shape_Copy_Mode mCopy = SHAPE_COPY) { return( NULL ); }
+ virtual bool Del_Shape (CSG_Shape *pShape) { return( false ); }
- TSG_Data_Type *m_Field_Type;
+ virtual bool Select (int iRecord , bool bInvert = false);
+ virtual bool Select (CSG_Shape *pShape = NULL, bool bInvert = false);
+ virtual bool Select (TSG_Rect Extent , bool bInvert = false);
+ virtual bool Select (TSG_Point Point , bool bInvert = false);
- CSG_Simple_Statistics **m_Field_Stats;
+ virtual bool is_Selected (int iRecord) const;
- CSG_String **m_Field_Name;
+ virtual int Del_Selection (void);
+ virtual int Inv_Selection (void);
+ virtual CSG_Shape * Get_Selection (int Index = 0);
+ virtual const CSG_Rect & Get_Selection_Extent(void);
- CSG_Rect m_Extent;
+protected:
+
+ virtual bool On_Update (void);
virtual void _On_Construction (void);
+ virtual bool _Stats_Update (int iField) const;
+
+
+private:
+
+ bool m_bXYZPrecDbl;
+
+ char **m_Points, *m_Cursor;
+
+ int m_nPointBytes, *m_Field_Offset, m_Shapes_Index, *m_Selected;
+
+ double m_NoData_Value;
+
+ CSG_Array m_Array_Points, m_Array_Selected;
+
+ CSG_Shapes m_Shapes;
+
+
bool _Load (const CSG_String &File_Name);
bool _Save (const CSG_String &File_Name);
- bool _Add_Field (const SG_Char *Name, TSG_Data_Type Type);
+ bool _Add_Field (const SG_Char *Name, TSG_Data_Type Type, int iField = -1);
bool _Set_Field_Value (char *pPoint, int iField, double Value);
double _Get_Field_Value (char *pPoint, int iField) const;
int _Get_Field_Bytes (TSG_Data_Type Type);
@@ -205,9 +229,7 @@ protected:
bool _Inc_Array (void);
bool _Dec_Array (void);
- bool _Stats_Invalidate (void) const;
- bool _Stats_Invalidate (int iField) const;
- bool _Stats_Update (int iField) const;
+ CSG_Shape * _Set_Shape (int iPoint);
};
diff --git a/src/saga_core/saga_api/projections.cpp b/src/saga_core/saga_api/projections.cpp
index ec802a3..d069fa6 100644
--- a/src/saga_core/saga_api/projections.cpp
+++ b/src/saga_core/saga_api/projections.cpp
@@ -120,106 +120,111 @@ bool CSG_Projection::Create(const CSG_Projection &Projection)
return( Assign(Projection) );
}
+bool CSG_Projection::Assign(const CSG_Projection &Projection)
+{
+ m_Name = Projection.m_Name;
+ m_Type = Projection.m_Type;
+ m_WKT = Projection.m_WKT;
+ m_Proj4 = Projection.m_Proj4;
+ m_EPSG = Projection.m_EPSG;
+
+ return( true );
+}
+
//---------------------------------------------------------
-CSG_Projection::CSG_Projection(int SRID, const SG_Char *Authority, const SG_Char *OpenGIS, const SG_Char *Proj4)
+CSG_Projection::CSG_Projection(int EPSG_SRID)
{
_Reset();
- Create(SRID, Authority, OpenGIS, Proj4);
+ Create(EPSG_SRID);
}
-bool CSG_Projection::Create(int SRID, const SG_Char *Authority, const SG_Char *OpenGIS, const SG_Char *Proj4)
+bool CSG_Projection::Create(int EPSG_SRID)
{
- return( Assign(SRID, Authority, OpenGIS, Proj4) );
+ return( Assign(EPSG_SRID) );
}
-//---------------------------------------------------------
-void CSG_Projection::_Reset(void)
+bool CSG_Projection::Assign(int EPSG_SRID)
{
- m_SRID = -1;
- m_Type = SG_PROJ_TYPE_CS_Undefined;
- m_Name = LNG("undefined");
- m_OpenGIS .Clear();
- m_Proj4 .Clear();
- m_Authority .Clear();
+ return( Assign(CSG_String::Format(SG_T("%d"), EPSG_SRID), SG_PROJ_FMT_EPSG) );
}
+//---------------------------------------------------------
+CSG_Projection::CSG_Projection(const CSG_String &Projection, TSG_Projection_Format Format)
+{
+ _Reset();
-///////////////////////////////////////////////////////////
-// //
-///////////////////////////////////////////////////////////
+ Create(Projection, Format);
+}
-//---------------------------------------------------------
-bool CSG_Projection::Assign(int SRID, const SG_Char *Authority, const SG_Char *OpenGIS, const SG_Char *Proj4)
+bool CSG_Projection::Create(const CSG_String &Projection, TSG_Projection_Format Format)
+{
+ return( Assign(Projection, Format) );
+}
+
+bool CSG_Projection::Assign(const CSG_String &Projection, TSG_Projection_Format Format)
{
_Reset();
- if( !OpenGIS )
+ switch( Format )
{
- if( !_Get_OpenGIS_from_Proj4(Proj4) )
+ default:
+ return( false );
+
+ case SG_PROJ_FMT_WKT:
+ if( !gSG_Projections.WKT_to_Proj4(m_Proj4, Projection) )
{
return( false );
}
- }
- else
- {
- m_OpenGIS = OpenGIS;
- }
- CSG_String s(m_OpenGIS.BeforeFirst('['));
+ m_WKT = Projection;
- if( !s.Cmp(SG_T("PROJCS")) )
- {
- m_Type = SG_PROJ_TYPE_CS_Projected;
+ break;
+
+ case SG_PROJ_FMT_Proj4:
+ if( !gSG_Projections.WKT_to_Proj4(m_WKT , Projection) )
+ {
+ return( false );
+ }
+
+ m_Proj4 = Projection;
+
+ break;
+
+ case SG_PROJ_FMT_EPSG:
+ if( !Projection.asInt(m_EPSG) || !gSG_Projections.Get_Projection(m_EPSG, *this) )
+ {
+ return( false );
+ }
+ break;
}
- else if( !s.Cmp(SG_T("GEOGCS")) )
+
+ m_Name = m_WKT.AfterFirst(SG_T('\"')).BeforeFirst(SG_T('\"'));
+
+ if( m_WKT.Make_Upper().Find(SG_T("GEOGCS")) >= 0 )
{
m_Type = SG_PROJ_TYPE_CS_Geographic;
}
- else if( !s.Cmp(SG_T("GEOCCS")) )
- {
- m_Type = SG_PROJ_TYPE_CS_Geocentric;
- }
- else
- {
- return( false );
- }
-
- if( !Proj4 )
+ else if( m_WKT.Make_Upper().Find(SG_T("PROJCS")) >= 0 )
{
- _Get_Proj4_from_OpenGIS(OpenGIS);
+ m_Type = SG_PROJ_TYPE_CS_Projected;
}
else
{
- m_Proj4 = Proj4;
+ m_Type = SG_PROJ_TYPE_CS_Geocentric;
}
- m_SRID = SRID;
- m_Authority = Authority ? Authority : SG_T("");
- m_Name = m_OpenGIS.AfterFirst('\"').BeforeFirst('\"');
-
return( true );
}
//---------------------------------------------------------
-bool CSG_Projection::Assign(const CSG_Projection &Projection)
-{
- m_SRID = Projection.m_SRID;
- m_Type = Projection.m_Type;
- m_Name = Projection.m_Name;
- m_OpenGIS = Projection.m_OpenGIS;
- m_Proj4 = Projection.m_Proj4;
- m_Authority = Projection.m_Authority;
-
- return( true );
-}
-
-//---------------------------------------------------------
-bool CSG_Projection::is_Equal(const CSG_Projection &Projection) const
+void CSG_Projection::_Reset(void)
{
- return( m_SRID == Projection.m_SRID
- && m_Type == Projection.m_Type
- );
+ m_Name = LNG("undefined");
+ m_Type = SG_PROJ_TYPE_CS_Undefined;
+ m_WKT .Clear();
+ m_Proj4 .Clear();
+ m_EPSG = -1;
}
@@ -228,27 +233,84 @@ bool CSG_Projection::is_Equal(const CSG_Projection &Projection) const
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-bool CSG_Projection::_Get_OpenGIS_from_Proj4(const SG_Char *Text)
+bool CSG_Projection::Load(const CSG_String &File_Name, TSG_Projection_Format Format)
{
+ CSG_File Stream;
+ CSG_String s;
+
+ if( Stream.Open(File_Name, SG_FILE_R, false) )
+ {
+ Stream.Read(s, Stream.Length());
+
+ return( Assign(s, Format) );
+ }
+
return( false );
}
//---------------------------------------------------------
-bool CSG_Projection::_Get_Proj4_from_OpenGIS(const SG_Char *Text)
+bool CSG_Projection::Save(const CSG_String &File_Name, TSG_Projection_Format Format) const
{
+ if( is_Okay() )
+ {
+ CSG_File Stream;
+
+ switch( Format )
+ {
+ default:
+ break;
+
+ case SG_PROJ_FMT_WKT:
+ if( Stream.Open(File_Name, SG_FILE_W, false) )
+ {
+ Stream.Write((void *)m_WKT.c_str(), m_WKT.Length());
+
+ return( true );
+ }
+ break;
+
+ case SG_PROJ_FMT_Proj4:
+ if( Stream.Open(File_Name, SG_FILE_W, false) )
+ {
+ Stream.Write((void *)m_Proj4.c_str(), m_Proj4.Length());
+
+ return( true );
+ }
+ break;
+ }
+ }
+
return( false );
}
//---------------------------------------------------------
-bool CSG_Projection::from_ESRI(const CSG_String &ESRI_PRJ)
+bool CSG_Projection::Load(const CSG_MetaData &Projection)
{
+ CSG_MetaData *pEntry;
+
+ if( (pEntry = Projection.Get_Child(SG_T("OGC_WKT"))) != NULL )
+ {
+ Assign(pEntry->Get_Content(), SG_PROJ_FMT_WKT);
+
+ if( (pEntry = Projection.Get_Child(SG_T("PROJ4"))) != NULL )
+ {
+ m_Proj4 = pEntry->Get_Content();
+ }
+
+ return( true );
+ }
+
return( false );
}
//---------------------------------------------------------
-bool CSG_Projection::to_ESRI(CSG_String &ESRI_PRJ) const
+bool CSG_Projection::Save(CSG_MetaData &Projection) const
{
- return( false );
+ Projection.Add_Child(SG_T("OGC_WKT"), m_WKT );
+ Projection.Add_Child(SG_T("PROJ4") , m_Proj4);
+ Projection.Add_Child(SG_T("EPSG") , m_EPSG );
+
+ return( true );
}
@@ -257,9 +319,9 @@ bool CSG_Projection::to_ESRI(CSG_String &ESRI_PRJ) const
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-CSG_String CSG_Projection::asString(void) const
+bool CSG_Projection::is_Equal(const CSG_Projection &Projection) const
{
- return( m_Name );
+ return( m_Proj4 == Projection.m_Proj4 );
}
@@ -270,14 +332,14 @@ CSG_String CSG_Projection::asString(void) const
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define PRJ_FIELD_SRID 0
-#define PRJ_FIELD_AUTH_NAME 1
-#define PRJ_FIELD_AUTH_SRID 2
-#define PRJ_FIELD_SRTEXT 3
-#define PRJ_FIELD_PROJ4TEXT 4
-
-//---------------------------------------------------------
-CSG_Projections *CSG_Projections::s_pProjections = NULL;
+enum ESG_PROJ_FIELD_ID
+{
+ PRJ_FIELD_SRID = 0,
+ PRJ_FIELD_AUTH_NAME,
+ PRJ_FIELD_AUTH_SRID,
+ PRJ_FIELD_SRTEXT,
+ PRJ_FIELD_PROJ4TEXT
+};
///////////////////////////////////////////////////////////
@@ -324,17 +386,7 @@ bool CSG_Projections::Create(CSG_Table *pProjections)
for(int i=0; i<pProjections->Get_Count() && SG_UI_Process_Set_Progress(i, pProjections->Get_Count()); i++)
{
- CSG_Projection Projection;
- CSG_Table_Record *pRecord = pProjections->Get_Record(i);
-
- if( Projection.Assign(
- pRecord->asInt (PRJ_FIELD_SRID),
- pRecord->asString(PRJ_FIELD_AUTH_NAME),
- pRecord->asString(PRJ_FIELD_SRTEXT),
- pRecord->asString(PRJ_FIELD_PROJ4TEXT)) )
- {
- Add(Projection);
- }
+ m_pProjections->Add_Record(pProjections->Get_Record(i));
}
return( Get_Count() > 0 );
@@ -343,12 +395,13 @@ bool CSG_Projections::Create(CSG_Table *pProjections)
//---------------------------------------------------------
void CSG_Projections::_On_Construction(void)
{
- m_pProjections = NULL;
- m_nProjections = 0;
- m_nBuffer = 0;
+ m_pProjections = new CSG_Table;
- m_pIdx_Names = new CSG_Index;
- m_pIdx_SRIDs = new CSG_Index;
+ m_pProjections->Add_Field(SG_T("srid") , SG_DATATYPE_Int);
+ m_pProjections->Add_Field(SG_T("auth_name") , SG_DATATYPE_String);
+ m_pProjections->Add_Field(SG_T("auth_srid") , SG_DATATYPE_Int);
+ m_pProjections->Add_Field(SG_T("srtext") , SG_DATATYPE_String);
+ m_pProjections->Add_Field(SG_T("proj4text") , SG_DATATYPE_String);
}
//---------------------------------------------------------
@@ -356,8 +409,7 @@ CSG_Projections::~CSG_Projections(void)
{
Destroy();
- delete(m_pIdx_Names);
- delete(m_pIdx_SRIDs);
+ delete(m_pProjections);
}
//---------------------------------------------------------
@@ -365,16 +417,7 @@ void CSG_Projections::Destroy(void)
{
if( m_pProjections )
{
- for(int i=0; i<m_nProjections; i++)
- {
- delete(m_pProjections[i]);
- }
-
- SG_Free(m_pProjections);
-
- m_pProjections = NULL;
- m_nProjections = 0;
- m_nBuffer = 0;
+ m_pProjections->Del_Records();
}
}
@@ -394,24 +437,23 @@ bool CSG_Projections::Save(const CSG_String &File_Name)
{
CSG_Table Table;
- Table.Add_Field(SG_T("srid") , SG_DATATYPE_Int);
+/* Table.Add_Field(SG_T("srid") , SG_DATATYPE_Int);
Table.Add_Field(SG_T("auth_name") , SG_DATATYPE_String);
Table.Add_Field(SG_T("auth_srid") , SG_DATATYPE_Int);
Table.Add_Field(SG_T("srtext") , SG_DATATYPE_String);
Table.Add_Field(SG_T("proj4text") , SG_DATATYPE_String);
- for(int i=0; i<m_nProjections && SG_UI_Process_Set_Progress(i, m_nProjections); i++)
+ for(int i=0; i<Get_Count() && SG_UI_Process_Set_Progress(i, Get_Count()); i++)
{
- CSG_Projection *pProjection = m_pProjections[i];
- CSG_Table_Record *pRecord = Table.Add_Record();
-
- pRecord->Set_Value(PRJ_FIELD_SRID , pProjection->Get_SRID());
- pRecord->Set_Value(PRJ_FIELD_AUTH_NAME , pProjection->Get_Authority());
- pRecord->Set_Value(PRJ_FIELD_AUTH_SRID , pProjection->Get_SRID());
- pRecord->Set_Value(PRJ_FIELD_SRTEXT , pProjection->Get_OpenGIS());
- pRecord->Set_Value(PRJ_FIELD_PROJ4TEXT , pProjection->Get_Proj4());
- }
+ CSG_Table_Record *pRecord = Table.Add_Record();
+ pRecord->Set_Value(PRJ_FIELD_SRID , Table.Get_Count());
+ pRecord->Set_Value(PRJ_FIELD_AUTH_NAME , m_pProjections[i]->Get_EPSG() > 0 ? SG_T("EPSG") : SG_T(""));
+ pRecord->Set_Value(PRJ_FIELD_AUTH_SRID , m_pProjections[i]->Get_EPSG());
+ pRecord->Set_Value(PRJ_FIELD_SRTEXT , m_pProjections[i]->Get_WKT());
+ pRecord->Set_Value(PRJ_FIELD_PROJ4TEXT , m_pProjections[i]->Get_Proj4());
+ }
+/**/
return( Table.Save(File_Name) );
}
@@ -421,46 +463,77 @@ bool CSG_Projections::Save(const CSG_String &File_Name)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define GET_GROW_SIZE(n) (n < 64 ? 1 : (n < 1024 ? 64 : 1024))
+int CSG_Projections::Get_Count(void) const
+{
+ return( m_pProjections->Get_Count() );
+}
//---------------------------------------------------------
-CSG_Projection * CSG_Projections::_Add(void)
+bool CSG_Projections::Add(const CSG_Projection &Projection)
{
- if( (m_nProjections + 1) >= m_nBuffer )
- {
- CSG_Projection **pProjections = (CSG_Projection **)SG_Realloc(m_pProjections, (m_nBuffer + GET_GROW_SIZE(m_nBuffer)) * sizeof(char *));
+ return( false );
+}
- if( !pProjections )
- {
- return( NULL );
- }
+//---------------------------------------------------------
+bool CSG_Projections::Add(int SRID, const SG_Char *Authority, const SG_Char *WKT, const SG_Char *Proj4)
+{
+ CSG_Table_Record *pProjection = m_pProjections->Add_Record();
- m_pProjections = pProjections;
- m_nBuffer += GET_GROW_SIZE(m_nBuffer);
- }
+ pProjection->Set_Value(SG_T("srid") , SRID);
+ pProjection->Set_Value(SG_T("auth_name"), Authority);
+ pProjection->Set_Value(SG_T("auth_srid"), SRID);
+ pProjection->Set_Value(SG_T("srtext") , WKT);
+ pProjection->Set_Value(SG_T("proj4text"), Proj4);
- return( m_pProjections[m_nProjections++] = new CSG_Projection );
+ return( true );
}
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
//---------------------------------------------------------
-bool CSG_Projections::Add(const CSG_Projection &Projection)
+CSG_String CSG_Projections::Get_Names(void) const
{
- CSG_Projection *pProjection = _Add();
+ CSG_String Names, WKT, Type;
+
+ m_pProjections->Set_Index(PRJ_FIELD_SRTEXT, TABLE_INDEX_Ascending);
- if( pProjection )
+ for(int i=0; i<Get_Count(); i++)
{
- return( pProjection->Assign(Projection) );
+ WKT = m_pProjections->Get_Record_byIndex(i)->asString(PRJ_FIELD_SRTEXT);
+
+ if( !WKT.BeforeFirst('[').Cmp(SG_T("PROJCS")) )
+ {
+ Type = SG_Get_Projection_Type_Name(SG_PROJ_TYPE_CS_Projected);
+ }
+ else if( !WKT.BeforeFirst('[').Cmp(SG_T("GEOGCS")) )
+ {
+ Type = SG_Get_Projection_Type_Name(SG_PROJ_TYPE_CS_Geographic);
+ }
+ else // if( !WKT.BeforeFirst('[').Cmp(SG_T("GEOCCS")) )
+ {
+ Type = SG_Get_Projection_Type_Name(SG_PROJ_TYPE_CS_Geocentric);
+ }
+
+ Names += CSG_String::Format(SG_T("[%s] %s|"), Type.c_str(), WKT.AfterFirst('\"').BeforeFirst('\"').c_str());
}
- return( false );
+ return( Names );
}
//---------------------------------------------------------
-bool CSG_Projections::Add(int SRID, const SG_Char *Authority, const SG_Char *OpenGIS, const SG_Char *Proj4)
+int CSG_Projections::Get_SRID_byNamesIndex(int i) const
{
- CSG_Projection Projection;
+ if( i >= 0 && i < Get_Count() )
+ {
+ m_pProjections->Set_Index(PRJ_FIELD_SRTEXT, TABLE_INDEX_Ascending);
- return( Projection.Create(SRID, Authority, OpenGIS, Proj4) && Add(Projection) );
+ return( m_pProjections->Get_Record_byIndex(i)->asInt(PRJ_FIELD_SRID) );
+ }
+
+ return( -1 );
}
@@ -469,59 +542,43 @@ bool CSG_Projections::Add(int SRID, const SG_Char *Authority, const SG_Char *Ope
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-int CSG_Projections::_Cmp_Names(const int iElement_1, const int iElement_2)
+bool CSG_Projections::WKT_to_Proj4(CSG_String &Proj4, const CSG_String &WKT)
{
- return( (*s_pProjections)[iElement_1].Get_Type() == (*s_pProjections)[iElement_2].Get_Type()
- ? (*s_pProjections)[iElement_1].Get_Name().Cmp((*s_pProjections)[iElement_2].Get_Name())
- : (*s_pProjections)[iElement_1].Get_Type() - (*s_pProjections)[iElement_2].Get_Type() );
+ return( true );
}
//---------------------------------------------------------
-int CSG_Projections::_Cmp_SRIDs(const int iElement_1, const int iElement_2)
+bool CSG_Projections::WKT_from_Proj4(CSG_String &Projection, const CSG_String &Proj4)
{
- return( (*s_pProjections)[iElement_1].Get_SRID() - (*s_pProjections)[iElement_2].Get_SRID() );
+ return( false );
}
-//---------------------------------------------------------
-CSG_String CSG_Projections::Get_Names(void) const
-{
- s_pProjections = (CSG_Projections *)this;
-
- if( m_pIdx_Names->Get_Count() != m_nProjections )
- {
- m_pIdx_Names->Create(m_nProjections, (TSG_PFNC_Compare)CSG_Projections::_Cmp_Names, true);
- }
- if( m_pIdx_SRIDs->Get_Count() != m_nProjections )
- {
- m_pIdx_SRIDs->Create(m_nProjections, _Cmp_SRIDs, true);
- }
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
- //-----------------------------------------------------
- CSG_String s;
+//---------------------------------------------------------
+// obsolete: to be removed...
- for(int i=0; i<m_nProjections; i++)
- {
- CSG_Projection *pProjection = m_pProjections[(*m_pIdx_Names)[i]];
+const CSG_Projection & CSG_Projections::Get_Projection(int i) const
+{
+ static CSG_Projection p;
- s += CSG_String::Format(SG_T("[%s] %s|"),
- pProjection->Get_Type_Name().c_str(),
- pProjection->Get_Name().c_str()
- );
- }
+ return( p );
+}
- return( s );
+const CSG_Projection & CSG_Projections::operator [] (int i) const
+{
+ return( Get_Projection(i) );
}
//---------------------------------------------------------
-int CSG_Projections::Get_SRID_byNamesIndex(int i) const
+bool CSG_Projections::Get_Projection(int EPSG, CSG_Projection &Projection) const
{
- if( i >= 0 && i < Get_Count() )
- {
- return( Get_Projection((*m_pIdx_Names)[i]).Get_SRID() );
- }
-
- return( -1 );
+ return( false );
}
diff --git a/src/saga_core/saga_api/quadtree.cpp b/src/saga_core/saga_api/quadtree.cpp
index 58786c4..0df8553 100644
--- a/src/saga_core/saga_api/quadtree.cpp
+++ b/src/saga_core/saga_api/quadtree.cpp
@@ -221,18 +221,23 @@ bool CSG_PRQuadTree::Create(CSG_Shapes *pShapes, int Attribute)
{
CSG_Shape *pShape = pShapes->Get_Shape(iShape);
- for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ if( Attribute < 0 || !pShape->is_NoData(Attribute) )
{
- for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ double z = Attribute < 0 ? iShape : pShape->asDouble(Attribute);
+
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
{
- TSG_Point p = pShape->Get_Point(iPoint, iPart);
+ for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ TSG_Point p = pShape->Get_Point(iPoint, iPart);
- Add_Point(p.x, p.y, pShape->asDouble(Attribute));
+ Add_Point(p.x, p.y, z);
+ }
}
}
}
- return( true );
+ return( Get_Point_Count() > 0 );
}
return( false );
diff --git a/src/saga_core/saga_api/saga_api.h b/src/saga_core/saga_api/saga_api.h
index 00cd31f..97edf65 100644
--- a/src/saga_core/saga_api/saga_api.h
+++ b/src/saga_core/saga_api/saga_api.h
@@ -132,7 +132,7 @@ SAGA_API_DLL_EXPORT const SG_Char * SAGA_API_Get_Version(void);
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define SAGA_API_VERSION SG_T("2.0.4")
+#define SAGA_API_VERSION SG_T("2.0.5")
///////////////////////////////////////////////////////////
diff --git a/src/saga_core/saga_api/shape_part.cpp b/src/saga_core/saga_api/shape_part.cpp
index f4769bf..8ccab2b 100644
--- a/src/saga_core/saga_api/shape_part.cpp
+++ b/src/saga_core/saga_api/shape_part.cpp
@@ -317,3 +317,190 @@ void CSG_Shape_Part::_Update_Extent(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+CSG_Shape_Part_Z::CSG_Shape_Part_Z(CSG_Shape_Points *pOwner)
+ : CSG_Shape_Part(pOwner)
+{
+ m_Z = NULL;
+}
+
+//---------------------------------------------------------
+CSG_Shape_Part_Z::~CSG_Shape_Part_Z(void)
+{
+ Destroy();
+}
+
+//---------------------------------------------------------
+bool CSG_Shape_Part_Z::Destroy(void)
+{
+ if( m_Z != NULL )
+ {
+ SG_Free(m_Z);
+ }
+
+ m_Z = NULL;
+
+ return( CSG_Shape_Part::Destroy() );
+}
+
+//---------------------------------------------------------
+bool CSG_Shape_Part_Z::_Alloc_Memory(int nPoints)
+{
+ if( CSG_Shape_Part::_Alloc_Memory(nPoints) )
+ {
+ double *Z = (double *)SG_Realloc(m_Z, m_nBuffer * sizeof(double));
+
+ if( Z )
+ {
+ m_Z = Z;
+
+ return( true );
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_Shape_Part_Z::Assign(CSG_Shape_Part *pPart)
+{
+ if( CSG_Shape_Part::Assign(pPart) )
+ {
+ if( ((CSG_Shapes *)pPart->Get_Owner()->Get_Table())->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZ
+ || ((CSG_Shapes *)pPart->Get_Owner()->Get_Table())->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM )
+ {
+ memcpy(m_Z, ((CSG_Shape_Part_Z *)pPart)->m_Z, pPart->Get_Count() * sizeof(double));
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+void CSG_Shape_Part_Z::_Update_Extent(void)
+{
+ if( m_bUpdate )
+ {
+ if( m_nPoints > 0 )
+ {
+ m_ZMin = m_ZMax = m_Z[0];
+
+ for(int i=1; i<m_nPoints; i++)
+ {
+ if( m_ZMin > m_Z[i] )
+ {
+ m_ZMin = m_Z[i];
+ }
+ else if( m_ZMax < m_Z[i] )
+ {
+ m_ZMax = m_Z[i];
+ }
+ }
+ }
+
+ CSG_Shape_Part::_Update_Extent();
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Shape_Part_ZM::CSG_Shape_Part_ZM(CSG_Shape_Points *pOwner)
+ : CSG_Shape_Part_Z(pOwner)
+{
+ m_M = NULL;
+}
+
+//---------------------------------------------------------
+CSG_Shape_Part_ZM::~CSG_Shape_Part_ZM(void)
+{
+ Destroy();
+}
+
+//---------------------------------------------------------
+bool CSG_Shape_Part_ZM::Destroy(void)
+{
+ if( m_M != NULL )
+ {
+ SG_Free(m_M);
+ }
+
+ m_M = NULL;
+
+ return( CSG_Shape_Part_Z::Destroy() );
+}
+
+//---------------------------------------------------------
+bool CSG_Shape_Part_ZM::_Alloc_Memory(int nPoints)
+{
+ if( CSG_Shape_Part_Z::_Alloc_Memory(nPoints) )
+ {
+ double *M = (double *)SG_Realloc(m_M, m_nBuffer * sizeof(double));
+
+ if( M )
+ {
+ m_M = M;
+
+ return( true );
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_Shape_Part_ZM::Assign(CSG_Shape_Part *pPart)
+{
+ if( CSG_Shape_Part_Z::Assign(pPart) )
+ {
+ if( ((CSG_Shapes *)pPart->Get_Owner()->Get_Table())->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM )
+ {
+ memcpy(m_M, ((CSG_Shape_Part_ZM *)pPart)->m_M, pPart->Get_Count() * sizeof(double));
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+void CSG_Shape_Part_ZM::_Update_Extent(void)
+{
+ if( m_bUpdate )
+ {
+ if( m_nPoints > 0 )
+ {
+ m_ZMin = m_ZMax = m_Z[0];
+
+ for(int i=1; i<m_nPoints; i++)
+ {
+ if( m_ZMin > m_Z[i] )
+ {
+ m_ZMin = m_Z[i];
+ }
+ else if( m_ZMax < m_Z[i] )
+ {
+ m_ZMax = m_Z[i];
+ }
+ }
+ }
+
+ CSG_Shape_Part_Z::_Update_Extent();
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_api/shape_point.cpp b/src/saga_core/saga_api/shape_point.cpp
index 1044e84..97702a6 100644
--- a/src/saga_core/saga_api/shape_point.cpp
+++ b/src/saga_core/saga_api/shape_point.cpp
@@ -92,6 +92,9 @@ bool CSG_Shape_Point::On_Assign(CSG_Shape *pShape)
{
CSG_Shape::Add_Point(pShape->Get_Point(0));
+ Set_Z(Get_Z(0), 0);
+ Set_M(Get_M(0), 0);
+
return( true );
}
diff --git a/src/saga_core/saga_api/shape_points.cpp b/src/saga_core/saga_api/shape_points.cpp
index f83721f..95ac9e7 100644
--- a/src/saga_core/saga_api/shape_points.cpp
+++ b/src/saga_core/saga_api/shape_points.cpp
@@ -142,6 +142,19 @@ int CSG_Shape_Points::_Add_Part(void)
}
//---------------------------------------------------------
+CSG_Shape_Part * CSG_Shape_Points::_Get_Part(void)
+{
+ switch( ((CSG_Shapes *)Get_Table())->Get_Vertex_Type() )
+ {
+ default:
+ case SG_VERTEX_TYPE_XY: return( new CSG_Shape_Part (this) );
+ case SG_VERTEX_TYPE_XYZ: return( new CSG_Shape_Part_Z (this) );
+ case SG_VERTEX_TYPE_XYZM: return( new CSG_Shape_Part_ZM(this) );
+ }
+}
+
+
+//---------------------------------------------------------
int CSG_Shape_Points::Del_Part(int del_Part)
{
if( del_Part >= 0 && del_Part < m_nParts )
@@ -233,20 +246,36 @@ void CSG_Shape_Points::_Update_Extent(void)
{
if( m_bUpdate )
{
- bool bOkay = false;
+ bool bFirst;
+ int iPart;
- for(int iPart=0; iPart<m_nParts; iPart++)
+ for(iPart=0, bFirst=true; iPart<m_nParts; iPart++)
{
- if( m_pParts[iPart]->Get_Count() > 0 )
+ CSG_Shape_Part *pPart = m_pParts[iPart];
+
+ if( pPart->Get_Count() > 0 )
{
- if( !bOkay )
+ if( bFirst )
{
- bOkay = true;
- m_Extent = m_pParts[iPart]->Get_Extent();
+ bFirst = false;
+
+ m_Extent = pPart->Get_Extent();
+
+ m_ZMin = pPart->Get_ZMin();
+ m_ZMax = pPart->Get_ZMax();
+
+ m_MMin = pPart->Get_MMin();
+ m_MMax = pPart->Get_MMax();
}
else
{
- m_Extent.Union(m_pParts[iPart]->Get_Extent());
+ m_Extent.Union(pPart->Get_Extent());
+
+ if( m_ZMin > pPart->Get_ZMin() ) m_ZMin = pPart->Get_ZMin();
+ if( m_ZMax < pPart->Get_ZMax() ) m_ZMax = pPart->Get_ZMax();
+
+ if( m_MMin > pPart->Get_MMin() ) m_MMin = pPart->Get_MMin();
+ if( m_MMax < pPart->Get_MMax() ) m_MMax = pPart->Get_MMax();
}
}
}
diff --git a/src/saga_core/saga_api/shapes.cpp b/src/saga_core/saga_api/shapes.cpp
index b9dbddc..e6c0665 100644
--- a/src/saga_core/saga_api/shapes.cpp
+++ b/src/saga_core/saga_api/shapes.cpp
@@ -110,9 +110,9 @@ CSG_Shapes * SG_Create_Shapes(const CSG_String &File_Name)
}
//---------------------------------------------------------
-CSG_Shapes * SG_Create_Shapes(TSG_Shape_Type Type, const SG_Char *Name, CSG_Table *pStructure)
+CSG_Shapes * SG_Create_Shapes(TSG_Shape_Type Type, const SG_Char *Name, CSG_Table *pStructure, TSG_Vertex_Type Vertex_Type)
{
- return( new CSG_Shapes(Type, Name, pStructure) );
+ return( new CSG_Shapes(Type, Name, pStructure, Vertex_Type) );
}
@@ -148,12 +148,12 @@ CSG_Shapes::CSG_Shapes(const CSG_String &File_Name)
}
//---------------------------------------------------------
-CSG_Shapes::CSG_Shapes(TSG_Shape_Type Type, const SG_Char *Name, CSG_Table *pStructure)
+CSG_Shapes::CSG_Shapes(TSG_Shape_Type Type, const SG_Char *Name, CSG_Table *pStructure, TSG_Vertex_Type Vertex_Type)
: CSG_Table()
{
_On_Construction();
- Create(Type, Name, pStructure);
+ Create(Type, Name, pStructure, Vertex_Type);
}
@@ -168,7 +168,8 @@ void CSG_Shapes::_On_Construction(void)
{
CSG_Table::_On_Construction();
- m_Type = SHAPE_TYPE_Undefined;
+ m_Type = SHAPE_TYPE_Undefined;
+ m_Vertex_Type = SG_VERTEX_TYPE_XY;
}
@@ -189,6 +190,8 @@ bool CSG_Shapes::Create(const CSG_String &File_Name)
{
Destroy();
+ SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), LNG("[MSG] Load shapes"), File_Name.c_str()), true);
+
if( _Load_ESRI(File_Name) )
{
for(int iShape=Get_Count()-1; iShape >= 0; iShape--)
@@ -203,16 +206,20 @@ bool CSG_Shapes::Create(const CSG_String &File_Name)
Load_MetaData(File_Name);
+ SG_UI_Msg_Add(LNG("[MSG] okay"), false, SG_UI_MSG_STYLE_SUCCESS);
+
return( true );
}
Destroy(); // loading failure...
+ SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+
return( false );
}
//---------------------------------------------------------
-bool CSG_Shapes::Create(TSG_Shape_Type Type, const SG_Char *Name, CSG_Table *pStructure)
+bool CSG_Shapes::Create(TSG_Shape_Type Type, const SG_Char *Name, CSG_Table *pStructure, TSG_Vertex_Type Vertex_Type)
{
Destroy();
@@ -220,7 +227,8 @@ bool CSG_Shapes::Create(TSG_Shape_Type Type, const SG_Char *Name, CSG_Table *pSt
Set_Name(Name);
- m_Type = Type;
+ m_Type = Type;
+ m_Vertex_Type = Vertex_Type;
return( true );
}
@@ -293,26 +301,24 @@ bool CSG_Shapes::Assign(CSG_Data_Object *pObject)
//---------------------------------------------------------
bool CSG_Shapes::Save(const CSG_String &File_Name, int Format)
{
- bool bResult = false;
- CSG_String sFile_Name = SG_File_Make_Path(NULL, File_Name, SG_T("shp"));
-
- switch( Format )
- {
- case 0: default:
- bResult = _Save_ESRI(sFile_Name);
- break;
- }
+ SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), LNG("[MSG] Save shapes"), File_Name.c_str()), true);
- if( bResult )
+ if( _Save_ESRI(File_Name) )
{
Set_Modified(false);
- Set_File_Name(sFile_Name);
+ Set_File_Name(File_Name);
Save_MetaData(File_Name);
+
+ SG_UI_Msg_Add(LNG("[MSG] okay"), false, SG_UI_MSG_STYLE_SUCCESS);
+
+ return( true );
}
- return( bResult );
+ SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+
+ return( false );
}
@@ -327,11 +333,30 @@ CSG_Table_Record * CSG_Shapes::_Get_New_Record(int Index)
{
switch( m_Type )
{
- case SHAPE_TYPE_Point: return( new CSG_Shape_Point (this, Index) );
- case SHAPE_TYPE_Points: return( new CSG_Shape_Points (this, Index) );
- case SHAPE_TYPE_Line: return( new CSG_Shape_Line (this, Index) );
- case SHAPE_TYPE_Polygon: return( new CSG_Shape_Polygon (this, Index) );
- default: return( NULL );
+ case SHAPE_TYPE_Point:
+ switch( m_Vertex_Type )
+ {
+ case SG_VERTEX_TYPE_XY: default:
+ return( new CSG_Shape_Point (this, Index) );
+
+ case SG_VERTEX_TYPE_XYZ:
+ return( new CSG_Shape_Point_Z (this, Index) );
+
+ case SG_VERTEX_TYPE_XYZM:
+ return( new CSG_Shape_Point_ZM (this, Index) );
+ }
+
+ case SHAPE_TYPE_Points:
+ return( new CSG_Shape_Points (this, Index) );
+
+ case SHAPE_TYPE_Line:
+ return( new CSG_Shape_Line (this, Index) );
+
+ case SHAPE_TYPE_Polygon:
+ return( new CSG_Shape_Polygon (this, Index) );
+
+ default:
+ return( NULL );
}
}
@@ -342,12 +367,12 @@ CSG_Shape * CSG_Shapes::Add_Shape(CSG_Table_Record *pCopy, TSG_ADD_Shape_Copy_Mo
if( pShape && pCopy )
{
- if( mCopy == SHAPE_COPY || mCopy == SHAPE_COPY_ATTR )
+ if( (mCopy == SHAPE_COPY || mCopy == SHAPE_COPY_ATTR) )
{
((CSG_Table_Record *)pShape)->Assign(pCopy);
}
- if( mCopy == SHAPE_COPY || mCopy == SHAPE_COPY_GEOM && pCopy->Get_Table()->Get_ObjectType() == DATAOBJECT_TYPE_Shapes )
+ if( (mCopy == SHAPE_COPY || mCopy == SHAPE_COPY_GEOM) && pCopy->Get_Table()->Get_ObjectType() == DATAOBJECT_TYPE_Shapes )
{
pShape->Assign((CSG_Shape *)pCopy, false);
}
@@ -379,11 +404,31 @@ bool CSG_Shapes::On_Update(void)
{
if( Get_Count() > 0 )
{
- m_Extent = Get_Shape(0)->Get_Extent();
+ CSG_Shape *pShape = Get_Shape(0);
+
+ m_Extent = pShape->Get_Extent();
+ m_ZMin = pShape->Get_ZMin();
+ m_ZMax = pShape->Get_ZMax();
+ m_MMin = pShape->Get_MMin();
+ m_MMax = pShape->Get_MMax();
for(int i=1; i<Get_Count(); i++)
{
- m_Extent.Union(Get_Shape(i)->Get_Extent());
+ pShape = Get_Shape(i);
+
+ m_Extent.Union(pShape->Get_Extent());
+
+ switch( m_Vertex_Type )
+ {
+ case SG_VERTEX_TYPE_XYZM:
+ if( m_MMin > pShape->Get_MMin() ) m_MMin = pShape->Get_MMin();
+ if( m_MMax < pShape->Get_MMax() ) m_MMax = pShape->Get_MMax();
+
+ case SG_VERTEX_TYPE_XYZ:
+ if( m_ZMin > pShape->Get_ZMin() ) m_ZMin = pShape->Get_ZMin();
+ if( m_ZMax < pShape->Get_ZMax() ) m_ZMax = pShape->Get_ZMax();
+ break;
+ }
}
}
else
@@ -451,3 +496,56 @@ CSG_Shape * CSG_Shapes::Get_Shape(TSG_Point Point, double Epsilon)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+bool CSG_Shapes::Make_Clean(void)
+{
+ if( m_Type != SHAPE_TYPE_Polygon )
+ {
+ return( true );
+ }
+
+ for(int iShape=0; iShape<Get_Count() && SG_UI_Process_Set_Progress(iShape, Get_Count()); iShape++)
+ {
+ CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)Get_Shape(iShape);
+
+ for(int iPart=0; iPart<pPolygon->Get_Part_Count(); iPart++)
+ {
+ //--------------------------------------------
+ // last point == first point !
+
+ if( !CSG_Point(pPolygon->Get_Point(0, iPart)).is_Equal(pPolygon->Get_Point(pPolygon->Get_Point_Count(iPart) - 1, iPart)) )
+ {
+ ((CSG_Shape *)pPolygon)->Add_Point(pPolygon->Get_Point(0, iPart), iPart);
+ }
+
+ //--------------------------------------------
+ // ring direction !
+
+ if( (pPolygon->is_Lake(iPart) == false && pPolygon->is_Clockwise(iPart) == false)
+ || (pPolygon->is_Lake(iPart) == true && pPolygon->is_Clockwise(iPart) == true) )
+ {
+ for(int i=0, j=pPolygon->Get_Point_Count(iPart)-1; i<j; i++, j--)
+ {
+ TSG_Point iPoint = pPolygon->Get_Point(i, iPart);
+ TSG_Point jPoint = pPolygon->Get_Point(j, iPart);
+ pPolygon->Set_Point(iPoint.x, iPoint.y, j, iPart);
+ pPolygon->Set_Point(jPoint.x, jPoint.y, i, iPart);
+ }
+ }
+
+ //--------------------------------------------
+ // no self intersection !
+
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_api/shapes.h b/src/saga_core/saga_api/shapes.h
index d9fa7ce..de8fee2 100644
--- a/src/saga_core/saga_api/shapes.h
+++ b/src/saga_core/saga_api/shapes.h
@@ -80,9 +80,18 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+typedef enum ESG_Vertex_Type
+{
+ SG_VERTEX_TYPE_XY = 0,
+ SG_VERTEX_TYPE_XYZ,
+ SG_VERTEX_TYPE_XYZM
+}
+TSG_Vertex_Type;
+
+//---------------------------------------------------------
typedef enum ESG_Shape_Type
{
- SHAPE_TYPE_Undefined = 0,
+ SHAPE_TYPE_Undefined = 0,
SHAPE_TYPE_Point,
SHAPE_TYPE_Points,
SHAPE_TYPE_Line,
@@ -135,6 +144,15 @@ public:
virtual int Get_Point_Count (int iPart) = 0;
virtual TSG_Point Get_Point (int iPoint, int iPart = 0) = 0;
+ virtual void Set_Z (double z, int iPoint, int iPart = 0) { }
+ virtual double Get_Z (int iPoint, int iPart = 0) { return( 0.0 ); }
+ virtual double Get_ZMin (void) { return( 0.0 ); }
+ virtual double Get_ZMax (void) { return( 0.0 ); }
+
+ virtual void Set_M (double m, int iPoint, int iPart = 0) { }
+ virtual double Get_M (int iPoint, int iPart = 0) { return( 0.0 ); }
+ virtual double Get_MMin (void) { return( 0.0 ); }
+ virtual double Get_MMax (void) { return( 0.0 ); }
//-----------------------------------------------------
virtual const CSG_Rect & Get_Extent (void) = 0;
@@ -210,6 +228,48 @@ protected:
};
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Shape_Point_Z : public CSG_Shape_Point
+{
+ friend class CSG_Shapes;
+
+public:
+
+ CSG_Shape_Point_Z(class CSG_Shapes *pOwner, int Index) : CSG_Shape_Point(pOwner, Index) { m_Z = 0.0; }
+
+ virtual void Set_Z (double z, int iPoint, int iPart = 0) { m_Z = z; _Invalidate(); }
+ virtual double Get_Z (int iPoint, int iPart = 0) { return( m_Z ); }
+ virtual double Get_ZMin (void) { return( m_Z ); }
+ virtual double Get_ZMax (void) { return( m_Z ); }
+
+
+private:
+
+ double m_Z;
+
+};
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Shape_Point_ZM : public CSG_Shape_Point_Z
+{
+ friend class CSG_Shapes;
+
+public:
+
+ CSG_Shape_Point_ZM(class CSG_Shapes *pOwner, int Index) : CSG_Shape_Point_Z(pOwner, Index) { m_M = 0.0; }
+
+ virtual void Set_M (double m, int iPoint, int iPart = 0) { m_M = m; _Invalidate(); }
+ virtual double Get_M (int iPoint, int iPart = 0) { return( m_M ); }
+ virtual double Get_MMin (void) { return( m_M ); }
+ virtual double Get_MMax (void) { return( m_M ); }
+
+
+private:
+
+ double m_M;
+
+};
+
///////////////////////////////////////////////////////////
// //
@@ -226,9 +286,10 @@ class SAGA_API_DLL_EXPORT CSG_Shape_Part
public:
- bool Destroy (void);
+ class CSG_Shape_Points * Get_Owner (void) { return( m_pOwner ); }
- bool Assign (CSG_Shape_Part *pPart);
+ virtual bool Destroy (void);
+ virtual bool Assign (CSG_Shape_Part *pPart);
const CSG_Rect & Get_Extent (void) { _Update_Extent(); return( m_Extent ); }
@@ -253,6 +314,16 @@ public:
int Set_Point (double x, double y, int iPoint);
int Del_Point ( int iPoint);
+ virtual void Set_Z (double z, int iPoint) { }
+ virtual double Get_Z (int iPoint) { return( 0.0 ); }
+ virtual double Get_ZMin (void) { return( 0.0 ); }
+ virtual double Get_ZMax (void) { return( 0.0 ); }
+
+ virtual void Set_M (double m, int iPoint) { }
+ virtual double Get_M (int iPoint) { return( 0.0 ); }
+ virtual double Get_MMin (void) { return( 0.0 ); }
+ virtual double Get_MMax (void) { return( 0.0 ); }
+
protected:
@@ -268,13 +339,75 @@ protected:
CSG_Rect m_Extent;
- CSG_Shape_Points *m_pOwner;
+ class CSG_Shape_Points *m_pOwner;
- bool _Alloc_Memory (int nPoints);
-
+ virtual bool _Alloc_Memory (int nPoints);
virtual void _Invalidate (void);
+ virtual void _Update_Extent (void);
+
+};
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Shape_Part_Z : public CSG_Shape_Part
+{
+ friend class CSG_Shape_Points;
+ friend class CSG_Shape_Line;
+ friend class CSG_Shape_Polygon;
+
+public:
+
+ virtual bool Destroy (void);
+ virtual bool Assign (CSG_Shape_Part *pPart);
+
+ virtual void Set_Z (double z, int iPoint) { if( iPoint >= 0 && iPoint < m_nPoints ) { m_Z[iPoint] = z; _Invalidate(); } }
+ virtual double Get_Z (int iPoint) { return( iPoint >= 0 && iPoint < m_nPoints ? m_Z[iPoint] : 0.0 ); }
+ virtual double Get_ZMin (void) { _Update_Extent(); return( m_ZMin ); }
+ virtual double Get_ZMax (void) { _Update_Extent(); return( m_ZMax ); }
+
+
+protected:
+
+ CSG_Shape_Part_Z(class CSG_Shape_Points *pOwner);
+ virtual ~CSG_Shape_Part_Z(void);
+
+
+ double *m_Z, m_ZMin, m_ZMax;
+
+
+ virtual bool _Alloc_Memory (int nPoints);
+ virtual void _Update_Extent (void);
+
+};
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Shape_Part_ZM : public CSG_Shape_Part_Z
+{
+ friend class CSG_Shape_Points;
+ friend class CSG_Shape_Line;
+ friend class CSG_Shape_Polygon;
+
+public:
+
+ virtual bool Destroy (void);
+ virtual bool Assign (CSG_Shape_Part *pPart);
+
+ virtual void Set_M (double m, int iPoint) { if( iPoint >= 0 && iPoint < m_nPoints ) { m_M[iPoint] = m; _Invalidate(); } }
+ virtual double Get_M (int iPoint) { return( iPoint >= 0 && iPoint < m_nPoints ? m_M[iPoint] : 0.0 ); }
+ virtual double Get_MMin (void) { _Update_Extent(); return( m_MMin ); }
+ virtual double Get_MMax (void) { _Update_Extent(); return( m_MMax ); }
+
+protected:
+
+ CSG_Shape_Part_ZM(class CSG_Shape_Points *pOwner);
+ virtual ~CSG_Shape_Part_ZM(void);
+
+
+ double *m_M, m_MMin, m_MMax;
+
+
+ virtual bool _Alloc_Memory (int nPoints);
virtual void _Update_Extent (void);
};
@@ -312,7 +445,7 @@ public:
virtual TSG_Point Get_Point (int iPoint, int iPart = 0)
{
- if( iPart >= 0 && iPart < m_nParts && iPoint >= 0 && iPoint < m_pParts[iPart]->Get_Count() )
+ if( iPart >= 0 && iPart < m_nParts )
{
return( m_pParts[iPart]->Get_Point(iPoint) );
}
@@ -320,6 +453,16 @@ public:
return( CSG_Point(0.0, 0.0) );
}
+ virtual void Set_Z (double z, int iPoint, int iPart = 0) { if( iPart >= 0 && iPart < m_nParts ) m_pParts[iPart]->Set_Z(z, iPoint); }
+ virtual double Get_Z ( int iPoint, int iPart = 0) { return( iPart >= 0 && iPart < m_nParts ? m_pParts[iPart]->Get_Z(iPoint) : 0.0 ); }
+ virtual double Get_ZMin (void) { _Update_Extent(); return( m_ZMin ); }
+ virtual double Get_ZMax (void) { _Update_Extent(); return( m_ZMax ); }
+
+ virtual void Set_M (double m, int iPoint, int iPart = 0) { if( iPart >= 0 && iPart < m_nParts ) m_pParts[iPart]->Set_M(m, iPoint); }
+ virtual double Get_M ( int iPoint, int iPart = 0) { return( iPart >= 0 && iPart < m_nParts ? m_pParts[iPart]->Get_M(iPoint) : 0.0 ); }
+ virtual double Get_MMin (void) { _Update_Extent(); return( m_MMin ); }
+ virtual double Get_MMax (void) { _Update_Extent(); return( m_MMax ); }
+
virtual const CSG_Rect & Get_Extent (void) { _Update_Extent(); return( m_Extent ); }
virtual double Get_Distance (TSG_Point Point);
@@ -338,6 +481,8 @@ protected:
int m_nParts;
+ double m_ZMin, m_ZMax, m_MMin, m_MMax;
+
CSG_Rect m_Extent;
CSG_Shape_Part **m_pParts;
@@ -345,7 +490,7 @@ protected:
int _Add_Part (void);
- virtual CSG_Shape_Part * _Get_Part (void) { return( new CSG_Shape_Part(this) ); }
+ virtual CSG_Shape_Part * _Get_Part (void);
virtual void _Invalidate (void)
{
@@ -525,8 +670,8 @@ public:
CSG_Shapes (const CSG_String &File_Name);
bool Create (const CSG_String &File_Name);
- CSG_Shapes (TSG_Shape_Type Type, const SG_Char *Name = NULL, CSG_Table *pStructure = NULL);
- bool Create (TSG_Shape_Type Type, const SG_Char *Name = NULL, CSG_Table *pStructure = NULL);
+ CSG_Shapes (TSG_Shape_Type Type, const SG_Char *Name = NULL, CSG_Table *pStructure = NULL, TSG_Vertex_Type Vertex_Type = SG_VERTEX_TYPE_XY);
+ bool Create (TSG_Shape_Type Type, const SG_Char *Name = NULL, CSG_Table *pStructure = NULL, TSG_Vertex_Type Vertex_Type = SG_VERTEX_TYPE_XY);
virtual ~CSG_Shapes(void);
@@ -540,23 +685,33 @@ public:
virtual bool is_Valid (void) const { return( m_Type != SHAPE_TYPE_Undefined && Get_Count() >= 0 ); }
- TSG_Shape_Type Get_Type (void) const { return( m_Type ); }
+ virtual TSG_Shape_Type Get_Type (void) const { return( m_Type ); }
+
+ TSG_Vertex_Type Get_Vertex_Type (void) const { return( m_Vertex_Type ); }
const CSG_Rect & Get_Extent (void) { Update(); return( m_Extent ); }
+ double Get_ZMin (void) { Update(); return( m_ZMin ); }
+ double Get_ZMax (void) { Update(); return( m_ZMax ); }
+ double Get_MMin (void) { Update(); return( m_MMin ); }
+ double Get_MMax (void) { Update(); return( m_MMax ); }
+
//-----------------------------------------------------
- CSG_Shape * Add_Shape (CSG_Table_Record *pCopy = NULL, TSG_ADD_Shape_Copy_Mode mCopy = SHAPE_COPY);
- bool Del_Shape (int iShape);
- bool Del_Shape (CSG_Shape *pShape);
- bool Del_Shapes (void) { return( Del_Records() ); }
+ virtual CSG_Shape * Add_Shape (CSG_Table_Record *pCopy = NULL, TSG_ADD_Shape_Copy_Mode mCopy = SHAPE_COPY);
+ virtual bool Del_Shape (int iShape);
+ virtual bool Del_Shape (CSG_Shape *pShape);
+ virtual bool Del_Shapes (void) { return( Del_Records() ); }
- CSG_Shape * Get_Shape (TSG_Point Point, double Epsilon = 0.0);
- CSG_Shape * Get_Shape (int iShape) const { return( (CSG_Shape *)Get_Record(iShape) ); }
- CSG_Shape * Get_Shape_byIndex (int Index) const { return( (CSG_Shape *)Get_Record_byIndex(Index) ); }
+ virtual CSG_Shape * Get_Shape (TSG_Point Point, double Epsilon = 0.0);
+ virtual CSG_Shape * Get_Shape (int iShape) const { return( (CSG_Shape *)Get_Record(iShape) ); }
+ virtual CSG_Shape * Get_Shape_byIndex (int Index) const { return( (CSG_Shape *)Get_Record_byIndex(Index) ); }
+
+ //-----------------------------------------------------
+ bool Make_Clean (void);
//-----------------------------------------------------
virtual CSG_Shape * Get_Selection (int Index = 0) { return( (CSG_Shape *)CSG_Table::Get_Selection(Index) ); };
- const CSG_Rect & Get_Selection_Extent (void);
+ virtual const CSG_Rect & Get_Selection_Extent (void);
virtual bool Select (CSG_Shape *pShape = NULL, bool bInvert = false);
virtual bool Select (TSG_Rect Extent , bool bInvert = false);
@@ -565,16 +720,23 @@ public:
protected:
+ double m_ZMin, m_ZMax, m_MMin, m_MMax;
+
TSG_Shape_Type m_Type;
+ TSG_Vertex_Type m_Vertex_Type;
+
CSG_Rect m_Extent, m_Extent_Selected;
+ virtual bool On_Update (void);
+
virtual void _On_Construction (void);
virtual CSG_Table_Record * _Get_New_Record (int Index);
- virtual bool On_Update (void);
+
+private:
bool _Load_ESRI (const CSG_String &File_Name);
bool _Save_ESRI (const CSG_String &File_Name);
@@ -599,7 +761,7 @@ SAGA_API_DLL_EXPORT CSG_Shapes * SG_Create_Shapes (const CSG_Shapes &Shapes);
SAGA_API_DLL_EXPORT CSG_Shapes * SG_Create_Shapes (const CSG_String &File_Name);
/** Safe shapes construction */
-SAGA_API_DLL_EXPORT CSG_Shapes * SG_Create_Shapes (TSG_Shape_Type Type, const SG_Char *Name = NULL, CSG_Table *pStructure = NULL);
+SAGA_API_DLL_EXPORT CSG_Shapes * SG_Create_Shapes (TSG_Shape_Type Type, const SG_Char *Name = NULL, CSG_Table *pStructure = NULL, TSG_Vertex_Type Vertex_Type = SG_VERTEX_TYPE_XY);
///////////////////////////////////////////////////////////
@@ -720,16 +882,17 @@ public:
void Destroy (void);
bool Add_Point (double x, double y, double z);
+ int Get_Point_Count (void) const { return( m_nPoints ); }
- const CSG_PRQuadTree_Node & Get_Root (void) const { return( *m_pRoot ); }
+ const CSG_PRQuadTree_Node & Get_Root (void) const { return( *m_pRoot ); }
- bool is_Okay (void) const { return( m_pRoot != NULL ); }
+ bool is_Okay (void) const { return( m_pRoot != NULL ); }
bool Get_Nearest_Point (double x, double y, TSG_Point &Point, double &Value, double &Distance);
int Select_Nearest_Points (double x, double y, int maxPoints, double Radius = 0.0, int iQuadrant = -1);
- int Get_Selected_Count (void) const { return( m_nSelected ); }
+ int Get_Selected_Count (void) const { return( m_nSelected ); }
bool Get_Selected_Point (int i, double &x, double &y, double &z) const
{
@@ -836,6 +999,157 @@ protected:
///////////////////////////////////////////////////////////
// //
+// OpenGIS //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+enum ESG_OGIS_ByteOrder
+{
+ SG_OGIS_BYTEORDER_XDR = 0, // Big Endian
+ SG_OGIS_BYTEORDER_NDR = 1 // Little Endian
+};
+
+//---------------------------------------------------------
+enum ESG_SG_OGIS_Type_Geometry
+{
+ SG_OGIS_TYPE_Point = 1,
+ SG_OGIS_TYPE_LineString = 2,
+ SG_OGIS_TYPE_Polygon = 3,
+ SG_OGIS_TYPE_MultiPoint = 4,
+ SG_OGIS_TYPE_MultiLineString = 5,
+ SG_OGIS_TYPE_MultiPolygon = 6,
+ SG_OGIS_TYPE_GeometryCollection = 7,
+ SG_OGIS_TYPE_PolyhedralSurface = 15,
+ SG_OGIS_TYPE_TIN = 16,
+ SG_OGIS_TYPE_Triangle = 17,
+
+ SG_OGIS_TYPE_PointZ = 1001,
+ SG_OGIS_TYPE_LineStringZ = 1002,
+ SG_OGIS_TYPE_PolygonZ = 1003,
+ SG_OGIS_TYPE_MultiPointZ = 1004,
+ SG_OGIS_TYPE_MultiLineStringZ = 1005,
+ SG_OGIS_TYPE_MultiPolygonZ = 1006,
+ SG_OGIS_TYPE_GeometryCollectionZ = 1007,
+ SG_OGIS_TYPE_PolyhedralSurfaceZ = 1015,
+ SG_OGIS_TYPE_TINZ = 1016,
+ SG_OGIS_TYPE_Trianglez = 1017,
+
+ SG_OGIS_TYPE_PointM = 2001,
+ SG_OGIS_TYPE_LineStringM = 2002,
+ SG_OGIS_TYPE_PolygonM = 2003,
+ SG_OGIS_TYPE_MultiPointM = 2004,
+ SG_OGIS_TYPE_MultiLineStringM = 2005,
+ SG_OGIS_TYPE_MultiPolygonM = 2006,
+ SG_OGIS_TYPE_GeometryCollectionM = 2007,
+ SG_OGIS_TYPE_PolyhedralSurfaceM = 2015,
+ SG_OGIS_TYPE_TINM = 2016,
+ SG_OGIS_TYPE_TriangleM = 2017,
+
+ SG_OGIS_TYPE_PointZM = 3001,
+ SG_OGIS_TYPE_LineStringZM = 3002,
+ SG_OGIS_TYPE_PolygonZM = 3003,
+ SG_OGIS_TYPE_MultiPointZM = 3004,
+ SG_OGIS_TYPE_MultiLineStringZM = 3005,
+ SG_OGIS_TYPE_MultiPolygonZM = 3006,
+ SG_OGIS_TYPE_GeometryCollectionZM = 3007,
+ SG_OGIS_TYPE_PolyhedralSurfaceZM = 3015,
+ SG_OGIS_TYPE_TinZM = 3016,
+ SG_OGIS_TYPE_TriangleZM = 3017
+};
+
+//---------------------------------------------------------
+#define SG_OGIS_TYPE_STR_Point SG_T("Point")
+#define SG_OGIS_TYPE_STR_Line SG_T("LineString")
+#define SG_OGIS_TYPE_STR_Polygon SG_T("Polygon")
+#define SG_OGIS_TYPE_STR_MultiPoint SG_T("MultiPoint")
+#define SG_OGIS_TYPE_STR_MultiLine SG_T("MultiLineString")
+#define SG_OGIS_TYPE_STR_MultiPolygon SG_T("MultiPolygon")
+#define SG_OGIS_TYPE_STR_GeometryCollection SG_T("GeometryCollection")
+#define SG_OGIS_TYPE_STR_PolyhedralSurface SG_T("PolyhedralSurface")
+#define SG_OGIS_TYPE_STR_TIN SG_T("TIN")
+#define SG_OGIS_TYPE_STR_Triangle SG_T("Triangle")
+
+#define SG_OGIS_TYPE_STR_Point_Z SG_T("Point Z")
+#define SG_OGIS_TYPE_STR_Line_Z SG_T("LineString Z")
+#define SG_OGIS_TYPE_STR_Polygon_Z SG_T("Polygon Z")
+#define SG_OGIS_TYPE_STR_MultiPoint_Z SG_T("MultiPoint Z")
+#define SG_OGIS_TYPE_STR_MultiLine_Z SG_T("MultiLineString Z")
+#define SG_OGIS_TYPE_STR_MultiPolygon_Z SG_T("MultiPolygon Z")
+#define SG_OGIS_TYPE_STR_GeometryCollection_Z SG_T("GeometryCollection Z")
+#define SG_OGIS_TYPE_STR_PolyhedralSurface_Z SG_T("PolyhedralSurface Z")
+#define SG_OGIS_TYPE_STR_TIN_Z SG_T("TIN Z")
+#define SG_OGIS_TYPE_STR_Triangle_Z SG_T("Triangle Z")
+
+#define SG_OGIS_TYPE_STR_Point_M SG_T("Point M")
+#define SG_OGIS_TYPE_STR_Line_M SG_T("LineString M")
+#define SG_OGIS_TYPE_STR_Polygon_M SG_T("Polygon M")
+#define SG_OGIS_TYPE_STR_MultiPoint_M SG_T("MultiPoint M")
+#define SG_OGIS_TYPE_STR_MultiLine_M SG_T("MultiLineString M")
+#define SG_OGIS_TYPE_STR_MultiPolygon_M SG_T("MultiPolygon M")
+#define SG_OGIS_TYPE_STR_GeometryCollection_M SG_T("GeometryCollection M")
+#define SG_OGIS_TYPE_STR_PolyhedralSurface_M SG_T("PolyhedralSurface M")
+#define SG_OGIS_TYPE_STR_TIN_M SG_T("TIN M")
+#define SG_OGIS_TYPE_STR_Triangle_M SG_T("Triangle M")
+
+#define SG_OGIS_TYPE_STR_Point_ZM SG_T("Point ZM")
+#define SG_OGIS_TYPE_STR_Line_ZM SG_T("LineString ZM")
+#define SG_OGIS_TYPE_STR_Polygon_ZM SG_T("Polygon ZM")
+#define SG_OGIS_TYPE_STR_MultiPoint_ZM SG_T("MultiPoint ZM")
+#define SG_OGIS_TYPE_STR_MultiLine_ZM SG_T("MultiLineString ZM")
+#define SG_OGIS_TYPE_STR_MultiPolygon_ZM SG_T("MultiPolygon ZM")
+#define SG_OGIS_TYPE_STR_GeometryCollection_ZM SG_T("GeometryCollection ZM")
+#define SG_OGIS_TYPE_STR_PolyhedralSurface_ZM SG_T("PolyhedralSurface ZM")
+#define SG_OGIS_TYPE_STR_TIN_ZM SG_T("TIN ZM")
+#define SG_OGIS_TYPE_STR_Triangle_ZM SG_T("Triangle ZM")
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class SAGA_API_DLL_EXPORT CSG_Shapes_OGIS_Converter
+{
+public:
+ CSG_Shapes_OGIS_Converter(void) {}
+
+ static bool from_WKText (const CSG_String &Text, CSG_Shape *pShape);
+ static bool to_WKText (CSG_Shape *pShape, CSG_String &Text);
+
+ static bool from_WKBinary (CSG_Bytes &Bytes, CSG_Shape *pShape);
+ static bool to_WKBinary (CSG_Shape *pShape, CSG_Bytes &Bytes);
+
+
+private:
+
+ static bool _WKT_Read_Point (const CSG_String &Text, CSG_Shape *pShape, int iPart);
+ static bool _WKT_Read_Points (const CSG_String &Text, CSG_Shape *pShape);
+ static bool _WKT_Read_Parts (const CSG_String &Text, CSG_Shape *pShape);
+ static bool _WKT_Read_Polygon (const CSG_String &Text, CSG_Shape *pShape);
+
+ static bool _WKT_Write_Point (CSG_String &Text, CSG_Shape *pShape, int iPoint, int iPart);
+ static bool _WKT_Write_Points (CSG_String &Text, CSG_Shape *pShape, int iPart);
+ static bool _WKT_Write_Parts (CSG_String &Text, CSG_Shape *pShape);
+ static bool _WKT_Write_Polygon (CSG_String &Text, CSG_Shape *pShape);
+
+ static bool _WKB_Read_Point (CSG_Bytes &Bytes, bool bSwapBytes, CSG_Shape *pShape, int iPart);
+ static bool _WKB_Read_Points (CSG_Bytes &Bytes, bool bSwapBytes, CSG_Shape *pShape);
+ static bool _WKB_Read_Parts (CSG_Bytes &Bytes, bool bSwapBytes, CSG_Shape *pShape);
+ static bool _WKB_Read_MultiLine (CSG_Bytes &Bytes, bool bSwapBytes, CSG_Shape *pShape);
+ static bool _WKB_Read_MultiPolygon (CSG_Bytes &Bytes, bool bSwapBytes, CSG_Shape *pShape);
+
+ static bool _WKB_Write_Point (CSG_Bytes &Bytes, CSG_Shape *pShape, int iPoint, int iPart);
+ static bool _WKB_Write_Points (CSG_Bytes &Bytes, CSG_Shape *pShape, int iPart);
+ static bool _WKB_Write_Parts (CSG_Bytes &Bytes, CSG_Shape *pShape);
+ static bool _WKB_Write_MultiLine (CSG_Bytes &Bytes, CSG_Shape *pShape);
+ static bool _WKB_Write_MultiPolygon (CSG_Bytes &Bytes, CSG_Shape *pShape);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
// //
// //
///////////////////////////////////////////////////////////
diff --git a/src/saga_core/saga_api/shapes_io.cpp b/src/saga_core/saga_api/shapes_io.cpp
index 9cf7f87..9005aec 100644
--- a/src/saga_core/saga_api/shapes_io.cpp
+++ b/src/saga_core/saga_api/shapes_io.cpp
@@ -62,6 +62,8 @@
//---------------------------------------------------------
#include "shapes.h"
+#include "table_dbase.h"
+
///////////////////////////////////////////////////////////
// //
@@ -72,272 +74,295 @@
//---------------------------------------------------------
bool CSG_Shapes::_Load_ESRI(const CSG_String &File_Name)
{
- bool bError;
+ int Type, iField, iPart, nParts, *Parts, iPoint, nPoints;
+ double *pZ, *pM;
+ TSG_Point *pPoint;
+ CSG_Buffer File_Header(100), Record_Header(8), Content;
+ CSG_File fSHP;
+ CSG_Table_DBase fDBF;
- char buf_Header[100];
+ //-----------------------------------------------------
+ // Open DBase File...
- int Type_File, Type_Shape, Type_Ext,
- FileCode, FileLength, Version,
- RecordNumber, ContentLength,
- iShape, iPart, nParts, iPoint, nPoints,
- buf_nParts, *buf_nPoints;
+ if( !fDBF.Open(SG_File_Make_Path(NULL, File_Name, SG_T("dbf"))) )
+ {
+ SG_UI_Msg_Add_Error(LNG("[ERR] DBase file could not be opened."));
- TSG_Point dPoint;
+ return( false );
+ }
- TSG_Rect dRect;
+ if( !fDBF.Move_First() || fDBF.Get_Record_Count() <= 0 )
+ {
+ SG_UI_Msg_Add_Error(LNG("[ERR] DBase file does not contain any records."));
- CSG_String fName;
+ return( false );
+ }
- CSG_File Stream;
+ for(iField=0; iField<fDBF.Get_FieldCount(); iField++)
+ {
+ switch( fDBF.Get_FieldType(iField) )
+ {
+ case DBF_FT_LOGICAL:
+ Add_Field(SG_STR_MBTOSG(fDBF.Get_FieldName(iField)), SG_DATATYPE_Char);
+ break;
+ case DBF_FT_CHARACTER: default:
+ Add_Field(SG_STR_MBTOSG(fDBF.Get_FieldName(iField)), SG_DATATYPE_String);
+ break;
- //-----------------------------------------------------
- // Open Shapes File...
+ case DBF_FT_DATE:
+ Add_Field(SG_STR_MBTOSG(fDBF.Get_FieldName(iField)), SG_DATATYPE_Date);
+ break;
- SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), LNG("[MSG] Load shapes"), File_Name.c_str()), true);
+ case DBF_FT_NUMERIC:
+ Add_Field(SG_STR_MBTOSG(fDBF.Get_FieldName(iField)), fDBF.Get_FieldDecimals(iField) > 0
+ ? SG_DATATYPE_Double
+ : SG_DATATYPE_Long
+ );
+ break;
+ }
+ }
- fName = SG_File_Make_Path(NULL, File_Name, SG_T("shp"));
+ //-----------------------------------------------------
+ // Open Shapes File...
- if( !Stream.Open(fName, SG_FILE_R, true) )
+ if( !fSHP.Open(SG_File_Make_Path(NULL, File_Name, SG_T("shp")), SG_FILE_R, true) )
{
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
-
SG_UI_Msg_Add_Error(LNG("[ERR] Shape file could not be opened."));
return( false );
}
//-----------------------------------------------------
- // Load File-Header (100-Bytes)...
-
- Stream.Read(buf_Header, sizeof(char), 100);
-
- FileCode = SG_Mem_Get_Int (buf_Header + 0, true ); // Byte 0 -> File Code 9994 Integer Big...
- // ... // Byte 4-20 -> Unused 0 Integer Big...
- FileLength = SG_Mem_Get_Int (buf_Header + 24, true ); // Byte 24 -> File Length File Length Integer Big...
- Version = SG_Mem_Get_Int (buf_Header + 28, false); // Byte 28 -> Version 1000 Integer Little...
- Type_File = SG_Mem_Get_Int (buf_Header + 32, false); // Byte 32 -> Shape m_Type Shape m_Type Integer Little...
- dRect.xMin = SG_Mem_Get_Double (buf_Header + 36, false); // Byte 36 -> Bounding Box Xmin Double Little...
- dRect.yMin = SG_Mem_Get_Double (buf_Header + 44, false); // Byte 44 -> Bounding Box Ymin Double Little...
- dRect.xMax = SG_Mem_Get_Double (buf_Header + 52, false); // Byte 52 -> Bounding Box Xmax Double Little...
- dRect.yMax = SG_Mem_Get_Double (buf_Header + 60, false); // Byte 60 -> Bounding Box Ymax Double Little...
- // ... // Byte 68* -> Bounding Box Zmin Double Little...
- // ... // Byte 76* -> Bounding Box Zmax Double Little...
- // ... // Byte 84* -> Bounding Box Mmin Double Little...
- // ... // Byte 92* -> Bounding Box Mmax Double Little...
-
- m_Extent.Assign(dRect);
-
- switch( Type_File )
+ // Read File Header (100 Bytes)...
+
+ if( fSHP.Read(File_Header.Get_Data(), sizeof(char), 100) != 100 )
{
- default: m_Type = SHAPE_TYPE_Undefined; break; // unsupported...
- case 31: m_Type = SHAPE_TYPE_Undefined; break; // unsupported: MultiPatch...
-
- case 1: m_Type = SHAPE_TYPE_Point; Type_Ext = 0; break; // Point
- case 8: m_Type = SHAPE_TYPE_Points; Type_Ext = 0; break; // MultiPoint
- case 3: m_Type = SHAPE_TYPE_Line; Type_Ext = 0; break; // PolyLine
- case 5: m_Type = SHAPE_TYPE_Polygon; Type_Ext = 0; break; // Polygon
-
- case 11: m_Type = SHAPE_TYPE_Point; Type_Ext = 2; break; // PointZ
- case 18: m_Type = SHAPE_TYPE_Points; Type_Ext = 2; break; // MultiPointZ
- case 13: m_Type = SHAPE_TYPE_Line; Type_Ext = 2; break; // PolyLineZ
- case 15: m_Type = SHAPE_TYPE_Polygon; Type_Ext = 2; break; // PolygonZ
-
- case 21: m_Type = SHAPE_TYPE_Point; Type_Ext = 1; break; // PointM
- case 28: m_Type = SHAPE_TYPE_Points; Type_Ext = 1; break; // MultiPointM
- case 23: m_Type = SHAPE_TYPE_Line; Type_Ext = 1; break; // PolyLineM
- case 25: m_Type = SHAPE_TYPE_Polygon; Type_Ext = 1; break; // PolygonM
+ SG_UI_Msg_Add_Error(LNG("[ERR] corrupted file header"));
+
+ return( false );
}
- if( Stream.is_EOF() || FileCode != 9994 || Version != 1000 || m_Type == SHAPE_TYPE_Undefined )
+ if( File_Header.asInt( 0, true) != 9994 ) // Byte 00 -> File Code 9994 (Integer Big)...
{
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
-
- SG_UI_Msg_Add_Error(LNG("[ERR] Shape file invalid or of unsupported type."));
+ SG_UI_Msg_Add_Error(LNG("[ERR] invalid file code"));
return( false );
}
- //-----------------------------------------------------
- // Load Attributes...
-
- fName = SG_File_Make_Path(NULL, File_Name, SG_T("dbf"));
+ if( File_Header.asInt(28, false) != 1000 ) // Byte 28 -> Version 1000 (Integer Little)...
+ {
+ SG_UI_Msg_Add_Error(LNG("[ERR] unsupported file version"));
- SG_UI_Msg_Lock(true);
+ return( false );
+ }
- if( !_Create(fName.c_str(), TABLE_FILETYPE_DBase, SG_T("")) || Get_Count() == 0 )
+ switch( Type = File_Header.asInt(32) ) // Byte 32 -> Shape Type (Integer Little)...
{
- SG_UI_Msg_Lock(false);
+ case 1: m_Type = SHAPE_TYPE_Point; m_Vertex_Type = SG_VERTEX_TYPE_XY; break; // Point
+ case 8: m_Type = SHAPE_TYPE_Points; m_Vertex_Type = SG_VERTEX_TYPE_XY; break; // MultiPoint
+ case 3: m_Type = SHAPE_TYPE_Line; m_Vertex_Type = SG_VERTEX_TYPE_XY; break; // PolyLine
+ case 5: m_Type = SHAPE_TYPE_Polygon; m_Vertex_Type = SG_VERTEX_TYPE_XY; break; // Polygon
+
+ case 11: m_Type = SHAPE_TYPE_Point; m_Vertex_Type = SG_VERTEX_TYPE_XYZM; break; // PointZ
+ case 18: m_Type = SHAPE_TYPE_Points; m_Vertex_Type = SG_VERTEX_TYPE_XYZM; break; // MultiPointZ
+ case 13: m_Type = SHAPE_TYPE_Line; m_Vertex_Type = SG_VERTEX_TYPE_XYZM; break; // PolyLineZ
+ case 15: m_Type = SHAPE_TYPE_Polygon; m_Vertex_Type = SG_VERTEX_TYPE_XYZM; break; // PolygonZ
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+ case 21: m_Type = SHAPE_TYPE_Point; m_Vertex_Type = SG_VERTEX_TYPE_XYZ; break; // PointM
+ case 28: m_Type = SHAPE_TYPE_Points; m_Vertex_Type = SG_VERTEX_TYPE_XYZ; break; // MultiPointM
+ case 23: m_Type = SHAPE_TYPE_Line; m_Vertex_Type = SG_VERTEX_TYPE_XYZ; break; // PolyLineM
+ case 25: m_Type = SHAPE_TYPE_Polygon; m_Vertex_Type = SG_VERTEX_TYPE_XYZ; break; // PolygonM
- SG_UI_Msg_Add_Error(LNG("[ERR] DBase file could not be opened or it did not contain any records."));
+ default: // unsupported...
+ case 31: // unsupported: MultiPatch...
+ SG_UI_Msg_Add_Error(LNG("[ERR] unsupported shape type."));
return( false );
}
- SG_UI_Msg_Lock(false);
-
- //-------------------------------------------------
+ //-----------------------------------------------------
// Load Shapes...
- buf_nParts = 0;
- buf_nPoints = NULL;
-
- for(iShape=0, bError=false; iShape<Get_Count() && SG_UI_Process_Set_Progress(iShape, Get_Count()); iShape++)
+ for(int iShape=0; iShape<fDBF.Get_Record_Count() && SG_UI_Process_Set_Progress(iShape, fDBF.Get_Record_Count()); iShape++)
{
- CSG_Shape *pShape = Get_Shape(iShape);
+ if( fSHP.Read(Record_Header.Get_Data(0), sizeof(int), 2) != 2 ) // read record header
+ {
+ SG_UI_Msg_Add_Error(LNG("[ERR] corrupted record header"));
- RecordNumber = Stream.Read_Int(true);
- ContentLength = Stream.Read_Int(true);
+ return( false );
+ }
- Stream.Read(&Type_Shape, sizeof(int));
+ if( Record_Header.asInt(0, true) != iShape + 1 ) // record number
+ {
+ SG_UI_Msg_Add_Error(LNG("[ERR] corrupted shapefile."));
- if( Type_Shape != Type_File || Stream.is_EOF() )
+ return( false );
+ }
+
+ if( !Content.Set_Size(2 * Record_Header.asInt(4, true), false) ) // content length as 16-bit words !!!
{
- bError = true;
+ SG_UI_Msg_Add_Error(LNG("[ERR] memory allocation error."));
+
+ return( false );
}
+
+ if( !fSHP.Read(Content.Get_Data(), sizeof(char), 2 * Record_Header.asInt(4, true)) )
+ {
+ SG_UI_Msg_Add_Error(LNG("[ERR] corrupted shapefile."));
+
+ return( false );
+ }
+
+ if( Content.asInt(0) != Type )
+ {
+ if( Content.asInt(0) == 0 )
+ {
+ // null shape is allowed !!!
+ }
+ else
+ {
+ SG_UI_Msg_Add_Error(LNG("[ERR] corrupted shapefile."));
+
+ return( false );
+ }
+ }
+
+ //-------------------------------------------------
else
{
+ CSG_Shape *pShape = Add_Shape();
+
switch( m_Type )
{
- default:
- SG_UI_Msg_Add_Error(LNG("[ERR] Corrupted shape file."));
- break;
+ default: break;
//---------------------------------------------
- case SHAPE_TYPE_Point:
+ case SHAPE_TYPE_Point: ////////////////////////
- Stream.Read(&dPoint , sizeof(TSG_Point));
- pShape->Add_Point(dPoint.x, dPoint.y);
+ pPoint = (TSG_Point *)Content.Get_Data(4);
- //-----------------------------------------
- if( Type_Ext != 0 )
- {
- if( Type_Ext == 1 ) // read Z
- {
- Stream.Read_Double(false);
- }
+ pShape->Add_Point(pPoint->x, pPoint->y);
- // read M (optional)
- Stream.Read_Double(false);
+ switch( m_Vertex_Type ) // reak Z + M
+ {
+ case SG_VERTEX_TYPE_XYZM: pShape->Set_M(Content.asDouble(28), 0);
+ case SG_VERTEX_TYPE_XYZ: pShape->Set_Z(Content.asDouble(20), 0);
}
+
break;
//---------------------------------------------
- case SHAPE_TYPE_Points:
+ case SHAPE_TYPE_Points: ///////////////////////
- Stream.Read(&dRect , sizeof(TSG_Rect));
- Stream.Read(&nPoints, sizeof(int));
+ nPoints = Content.asInt(36);
+ pPoint = (TSG_Point *)Content.Get_Data(40);
- for(iPoint=0; iPoint<nPoints; iPoint++)
+ switch( m_Vertex_Type ) // reak Z + M
{
- Stream.Read(&dPoint, sizeof(TSG_Point));
- pShape->Add_Point(dPoint.x, dPoint.y);
+ case SG_VERTEX_TYPE_XYZ:
+ pZ = (double *)Content.Get_Data(40 + nPoints * 16 + 16);
+ break;
+
+ case SG_VERTEX_TYPE_XYZM:
+ pZ = (double *)Content.Get_Data(40 + nPoints * 16 + 16);
+ pM = pZ + nPoints + 2;
+ break;
}
//-----------------------------------------
- if( Type_Ext != 0 )
+ for(iPoint=0; iPoint<nPoints; iPoint++, pPoint++)
{
- if( Type_Ext == 1 ) // read Z
- {
- Stream.Read_Double(false);
- Stream.Read_Double(false);
+ pShape->Add_Point(pPoint->x, pPoint->y);
- for(iPoint=0; iPoint<nPoints; iPoint++)
- Stream.Read_Double(false);
+ switch( m_Vertex_Type ) // reak Z + M
+ {
+ case SG_VERTEX_TYPE_XYZM: pShape->Set_M(*pM, iPoint); pM++;
+ case SG_VERTEX_TYPE_XYZ: pShape->Set_Z(*pZ, iPoint); pZ++;
}
-
- // read M (optional)
- Stream.Read_Double(false);
- Stream.Read_Double(false);
-
- for(iPoint=0; iPoint<nPoints; iPoint++)
- Stream.Read_Double(false);
- break;
}
+
break;
//---------------------------------------------
- case SHAPE_TYPE_Line:
- case SHAPE_TYPE_Polygon:
+ case SHAPE_TYPE_Line: //////////////////////
+ case SHAPE_TYPE_Polygon: //////////////////////
- Stream.Read(&dRect , sizeof(TSG_Rect));
- Stream.Read(&nParts , sizeof(int));
- Stream.Read(&nPoints, sizeof(int));
+ nParts = Content.asInt(36);
+ nPoints = Content.asInt(40);
+ Parts = (int *)Content.Get_Data(44);
+ pPoint = (TSG_Point *)Content.Get_Data(44 + 4 * nParts);
- //-----------------------------------------
- if( buf_nParts <= nParts )
+ switch( m_Vertex_Type ) // read Z + M
{
- buf_nParts = nParts + 1;
- buf_nPoints = (int *)SG_Realloc(buf_nPoints, buf_nParts * sizeof(int));
- }
+ case SG_VERTEX_TYPE_XYZ:
+ pZ = (double *)Content.Get_Data(40 + nPoints * 16 + 16);
+ break;
- for(iPart=0; iPart<nParts; iPart++)
- {
- Stream.Read(buf_nPoints + iPart, sizeof(int));
+ case SG_VERTEX_TYPE_XYZM:
+ pZ = (double *)Content.Get_Data(40 + nPoints * 16 + 16);
+ pM = pZ + nPoints + 2;
+ break;
}
- buf_nPoints[nParts] = nPoints;
//-----------------------------------------
- for(iPoint=0, iPart=0; iPoint<nPoints; iPoint++)
+ for(iPoint=0, iPart=0; iPoint<nPoints; iPoint++, pPoint++)
{
- if( iPoint >= buf_nPoints[iPart + 1] && iPart < nParts - 1 )
+ if( iPart < nParts - 1 && iPoint >= Parts[iPart + 1] )
{
iPart++;
}
- Stream.Read(&dPoint, sizeof(TSG_Point));
- pShape->Add_Point(dPoint.x, dPoint.y, iPart);
- }
+ pShape->Add_Point(pPoint->x, pPoint->y, iPart);
- //-----------------------------------------
- if( Type_Ext != 0 )
- {
- if( Type_Ext == 1 ) // read Z
+ switch( m_Vertex_Type ) // read Z + M
{
- Stream.Read_Double(false);
- Stream.Read_Double(false);
-
- for(iPoint=0; iPoint<nPoints; iPoint++)
- Stream.Read_Double(false);
+ case SG_VERTEX_TYPE_XYZM: pShape->Set_M(*pM, iPoint, iPart); pM++;
+ case SG_VERTEX_TYPE_XYZ: pShape->Set_Z(*pZ, iPoint, iPart); pZ++;
}
-
- // read M (optional)
- Stream.Read_Double(false);
- Stream.Read_Double(false);
-
- for(iPoint=0; iPoint<nPoints; iPoint++)
- Stream.Read_Double(false);
}
+
break;
}
- }
- }
- //-----------------------------------------------------
- // Clean up...
+ //---------------------------------------------
+ for(iField=0; iField<Get_Field_Count(); iField++)
+ {
+ switch( Get_Field_Type(iField) )
+ {
+ case SG_DATATYPE_Char:
+ pShape->Set_Value(iField, SG_STR_MBTOSG(fDBF.asString(iField)) );
+ break;
- if( buf_nPoints )
- {
- SG_Free(buf_nPoints);
- }
+ case SG_DATATYPE_String: default:
+ pShape->Set_Value(iField, SG_STR_MBTOSG(fDBF.asString(iField)) );
+ break;
- if( bError )
- {
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
+ case SG_DATATYPE_Date:
+ pShape->Set_Value(iField, fDBF.asDouble(iField) );
+ break;
- SG_UI_Msg_Add_Error(LNG("[ERR] Shape file is corrupted."));
- }
- else
- {
- SG_UI_Msg_Add(LNG("[MSG] okay"), false, SG_UI_MSG_STYLE_SUCCESS);
+ case SG_DATATYPE_Long:
+ pShape->Set_Value(iField, fDBF.asInt(iField) );
+ break;
+
+ case SG_DATATYPE_Double:
+ pShape->Set_Value(iField, fDBF.asDouble(iField) );
+ break;
+ }
+ }
+ }
+
+ fDBF.Move_Next();
}
+ //-----------------------------------------------------
SG_UI_Process_Set_Ready();
- return( bError == false );
+ Get_Projection().Load(SG_File_Make_Path(NULL, File_Name, SG_T("prj")), SG_PROJ_FMT_WKT);
+
+ return( true );
}
@@ -348,244 +373,333 @@ bool CSG_Shapes::_Load_ESRI(const CSG_String &File_Name)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define Save_ESRI_RecordHeader Stream .Write_Int(RecordNumber++, true);\
- Stream .Write_Int(ContentLength , true);\
- Stream_Idx.Write_Int(FileLength , true);\
- Stream_Idx.Write_Int(ContentLength , true);\
- FileLength += 4 + ContentLength;\
- FileLength_idx += 4;\
+#define Set_Content_Length(n) Record_Header.Set_Value(4, (int)(n), true);\
+ fSHP.Write(Record_Header.Get_Data(), sizeof(int), 2);\
+ fSHX.Write_Int(fSHP_Size, true);\
+ fSHX.Write_Int((n) , true);\
+ fSHP_Size += 4 + (n);\
+ fSHX_Size += 4;
//---------------------------------------------------------
bool CSG_Shapes::_Save_ESRI(const CSG_String &File_Name)
{
- char buf_Header[100];
+ int Type, fSHP_Size, fSHX_Size, iField, iPart, iPoint, nPoints, nBytes;
+ TSG_Point Point;
+ CSG_Buffer File_Header(100), Record_Header(8), Content;
+ CSG_File fSHP, fSHX;
+ CSG_Table_DBase fDBF;
- int FileLength, FileLength_idx, Type_File,
- RecordNumber, ContentLength,
- iShape, iPoint, iPart, nPoints;
+ //-----------------------------------------------------
+ // Determine Shape Type...
- TSG_Point dPoint;
+ switch( m_Type )
+ {
+ case SHAPE_TYPE_Point: Type = 1; break;
+ case SHAPE_TYPE_Points: Type = 8; break;
+ case SHAPE_TYPE_Line: Type = 3; break;
+ case SHAPE_TYPE_Polygon: Type = 5; break;
+ default: return( false );
+ }
- TSG_Rect dRect;
+ switch( m_Vertex_Type )
+ {
+ case SG_VERTEX_TYPE_XY: break;
+ case SG_VERTEX_TYPE_XYZM: Type += 10; break; // Z (+M)
+ case SG_VERTEX_TYPE_XYZ: Type += 20; break; // M
+ default: return( false );
+ }
- CSG_String fName;
+ //-----------------------------------------------------
+ // DBase File Access...
- CSG_File Stream, Stream_Idx;
+ CSG_Table_DBase::TFieldDesc *dbfFields = new CSG_Table_DBase::TFieldDesc[Get_Field_Count()];
- CSG_Shape *pShape;
+ for(iField=0; iField<Get_Field_Count(); iField++)
+ {
+ strncpy(dbfFields[iField].Name, SG_STR_SGTOMB(Get_Field_Name(iField)), 11);
+ switch( Get_Field_Type(iField) )
+ {
+ case SG_DATATYPE_String: default:
+ dbfFields[iField].Type = DBF_FT_CHARACTER;
+ dbfFields[iField].Width = (BYTE)((nBytes = Get_Field_Length(iField)) > 255 ? 255 : nBytes);
+ break;
- //-----------------------------------------------------
- // Set Shape m_Type...
+ case SG_DATATYPE_Date:
+ dbfFields[iField].Type = DBF_FT_DATE;
+ dbfFields[iField].Width = (BYTE)8;
+ break;
- switch( m_Type )
- {
- case SHAPE_TYPE_Point: // Point...
- Type_File = 1;
- break;
+ case SG_DATATYPE_Char:
+ dbfFields[iField].Type = DBF_FT_CHARACTER;
+ dbfFields[iField].Width = (BYTE)1;
+ break;
- case SHAPE_TYPE_Points: // Multipoint...
- Type_File = 8;
- break;
+ case SG_DATATYPE_Short:
+ case SG_DATATYPE_Int:
+ case SG_DATATYPE_Long:
+ case SG_DATATYPE_Color:
+ dbfFields[iField].Type = DBF_FT_NUMERIC;
+ dbfFields[iField].Width = (BYTE)16;
+ dbfFields[iField].Decimals = (BYTE)0;
+ break;
- case SHAPE_TYPE_Line: // Line, Polyline...
- Type_File = 3;
- break;
+ case SG_DATATYPE_Float:
+ case SG_DATATYPE_Double:
+ dbfFields[iField].Type = DBF_FT_NUMERIC;
+ dbfFields[iField].Width = (BYTE)16;
+ dbfFields[iField].Decimals = (BYTE)8;
+ break;
+ }
+ }
- case SHAPE_TYPE_Polygon: // Polygon...
- Type_File = 5;
- break;
+ if( !fDBF.Open(SG_File_Make_Path(NULL, File_Name, SG_T("dbf")), Get_Field_Count(), dbfFields) )
+ {
+ delete[](dbfFields);
+
+ SG_UI_Msg_Add_Error(LNG("[ERR] dbase file could not be opened"));
- default: // unsupported...
return( false );
}
+ delete[](dbfFields);
//-----------------------------------------------------
- // File Access...
-
- SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %s..."), LNG("[MSG] Save shapes"), File_Name.c_str()), true);
+ // Shape File Access...
- fName = SG_File_Make_Path(NULL, File_Name, SG_T("shx"));
-
- if( !Stream_Idx.Open(fName, SG_FILE_W, true) )
+ if( !fSHX.Open(SG_File_Make_Path(NULL, File_Name, SG_T("shx")), SG_FILE_W, true) )
{
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
-
- SG_UI_Msg_Add_Error(LNG("[ERR] Shape index file could not be opened."));
+ SG_UI_Msg_Add_Error(LNG("[ERR] index file could not be opened"));
return( false );
}
- fName = SG_File_Make_Path(NULL, File_Name, SG_T("shp"));
-
- if( !Stream.Open(fName, SG_FILE_W, true) )
+ if( !fSHP.Open(SG_File_Make_Path(NULL, File_Name, SG_T("shp")), SG_FILE_W, true) )
{
- SG_UI_Msg_Add(LNG("[MSG] failed"), false, SG_UI_MSG_STYLE_FAILURE);
-
- SG_UI_Msg_Add_Error(LNG("[ERR] Shape file could not be opened."));
+ SG_UI_Msg_Add_Error(LNG("[ERR] shape file could not be opened."));
return( false );
}
- SG_UI_Process_Set_Text(CSG_String::Format(SG_T("%s: %s"), LNG("[DAT] Save shapes"), fName.c_str() ));
-
//-----------------------------------------------------
// Save Header...
+ Make_Clean(); // polygons: first == last point, inner rings > anti-clockwise...
+
Update();
- dRect = m_Extent.m_rect;
-
- SG_Mem_Set_Int (buf_Header + 0, 9994 , true ); // Byte 0 -> File Code 9994 Integer Big...
- SG_Mem_Set_Int (buf_Header + 4, 0 , true ); // Byte 4 -> unused Integer Big...
- SG_Mem_Set_Int (buf_Header + 8, 0 , true ); // Byte 8 -> unused Integer Big...
- SG_Mem_Set_Int (buf_Header + 12, 0 , true ); // Byte 12 -> unused Integer Big...
- SG_Mem_Set_Int (buf_Header + 16, 0 , true ); // Byte 16 -> unused Integer Big...
- SG_Mem_Set_Int (buf_Header + 20, 0 , true ); // Byte 20 -> unused Integer Big...
- SG_Mem_Set_Int (buf_Header + 24, 0 , true ); // Byte 24 -> File Length File Length Integer Big...
- SG_Mem_Set_Int (buf_Header + 28, 1000 , false); // Byte 28 -> Version 1000 Integer Little...
- SG_Mem_Set_Int (buf_Header + 32, Type_File , false); // Byte 32 -> Shape m_Type Shape m_Type Integer Little...
- SG_Mem_Set_Double (buf_Header + 36, dRect.xMin, false); // Byte 36 -> Bounding Box Xmin Double Little...
- SG_Mem_Set_Double (buf_Header + 44, dRect.yMin, false); // Byte 44 -> Bounding Box Ymin Double Little...
- SG_Mem_Set_Double (buf_Header + 52, dRect.xMax, false); // Byte 52 -> Bounding Box Xmax Double Little...
- SG_Mem_Set_Double (buf_Header + 60, dRect.yMax, false); // Byte 60 -> Bounding Box Ymax Double Little...
- SG_Mem_Set_Double (buf_Header + 68, 0 , false); // Byte 68 -> Bounding Box Zmin Double Little...
- SG_Mem_Set_Double (buf_Header + 76, 0 , false); // Byte 76 -> Bounding Box Zmax Double Little...
- SG_Mem_Set_Double (buf_Header + 84, 0 , false); // Byte 84 -> Bounding Box Mmin Double Little...
- SG_Mem_Set_Double (buf_Header + 92, 0 , false); // Byte 92 -> Bounding Box Mmax Double Little...
-
- Stream .Write(buf_Header, sizeof(char), 100);
- Stream_Idx .Write(buf_Header, sizeof(char), 100);
-
- FileLength = 50; // FileLength measured in 16-bit words...
- FileLength_idx = 50; // FileLength measured in 16-bit words...
-
- RecordNumber = 1;
+ File_Header.Set_Value( 0, 9994 , true ); // Byte 0 Integer Big File Code = 9994
+ File_Header.Set_Value( 4, 0 , true ); // Byte 4 Integer Big unused
+ File_Header.Set_Value( 8, 0 , true ); // Byte 8 Integer Big unused
+ File_Header.Set_Value(12, 0 , true ); // Byte 12 Integer Big unused
+ File_Header.Set_Value(16, 0 , true ); // Byte 16 Integer Big unused
+ File_Header.Set_Value(20, 0 , true ); // Byte 20 Integer Big unused
+ File_Header.Set_Value(24, 0 , true ); // Byte 24 Integer Big File Length
+ File_Header.Set_Value(28, 1000 , false); // Byte 28 Integer Little Version = 1000
+ File_Header.Set_Value(32, Type , false); // Byte 32 Integer Little Shape Type
+ File_Header.Set_Value(36, m_Extent.Get_XMin() , false); // Byte 36 Double Little Bounding Box Xmin
+ File_Header.Set_Value(44, m_Extent.Get_YMin() , false); // Byte 44 Double Little Bounding Box Ymin
+ File_Header.Set_Value(52, m_Extent.Get_XMax() , false); // Byte 52 Double Little Bounding Box Xmax
+ File_Header.Set_Value(60, m_Extent.Get_YMax() , false); // Byte 60 Double Little Bounding Box Ymax
+ File_Header.Set_Value(68, Get_ZMin() , false); // Byte 68 Double Little Bounding Box Zmin
+ File_Header.Set_Value(76, Get_ZMax() , false); // Byte 76 Double Little Bounding Box Zmax
+ File_Header.Set_Value(84, Get_MMin() , false); // Byte 84 Double Little Bounding Box Mmin
+ File_Header.Set_Value(92, Get_MMax() , false); // Byte 92 Double Little Bounding Box Mmax
+
+ fSHP.Write(File_Header.Get_Data(), sizeof(char), 100);
+ fSHX.Write(File_Header.Get_Data(), sizeof(char), 100);
+
+ fSHP_Size = 50; // file size measured in 16-bit words...
+ fSHX_Size = 50; // file size measured in 16-bit words...
//-----------------------------------------------------
// Save Shapes...
- for(iShape=0; iShape<Get_Count() && SG_UI_Process_Set_Progress(iShape, Get_Count()); iShape++)
+ for(int iShape=0; iShape<Get_Count() && SG_UI_Process_Set_Progress(iShape, Get_Count()); iShape++)
{
- pShape = Get_Shape(iShape);
+ CSG_Shape *pShape = Get_Shape(iShape);
- switch( Type_File )
- {
//-------------------------------------------------
- case 1: // Point...
- //---------------------------------------------
- // Record-Header...
- ContentLength = 10; // ShapeType + Point...
- Save_ESRI_RecordHeader;
+ // geometries...
- //---------------------------------------------
- // Shape-Header...
- Stream.Write(&Type_File , sizeof(Type_File));
+ Record_Header.Set_Value(0, iShape + 1, true); // record number
- //---------------------------------------------
- // Shape-Points...
- dPoint = pShape->Get_Point(0);
- Stream.Write(&dPoint , sizeof(TSG_Point));
- break;
+ for(iPart=0, nPoints=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ nPoints += pShape->Get_Point_Count(iPart); // total number of points in shape
+ }
//-------------------------------------------------
- case 8: // Multipoint...
- //---------------------------------------------
- // Total Number of Points in Shape...
- for(iPart=0, nPoints=0; iPart<pShape->Get_Part_Count(); iPart++)
+ switch( m_Type ) // write content header
+ {
+ default: break;
+
+ //-------------------------------------------------
+ case SHAPE_TYPE_Point: ///////////////////////
+
+ switch( m_Vertex_Type )
{
- nPoints += pShape->Get_Point_Count(iPart);
+ case SG_VERTEX_TYPE_XY: Set_Content_Length(10); break;
+ case SG_VERTEX_TYPE_XYZ: Set_Content_Length(14); break;
+ case SG_VERTEX_TYPE_XYZM: Set_Content_Length(18); break;
}
- //-----------------------------------------
- // Record-Header...
- ContentLength = 10; // ShapeType + Point...
- Save_ESRI_RecordHeader;
+ fSHP.Write_Int (Type);
- //-----------------------------------------
- // Shape-Header...
- dRect = pShape->Get_Extent();
+ break;
- Stream.Write(&Type_File , sizeof(Type_File));
- Stream.Write(&dRect , sizeof(TSG_Rect));
- Stream.Write(&nPoints , sizeof(int));
+ //-------------------------------------------------
+ case SHAPE_TYPE_Points: ///////////////////////
- //-----------------------------------------
- // Shape-Points...
- for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ switch( m_Vertex_Type )
{
- for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
- {
- dPoint = pShape->Get_Point(iPoint, iPart);
- Stream.Write(&dPoint, sizeof(TSG_Point));
- }
+ case SG_VERTEX_TYPE_XY: Set_Content_Length(20 + 8 * nPoints); break;
+ case SG_VERTEX_TYPE_XYZ: Set_Content_Length(28 + 12 * nPoints); break;
+ case SG_VERTEX_TYPE_XYZM: Set_Content_Length(36 + 16 * nPoints); break;
}
+
+ fSHP.Write_Int (Type);
+ fSHP.Write_Double (pShape->Get_Extent().Get_XMin());
+ fSHP.Write_Double (pShape->Get_Extent().Get_YMin());
+ fSHP.Write_Double (pShape->Get_Extent().Get_XMax());
+ fSHP.Write_Double (pShape->Get_Extent().Get_YMax());
+ fSHP.Write_Int (nPoints);
+
break;
//-------------------------------------------------
- case 3: case 5: // Line, Polygon...
- //---------------------------------------------
- // Total Number of Points in Shape...
- for(iPart=0, nPoints=0; iPart<pShape->Get_Part_Count(); iPart++)
+ case SHAPE_TYPE_Line: ///////////////////////
+ case SHAPE_TYPE_Polygon: ///////////////////////
+
+ switch( m_Vertex_Type )
{
- nPoints += pShape->Get_Point_Count(iPart);
+ case SG_VERTEX_TYPE_XY: Set_Content_Length(22 + 2 * pShape->Get_Part_Count() + 8 * nPoints); break;
+ case SG_VERTEX_TYPE_XYZ: Set_Content_Length(30 + 2 * pShape->Get_Part_Count() + 12 * nPoints); break;
+ case SG_VERTEX_TYPE_XYZM: Set_Content_Length(38 + 2 * pShape->Get_Part_Count() + 16 * nPoints); break;
}
- //---------------------------------------------
- // Record-Header...
- ContentLength = 22 + 2 * pShape->Get_Part_Count() + 8 * nPoints; // ShapeType + nParts + nParts*Offsets + nPoints...
- Save_ESRI_RecordHeader;
-
- //---------------------------------------------
- // Shape-Header...
- dRect = pShape->Get_Extent();
- iPart = pShape->Get_Part_Count();
-
- Stream.Write(&Type_File , sizeof(Type_File));
- Stream.Write(&dRect , sizeof(TSG_Rect));
- Stream.Write(&iPart , sizeof(int));
- Stream.Write(&nPoints , sizeof(int));
+ fSHP.Write_Int (Type);
+ fSHP.Write_Double (pShape->Get_Extent().Get_XMin());
+ fSHP.Write_Double (pShape->Get_Extent().Get_YMin());
+ fSHP.Write_Double (pShape->Get_Extent().Get_XMax());
+ fSHP.Write_Double (pShape->Get_Extent().Get_YMax());
+ fSHP.Write_Int (pShape->Get_Part_Count());
+ fSHP.Write_Int (nPoints);
for(iPart=0, iPoint=0; iPart<pShape->Get_Part_Count(); iPart++)
{
- Stream.Write(&iPoint, sizeof(int));
+ fSHP.Write_Int(iPoint);
+
iPoint += pShape->Get_Point_Count(iPart);
}
+ break;
+ }
+
+ //-------------------------------------------------
+ switch( m_Type ) // write point data
+ {
+ default: break;
+
+ //-------------------------------------------------
+ case SHAPE_TYPE_Point: ///////////////////////
+
+ fSHP.Write(&(Point = pShape->Get_Point(0)), sizeof(TSG_Point));
+
//---------------------------------------------
- // Shape-Points...
+ if( m_Vertex_Type != SG_VERTEX_TYPE_XY )
+ {
+ fSHP.Write_Double(pShape->Get_Z(0));
+
+ if( m_Vertex_Type == SG_VERTEX_TYPE_XYZM )
+ {
+ fSHP.Write_Double(pShape->Get_M(0));
+ }
+ }
+
+ break;
+
+ //-------------------------------------------------
+ case SHAPE_TYPE_Points: ///////////////////////
+ case SHAPE_TYPE_Line: ///////////////////////
+ case SHAPE_TYPE_Polygon: ///////////////////////
+
for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
{
for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
{
- dPoint = pShape->Get_Point(iPoint, iPart);
- Stream.Write(&dPoint, sizeof(TSG_Point));
+ fSHP.Write(&(Point = pShape->Get_Point(iPoint, iPart)), sizeof(TSG_Point));
}
}
- break;
+
+ //---------------------------------------------
+ if( m_Vertex_Type != SG_VERTEX_TYPE_XY )
+ {
+ fSHP.Write_Double(pShape->Get_ZMin());
+ fSHP.Write_Double(pShape->Get_ZMin());
+
+ for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ fSHP.Write_Double(pShape->Get_Z(iPoint, iPart));
+ }
+ }
+
+ if( m_Vertex_Type == SG_VERTEX_TYPE_XYZM )
+ {
+ fSHP.Write_Double(pShape->Get_MMin());
+ fSHP.Write_Double(pShape->Get_MMin());
+
+ for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ for(iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ fSHP.Write_Double(pShape->Get_M(iPoint, iPart));
+ }
+ }
+ }
+ }
+ }
+
+ //-------------------------------------------------
+ // attributes...
+
+ fDBF.Add_Record();
+
+ for(iField=0; iField<Get_Field_Count(); iField++)
+ {
+ switch( fDBF.Get_FieldType(iField) )
+ {
+ case DBF_FT_DATE:
+ case DBF_FT_CHARACTER:
+ fDBF.Set_Value(iField, SG_STR_SGTOMB(pShape->asString(iField)));
+ break;
+
+ case DBF_FT_NUMERIC:
+ fDBF.Set_Value(iField, pShape->asDouble(iField));
+ break;
+ }
}
+
+ fDBF.Flush_Record();
}
//-----------------------------------------------------
// File Sizes...
- Stream .Seek(24);
- Stream_Idx .Seek(24);
-
- Stream .Write_Int(FileLength , true);
- Stream_Idx .Write_Int(FileLength_idx, true);
+ fSHP.Seek(24);
+ fSHP.Write_Int(fSHP_Size, true);
- SG_UI_Msg_Add(LNG("[MSG] okay"), false, SG_UI_MSG_STYLE_SUCCESS);
-
- SG_UI_Process_Set_Ready();
+ fSHX.Seek(24);
+ fSHX.Write_Int(fSHX_Size, true);
//-----------------------------------------------------
- // Attributes...
+ SG_UI_Process_Set_Ready();
- fName = SG_File_Make_Path(NULL, File_Name, SG_T("dbf"));
+ Get_Projection().Save(SG_File_Make_Path(NULL, File_Name, SG_T("prj")), SG_PROJ_FMT_WKT);
- return( CSG_Table::Save(fName, TABLE_FILETYPE_DBase) );
+ return( true );
}
diff --git a/src/saga_core/saga_api/shapes_ogis.cpp b/src/saga_core/saga_api/shapes_ogis.cpp
new file mode 100644
index 0000000..f44e5b3
--- /dev/null
+++ b/src/saga_core/saga_api/shapes_ogis.cpp
@@ -0,0 +1,712 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Application Programming Interface //
+// //
+// Library: SAGA_API //
+// //
+//-------------------------------------------------------//
+// //
+// shapes_ogis.cpp //
+// //
+// Copyright (C) 2010 by Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. //
+// //
+// This library is free software; you can redistribute //
+// it and/or modify it under the terms of the GNU Lesser //
+// General Public License as published by the Free //
+// Software Foundation, version 2.1 of the License. //
+// //
+// This library is distributed in the hope that it will //
+// be useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU Lesser General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU Lesser //
+// General Public License along with this program; if //
+// not, write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "shapes.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+inline bool CSG_Shapes_OGIS_Converter::_WKT_Read_Point(const CSG_String &Text, CSG_Shape *pShape, int iPart)
+{
+ double x, y, z, m;
+
+ switch( ((CSG_Shapes *)pShape->Get_Table())->Get_Vertex_Type() )
+ {
+ case SG_VERTEX_TYPE_XY:
+ if( SG_SSCANF(Text.c_str(), SG_T("%f %f"), &x, &y) == 2 )
+ {
+ pShape->Add_Point(x, y, iPart);
+
+ return( true );
+ }
+ break;
+
+ case SG_VERTEX_TYPE_XYZ:
+ if( SG_SSCANF(Text.c_str(), SG_T("%f %f %f"), &x, &y, &z) == 3 )
+ {
+ pShape->Add_Point(x, y, iPart);
+ pShape->Set_Z (z, pShape->Get_Point_Count(iPart) - 1, iPart);
+
+ return( true );
+ }
+ break;
+
+ case SG_VERTEX_TYPE_XYZM:
+ if( SG_SSCANF(Text.c_str(), SG_T("%f %f %f %f"), &x, &y, &z, &m) == 4 )
+ {
+ pShape->Add_Point(x, y, iPart);
+ pShape->Set_Z (z, pShape->Get_Point_Count(iPart) - 1, iPart);
+ pShape->Set_M (m, pShape->Get_Point_Count(iPart) - 1, iPart);
+
+ return( true );
+ }
+ break;
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::_WKT_Read_Points(const CSG_String &Text, CSG_Shape *pShape)
+{
+ int iPart = pShape->Get_Part_Count();
+ CSG_String s(Text.AfterFirst('(').BeforeFirst(')'));
+
+ while( s.Length() > 0 )
+ {
+ if( !_WKT_Read_Point(s, pShape, iPart) )
+ {
+ return( false );
+ }
+
+ s = s.AfterFirst(',');
+ }
+
+ return( pShape->Get_Point_Count(iPart) > 0 );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::_WKT_Read_Parts(const CSG_String &Text, CSG_Shape *pShape)
+{
+ CSG_String s = Text.AfterFirst('(').BeforeLast(')');
+
+ while( s.Length() > 0 )
+ {
+ _WKT_Read_Points(s, pShape);
+
+ s = s.AfterFirst(',');
+ }
+
+ return( pShape->Get_Part_Count() > 0 );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::_WKT_Read_Polygon(const CSG_String &Text, CSG_Shape *pShape)
+{
+ CSG_String Part;
+
+ for(int i=0, Level=-2; i<(int)Text.Length(); i++)
+ {
+ if( Text[i] == '(' )
+ {
+ Level++;
+ }
+ else if( Text[i] == ')' )
+ {
+ if( Level == 0 )
+ {
+ Part += Text[i];
+ _WKT_Read_Parts(Part, pShape);
+ Part.Clear();
+ }
+
+ Level--;
+ }
+
+ if( Level >= 0 )
+ {
+ Part += Text[i];
+ }
+ }
+
+ return( pShape->Get_Part_Count() > 0 );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::from_WKText(const CSG_String &Text, CSG_Shape *pShape)
+{
+ pShape->Del_Parts();
+
+ switch( pShape->Get_Type() )
+ {
+ case SHAPE_TYPE_Point:
+ if( !Text.BeforeFirst('(').Cmp(SG_OGIS_TYPE_STR_Point) )
+ {
+ return( _WKT_Read_Point(Text.AfterFirst('(').BeforeFirst(')'), pShape, 0) );
+ }
+ break;
+
+ case SHAPE_TYPE_Points:
+ if( !Text.BeforeFirst('(').Cmp(SG_OGIS_TYPE_STR_MultiPoint) )
+ {
+ return( _WKT_Read_Parts(Text, pShape) );
+ }
+ break;
+
+ case SHAPE_TYPE_Line:
+ if( !Text.BeforeFirst('(').Cmp(SG_OGIS_TYPE_STR_Line) )
+ {
+ return( _WKT_Read_Points(Text, pShape) );
+ }
+
+ if( !Text.BeforeFirst('(').Cmp(SG_OGIS_TYPE_STR_MultiLine) )
+ {
+ return( _WKT_Read_Parts(Text, pShape) );
+ }
+ break;
+
+ case SHAPE_TYPE_Polygon:
+ if( !Text.BeforeFirst('(').Cmp(SG_OGIS_TYPE_STR_Polygon) )
+ {
+ return( _WKT_Read_Parts(Text, pShape) );
+ }
+
+ if( !Text.BeforeFirst('(').Cmp(SG_OGIS_TYPE_STR_MultiPolygon) )
+ {
+ return( _WKT_Read_Polygon(Text, pShape) );
+ }
+ break;
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Point(CSG_String &Text, CSG_Shape *pShape, int iPoint, int iPart)
+{
+ TSG_Point Point = pShape->Get_Point(iPoint, iPart);
+
+ switch( ((CSG_Shapes *)pShape->Get_Table())->Get_Vertex_Type() )
+ {
+ case SG_VERTEX_TYPE_XY:
+ Text += CSG_String::Format(SG_T("%f %f") , Point.x, Point.y);
+ break;
+
+ case SG_VERTEX_TYPE_XYZ:
+ Text += CSG_String::Format(SG_T("%f %f %f") , Point.x, Point.y, pShape->Get_Z(iPoint, iPart));
+ break;
+
+ case SG_VERTEX_TYPE_XYZM:
+ Text += CSG_String::Format(SG_T("%f %f %f %f"), Point.x, Point.y, pShape->Get_Z(iPoint, iPart), pShape->Get_M(iPoint, iPart));
+ break;
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Points(CSG_String &Text, CSG_Shape *pShape, int iPart)
+{
+ Text += SG_T("(");
+
+ for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ if( iPoint > 0 )
+ {
+ Text += SG_T(", ");
+ }
+
+ _WKT_Write_Point(Text, pShape, iPoint, iPart);
+ }
+
+ if( pShape->Get_Type() == SHAPE_TYPE_Polygon && CSG_Point(pShape->Get_Point(0, iPart)) != pShape->Get_Point(pShape->Get_Point_Count(iPart) -1, iPart) )
+ {
+ Text += SG_T(", ");
+
+ _WKT_Write_Point(Text, pShape, 0, iPart);
+ }
+
+ Text += SG_T(")");
+
+ return( true );
+}
+
+//---------------------------------------------------------
+inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Parts(CSG_String &Text, CSG_Shape *pShape)
+{
+ Text += SG_T("(");
+
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ if( iPart > 0 )
+ {
+ Text += SG_T(", ");
+ }
+
+ _WKT_Write_Points(Text, pShape, iPart);
+ }
+
+ Text += SG_T(")");
+
+ return( true );
+}
+
+//---------------------------------------------------------
+inline bool CSG_Shapes_OGIS_Converter::_WKT_Write_Polygon(CSG_String &Text, CSG_Shape *pShape)
+{
+ Text += SG_T("(");
+
+ for(int iPart=0, nIslands=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ if( ((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) == false )
+ {
+ if( nIslands++ > 0 )
+ {
+ Text += SG_T(", ");
+ }
+
+ Text += SG_T("(");
+
+ _WKT_Write_Points(Text, pShape, iPart);
+
+ for(int jPart=0; jPart<pShape->Get_Part_Count(); jPart++)
+ {
+ if( ((CSG_Shape_Polygon *)pShape)->is_Lake(jPart) && ((CSG_Shape_Polygon *)pShape)->is_Containing(pShape->Get_Point(0, jPart), iPart) )
+ {
+ Text += SG_T(", ");
+
+ _WKT_Write_Points(Text, pShape, jPart);
+ }
+ }
+
+ Text += SG_T(")");
+ }
+ }
+
+ Text += SG_T(")");
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::to_WKText(CSG_Shape *pShape, CSG_String &Text)
+{
+ switch( pShape->Get_Type() )
+ {
+ default:
+ return( false );
+
+ case SHAPE_TYPE_Point:
+ Text = SG_OGIS_TYPE_STR_Point;
+ _WKT_Write_Points(Text, pShape, 0);
+ break;
+
+ case SHAPE_TYPE_Points:
+ Text = SG_OGIS_TYPE_STR_MultiPoint;
+ _WKT_Write_Parts(Text, pShape);
+ break;
+
+ case SHAPE_TYPE_Line:
+ Text = SG_OGIS_TYPE_STR_MultiLine;
+ _WKT_Write_Parts(Text, pShape);
+ break;
+
+ case SHAPE_TYPE_Polygon:
+ Text = SG_OGIS_TYPE_STR_MultiPolygon;
+ _WKT_Write_Polygon(Text, pShape);
+ break;
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+inline bool CSG_Shapes_OGIS_Converter::_WKB_Read_Point(CSG_Bytes &Bytes, bool bSwapBytes, CSG_Shape *pShape, int iPart)
+{
+ if( Bytes.is_EOF() )
+ {
+ return( false );
+ }
+
+ double x, y;
+
+ x = Bytes.Read_Double(bSwapBytes);
+ y = Bytes.Read_Double(bSwapBytes);
+
+ pShape->Add_Point(x, y, iPart);
+
+ switch( ((CSG_Shapes *)pShape->Get_Table())->Get_Vertex_Type() )
+ {
+ case SG_VERTEX_TYPE_XY:
+ break;
+
+ case SG_VERTEX_TYPE_XYZ:
+ pShape->Set_Z(Bytes.Read_Double(bSwapBytes), pShape->Get_Point_Count(iPart) - 1, iPart);
+ break;
+
+ case SG_VERTEX_TYPE_XYZM:
+ pShape->Set_Z(Bytes.Read_Double(bSwapBytes), pShape->Get_Point_Count(iPart) - 1, iPart);
+ pShape->Set_M(Bytes.Read_Double(bSwapBytes), pShape->Get_Point_Count(iPart) - 1, iPart);
+ break;
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::_WKB_Read_Points(CSG_Bytes &Bytes, bool bSwapBytes, CSG_Shape *pShape)
+{
+ DWORD iPart = pShape->Get_Part_Count();
+ DWORD nPoints = Bytes.Read_DWord(bSwapBytes);
+
+ for(DWORD iPoint=0; iPoint<nPoints; iPoint++)
+ {
+ if( !_WKB_Read_Point(Bytes, bSwapBytes, pShape, iPart) )
+ {
+ return( false );
+ }
+ }
+
+ return( pShape->Get_Point_Count(iPart) > 0 );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::_WKB_Read_Parts(CSG_Bytes &Bytes, bool bSwapBytes, CSG_Shape *pShape)
+{
+ DWORD iPart, nParts = Bytes.Read_DWord(bSwapBytes);
+
+ for(iPart=0; iPart<nParts; iPart++)
+ {
+ if( !_WKB_Read_Points(Bytes, bSwapBytes, pShape) )
+ {
+ return( false );
+ }
+ }
+
+ return( pShape->Get_Part_Count() > 0 );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::_WKB_Read_MultiLine(CSG_Bytes &Bytes, bool bSwapBytes, CSG_Shape *pShape)
+{
+ DWORD nLines = Bytes.Read_DWord(bSwapBytes);
+
+ for(DWORD iLine=0; iLine<nLines; iLine++)
+ {
+ bSwapBytes = Bytes.Read_Byte() != SG_OGIS_BYTEORDER_NDR;
+
+ if( Bytes.Read_DWord(bSwapBytes) != SG_OGIS_TYPE_LineString || !_WKB_Read_Points(Bytes, bSwapBytes, pShape) )
+ {
+ return( false );
+ }
+ }
+
+ return( pShape->Get_Part_Count() > 0 );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::_WKB_Read_MultiPolygon(CSG_Bytes &Bytes, bool bSwapBytes, CSG_Shape *pShape)
+{
+ DWORD nPolygons = Bytes.Read_DWord(bSwapBytes);
+
+ for(DWORD iPolygon=0; iPolygon<nPolygons; iPolygon++)
+ {
+ bSwapBytes = Bytes.Read_Byte() != SG_OGIS_BYTEORDER_NDR;
+
+ if( Bytes.Read_DWord(bSwapBytes) != SG_OGIS_TYPE_Polygon || !_WKB_Read_Parts(Bytes, bSwapBytes, pShape) )
+ {
+ return( false );
+ }
+ }
+
+ return( pShape->Get_Part_Count() > 0 );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::from_WKBinary(CSG_Bytes &Bytes, CSG_Shape *pShape)
+{
+ pShape->Del_Parts();
+
+ Bytes.Rewind();
+
+ bool bSwapBytes = Bytes.Read_Byte() != SG_OGIS_BYTEORDER_NDR;
+
+ switch( pShape->Get_Type() )
+ {
+ case SHAPE_TYPE_Point:
+ if( Bytes.Read_DWord() == SG_OGIS_TYPE_Point )
+ {
+ return( _WKB_Read_Point(Bytes, bSwapBytes, pShape, 0) );
+ }
+ break;
+
+ case SHAPE_TYPE_Points:
+ if( Bytes.Read_DWord() == SG_OGIS_TYPE_MultiPoint )
+ {
+ return( _WKB_Read_Parts(Bytes, bSwapBytes, pShape) );
+ }
+ break;
+
+ case SHAPE_TYPE_Line:
+ switch( Bytes.Read_DWord() )
+ {
+ case SG_OGIS_TYPE_LineString:
+ return( _WKB_Read_Points (Bytes, bSwapBytes, pShape) );
+
+ case SG_OGIS_TYPE_MultiLineString:
+ return( _WKB_Read_MultiLine (Bytes, bSwapBytes, pShape) );
+ }
+ break;
+
+ case SHAPE_TYPE_Polygon:
+ switch( Bytes.Read_DWord() )
+ {
+ case SG_OGIS_TYPE_Polygon:
+ return( _WKB_Read_Parts (Bytes, bSwapBytes, pShape) );
+
+ case SG_OGIS_TYPE_MultiPolygon:
+ return( _WKB_Read_MultiPolygon (Bytes, bSwapBytes, pShape) );
+ }
+ break;
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+inline bool CSG_Shapes_OGIS_Converter::_WKB_Write_Point(CSG_Bytes &Bytes, CSG_Shape *pShape, int iPoint, int iPart)
+{
+ TSG_Point Point = pShape->Get_Point(iPoint, iPart);
+
+ Bytes += Point.x;
+ Bytes += Point.y;
+
+ switch( ((CSG_Shapes *)pShape->Get_Table())->Get_Vertex_Type() )
+ {
+ case SG_VERTEX_TYPE_XY:
+ break;
+
+ case SG_VERTEX_TYPE_XYZ:
+ Bytes += pShape->Get_Z(iPoint, iPart);
+ break;
+
+ case SG_VERTEX_TYPE_XYZM:
+ Bytes += pShape->Get_Z(iPoint, iPart);
+ Bytes += pShape->Get_M(iPoint, iPart);
+ break;
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::_WKB_Write_Points(CSG_Bytes &Bytes, CSG_Shape *pShape, int iPart)
+{
+ bool bFirstTwice = pShape->Get_Type() == SHAPE_TYPE_Polygon && CSG_Point(pShape->Get_Point(0, iPart)) != pShape->Get_Point(pShape->Get_Point_Count(iPart) -1, iPart);
+
+ Bytes += (DWORD)(pShape->Get_Point_Count(iPart) + (bFirstTwice ? 1 : 0));
+
+ for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++)
+ {
+ _WKB_Write_Point(Bytes, pShape, iPoint, iPart);
+ }
+
+ if( bFirstTwice )
+ {
+ _WKB_Write_Point(Bytes, pShape, 0, iPart);
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::_WKB_Write_Parts(CSG_Bytes &Bytes, CSG_Shape *pShape)
+{
+ Bytes += (DWORD)pShape->Get_Part_Count();
+
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ if( !_WKB_Write_Points(Bytes, pShape, iPart) )
+ {
+ return( false );
+ }
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::_WKB_Write_MultiLine(CSG_Bytes &Bytes, CSG_Shape *pShape)
+{
+ Bytes += (DWORD)pShape->Get_Part_Count();
+
+ for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ Bytes += (BYTE)SG_OGIS_BYTEORDER_NDR;
+ Bytes += (DWORD)SG_OGIS_TYPE_LineString;
+
+ if( !_WKB_Write_Points(Bytes, pShape, iPart) )
+ {
+ return( false );
+ }
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::_WKB_Write_MultiPolygon(CSG_Bytes &Bytes, CSG_Shape *pShape)
+{
+ int iPart, nPolygons, *nRings, *iPolygon;
+
+ nPolygons = 0;
+ nRings = new int[pShape->Get_Part_Count()];
+ iPolygon = new int[pShape->Get_Part_Count()];
+
+ for(iPart=0, nPolygons=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ nRings [iPart] = 0;
+
+ if( ((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) == false )
+ {
+ nPolygons ++;
+ nRings [iPart] ++;
+ iPolygon[iPart] = iPart;
+
+ for(int jPart=0; jPart<pShape->Get_Part_Count(); jPart++)
+ {
+ if( ((CSG_Shape_Polygon *)pShape)->is_Lake(jPart) && ((CSG_Shape_Polygon *)pShape)->is_Containing(pShape->Get_Point(0, jPart), iPart) )
+ {
+ nRings [iPart]++;
+ iPolygon[jPart] = iPart;
+ }
+ }
+ }
+ }
+
+ Bytes += (DWORD)nPolygons;
+
+ for(iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
+ {
+ if( nRings[iPart] > 0 )
+ {
+ Bytes += (BYTE)SG_OGIS_BYTEORDER_NDR;
+ Bytes += (DWORD)SG_OGIS_TYPE_Polygon;
+ Bytes += (DWORD)nRings[iPart];
+
+ for(int jPart=0; jPart<pShape->Get_Part_Count(); jPart++)
+ {
+ if( iPolygon[jPart] == iPart )
+ {
+ if( !_WKB_Write_Points(Bytes, pShape, jPart) )
+ {
+ return( false );
+ }
+ }
+ }
+ }
+ }
+
+ delete[](nRings);
+ delete[](iPolygon);
+
+ return( nPolygons > 0 );
+}
+
+//---------------------------------------------------------
+bool CSG_Shapes_OGIS_Converter::to_WKBinary(CSG_Shape *pShape, CSG_Bytes &Bytes)
+{
+ Bytes.Destroy();
+
+ Bytes += (BYTE)SG_OGIS_BYTEORDER_NDR;
+
+ switch( pShape->Get_Type() )
+ {
+ default:
+ return( false );
+
+ case SHAPE_TYPE_Point:
+ Bytes += (BYTE)SG_OGIS_TYPE_Point;
+ return( _WKB_Write_Point(Bytes, pShape, 0, 0) );
+
+ case SHAPE_TYPE_Points:
+ Bytes += (BYTE)SG_OGIS_TYPE_MultiPoint;
+ return( _WKB_Write_Points(Bytes, pShape, 0) );
+
+ case SHAPE_TYPE_Line:
+ Bytes += (BYTE)SG_OGIS_TYPE_MultiLineString;
+ return( _WKB_Write_MultiLine(Bytes, pShape) );
+
+ case SHAPE_TYPE_Polygon:
+ Bytes += (BYTE)SG_OGIS_TYPE_MultiPolygon;
+ return( _WKB_Write_MultiPolygon(Bytes, pShape) );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_api/table.cpp b/src/saga_core/saga_api/table.cpp
index fef0f1b..bc10a88 100644
--- a/src/saga_core/saga_api/table.cpp
+++ b/src/saga_core/saga_api/table.cpp
@@ -60,8 +60,6 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#include <string.h>
-
#include "table.h"
#include "shapes.h"
@@ -409,7 +407,7 @@ bool CSG_Table::is_Compatible(CSG_Table *pTable, bool bExactMatch) const
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-void CSG_Table::Add_Field(const SG_Char *Name, TSG_Data_Type Type, int add_Field)
+bool CSG_Table::Add_Field(const SG_Char *Name, TSG_Data_Type Type, int add_Field)
{
int iField, iRecord;
@@ -446,12 +444,14 @@ void CSG_Table::Add_Field(const SG_Char *Name, TSG_Data_Type Type, int add_Field
}
Set_Modified();
+
+ return( true );
}
//---------------------------------------------------------
#ifdef _SAGA_UNICODE
-void CSG_Table::Add_Field(const char *Name, TSG_Data_Type Type, int iField)
-{ Add_Field(CSG_String(Name), Type, iField); }
+bool CSG_Table::Add_Field(const char *Name, TSG_Data_Type Type, int iField)
+{ return( Add_Field(CSG_String(Name), Type, iField) ); }
#endif
//---------------------------------------------------------
@@ -509,6 +509,32 @@ bool CSG_Table::Set_Field_Name(int iField, const SG_Char *Name)
return( false );
}
+//---------------------------------------------------------
+int CSG_Table::Get_Field_Length(int iField) const
+{
+ int Length = 0;
+
+ if( iField >= 0 && iField < m_nFields && m_Field_Type[iField] == SG_DATATYPE_String )
+ {
+ for(int i=0; i<m_nRecords; i++)
+ {
+ const SG_Char *s = m_Records[i]->asString(iField);
+
+ if( s && s[0] )
+ {
+ int n = SG_STR_LEN(s);
+
+ if( Length < n )
+ {
+ Length = n;
+ }
+ }
+ }
+ }
+
+ return( Length );
+}
+
///////////////////////////////////////////////////////////
// //
@@ -791,6 +817,28 @@ bool CSG_Table::_Del_Records(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+void CSG_Table::Set_Modified(bool bModified)
+{
+ if( bModified != is_Modified() )
+ {
+ CSG_Data_Object::Set_Modified(bModified);
+
+ if( m_pOwner )
+ {
+ m_pOwner->Set_Modified(bModified);
+ }
+
+ if( bModified == false )
+ {
+ for(int iRecord=0; iRecord<Get_Count() && SG_UI_Process_Set_Progress(iRecord, Get_Count()); iRecord++)
+ {
+ Get_Record(iRecord)->Set_Modified(false);
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
bool CSG_Table::Set_Value(int iRecord, int iField, const SG_Char *Value)
{
CSG_Table_Record *pRecord;
@@ -888,7 +936,10 @@ bool CSG_Table::_Stats_Update(int iField) const
for(int iRecord=0; iRecord<m_nRecords; iRecord++, ppRecord++)
{
- m_Field_Stats[iField]->Add_Value((*ppRecord)->asDouble(iField));
+ if( !(*ppRecord)->is_NoData(iField) )
+ {
+ m_Field_Stats[iField]->Add_Value((*ppRecord)->asDouble(iField));
+ }
}
}
diff --git a/src/saga_core/saga_api/table.h b/src/saga_core/saga_api/table.h
index e027393..6ce6c74 100644
--- a/src/saga_core/saga_api/table.h
+++ b/src/saga_core/saga_api/table.h
@@ -108,6 +108,17 @@ TSG_Table_Index_Order;
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+#define SG_TABLE_REC_FLAG_Modified 0x01
+#define SG_TABLE_REC_FLAG_Selected 0x02
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
class SAGA_API_DLL_EXPORT CSG_Table_Record
{
friend class CSG_Table;
@@ -117,14 +128,16 @@ public:
class CSG_Table * Get_Table (void) { return( m_pTable ); }
int Get_Index (void) const { return( m_Index ); }
- bool Set_Value (int iField, const SG_Char *Value);
- bool Set_Value (const SG_Char *Field, const SG_Char *Value);
- bool Set_Value (int iField, double Value);
- bool Set_Value (const SG_Char *Field, double Value);
- bool Add_Value (int iField, double Value);
- bool Add_Value (const SG_Char *Field, double Value);
- bool Mul_Value (int iField, double Value);
- bool Mul_Value (const SG_Char *Field, double Value);
+ bool Set_Value (int iField, const CSG_Bytes &Value);
+ bool Set_Value (const SG_Char *Field, const CSG_Bytes &Value);
+ bool Set_Value (int iField, const SG_Char *Value);
+ bool Set_Value (const SG_Char *Field, const SG_Char *Value);
+ bool Set_Value (int iField, double Value);
+ bool Set_Value (const SG_Char *Field, double Value);
+ bool Add_Value (int iField, double Value);
+ bool Add_Value (const SG_Char *Field, double Value);
+ bool Mul_Value (int iField, double Value);
+ bool Mul_Value (const SG_Char *Field, double Value);
bool Set_NoData (int iField);
bool Set_NoData (const SG_Char *Field);
@@ -146,11 +159,13 @@ public:
double asDouble (int iField) const;
double asDouble (const SG_Char *Field) const;
+ CSG_Table_Value * Get_Value (int iField) { return( m_Values[iField] ); }
CSG_Table_Value & operator [] (int iField) const { return( *m_Values[iField] ); }
virtual bool Assign (CSG_Table_Record *pRecord);
- bool is_Selected (void) const { return( m_bSelected ); }
+ bool is_Selected (void) const { return( (m_Flags & SG_TABLE_REC_FLAG_Selected) != 0 ); }
+ bool is_Modified (void) const { return( (m_Flags & SG_TABLE_REC_FLAG_Modified) != 0 ); }
protected:
@@ -159,7 +174,7 @@ protected:
virtual ~CSG_Table_Record(void);
- bool m_bSelected;
+ char m_Flags;
int m_Index;
@@ -168,6 +183,10 @@ protected:
class CSG_Table *m_pTable;
+ void Set_Selected (bool bOn = true);
+ void Set_Modified (bool bOn = true);
+
+
class CSG_Table_Value * _Create_Value (TSG_Data_Type Type);
bool _Add_Field (int add_Field);
@@ -227,15 +246,16 @@ public:
bool is_Compatible (CSG_Table *pTable, bool bExactMatch = false) const;
//-----------------------------------------------------
- void Add_Field (const SG_Char *Name, TSG_Data_Type Type, int iField = -1);
+ virtual bool Add_Field (const SG_Char *Name, TSG_Data_Type Type, int iField = -1);
#ifdef _SAGA_UNICODE
- void Add_Field (const char *Name, TSG_Data_Type Type, int iField = -1);
+ virtual bool Add_Field (const char *Name, TSG_Data_Type Type, int iField = -1);
#endif
- bool Del_Field (int iField);
+ virtual bool Del_Field (int iField);
int Get_Field_Count (void) const { return( m_nFields ); }
const SG_Char * Get_Field_Name (int iField) const { return( iField >= 0 && iField < m_nFields ? m_Field_Name[iField]->c_str() : NULL ); }
TSG_Data_Type Get_Field_Type (int iField) const { return( iField >= 0 && iField < m_nFields ? m_Field_Type[iField] : SG_DATATYPE_Undefined ); }
+ int Get_Field_Length (int iField) const; // returns the maximum number of characters for data type string and zero for all other data types.
bool Set_Field_Name (int iField, const SG_Char *Name);
@@ -247,15 +267,15 @@ public:
double Get_Variance (int iField) const { return( _Stats_Update(iField) ? m_Field_Stats[iField]->Get_Variance() : 0.0 ); }
//-----------------------------------------------------
- CSG_Table_Record * Add_Record ( CSG_Table_Record *pCopy = NULL);
- CSG_Table_Record * Ins_Record (int iRecord, CSG_Table_Record *pCopy = NULL);
- bool Del_Record (int iRecord);
- bool Del_Records (void);
+ virtual CSG_Table_Record * Add_Record ( CSG_Table_Record *pCopy = NULL);
+ virtual CSG_Table_Record * Ins_Record (int iRecord, CSG_Table_Record *pCopy = NULL);
+ virtual bool Del_Record (int iRecord);
+ virtual bool Del_Records (void);
int Get_Count (void) const { return( m_nRecords ); }
int Get_Record_Count (void) const { return( m_nRecords ); }
- CSG_Table_Record * Get_Record (int iRecord) const { return( iRecord >= 0 && iRecord < m_nRecords ? m_Records[iRecord] : NULL ); }
- CSG_Table_Record & operator [] (int iRecord) const { return( *Get_Record(iRecord) ); }
+ virtual CSG_Table_Record * Get_Record (int iRecord) const { return( iRecord >= 0 && iRecord < m_nRecords ? m_Records[iRecord] : NULL ); }
+ virtual CSG_Table_Record & operator [] (int iRecord) const { return( *Get_Record(iRecord) ); }
int Get_Index (int Index) const { return( Index >= 0 && Index < m_nRecords ? (m_Index ? m_Index[Index] : Index) : -1 ); }
@@ -265,33 +285,35 @@ public:
{
if( m_Index != NULL )
{
- return( m_Records[m_Index[Index]] );
+ return( Get_Record(m_Index[Index]) );
}
- return( m_Records[Index] );
+ return( Get_Record(Index) );
}
return( NULL );
}
//-----------------------------------------------------
- bool Set_Value (int iRecord, int iField, const SG_Char *Value);
- bool Set_Value (int iRecord, int iField, double Value);
+ virtual bool Set_Value (int iRecord, int iField, const SG_Char *Value);
+ virtual bool Set_Value (int iRecord, int iField, double Value);
- bool Get_Value (int iRecord, int iField, CSG_String &Value) const;
- bool Get_Value (int iRecord, int iField, double &Value) const;
+ virtual bool Get_Value (int iRecord, int iField, CSG_String &Value) const;
+ virtual bool Get_Value (int iRecord, int iField, double &Value) const;
- virtual void Set_Modified (bool bModified = true) { CSG_Data_Object::Set_Modified(bModified); if( m_pOwner ) m_pOwner->Set_Modified(bModified); }
+ virtual void Set_Modified (bool bModified = true);
//-----------------------------------------------------
int Get_Selection_Count (void) const { return( m_nSelected ); }
- CSG_Table_Record * Get_Selection (int Index = 0) const { return( Index >= 0 && Index < m_nSelected ? m_Selected[Index] : NULL ); }
+ virtual CSG_Table_Record * Get_Selection (int Index = 0) const { return( Index >= 0 && Index < m_nSelected ? m_Selected[Index] : NULL ); }
+
+ virtual bool is_Selected (int iRecord) const { return( iRecord >= 0 && iRecord < m_nRecords ? m_Records[iRecord]->is_Selected() : false ); }
virtual bool Select (int iRecord , bool bInvert = false);
virtual bool Select (CSG_Table_Record *pRecord = NULL , bool bInvert = false);
- int Del_Selection (void);
- int Inv_Selection (void);
+ virtual int Del_Selection (void);
+ virtual int Inv_Selection (void);
//-----------------------------------------------------
bool Set_Index (int Field_1, TSG_Table_Index_Order Order_1, int Field_2 = -1, TSG_Table_Index_Order Order_2 = TABLE_INDEX_None, int Field_3 = -1, TSG_Table_Index_Order Order_3 = TABLE_INDEX_None);
@@ -306,19 +328,13 @@ public:
protected:
- int m_nFields, m_nRecords, m_nBuffer, m_nSelected, *m_Index, m_Index_Field[3];
+ int m_nFields, m_nRecords, m_nBuffer, m_nSelected;
- TSG_Data_Type *m_Field_Type;
-
- TSG_Table_Index_Order m_Index_Order[3];
-
- CSG_Simple_Statistics **m_Field_Stats;
-
- CSG_Table_Record **m_Records, **m_Selected;
+ TSG_Data_Type *m_Field_Type;
CSG_String **m_Field_Name;
- CSG_Data_Object *m_pOwner;
+ CSG_Simple_Statistics **m_Field_Stats;
virtual void _On_Construction (void);
@@ -329,6 +345,22 @@ protected:
bool _Create (const CSG_String &File_Name, TSG_Table_File_Type Format, const SG_Char *Separator);
bool _Create (CSG_Table *pStructure);
+ bool _Stats_Invalidate (void) const;
+ bool _Stats_Invalidate (int iField) const;
+ virtual bool _Stats_Update (int iField) const;
+
+
+private:
+
+ int *m_Index, m_Index_Field[3];
+
+ TSG_Table_Index_Order m_Index_Order[3];
+
+ CSG_Table_Record **m_Records, **m_Selected;
+
+ CSG_Data_Object *m_pOwner;
+
+
bool _Destroy (void);
bool _Destroy_Selection (void);
@@ -342,10 +374,6 @@ protected:
bool _Del_Record (int iRecord);
bool _Del_Records (void);
- bool _Stats_Invalidate (void) const;
- bool _Stats_Invalidate (int iField) const;
- bool _Stats_Update (int iField) const;
-
bool _Load (const CSG_String &File_Name, TSG_Table_File_Type Format, const SG_Char *Separator);
bool _Load_Text (const CSG_String &File_Name, bool bHeadline, const SG_Char *Separator);
bool _Save_Text (const CSG_String &File_Name, bool bHeadline, const SG_Char *Separator);
diff --git a/src/saga_core/saga_api/table_dbase.cpp b/src/saga_core/saga_api/table_dbase.cpp
index ea12590..a938d19 100644
--- a/src/saga_core/saga_api/table_dbase.cpp
+++ b/src/saga_core/saga_api/table_dbase.cpp
@@ -277,6 +277,18 @@ void CSG_Table_DBase::Header_Write(void)
for(iField=0; iField<nFields; iField++)
{
+ if( FieldDesc[iField].Type == DBF_FT_CHARACTER )
+ {
+ if( FieldDesc[iField].Width < 1 )
+ {
+ FieldDesc[iField].Width = 1;
+ }
+ else if( FieldDesc[iField].Width > 255 )
+ {
+ FieldDesc[iField].Width = 255;
+ }
+ }
+
nRecordBytes += FieldDesc[iField].Width;
}
@@ -314,7 +326,7 @@ void CSG_Table_DBase::Header_Write(void)
// Bytes 32-n: Field Descriptor Array...
for(iField=0; iField<nFields; iField++)
{
- FieldDesc[iField].Name[11] = '\0';
+ FieldDesc[iField].Name[10] = '\0';
_strupr(FieldDesc[iField].Name);
fwrite( FieldDesc[iField].Name , sizeof(char), 11, hFile); // 00-10 Field Name ASCII padded with 0x00
@@ -379,7 +391,6 @@ bool CSG_Table_DBase::Header_Read(void)
while( ftell(hFile) < (long)nHeaderBytes - 1 && !feof(hFile) )
{
FieldDesc = (TFieldDesc *)SG_Realloc(FieldDesc, (nFields + 1) * sizeof(TFieldDesc));
- FieldDesc[nFields].Name[12] = '\0';
fread( FieldDesc[nFields].Name , sizeof(char), 11, hFile); // 0-10 Field Name ASCII padded with 0x00
fread(&FieldDesc[nFields].Type , sizeof(char), 1, hFile); // 11 Field Type Identifier (see table)
@@ -391,6 +402,8 @@ bool CSG_Table_DBase::Header_Read(void)
fread( buf , sizeof(char), 10, hFile); // 21-30 Reserved
fread(&FieldDesc[nFields].ProductionIdx , sizeof(char), 1, hFile); // 31 Field is part of production index - 0x01 else 0x00
+ FieldDesc[nFields].Name[11] = '\0';
+
nFields++;
}
@@ -601,19 +614,38 @@ double CSG_Table_DBase::asDouble(int iField)
//---------------------------------------------------------
char * CSG_Table_DBase::asString(int iField)
{
- int i;
-
if( bOpen && iField >= 0 && iField < nFields )
{
- i = FieldDesc[iField].Width;
- Result_String = (char *)SG_Realloc(Result_String, (i + 1) * sizeof(char));
- memcpy(Result_String, Record + FieldOffset[iField], FieldDesc[iField].Width);
+ if( FieldDesc[iField].Type != DBF_FT_DATE )
+ {
+ int i = FieldDesc[iField].Width;
+ Result_String = (char *)SG_Realloc(Result_String, (i + 1) * sizeof(char));
+ memcpy(Result_String, Record + FieldOffset[iField], FieldDesc[iField].Width);
- Result_String[i--] = '\0';
+ Result_String[i--] = '\0';
- while( i >= 0 && Result_String[i] == ' ' )
+ while( i >= 0 && Result_String[i] == ' ' )
+ {
+ Result_String[i--] = '\0';
+ }
+ }
+ else // if( FieldDesc[iField].Type == DBF_FT_DATE ) // SAGA(DD.MM.YYYY) from DBASE(YYYYMMDD)
{
- Result_String[i--] = '\0';
+ char *s = Record + FieldOffset[iField];
+
+ Result_String = (char *)SG_Realloc(Result_String, (10 + 1) * sizeof(char));
+
+ Result_String[0] = s[6]; // D1
+ Result_String[1] = s[7]; // D2
+ Result_String[2] = '.';
+ Result_String[3] = s[4]; // M1
+ Result_String[4] = s[5]; // M2
+ Result_String[5] = '.';
+ Result_String[6] = s[0]; // Y1
+ Result_String[7] = s[1]; // Y2
+ Result_String[8] = s[2]; // Y3
+ Result_String[9] = s[3]; // Y4
+ Result_String[2] = '\0';
}
return( Result_String );
@@ -661,7 +693,7 @@ bool CSG_Table_DBase::Set_Value(int iField, double Value)
return( true );
}
-
+
if( FieldDesc[iField].Type == DBF_FT_DATE )
{
int y = (int)(Value / 10000); Value -= y * 10000;
@@ -690,15 +722,15 @@ bool CSG_Table_DBase::Set_Value(int iField, double Value)
//---------------------------------------------------------
bool CSG_Table_DBase::Set_Value(int iField, const char *Value)
{
- int n;
-
if( bOpen && iField >= 0 && iField < nFields && FieldDesc[iField].Width > 0 )
{
- if( FieldDesc[iField].Type == DBF_FT_CHARACTER && Value )
+ int n = Value && Value[0] ? strlen(Value) : 0;
+
+ if( FieldDesc[iField].Type == DBF_FT_CHARACTER )
{
bRecModified = true;
- if( (n = strlen(Value)) > FieldDesc[iField].Width )
+ if( n > FieldDesc[iField].Width )
{
n = FieldDesc[iField].Width;
}
@@ -708,6 +740,24 @@ bool CSG_Table_DBase::Set_Value(int iField, const char *Value)
return( true );
}
+
+ if( FieldDesc[iField].Type == DBF_FT_DATE && n == 10 ) // SAGA(DD.MM.YYYY) to DBASE(YYYYMMDD)
+ {
+ bRecModified = true;
+
+ char *s = Record + FieldOffset[iField];
+
+ s[0] = Value[6]; // Y1
+ s[1] = Value[7]; // Y2
+ s[2] = Value[8]; // Y3
+ s[3] = Value[9]; // Y4
+ s[4] = Value[3]; // M1
+ s[5] = Value[4]; // M2
+ s[6] = Value[0]; // D1
+ s[7] = Value[1]; // D2
+
+ return( true );
+ }
}
return( false );
diff --git a/src/saga_core/saga_api/table_io.cpp b/src/saga_core/saga_api/table_io.cpp
index 0413044..df062fb 100644
--- a/src/saga_core/saga_api/table_io.cpp
+++ b/src/saga_core/saga_api/table_io.cpp
@@ -75,6 +75,11 @@
//---------------------------------------------------------
bool CSG_Table::_Load(const CSG_String &File_Name, TSG_Table_File_Type Format, const SG_Char *Separator)
{
+ if( !::SG_File_Exists(File_Name) )
+ {
+ return( false );
+ }
+
bool bResult;
CSG_String fName, sSeparator(Separator);
@@ -241,7 +246,7 @@ bool CSG_Table::_Load_Text(const CSG_String &File_Name, bool bHeadline, const SG
while( (i = sLine.Find(Separator)) >= 0 )
{
- sField.Printf(bHeadline ? sLine.Left(i) : SG_T("FIELD_%02d"), Table.Get_Field_Count() + 1);
+ sField = bHeadline ? sLine.Left(i) : CSG_String::Format(SG_T("FIELD_%02d"), Table.Get_Field_Count() + 1);
if( sField[0] == SG_T('\"') && sField[(int)(sField.Length() - 1)] == SG_T('\"') ) // remove quota
{
@@ -278,7 +283,7 @@ bool CSG_Table::_Load_Text(const CSG_String &File_Name, bool bHeadline, const SG
{
if( (i = sLine.Find(Separator)) >= 0 )
{
- sField.Printf(sLine.Left(i));
+ sField = sLine.Left(i);
if( sField[0] == SG_T('\"') && sField[(int)(sField.Length() - 1)] == SG_T('\"') ) // remove quota
{
@@ -478,102 +483,66 @@ bool CSG_Table::_Load_DBase(const CSG_String &File_Name)
//---------------------------------------------------------
bool CSG_Table::_Save_DBase(const CSG_String &File_Name)
{
- int iField, iRecord;
- size_t *nStringBytes;
- CSG_Table_Record *pRecord;
- CSG_Table_DBase dbf;
- CSG_Table_DBase::TFieldDesc *dbfFieldDesc;
+ int iField, iRecord, nBytes;
+ CSG_Table_DBase dbf;
//-----------------------------------------------------
- for(iField=0, nStringBytes=NULL; iField<Get_Field_Count(); iField++)
- {
- if( Get_Field_Type(iField) == SG_DATATYPE_String )
- {
- if( nStringBytes == NULL )
- {
- nStringBytes = new size_t[Get_Field_Count()];
- }
-
- nStringBytes[iField] = 8;
- }
- }
-
- if( nStringBytes )
- {
- for(iRecord=0; iRecord<Get_Record_Count() && SG_UI_Process_Set_Progress(iRecord, Get_Record_Count()); iRecord++)
- {
- pRecord = Get_Record(iRecord);
-
- for(iField=0; iField<Get_Field_Count(); iField++)
- {
- if( Get_Field_Type(iField) == SG_DATATYPE_String && SG_STR_LEN(pRecord->asString(iField)) > nStringBytes[iField] )
- {
- nStringBytes[iField] = SG_STR_LEN(pRecord->asString(iField));
- }
- }
- }
- }
-
- //-----------------------------------------------------
- dbfFieldDesc = (CSG_Table_DBase::TFieldDesc *)SG_Calloc(Get_Field_Count(), sizeof(CSG_Table_DBase::TFieldDesc));
+ CSG_Table_DBase::TFieldDesc *dbfFields = new CSG_Table_DBase::TFieldDesc[Get_Field_Count()];
for(iField=0; iField<Get_Field_Count(); iField++)
{
- strncpy(dbfFieldDesc[iField].Name, SG_STR_SGTOMB(Get_Field_Name(iField)), 11);
+ strncpy(dbfFields[iField].Name, SG_STR_SGTOMB(Get_Field_Name(iField)), 11);
switch( Get_Field_Type(iField) )
{
- default:
- dbfFieldDesc[iField].Type = DBF_FT_CHARACTER;
- dbfFieldDesc[iField].Width = (char)64;
- break;
-
- case SG_DATATYPE_String:
- dbfFieldDesc[iField].Type = DBF_FT_CHARACTER;
- dbfFieldDesc[iField].Width = (char)nStringBytes[iField];
+ case SG_DATATYPE_String: default:
+ dbfFields[iField].Type = DBF_FT_CHARACTER;
+ dbfFields[iField].Width = (BYTE)((nBytes = Get_Field_Length(iField)) > 255 ? 255 : nBytes);
break;
case SG_DATATYPE_Date:
- dbfFieldDesc[iField].Type = DBF_FT_DATE;
- dbfFieldDesc[iField].Width = (char)8;
+ dbfFields[iField].Type = DBF_FT_DATE;
+ dbfFields[iField].Width = (BYTE)8;
break;
case SG_DATATYPE_Char:
- dbfFieldDesc[iField].Type = DBF_FT_CHARACTER;
- dbfFieldDesc[iField].Width = (char)1;
+ dbfFields[iField].Type = DBF_FT_CHARACTER;
+ dbfFields[iField].Width = (BYTE)1;
break;
case SG_DATATYPE_Short:
case SG_DATATYPE_Int:
case SG_DATATYPE_Long:
case SG_DATATYPE_Color:
- dbfFieldDesc[iField].Type = DBF_FT_NUMERIC;
- dbfFieldDesc[iField].Width = (char)16;
- dbfFieldDesc[iField].Decimals = (char)0;
+ dbfFields[iField].Type = DBF_FT_NUMERIC;
+ dbfFields[iField].Width = (BYTE)16;
+ dbfFields[iField].Decimals = (BYTE)0;
break;
case SG_DATATYPE_Float:
case SG_DATATYPE_Double:
- dbfFieldDesc[iField].Type = DBF_FT_NUMERIC;
- dbfFieldDesc[iField].Width = (char)16;
- dbfFieldDesc[iField].Decimals = (char)8;
+ dbfFields[iField].Type = DBF_FT_NUMERIC;
+ dbfFields[iField].Width = (BYTE)16;
+ dbfFields[iField].Decimals = (BYTE)8;
break;
}
}
- dbf.Open(File_Name, Get_Field_Count(), dbfFieldDesc);
+ if( !dbf.Open(File_Name, Get_Field_Count(), dbfFields) )
+ {
+ delete[](dbfFields);
- SG_Free(dbfFieldDesc);
+ SG_UI_Msg_Add_Error(LNG("[ERR] dbase file could not be opened"));
- if( nStringBytes )
- {
- delete[](nStringBytes);
+ return( false );
}
+ delete[](dbfFields);
+
//-----------------------------------------------------
for(iRecord=0; iRecord<Get_Record_Count() && SG_UI_Process_Set_Progress(iRecord, Get_Record_Count()); iRecord++)
{
- pRecord = Get_Record(iRecord);
+ CSG_Table_Record *pRecord = Get_Record(iRecord);
dbf.Add_Record();
@@ -581,14 +550,11 @@ bool CSG_Table::_Save_DBase(const CSG_String &File_Name)
{
switch( dbf.Get_FieldType(iField) )
{
+ case DBF_FT_DATE:
case DBF_FT_CHARACTER:
dbf.Set_Value(iField, SG_STR_SGTOMB(pRecord->asString(iField)));
break;
- case DBF_FT_DATE:
- dbf.Set_Value(iField, pRecord->asDouble(iField));
- break;
-
case DBF_FT_NUMERIC:
dbf.Set_Value(iField, pRecord->asDouble(iField));
break;
diff --git a/src/saga_core/saga_api/table_record.cpp b/src/saga_core/saga_api/table_record.cpp
index 79be617..047fd7c 100644
--- a/src/saga_core/saga_api/table_record.cpp
+++ b/src/saga_core/saga_api/table_record.cpp
@@ -60,8 +60,6 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#include <string.h>
-
#include "table.h"
#include "table_value.h"
@@ -77,7 +75,7 @@ CSG_Table_Record::CSG_Table_Record(CSG_Table *pTable, int Index)
{
m_pTable = pTable;
m_Index = Index;
- m_bSelected = false;
+ m_Flags = 0;
if( m_pTable && m_pTable->Get_Field_Count() > 0 )
{
@@ -97,7 +95,7 @@ CSG_Table_Record::CSG_Table_Record(CSG_Table *pTable, int Index)
//---------------------------------------------------------
CSG_Table_Record::~CSG_Table_Record(void)
{
- if( m_bSelected )
+ if( is_Selected() )
{
m_pTable->Select(m_Index, true);
}
@@ -142,6 +140,8 @@ CSG_Table_Value * CSG_Table_Record::_Create_Value(TSG_Data_Type Type)
case SG_DATATYPE_Float:
case SG_DATATYPE_Double: return( new CSG_Table_Value_Double() );
+
+ case SG_DATATYPE_Binary: return( new CSG_Table_Value_Binary() );
}
}
@@ -216,13 +216,79 @@ int CSG_Table_Record::_Get_Field(const SG_Char *Field) const
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+void CSG_Table_Record::Set_Selected(bool bOn)
+{
+ if( bOn != is_Selected() )
+ {
+ if( bOn )
+ {
+ m_Flags |= SG_TABLE_REC_FLAG_Selected;
+ }
+ else
+ {
+ m_Flags &= ~SG_TABLE_REC_FLAG_Selected;
+ }
+ }
+}
+
+//---------------------------------------------------------
+void CSG_Table_Record::Set_Modified(bool bOn)
+{
+ if( bOn != is_Modified() )
+ {
+ if( bOn )
+ {
+ m_Flags |= SG_TABLE_REC_FLAG_Modified;
+
+ m_pTable->Set_Modified();
+ }
+ else
+ {
+ m_Flags &= ~SG_TABLE_REC_FLAG_Modified;
+ }
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_Table_Record::Set_Value (int iField, const CSG_Bytes &Value)
+{
+ if( iField >= 0 && iField < m_pTable->Get_Field_Count() )
+ {
+ if( m_Values[iField]->Set_Value(Value) )
+ {
+ Set_Modified(true);
+
+ m_pTable->Set_Update_Flag();
+ m_pTable->_Stats_Invalidate(iField);
+
+ return( true );
+ }
+ }
+
+ return( false );
+}
+
+bool CSG_Table_Record::Set_Value (const SG_Char *Field, const CSG_Bytes &Value)
+{
+ return( Set_Value(_Get_Field(Field), Value) );
+}
+
+//---------------------------------------------------------
bool CSG_Table_Record::Set_Value(int iField, const SG_Char *Value)
{
if( iField >= 0 && iField < m_pTable->Get_Field_Count() )
{
if( m_Values[iField]->Set_Value(Value) )
{
- m_pTable->Set_Modified();
+ Set_Modified(true);
+
m_pTable->Set_Update_Flag();
m_pTable->_Stats_Invalidate(iField);
@@ -245,7 +311,8 @@ bool CSG_Table_Record::Set_Value(int iField, double Value)
{
if( m_Values[iField]->Set_Value(Value) )
{
- m_pTable->Set_Modified();
+ Set_Modified(true);
+
m_pTable->Set_Update_Flag();
m_pTable->_Stats_Invalidate(iField);
@@ -305,14 +372,41 @@ bool CSG_Table_Record::Set_NoData(int iField)
{
if( iField >= 0 && iField < m_pTable->Get_Field_Count() )
{
- if( m_Values[iField]->Set_NoData() )
+ switch( m_pTable->Get_Field_Type(iField) )
{
- m_pTable->Set_Modified();
- m_pTable->Set_Update_Flag();
- m_pTable->_Stats_Invalidate(iField);
-
- return( true );
+ default:
+ case SG_DATATYPE_String:
+ if( !m_Values[iField]->Set_Value(SG_T("")) )
+ return( false );
+ break;
+
+ case SG_DATATYPE_Date:
+ case SG_DATATYPE_Color:
+ case SG_DATATYPE_Byte:
+ case SG_DATATYPE_Char:
+ case SG_DATATYPE_Word:
+ case SG_DATATYPE_Short:
+ case SG_DATATYPE_DWord:
+ case SG_DATATYPE_Int:
+ case SG_DATATYPE_ULong:
+ case SG_DATATYPE_Long:
+ case SG_DATATYPE_Float:
+ case SG_DATATYPE_Double:
+ if( !m_Values[iField]->Set_Value(m_pTable->Get_NoData_Value()) )
+ return( false );
+ break;
+
+ case SG_DATATYPE_Binary:
+ m_Values[iField]->asBinary().Destroy();
+ break;
}
+
+ Set_Modified(true);
+
+ m_pTable->Set_Update_Flag();
+ m_pTable->_Stats_Invalidate(iField);
+
+ return( true );
}
return( false );
@@ -326,7 +420,36 @@ bool CSG_Table_Record::Set_NoData(const SG_Char *Field)
//---------------------------------------------------------
bool CSG_Table_Record::is_NoData(int iField) const
{
- return( iField >= 0 && iField < m_pTable->Get_Field_Count() ? m_Values[iField]->is_NoData() : true );
+ if( iField >= 0 && iField < m_pTable->Get_Field_Count() )
+ {
+ switch( m_pTable->Get_Field_Type(iField) )
+ {
+ default:
+ case SG_DATATYPE_String:
+ return( m_Values[iField]->asString() == NULL );
+
+ case SG_DATATYPE_Date:
+ case SG_DATATYPE_Color:
+ case SG_DATATYPE_Byte:
+ case SG_DATATYPE_Char:
+ case SG_DATATYPE_Word:
+ case SG_DATATYPE_Short:
+ case SG_DATATYPE_DWord:
+ case SG_DATATYPE_Int:
+ case SG_DATATYPE_ULong:
+ case SG_DATATYPE_Long:
+ return( m_pTable->is_NoData_Value(m_Values[iField]->asInt()) );
+
+ case SG_DATATYPE_Float:
+ case SG_DATATYPE_Double:
+ return( m_pTable->is_NoData_Value(m_Values[iField]->asDouble()) );
+
+ case SG_DATATYPE_Binary:
+ return( m_Values[iField]->asBinary().Get_Count() == 0 );
+ }
+ }
+
+ return( true );
}
bool CSG_Table_Record::is_NoData(const SG_Char *Field) const
@@ -386,9 +509,12 @@ bool CSG_Table_Record::Assign(CSG_Table_Record *pRecord)
{
if( pRecord )
{
- for(int iField=0; iField<m_pTable->Get_Field_Count(); iField++)
+ int nFields = m_pTable->Get_Field_Count() < pRecord->m_pTable->Get_Field_Count()
+ ? m_pTable->Get_Field_Count() : pRecord->m_pTable->Get_Field_Count();
+
+ for(int iField=0; iField<nFields; iField++)
{
- Set_Value(iField, pRecord->asString(iField));
+ *(m_Values[iField]) = *(pRecord->m_Values[iField]);
}
return( true );
diff --git a/src/saga_core/saga_api/table_selection.cpp b/src/saga_core/saga_api/table_selection.cpp
index 059c9ca..d871d06 100644
--- a/src/saga_core/saga_api/table_selection.cpp
+++ b/src/saga_core/saga_api/table_selection.cpp
@@ -76,7 +76,7 @@ bool CSG_Table::_Destroy_Selection(void)
{
for(int iRecord=0; iRecord<m_nSelected; iRecord++)
{
- m_Selected[iRecord]->m_bSelected = false;
+ m_Selected[iRecord]->Set_Selected(false);
}
SG_Free(m_Selected);
@@ -107,12 +107,12 @@ bool CSG_Table::Select(int iRecord, bool bInvert)
if( (pRecord = Get_Record(iRecord)) != NULL )
{
- if( pRecord->m_bSelected == false )
+ if( pRecord->is_Selected() == false )
{
m_nSelected++;
m_Selected = (CSG_Table_Record **)SG_Realloc(m_Selected, m_nSelected * sizeof(CSG_Table_Record *));
m_Selected[m_nSelected - 1] = pRecord;
- pRecord->m_bSelected = true;
+ pRecord->Set_Selected(true);
}
else
{
@@ -130,7 +130,7 @@ bool CSG_Table::Select(int iRecord, bool bInvert)
}
m_Selected = (CSG_Table_Record **)SG_Realloc(m_Selected, m_nSelected * sizeof(CSG_Table_Record *));
- pRecord->m_bSelected = false;
+ pRecord->Set_Selected(false);
}
return( true );
@@ -163,7 +163,7 @@ int CSG_Table::Del_Selection(void)
{
CSG_Table_Record *pRecord = m_Selected[i];
- pRecord->m_bSelected = false;
+ pRecord->Set_Selected(false);
if( _Del_Record(pRecord->Get_Index()) )
{
@@ -191,13 +191,13 @@ int CSG_Table::Inv_Selection(void)
for(int i=0, j=0; i<m_nRecords; i++, pRecord++)
{
- if( (*pRecord)->m_bSelected )
+ if( (*pRecord)->is_Selected() )
{
- (*pRecord)->m_bSelected = false;
+ (*pRecord)->Set_Selected(false);
}
else
{
- (*pRecord)->m_bSelected = true;
+ (*pRecord)->Set_Selected(true);
m_Selected[j++] = (*pRecord);
}
}
diff --git a/src/saga_core/saga_api/table_value.h b/src/saga_core/saga_api/table_value.h
index b440846..6a93d3f 100644
--- a/src/saga_core/saga_api/table_value.h
+++ b/src/saga_core/saga_api/table_value.h
@@ -81,37 +81,29 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define NODATA_STRING SG_T("[NO DATA]")
-#define NODATA_INT -2147483647
-#define NODATA_DOUBLE 2.2204460492503131e-016
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
class CSG_Table_Value
{
public:
CSG_Table_Value(void) {}
virtual ~CSG_Table_Value(void) {}
- virtual bool Set_Value (const SG_Char *Value) = 0;
- virtual bool Set_Value (double Value) = 0;
-
- virtual bool Set_NoData (void) = 0;
- virtual bool is_NoData (void) const = 0;
+ //-----------------------------------------------------
+ virtual bool Set_Value (const CSG_Bytes &Value) = 0;
+ virtual bool Set_Value (const SG_Char *Value) = 0;
+ virtual bool Set_Value (int Value) = 0;
+ virtual bool Set_Value (double Value) = 0;
+ //-----------------------------------------------------
+ virtual CSG_Bytes asBinary (void) const = 0;
virtual const SG_Char * asString (int Decimals = -1) const = 0;
virtual int asInt (void) const = 0;
virtual double asDouble (void) const = 0;
+ //-----------------------------------------------------
operator const SG_Char * (void) const { return( asString() ); }
operator double (void) const { return( asDouble() ); }
+ //-----------------------------------------------------
virtual CSG_Table_Value & operator = (const SG_Char *Value) { Set_Value(Value); return( *this ); }
virtual CSG_Table_Value & operator = (double Value) { Set_Value(Value); return( *this ); }
virtual CSG_Table_Value & operator = (const CSG_Table_Value &Value) = 0;
@@ -126,6 +118,63 @@ public:
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+class CSG_Table_Value_Binary : public CSG_Table_Value
+{
+public:
+ CSG_Table_Value_Binary(void) {}
+ virtual ~CSG_Table_Value_Binary(void) {}
+
+ //-----------------------------------------------------
+ virtual bool Set_Value (const CSG_Bytes &Value)
+ {
+ return( m_Value.Create(Value) );
+ }
+
+ virtual bool Set_Value (const SG_Char *Value)
+ {
+ return( m_Value.Create(Value) );
+ }
+
+ virtual bool Set_Value (int Value)
+ {
+ return( m_Value.Create((BYTE *)&Value, sizeof(Value)) );
+ }
+
+ virtual bool Set_Value (double Value)
+ {
+ return( m_Value.Create((BYTE *)&Value, sizeof(Value)) );
+ }
+
+ //-----------------------------------------------------
+ virtual bool Set_NoData (void) { return( m_Value.Destroy() ); }
+ virtual bool is_NoData (void) const { return( m_Value.Get_Count() <= 0 ); }
+
+ //-----------------------------------------------------
+ virtual CSG_Bytes asBinary (void) const { return( m_Value ); }
+ virtual const SG_Char * asString (int Decimals = -1) const { return( (const SG_Char *)m_Value.Get_Bytes() ); }
+ virtual int asInt (void) const { return( m_Value.Get_Count() ); }
+ virtual double asDouble (void) const { return( 0.0 ); }
+
+ virtual CSG_Table_Value & operator = (const CSG_Table_Value &Value) { Set_Value(Value.asBinary()); return( *this ); }
+
+ //-----------------------------------------------------
+ CSG_Bytes & Get_Binary (void) { return( m_Value ); }
+
+
+private:
+
+ CSG_Bytes m_Value;
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
class CSG_Table_Value_String : public CSG_Table_Value
{
public:
@@ -133,11 +182,16 @@ public:
virtual ~CSG_Table_Value_String(void) {}
//-----------------------------------------------------
- virtual bool Set_Value (const SG_Char *Value)
+ virtual bool Set_Value (const CSG_Bytes &Value)
+ {
+ return( Set_Value((SG_Char *)Value.Get_Bytes()) );
+ }
+
+ virtual bool Set_Value (const SG_Char *Value)
{
if( Value && m_Value.Cmp(Value) )
{
- m_Value.Printf(Value);
+ m_Value = Value;
return( true );
}
@@ -145,25 +199,23 @@ public:
return( false );
}
- //-----------------------------------------------------
- virtual bool Set_Value (double Value)
+ virtual bool Set_Value (int Value)
{
- CSG_String s;
-
- s.Printf(SG_T("%f"), Value);
+ return( Set_Value(CSG_String::Format(SG_T("%d"), Value).c_str()) );
+ }
- return( Set_Value(s.c_str()) );
+ virtual bool Set_Value (double Value)
+ {
+ return( Set_Value(CSG_String::Format(SG_T("%f"), Value).c_str()) );
}
//-----------------------------------------------------
- virtual bool Set_NoData (void) { return( Set_Value(NODATA_STRING) ); }
- virtual bool is_NoData (void) const { return( m_Value.Cmp(NODATA_STRING) == 0 ); }
+ virtual CSG_Bytes asBinary (void) const { return( CSG_Bytes(m_Value.c_str()) ); }
+ virtual const SG_Char * asString (int Decimals = -1) const { return( m_Value ); }
+ virtual int asInt (void) const { return( m_Value.asInt() ); }
+ virtual double asDouble (void) const { return( m_Value.asDouble() ); }
//-----------------------------------------------------
- virtual const SG_Char * asString (int Decimals = -1) const { return( m_Value ); }
- virtual int asInt (void) const { return( m_Value.asInt() ); }
- virtual double asDouble (void) const { return( m_Value.asDouble() ); }
-
virtual CSG_Table_Value & operator = (const CSG_Table_Value &Value) { Set_Value(Value.asString()); return( *this ); }
@@ -188,18 +240,22 @@ public:
virtual ~CSG_Table_Value_Date(void) {}
//-----------------------------------------------------
- virtual bool Set_Value (const SG_Char *Value)
+ virtual bool Set_Value (const CSG_Bytes &Value)
{
- return( Set_Value(SG_Date_To_Double(Value)) );
+ return( Set_Value((SG_Char *)Value.Get_Bytes()) );
}
- //-----------------------------------------------------
- virtual bool Set_Value (double Value)
+ virtual bool Set_Value (const SG_Char *Value)
{
- if( m_Value != (int)Value )
+ return( Set_Value(SG_Date_To_Number(Value)) );
+ }
+
+ virtual bool Set_Value (int Value)
+ {
+ if( m_Value != Value )
{
- m_Date = SG_Double_To_Date(Value);
- m_Value = (int)Value;
+ m_Date = SG_Number_To_Date(Value);
+ m_Value = Value;
return( true );
}
@@ -207,11 +263,13 @@ public:
return( false );
}
- //-----------------------------------------------------
- virtual bool Set_NoData (void) { return( Set_Value(NODATA_INT) ); }
- virtual bool is_NoData (void) const { return( m_Value == NODATA_INT ); }
+ virtual bool Set_Value (double Value)
+ {
+ return( Set_Value((int)Value) );
+ }
//-----------------------------------------------------
+ virtual CSG_Bytes asBinary (void) const { return( CSG_Bytes(asString()) ); }
virtual const SG_Char * asString (int Decimals = -1) const { return( m_Date ); }
virtual int asInt (void) const { return( m_Value ); }
virtual double asDouble (void) const { return( m_Value ); }
@@ -242,20 +300,24 @@ public:
virtual ~CSG_Table_Value_Int(void) {}
//-----------------------------------------------------
- virtual bool Set_Value (const SG_Char *Value)
+ virtual bool Set_Value (const CSG_Bytes &Value)
{
- double d;
+ return( Set_Value((SG_Char *)Value.Get_Bytes()) );
+ }
+
+ virtual bool Set_Value (const SG_Char *Value)
+ {
+ int i;
CSG_String s(Value);
- return( s.asDouble(d) ? Set_Value(d) : false );
+ return( s.asInt(i) ? Set_Value(i) : false );
}
- //-----------------------------------------------------
- virtual bool Set_Value (double Value)
+ virtual bool Set_Value (int Value)
{
if( m_Value != Value )
{
- m_Value = (int)Value;
+ m_Value = Value;
return( true );
}
@@ -263,9 +325,10 @@ public:
return( false );
}
- //-----------------------------------------------------
- virtual bool Set_NoData (void) { return( Set_Value(NODATA_INT) ); }
- virtual bool is_NoData (void) const { return( m_Value == NODATA_INT ); }
+ virtual bool Set_Value (double Value)
+ {
+ return( Set_Value((int)Value) );
+ }
//-----------------------------------------------------
virtual const SG_Char * asString (int Decimals = -1) const
@@ -277,7 +340,7 @@ public:
return( s.c_str() );
}
- //-----------------------------------------------------
+ virtual CSG_Bytes asBinary (void) const { return( CSG_Bytes(asString()) ); }
virtual int asInt (void) const { return( m_Value ); }
virtual double asDouble (void) const { return( m_Value ); }
@@ -305,7 +368,12 @@ public:
virtual ~CSG_Table_Value_Double(void) {}
//-----------------------------------------------------
- virtual bool Set_Value (const SG_Char *Value)
+ virtual bool Set_Value (const CSG_Bytes &Value)
+ {
+ return( Set_Value((SG_Char *)Value.Get_Bytes()) );
+ }
+
+ virtual bool Set_Value (const SG_Char *Value)
{
double d;
CSG_String s(Value);
@@ -313,8 +381,12 @@ public:
return( s.asDouble(d) ? Set_Value(d) : false );
}
- //-----------------------------------------------------
- virtual bool Set_Value (double Value)
+ virtual bool Set_Value (int Value)
+ {
+ return( Set_Value((double)Value) );
+ }
+
+ virtual bool Set_Value (double Value)
{
if( m_Value != Value )
{
@@ -327,10 +399,6 @@ public:
}
//-----------------------------------------------------
- virtual bool Set_NoData (void) { return( Set_Value(NODATA_DOUBLE) ); }
- virtual bool is_NoData (void) const { return( m_Value == NODATA_DOUBLE ); }
-
- //-----------------------------------------------------
virtual const SG_Char * asString (int Decimals = -1) const
{
static CSG_String s;
@@ -340,7 +408,7 @@ public:
return( s.c_str() );
}
- //-----------------------------------------------------
+ virtual CSG_Bytes asBinary (void) const { return( CSG_Bytes(asString()) ); }
virtual int asInt (void) const { return( (int)m_Value ); }
virtual double asDouble (void) const { return( m_Value ); }
diff --git a/src/saga_core/saga_api/tin_elements.cpp b/src/saga_core/saga_api/tin_elements.cpp
index 91e0cb2..5591b8b 100644
--- a/src/saga_core/saga_api/tin_elements.cpp
+++ b/src/saga_core/saga_api/tin_elements.cpp
@@ -175,8 +175,8 @@ double CSG_TIN_Node::Get_Gradient(int iNeighbor, int iField)
//---------------------------------------------------------
int SG_TIN_Compare_Triangle_Center(const void *pz1, const void *pz2)
{
- double z1 = ((TSG_Point_3D *)pz1)->z,
- z2 = ((TSG_Point_3D *)pz2)->z;
+ double z1 = ((TSG_Point_Z *)pz1)->z,
+ z2 = ((TSG_Point_Z *)pz2)->z;
if( z1 < z2 )
{
@@ -201,7 +201,7 @@ bool CSG_TIN_Node::Get_Polygon(CSG_Points &Points)
{
int i;
TSG_Point c;
- CSG_Points_3D p;
+ CSG_Points_Z p;
for(i=0; i<m_nTriangles; i++)
{
@@ -210,7 +210,7 @@ bool CSG_TIN_Node::Get_Polygon(CSG_Points &Points)
p.Add(c.x, c.y, M_GET_DIRECTION(m_Point, c));
}
- qsort(&(p[0]), p.Get_Count(), sizeof(TSG_Point_3D), SG_TIN_Compare_Triangle_Center);
+ qsort(&(p[0]), p.Get_Count(), sizeof(TSG_Point_Z), SG_TIN_Compare_Triangle_Center);
Points.Clear();
diff --git a/src/saga_core/saga_cmd/Makefile.am b/src/saga_core/saga_cmd/Makefile.am
index d001d2b..4d23f32 100644
--- a/src/saga_core/saga_cmd/Makefile.am
+++ b/src/saga_core/saga_cmd/Makefile.am
@@ -1,15 +1,17 @@
#
-# $Id: Makefile.am,v 1.8 2007/03/22 14:24:54 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/22 12:47:12 johanvdw Exp $
#
if DEBUG
DBGFLAGS = -g -DDEBUG
endif
+MLIBPATH = "MODULE_LIBRARY_PATH=\"$(prefix)/lib/saga\""
+BASEFLAGS = -D_SAGA_LINUX -D_SAGA_UNICODE -D_TYPEDEF_BYTE -D_TYPEDEF_WORD $(DBGFLAGS) -I.. -D$(MLIBPATH)
if SAGA_UNICODE
-AM_CXXFLAGS = -fPIC `wx-config --unicode=yes --cxxflags` -D_SAGA_LINUX -D_SAGA_UNICODE -D_TYPEDEF_BYTE -D_TYPEDEF_WORD $(DBGFLAGS) -I..
+AM_CXXFLAGS = -fPIC `wx-config --unicode=yes --cxxflags` $(BASEFLAGS)
AM_LDFLAGS = -fPIC `wx-config --unicode=yes --libs` -lm
else
-AM_CXXFLAGS = -fPIC `wx-config --unicode=no --cxxflags` -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD $(DBGFLAGS) -I..
+AM_CXXFLAGS = -fPIC `wx-config --unicode=no --cxxflags` $(BASEFLAGS)
AM_LDFLAGS = -fPIC `wx-config --unicode=no --libs` -lm
endif
@@ -22,4 +24,4 @@ saga_cmd.cpp\
callback.h\
module_library.h
-
+SUBDIRS = man
diff --git a/src/saga_core/saga_cmd/Makefile.in b/src/saga_core/saga_cmd/Makefile.in
index 864271c..0690f93 100644
--- a/src/saga_core/saga_cmd/Makefile.in
+++ b/src/saga_core/saga_cmd/Makefile.in
@@ -42,7 +42,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
@@ -51,7 +50,7 @@ am_saga_cmd_OBJECTS = callback.$(OBJEXT) module_library.$(OBJEXT) \
saga_cmd.$(OBJEXT)
saga_cmd_OBJECTS = $(am_saga_cmd_OBJECTS)
saga_cmd_DEPENDENCIES = ../saga_api/libsaga_api.la
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -75,9 +74,47 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(saga_cmd_SOURCES)
DIST_SOURCES = $(saga_cmd_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+ distdir
ETAGS = etags
CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
@@ -97,6 +134,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -106,6 +144,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -196,11 +235,13 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.8 2007/03/22 14:24:54 oconrad Exp $
+# $Id: Makefile.am,v 1.10 2010/07/22 12:47:12 johanvdw Exp $
#
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
- at SAGA_UNICODE_FALSE@AM_CXXFLAGS = -fPIC `wx-config --unicode=no --cxxflags` -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD $(DBGFLAGS) -I..
- at SAGA_UNICODE_TRUE@AM_CXXFLAGS = -fPIC `wx-config --unicode=yes --cxxflags` -D_SAGA_LINUX -D_SAGA_UNICODE -D_TYPEDEF_BYTE -D_TYPEDEF_WORD $(DBGFLAGS) -I..
+MLIBPATH = "MODULE_LIBRARY_PATH=\"$(prefix)/lib/saga\""
+BASEFLAGS = -D_SAGA_LINUX -D_SAGA_UNICODE -D_TYPEDEF_BYTE -D_TYPEDEF_WORD $(DBGFLAGS) -I.. -D$(MLIBPATH)
+ at SAGA_UNICODE_FALSE@AM_CXXFLAGS = -fPIC `wx-config --unicode=no --cxxflags` $(BASEFLAGS)
+ at SAGA_UNICODE_TRUE@AM_CXXFLAGS = -fPIC `wx-config --unicode=yes --cxxflags` $(BASEFLAGS)
@SAGA_UNICODE_FALSE at AM_LDFLAGS = -fPIC `wx-config --unicode=no --libs` -lm
@SAGA_UNICODE_TRUE at AM_LDFLAGS = -fPIC `wx-config --unicode=yes --libs` -lm
saga_cmd_LDADD = ../saga_api/libsaga_api.la
@@ -211,7 +252,8 @@ saga_cmd.cpp\
callback.h\
module_library.h
-all: all-am
+SUBDIRS = man
+all: all-recursive
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
@@ -329,6 +371,76 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
@@ -339,10 +451,23 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
mkid -fID $$unique
tags: TAGS
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
@@ -361,7 +486,7 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
fi; \
fi
ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
@@ -411,22 +536,51 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
check-am: all-am
-check: check-am
+check: check-recursive
all-am: Makefile $(PROGRAMS)
-installdirs:
+installdirs: installdirs-recursive
+installdirs-am:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-installcheck: installcheck-am
+installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
@@ -443,90 +597,93 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
+clean: clean-recursive
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
-distclean: distclean-am
+distclean: distclean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
-dvi: dvi-am
+dvi: dvi-recursive
dvi-am:
-html: html-am
+html: html-recursive
html-am:
-info: info-am
+info: info-recursive
info-am:
install-data-am:
-install-dvi: install-dvi-am
+install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am: install-binPROGRAMS
-install-html: install-html-am
+install-html: install-html-recursive
install-html-am:
-install-info: install-info-am
+install-info: install-info-recursive
install-info-am:
install-man:
-install-pdf: install-pdf-am
+install-pdf: install-pdf-recursive
install-pdf-am:
-install-ps: install-ps-am
+install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
-maintainer-clean: maintainer-clean-am
+maintainer-clean: maintainer-clean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
-mostlyclean: mostlyclean-am
+mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
-pdf: pdf-am
+pdf: pdf-recursive
pdf-am:
-ps: ps-am
+ps: ps-recursive
ps-am:
uninstall-am: uninstall-binPROGRAMS
-.MAKE: install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
- clean-generic clean-libtool ctags distclean distclean-compile \
- distclean-generic distclean-libtool distclean-tags distdir dvi \
- dvi-am html html-am info info-am install install-am \
- install-binPROGRAMS install-data install-data-am install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf 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 uninstall uninstall-am \
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+ install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+ all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool ctags ctags-recursive distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-binPROGRAMS install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-ps install-ps-am 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 \
+ tags tags-recursive uninstall uninstall-am \
uninstall-binPROGRAMS
diff --git a/src/saga_core/saga_cmd/callback.cpp b/src/saga_core/saga_cmd/callback.cpp
index b1def20..2956133 100644
--- a/src/saga_core/saga_cmd/callback.cpp
+++ b/src/saga_core/saga_cmd/callback.cpp
@@ -58,6 +58,10 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+#ifdef _SAGA_MSW
+#include <conio.h>
+#endif
+
#include <wx/utils.h>
#include "callback.h"
@@ -72,10 +76,33 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-static bool g_bSilent = false;
-
static CModule_Library *g_pLibrary = NULL;
+//---------------------------------------------------------
+void Set_Library (CModule_Library *pLibrary)
+{
+ g_pLibrary = pLibrary;
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+static bool g_bSilent = false;
+
+void Set_Silent (bool bOn) { g_bSilent = bOn; }
+
+bool Get_Silent (void) { return( g_bSilent ); }
+
+//---------------------------------------------------------
+static bool g_bInteractive = false;
+
+void Set_Interactive (bool bOn) { g_bInteractive = bOn; }
+
+bool Get_Interactive (void) { return( g_bInteractive ); }
+
///////////////////////////////////////////////////////////
// //
@@ -84,10 +111,82 @@ static CModule_Library *g_pLibrary = NULL;
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-int Callback(TSG_UI_Callback_ID ID, long Param_1, long Param_2)
+void Print (const SG_Char *String)
+{
+ if( !g_bSilent && String && String[0] )
+ {
+ SG_PRINTF(String);
+ }
+}
+
+//---------------------------------------------------------
+void Print_Error (const SG_Char *Error)
+{
+ SG_FPRINTF(stderr, SG_T("\n%s: %s\n"), LNG("error"), Error);
+}
+
+//---------------------------------------------------------
+void Print_Error (const SG_Char *Error, const SG_Char *Info)
+{
+ Print_Error(CSG_String::Format(SG_T("%s [%s]"), Error, Info));
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void Get_Pause (void)
+{
+ if( g_bInteractive )
+ {
+ SG_PRINTF(SG_T("\n%s..."), LNG("press any key"));
+
+#ifdef _SAGA_MSW
+ _getch();
+#endif
+ }
+}
+
+//---------------------------------------------------------
+bool Get_YesNo (const SG_Char *caption, const SG_Char *message)
{
- static int iBuisy = 0;
+ if( g_bInteractive )
+ {
+#ifdef _SAGA_MSW
+ CSG_String sKey, sYes(SG_T("y")), sNo(SG_T("n"));
+
+ SG_PRINTF(SG_T("\n%s: %s\n"), caption, message);
+
+ SG_PRINTF(SG_T("%s? (%s/%s)"), LNG("continue"), sYes.c_str(), sNo.c_str());
+
+ do
+ {
+ sKey.Printf(SG_T("%c"), _getch());
+ }
+ while( sYes.CmpNoCase(sKey) && sNo.CmpNoCase(sKey) );
+
+ return( sYes.CmpNoCase(sKey) == 0 );
+#endif
+ }
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int Callback(TSG_UI_Callback_ID ID, long Param_1, long Param_2)
+{
+ static int iBuisy = 0;
const SG_Char Buisy[4] = { '|', '/', '-', '\\' };
int Result;
@@ -107,16 +206,15 @@ int Callback(TSG_UI_Callback_ID ID, long Param_1, long Param_2)
///////////////////////////////////////////////////////
// //
- // //
- // //
///////////////////////////////////////////////////////
//-----------------------------------------------------
case CALLBACK_PROCESS_GET_OKAY:
- if( Param_1 != 0 )
+ if( !g_bSilent && Param_1 != 0 )
{
SG_PRINTF(SG_T("\r%c "), Buisy[iBuisy++]);
+
iBuisy %= 4;
}
@@ -132,10 +230,13 @@ int Callback(TSG_UI_Callback_ID ID, long Param_1, long Param_2)
//-----------------------------------------------------
case CALLBACK_PROCESS_SET_PROGRESS:
- d1 = *((double *)Param_1);
- d2 = *((double *)Param_2);
+ if( !g_bSilent )
+ {
+ d1 = *((double *)Param_1);
+ d2 = *((double *)Param_2);
- SG_PRINTF(SG_T("\r%3d%%"), d2 != 0.0 ? 1 + (int)(100.0 * d1 / d2) : 100);
+ SG_PRINTF(SG_T("\r%3d%%"), d2 != 0.0 ? 1 + (int)(100.0 * d1 / d2) : 100);
+ }
break;
@@ -148,21 +249,25 @@ int Callback(TSG_UI_Callback_ID ID, long Param_1, long Param_2)
//-----------------------------------------------------
case CALLBACK_PROCESS_SET_TEXT:
- SG_PRINTF(SG_T("\n%s\n"), (SG_Char *)Param_1);
+ if( !g_bSilent )
+ {
+ SG_PRINTF(SG_T("\n%s\n"), (SG_Char *)Param_1);
+ }
break;
///////////////////////////////////////////////////////
// //
- // //
- // //
///////////////////////////////////////////////////////
//-----------------------------------------------------
case CALLBACK_MESSAGE_ADD:
- SG_PRINTF(SG_T("\n%s\n"), (SG_Char *)Param_1);
+ if( !g_bSilent )
+ {
+ SG_PRINTF(SG_T("\n%s\n"), (SG_Char *)Param_1);
+ }
break;
@@ -170,7 +275,7 @@ int Callback(TSG_UI_Callback_ID ID, long Param_1, long Param_2)
//-----------------------------------------------------
case CALLBACK_MESSAGE_ADD_ERROR:
- SG_PRINTF(SG_T("\n%s: %s\n"), LNG("error"), (SG_Char *)Param_1);
+ Print_Error((SG_Char *)Param_1);
break;
@@ -178,21 +283,25 @@ int Callback(TSG_UI_Callback_ID ID, long Param_1, long Param_2)
//-----------------------------------------------------
case CALLBACK_MESSAGE_ADD_EXECUTION:
- SG_PRINTF(SG_T("\n%s\n"), (SG_Char *)Param_1);
+ if( !g_bSilent )
+ {
+ SG_PRINTF(SG_T("\n%s\n"), (SG_Char *)Param_1);
+ }
break;
///////////////////////////////////////////////////////
// //
- // //
- // //
///////////////////////////////////////////////////////
//-----------------------------------------------------
case CALLBACK_DLG_MESSAGE:
- SG_PRINTF(SG_T("\n%s: %s\n"), (const SG_Char *)Param_2, (const SG_Char *)Param_1);
+ if( !g_bSilent )
+ {
+ SG_PRINTF(SG_T("\n%s: %s\n"), (const SG_Char *)Param_2, (const SG_Char *)Param_1);
+ }
break;
@@ -215,8 +324,6 @@ int Callback(TSG_UI_Callback_ID ID, long Param_1, long Param_2)
///////////////////////////////////////////////////////
// //
- // //
- // //
///////////////////////////////////////////////////////
//-----------------------------------------------------
@@ -276,8 +383,6 @@ int Callback(TSG_UI_Callback_ID ID, long Param_1, long Param_2)
///////////////////////////////////////////////////////
// //
- // //
- // //
///////////////////////////////////////////////////////
//-----------------------------------------------------
@@ -291,101 +396,18 @@ int Callback(TSG_UI_Callback_ID ID, long Param_1, long Param_2)
}
break;
- }
-
- return( Result );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-TSG_PFNC_UI_Callback Get_Callback (void)
-{
- return( &Callback );
-}
-
-//---------------------------------------------------------
-void Set_Library (CModule_Library *pLibrary)
-{
- g_pLibrary = pLibrary;
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void Set_Silent (bool bOn)
-{
- g_bSilent = bOn;
-}
-//---------------------------------------------------------
-#ifdef _SAGA_MSW
-
-#include <conio.h>
-
-//---------------------------------------------------------
-void Get_Pause (void)
-{
- if( !g_bSilent )
- {
- SG_PRINTF(SG_T("\n%s..."), LNG("press any key"));
- _getch();
- }
-}
-
-//---------------------------------------------------------
-bool Get_YesNo (const SG_Char *caption, const SG_Char *message)
-{
- SG_PRINTF(SG_T("\n%s: %s\n"), caption, message);
-
- if( !g_bSilent )
- {
- CSG_String sKey, sYes(SG_T("y")), sNo(SG_T("n"));
-
- SG_PRINTF(SG_T("%s? (%s/%s)"), LNG("continue"), sYes.c_str(), sNo.c_str());
-
- do
- {
- sKey.Printf(SG_T("%c"), _getch());
- }
- while( sYes.CmpNoCase(sKey) && sNo.CmpNoCase(sKey) );
-
- return( sYes.CmpNoCase(sKey) == 0 );
- }
-
- return( true );
-}
-
-#else
+ ///////////////////////////////////////////////////////
+ // //
+ ///////////////////////////////////////////////////////
-//---------------------------------------------------------
-void Get_Pause (void)
-{
- if( !g_bSilent )
- {
- SG_PRINTF(SG_T("\n%s..."), LNG("press any key"));
+ //-----------------------------------------------------
}
-}
-//---------------------------------------------------------
-bool Get_YesNo (const SG_Char *caption, const SG_Char *message)
-{
- return( true );
+ return( Result );
}
-#endif
-
///////////////////////////////////////////////////////////
// //
@@ -394,15 +416,9 @@ bool Get_YesNo (const SG_Char *caption, const SG_Char *message)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-void Print_Error (const SG_Char *Error)
-{
- SG_PRINTF(SG_T("\n%s: %s\n"), LNG("error"), Error);
-}
-
-//---------------------------------------------------------
-void Print_Error (const SG_Char *Error, const SG_Char *Info)
+TSG_PFNC_UI_Callback Get_Callback (void)
{
- Print_Error(CSG_String::Format(SG_T("%s [%s]"), Error, Info));
+ return( &Callback );
}
diff --git a/src/saga_core/saga_cmd/callback.h b/src/saga_core/saga_cmd/callback.h
index be96a46..f669eea 100644
--- a/src/saga_core/saga_cmd/callback.h
+++ b/src/saga_core/saga_cmd/callback.h
@@ -79,20 +79,26 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-TSG_PFNC_UI_Callback Get_Callback (void);
-
void Set_Library (class CModule_Library *pLibrary);
//---------------------------------------------------------
void Set_Silent (bool bOn);
+bool Get_Silent (void);
-void Get_Pause (void);
-bool Get_YesNo (const SG_Char *caption, const SG_Char *message);
+void Set_Interactive (bool bOn);
+bool Get_Interactive (void);
//---------------------------------------------------------
void Print_Error (const SG_Char *Error);
void Print_Error (const SG_Char *Error, const SG_Char *Info);
+//---------------------------------------------------------
+void Get_Pause (void);
+bool Get_YesNo (const SG_Char *caption, const SG_Char *message);
+
+//---------------------------------------------------------
+TSG_PFNC_UI_Callback Get_Callback (void);
+
///////////////////////////////////////////////////////////
// //
diff --git a/src/saga_core/saga_cmd/man/Makefile.am b/src/saga_core/saga_cmd/man/Makefile.am
new file mode 100644
index 0000000..c452cc4
--- /dev/null
+++ b/src/saga_core/saga_cmd/man/Makefile.am
@@ -0,0 +1 @@
+dist_man_MANS = saga_cmd.1
diff --git a/src/saga_core/saga_cmd/man/Makefile.in b/src/saga_core/saga_cmd/man/Makefile.in
new file mode 100644
index 0000000..7801f25
--- /dev/null
+++ b/src/saga_core/saga_cmd/man/Makefile.in
@@ -0,0 +1,437 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/saga_core/saga_cmd/man
+DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+man1dir = $(mandir)/man1
+am__installdirs = "$(DESTDIR)$(man1dir)"
+NROFF = nroff
+MANS = $(dist_man_MANS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+HARU_LIB = @HARU_LIB@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POW_LIB = @POW_LIB@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+dist_man_MANS = saga_cmd.1
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/saga_core/saga_cmd/man/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/saga_core/saga_cmd/man/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-man1: $(dist_man_MANS)
+ @$(NORMAL_INSTALL)
+ test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
+ @list=''; test -n "$(man1dir)" || exit 0; \
+ { for i in $$list; do echo "$$i"; done; \
+ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.1[a-z]*$$/p'; \
+ } | while read p; do \
+ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; echo "$$p"; \
+ done | \
+ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+ sed 'N;N;s,\n, ,g' | { \
+ list=; while read file base inst; do \
+ if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
+ fi; \
+ done; \
+ for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+ while read files; do \
+ test -z "$$files" || { \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
+ done; }
+
+uninstall-man1:
+ @$(NORMAL_UNINSTALL)
+ @list=''; test -n "$(man1dir)" || exit 0; \
+ files=`{ for i in $$list; do echo "$$i"; done; \
+ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.1[a-z]*$$/p'; \
+ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+ test -z "$$files" || { \
+ echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+ @list='$(MANS)'; if test -n "$$list"; then \
+ list=`for p in $$list; do \
+ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
+ if test -n "$$list" && \
+ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
+ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
+ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \
+ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \
+ echo " typically \`make maintainer-clean' will remove them" >&2; \
+ exit 1; \
+ else :; fi; \
+ else :; fi
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(MANS)
+installdirs:
+ for dir in "$(DESTDIR)$(man1dir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man1
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-man
+
+uninstall-man: uninstall-man1
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ distclean distclean-generic distclean-libtool distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-man1 \
+ 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 \
+ uninstall uninstall-am uninstall-man uninstall-man1
+
+
+# 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:
diff --git a/src/saga_core/saga_cmd/man/saga_cmd.1 b/src/saga_core/saga_cmd/man/saga_cmd.1
new file mode 100644
index 0000000..5caae38
--- /dev/null
+++ b/src/saga_core/saga_cmd/man/saga_cmd.1
@@ -0,0 +1,174 @@
+.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.07)
+.\"
+.\" Standard preamble:
+.\" ========================================================================
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+.\" Set up some character translations and predefined strings. \*(-- will
+.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
+.\" double quote, and \*(R" will give a right double quote. \*(C+ will
+.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
+.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
+.\" nothing in troff, for use with C<>.
+.tr \(*W-
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.ie n \{\
+. ds -- \(*W-
+. ds PI pi
+. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
+. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
+. ds L" ""
+. ds R" ""
+. ds C` ""
+. ds C' ""
+'br\}
+.el\{\
+. ds -- \|\(em\|
+. ds PI \(*p
+. ds L" ``
+. ds R" ''
+'br\}
+.\"
+.\" Escape single quotes in literal strings from groff's Unicode transform.
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\"
+.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
+.\" entries marked with X<> in POD. Of course, you'll have to process the
+.\" output yourself in some meaningful fashion.
+.ie \nF \{\
+. de IX
+. tm Index:\\$1\t\\n%\t"\\$2"
+..
+. nr % 0
+. rr F
+.\}
+.el \{\
+. de IX
+..
+.\}
+.\"
+.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
+.\" Fear. Run. Save yourself. No user-serviceable parts.
+. \" fudge factors for nroff and troff
+.if n \{\
+. ds #H 0
+. ds #V .8m
+. ds #F .3m
+. ds #[ \f1
+. ds #] \fP
+.\}
+.if t \{\
+. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+. ds #V .6m
+. ds #F 0
+. ds #[ \&
+. ds #] \&
+.\}
+. \" simple accents for nroff and troff
+.if n \{\
+. ds ' \&
+. ds ` \&
+. ds ^ \&
+. ds , \&
+. ds ~ ~
+. ds /
+.\}
+.if t \{\
+. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+.\}
+. \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+. \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+. \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+. ds : e
+. ds 8 ss
+. ds o a
+. ds d- d\h'-1'\(ga
+. ds D- D\h'-1'\(hy
+. ds th \o'bp'
+. ds Th \o'LP'
+. ds ae ae
+. ds Ae AE
+.\}
+.rm #[ #] #H #V #F C
+.\" ========================================================================
+.\"
+.IX Title "SAGA_CMD 1"
+.TH SAGA_CMD 1 "2010-03-08" "2.0.4" " "
+.\" For nroff, turn off justification. Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
+.if n .ad l
+.nh
+.SH "NAME"
+\&\fBsaga_cmd\fR \- command-line interface to the System for Automated Geoscientific Analyses
+.SH "SYNOPSIS"
+.IX Header "SYNOPSIS"
+[\fB\s-1SAGA_MLB\s0\fR=\fIdirname\fR] \fBsaga_cmd\fR \fI\s-1LIBRARY\s0\fR [\fI\s-1MODULE\s0\fR] [\fB\-silent\fR] <module specific options...>
+.PP
+\&\fBsaga_cmd\fR [\fB\-h, \-\-help\fR]
+.SH "DESCRIPTION"
+.IX Header "DESCRIPTION"
+Command line interface to the System for Automated Geoscientific Analyses (\s-1SAGA\s0). When run without arguments, the module libraries in the current module library are listed. This can be specified by setting the environment variable \fI\s-1SAGA_MLB\s0\fR. If this is not specified, the current working directory is used.
+.PP
+\&\s-1SAGA\s0 \s-1GIS\s0 (System for Automated Geoscientific Analysis) is a free and open source geographic information system used for editing and analysing spatial data. It includes a large number of modules for the analysis of vector, table, grid and image data.
+.SH "OPTIONS"
+.IX Header "OPTIONS"
+.IP "[\fI\s-1SAGA_MLB\s0\fR=dirname]" 8
+.IX Item "[SAGA_MLB=dirname]"
+Module libraries are expected to be located in the directory that is specified by the environment variable '\s-1SAGA_MLB\s0'. If this is not found the current working directory will be searched for instead.
+.Sp
+To use the default modules, the environment variable can be set to \fI/usr/lib/saga\fR
+.IP "\fI\s-1LIBRARY\s0\fR [\fI\s-1MODULE\s0\fR]" 8
+.IX Item "LIBRARY [MODULE]"
+Specify the library (ie ta_morphometry) and the module (number or name). If no module is specified the different modules of a library are listed.
+.IP "\fB\-h, \-\-help\fR" 8
+.IX Item "-h, --help"
+Display help and exit
+.SH "EXAMPLE"
+.IX Header "EXAMPLE"
+export SAGA_MLB=/usr/lib/saga
+.PP
+\&\fBsaga_cmd\fR ta_morphometry \*(L"Local Morphometry\*(R" \-ELEVATION dem.sgrd \-SLOPE slope.sgrd \-ASPECT aspect.sgrd \-METHOD 1
+.PP
+Multiple input files can be specified by seperating them by a semicolon (;).
+.PP
+\&\fBsaga_cmd\fR libgrid_tools Merging \-GRIDS test1.sgrd\e;test2.sgrd \-GRID_TARGET merged.sgrd
+.SH "BUGS"
+.IX Header "BUGS"
+On the website of \fIhttp://www.saga\-gis.org\fR, a list of known bugs can be found and new bug reports can be submitted.
+.SH "AUTHORS"
+.IX Header "AUTHORS"
+\&\fB\s-1SAGA\s0\fR was written by Olaf Conrad with help from a large number of contributers. This manual page was written by Johan Van de Wauw.
+Both are released under the \s-1GNU\s0 General Public License v2.
+.PP
+More info \fIhttp://www.saga\-gis.org\fR
diff --git a/src/saga_core/saga_cmd/module_library.cpp b/src/saga_core/saga_cmd/module_library.cpp
index 3dc2efa..55fc021 100644
--- a/src/saga_core/saga_cmd/module_library.cpp
+++ b/src/saga_core/saga_cmd/module_library.cpp
@@ -1,757 +1,885 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// Command Line Interface //
-// //
-// Program: SAGA_CMD //
-// //
-//-------------------------------------------------------//
-// //
-// module_library.cpp //
-// //
-// Copyright (C) 2005 by Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include <wx/cmdline.h>
-
-#include <saga_api/saga_api.h>
-
-#include "callback.h"
-
-#include "module_library.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#define GET_ID1(p) (p->Get_Owner()->Get_Identifier() && *(p->Get_Owner()->Get_Identifier()) \
- ? wxString::Format(wxT("%s_%s"), p->Get_Owner()->Get_Identifier(), p->Get_Identifier()) \
- : wxString::Format(p->Get_Identifier()))
-
-#define GET_ID2(p, s) wxString::Format(wxT("%s_%s"), GET_ID1(p).c_str(), s)
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CModule_Library::CModule_Library(void)
-{
- m_nModules = 0;
- m_Modules = NULL;
- m_pSelected = NULL;
- m_pCMD = NULL;
-}
-
-//---------------------------------------------------------
-CModule_Library::~CModule_Library(void)
-{
- Destroy();
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CModule_Library::Create(const SG_Char *FileName, const SG_Char *FilePath)
-{
- TSG_PFNC_MLB_Initialize MLB_Initialize;
- TSG_PFNC_MLB_Get_Interface MLB_Get_Interface;
-
- CSG_Module_Library_Interface *pInterface;
- CSG_Module *pModule;
-
- //-----------------------------------------------------
- Destroy();
-
- m_FileName = SG_File_Make_Path(FilePath, FileName, NULL).c_str();
-
- m_Library.Load(m_FileName);
-
- //-----------------------------------------------------
- if( !m_Library.IsLoaded() )
- {
- Print_Error(LNG("[ERR] Library could not be loaded"), FileName);
- }
- else
- {
- MLB_Initialize = (TSG_PFNC_MLB_Initialize) m_Library.GetSymbol(SYMBOL_MLB_Initialize);
- MLB_Get_Interface = (TSG_PFNC_MLB_Get_Interface) m_Library.GetSymbol(SYMBOL_MLB_Get_Interface);
-
- if( !MLB_Get_Interface || !(pInterface = MLB_Get_Interface())
- || !MLB_Initialize || !MLB_Initialize(m_FileName) )
- {
- Print_Error(LNG("[ERR] Invalid library"), FileName);
- }
- else
- {
- while( (pModule = pInterface->Get_Module(m_nModules)) != NULL )
- {
- m_Modules = (CSG_Module **)SG_Realloc(m_Modules, (m_nModules + 1) * sizeof(CSG_Module *));
- m_Modules[m_nModules++] = pModule;
- }
-
- if( m_nModules > 0 )
- {
- return( true );
- }
-
- Print_Error(LNG("[ERR] Library does not contain any modules"), FileName);
- }
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-void CModule_Library::Destroy(void)
-{
- if( m_nModules > 0 )
- {
- SG_Free(m_Modules);
- m_nModules = 0;
- m_Modules = NULL;
- m_pSelected = NULL;
- }
-
- if( m_pCMD )
- {
- delete(m_pCMD);
- m_pCMD = NULL;
- }
-
- if( m_Library.IsLoaded() )
- {
- m_Library.Unload();
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Module * CModule_Library::Select(const SG_Char *ModuleName)
-{
- int i;
- wxString Description;
-
- //-----------------------------------------------------
- if( m_pCMD )
- {
- delete(m_pCMD);
- m_pCMD = NULL;
- }
-
- for(i=0, m_pSelected=NULL; i<m_nModules && !m_pSelected; i++)
- {
- if( !SG_STR_CMP(ModuleName, Get_Module(i)->Get_Name()) )
- {
- m_pSelected = Get_Module(i);
- }
- }
-
- if( !m_pSelected )
- {
- long l;
- wxString s(ModuleName);
-
- if( s.ToLong(&l) )
- {
- m_pSelected = Get_Module((int)l);
- }
- }
-
- //-----------------------------------------------------
- if( m_pSelected )
- {
- m_pCMD = new wxCmdLineParser;
-
- _Set_CMD(m_pSelected->Get_Parameters(), false);
-
- for(i=0; i<m_pSelected->Get_Parameters_Count(); i++)
- {
- _Set_CMD(m_pSelected->Get_Parameters(i), true);
- }
- }
-
- return( m_pSelected );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CModule_Library::Execute(int argc, char *argv[])
-{
- bool bResult = false;
-
- if( m_pSelected && m_pCMD )
- {
- m_pCMD->SetCmdLine(argc, argv);
-
- if( argc == 1 )
- {
- m_pCMD->Usage();
- return( true );
- }
-
- if( _Get_CMD(m_pSelected->Get_Parameters()) )
- {
- bResult = m_pSelected->Execute();
-
- _Destroy_DataObjects(bResult);
- }
- }
-
- if( !bResult )
- {
- Print_Error(LNG("executing module"), m_pSelected->Get_Name());
- }
-
- return( bResult );
-}
-
-//---------------------------------------------------------
-bool CModule_Library::Get_Parameters(CSG_Parameters *pParameters)
-{
- return( _Get_CMD(pParameters) );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CModule_Library::_Set_CMD(CSG_Parameters *pParameters, bool bExtra)
-{
- CSG_Parameter *pParameter;
- wxString Description;
-
- //-----------------------------------------------------
- if( m_pCMD && pParameters )
- {
- m_pCMD->SetSwitchChars(SG_T("-"));
-
- for(int i=0; i<pParameters->Get_Count(); i++)
- {
- pParameter = pParameters->Get_Parameter(i);
- Description = pParameter->Get_Description(
- PARAMETER_DESCRIPTION_NAME|PARAMETER_DESCRIPTION_TYPE|PARAMETER_DESCRIPTION_PROPERTIES, SG_T("\n\t")
- ).c_str();
-
- if( pParameter->is_Input() || pParameter->is_Output() )
- {
- m_pCMD->AddOption(
- GET_ID1(pParameter), wxEmptyString, Description,
- wxCMD_LINE_VAL_STRING,
- wxCMD_LINE_NEEDS_SEPARATOR | (pParameter->is_Optional() || bExtra ? wxCMD_LINE_PARAM_OPTIONAL : wxCMD_LINE_OPTION_MANDATORY)
- );
- }
- else if( pParameter->is_Option() && !pParameter->is_Information() )
- {
- switch( pParameter->Get_Type() )
- {
- default:
- break;
-
- case PARAMETER_TYPE_Bool:
- m_pCMD->AddSwitch(GET_ID1(pParameter), wxEmptyString, Description, wxCMD_LINE_PARAM_OPTIONAL);
- break;
-
- case PARAMETER_TYPE_Int:
- case PARAMETER_TYPE_Choice:
- case PARAMETER_TYPE_Table_Field:
- m_pCMD->AddOption(GET_ID1(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
- break;
-
- case PARAMETER_TYPE_Double:
- case PARAMETER_TYPE_Degree:
- m_pCMD->AddOption(GET_ID1(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
- break;
-
- case PARAMETER_TYPE_Range:
- m_pCMD->AddOption(GET_ID2(pParameter, wxT("MIN")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
- m_pCMD->AddOption(GET_ID2(pParameter, wxT("MAX")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
- break;
-
- case PARAMETER_TYPE_String:
- case PARAMETER_TYPE_Text:
- case PARAMETER_TYPE_FilePath:
- m_pCMD->AddOption(GET_ID1(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
- break;
-
- case PARAMETER_TYPE_FixedTable:
- m_pCMD->AddOption(GET_ID1(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
- break;
-
- case PARAMETER_TYPE_Grid_System:
- if( pParameter->Get_Children_Count() == 0 )
- {
- m_pCMD->AddOption(GET_ID2(pParameter, wxT("NX")), wxEmptyString, Description, wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
- m_pCMD->AddOption(GET_ID2(pParameter, wxT("NY")), wxEmptyString, Description, wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
- m_pCMD->AddOption(GET_ID2(pParameter, wxT( "X")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
- m_pCMD->AddOption(GET_ID2(pParameter, wxT( "Y")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
- m_pCMD->AddOption(GET_ID2(pParameter, wxT( "D")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
- }
- break;
- }
- }
- }
- }
-}
-
-//---------------------------------------------------------
-bool CModule_Library::_Get_CMD(CSG_Parameters *pParameters)
-{
- //-----------------------------------------------------
- if( m_pCMD == NULL || pParameters == NULL )
- {
- Print_Error(LNG("[ERR] Internal system error"));
-
- return( false );
- }
-
- if( m_pCMD->Parse(false) != 0 || _Create_DataObjects(pParameters) == false )
- {
- m_pCMD->Usage();
-
- return( false );
- }
-
- //-----------------------------------------------------
- for(int i=0; i<pParameters->Get_Count(); i++)
- {
- long l;
- double d;
- wxString s;
-
- CSG_Parameter *pParameter = pParameters->Get_Parameter(i);
-
- switch( pParameter->Get_Type() )
- {
- default:
- break;
-
- case PARAMETER_TYPE_Bool:
- pParameter->Set_Value(m_pCMD->Found(GET_ID1(pParameter)) ? 1 : 0);
- break;
-
- case PARAMETER_TYPE_Int:
- case PARAMETER_TYPE_Choice:
- case PARAMETER_TYPE_Table_Field:
- if( m_pCMD->Found(GET_ID1(pParameter), &l) )
- {
- pParameter->Set_Value((int)l);
- }
- break;
-
- case PARAMETER_TYPE_Double:
- case PARAMETER_TYPE_Degree:
- if( m_pCMD->Found(GET_ID1(pParameter), &s) && s.ToDouble(&d) )
- {
- pParameter->Set_Value(d);
- }
- break;
-
- case PARAMETER_TYPE_Range:
- if( m_pCMD->Found(GET_ID2(pParameter, wxT("MIN")), &s) && s.ToDouble(&d) )
- {
- pParameter->asRange()->Set_LoVal(d);
- }
-
- if( m_pCMD->Found(GET_ID2(pParameter, wxT("MAX")), &s) && s.ToDouble(&d) )
- {
- pParameter->asRange()->Set_HiVal(d);
- }
- break;
-
- case PARAMETER_TYPE_String:
- case PARAMETER_TYPE_Text:
- if( m_pCMD->Found(GET_ID1(pParameter), &s) )
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Command Line Interface //
+// //
+// Program: SAGA_CMD //
+// //
+//-------------------------------------------------------//
+// //
+// module_library.cpp //
+// //
+// Copyright (C) 2005 by Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include <wx/cmdline.h>
+
+#include <saga_api/saga_api.h>
+
+#include "callback.h"
+
+#include "module_library.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define GET_ID1(p) (p->Get_Owner()->Get_Identifier() && *(p->Get_Owner()->Get_Identifier()) \
+ ? wxString::Format(wxT("%s_%s"), p->Get_Owner()->Get_Identifier(), p->Get_Identifier()) \
+ : wxString::Format(p->Get_Identifier()))
+
+#define GET_ID2(p, s) wxString::Format(wxT("%s_%s"), GET_ID1(p).c_str(), s)
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CModule_Library::CModule_Library(void)
+{
+ m_nModules = 0;
+ m_Modules = NULL;
+ m_pSelected = NULL;
+ m_pCMD = NULL;
+}
+
+//---------------------------------------------------------
+CModule_Library::~CModule_Library(void)
+{
+ Destroy();
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CModule_Library::Create(const SG_Char *FileName, const SG_Char *FilePath)
+{
+ TSG_PFNC_MLB_Initialize MLB_Initialize;
+ TSG_PFNC_MLB_Get_Interface MLB_Get_Interface;
+
+ CSG_Module_Library_Interface *pInterface;
+ CSG_Module *pModule;
+
+ //-----------------------------------------------------
+ Destroy();
+
+ m_FileName = SG_File_Make_Path(FilePath, FileName, NULL).c_str();
+
+ m_Library.Load(m_FileName);
+
+ //-----------------------------------------------------
+ if( !m_Library.IsLoaded() )
+ {
+ Print_Error(LNG("[ERR] Library could not be loaded"), FileName);
+ }
+ else
+ {
+ MLB_Initialize = (TSG_PFNC_MLB_Initialize) m_Library.GetSymbol(SYMBOL_MLB_Initialize);
+ MLB_Get_Interface = (TSG_PFNC_MLB_Get_Interface) m_Library.GetSymbol(SYMBOL_MLB_Get_Interface);
+
+ if( !MLB_Get_Interface || !(pInterface = MLB_Get_Interface())
+ || !MLB_Initialize || !MLB_Initialize(m_FileName) )
+ {
+ Print_Error(LNG("[ERR] Invalid library"), FileName);
+ }
+ else
+ {
+ while( (pModule = pInterface->Get_Module(m_nModules)) != NULL )
+ {
+ m_Modules = (CSG_Module **)SG_Realloc(m_Modules, (m_nModules + 1) * sizeof(CSG_Module *));
+ m_Modules[m_nModules++] = pModule;
+ }
+
+ if( m_nModules > 0 )
+ {
+ return( true );
+ }
+
+ Print_Error(LNG("[ERR] Library does not contain any modules"), FileName);
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+void CModule_Library::Destroy(void)
+{
+ if( m_nModules > 0 )
+ {
+ SG_Free(m_Modules);
+ m_nModules = 0;
+ m_Modules = NULL;
+ m_pSelected = NULL;
+ }
+
+ if( m_pCMD )
+ {
+ delete(m_pCMD);
+ m_pCMD = NULL;
+ }
+
+ if( m_Library.IsLoaded() )
+ {
+ m_Library.Unload();
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Module * CModule_Library::Select(const SG_Char *ModuleName)
+{
+ int i;
+ wxString Description;
+
+ //-----------------------------------------------------
+ if( m_pCMD )
+ {
+ delete(m_pCMD);
+ m_pCMD = NULL;
+ }
+
+ for(i=0, m_pSelected=NULL; i<m_nModules && !m_pSelected; i++)
+ {
+ if( !SG_STR_CMP(ModuleName, Get_Module(i)->Get_Name()) )
+ {
+ m_pSelected = Get_Module(i);
+ }
+ }
+
+ if( !m_pSelected )
+ {
+ long l;
+ wxString s(ModuleName);
+
+ if( s.ToLong(&l) )
+ {
+ m_pSelected = Get_Module((int)l);
+ }
+ }
+
+ //-----------------------------------------------------
+ if( m_pSelected )
+ {
+ m_pCMD = new wxCmdLineParser;
+
+ _Set_CMD(m_pSelected->Get_Parameters(), false);
+
+ for(i=0; i<m_pSelected->Get_Parameters_Count(); i++)
+ {
+ _Set_CMD(m_pSelected->Get_Parameters(i), true);
+ }
+ }
+
+ return( m_pSelected );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CModule_Library::Execute(int argc, char *argv[])
+{
+ bool bResult = false;
+
+ if( m_pSelected && m_pCMD )
+ {
+ m_Data_Objects.Clear();
+
+ m_pCMD->SetCmdLine(argc, argv);
+
+ if( argc == 1 )
+ {
+ m_pCMD->Usage();
+
+ return( true );
+ }
+
+ if( _Get_CMD(m_pSelected->Get_Parameters()) && m_pSelected->On_Before_Execution() )
+ {
+ bResult = m_pSelected->Execute();
+
+ m_pSelected->On_After_Execution();
+ }
+
+ _Destroy_DataObjects(bResult);
+
+ m_Data_Objects.Clear();
+ }
+
+ if( !bResult )
+ {
+ Print_Error(LNG("executing module"), m_pSelected->Get_Name());
+ }
+
+ return( bResult );
+}
+
+//---------------------------------------------------------
+bool CModule_Library::Get_Parameters(CSG_Parameters *pParameters)
+{
+ return( _Get_CMD(pParameters) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CModule_Library::_Set_CMD(CSG_Parameters *pParameters, bool bExtra)
+{
+ CSG_Parameter *pParameter;
+ wxString Description;
+
+ //-----------------------------------------------------
+ if( m_pCMD && pParameters )
+ {
+ m_pCMD->SetSwitchChars(SG_T("-"));
+
+ for(int i=0; i<pParameters->Get_Count(); i++)
+ {
+ pParameter = pParameters->Get_Parameter(i);
+ Description = pParameter->Get_Description(
+ PARAMETER_DESCRIPTION_NAME|PARAMETER_DESCRIPTION_TYPE|PARAMETER_DESCRIPTION_PROPERTIES, SG_T("\n\t")
+ ).c_str();
+
+ if( pParameter->is_Input() || pParameter->is_Output() )
+ {
+ m_pCMD->AddOption(
+ GET_ID1(pParameter), wxEmptyString, Description,
+ wxCMD_LINE_VAL_STRING,
+ wxCMD_LINE_NEEDS_SEPARATOR | (pParameter->is_Optional() || bExtra ? wxCMD_LINE_PARAM_OPTIONAL : wxCMD_LINE_OPTION_MANDATORY)
+ );
+ }
+ else if( pParameter->is_Option() && !pParameter->is_Information() )
+ {
+ switch( pParameter->Get_Type() )
+ {
+ default:
+ break;
+
+ case PARAMETER_TYPE_Bool:
+ m_pCMD->AddSwitch(GET_ID1(pParameter), wxEmptyString, Description, wxCMD_LINE_PARAM_OPTIONAL);
+ break;
+
+ case PARAMETER_TYPE_Int:
+ m_pCMD->AddOption(GET_ID1(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
+ break;
+
+ case PARAMETER_TYPE_Choice:
+ case PARAMETER_TYPE_Table_Field:
+ m_pCMD->AddOption(GET_ID1(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
+ break;
+
+ case PARAMETER_TYPE_Double:
+ case PARAMETER_TYPE_Degree:
+ m_pCMD->AddOption(GET_ID1(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
+ break;
+
+ case PARAMETER_TYPE_Range:
+ m_pCMD->AddOption(GET_ID2(pParameter, wxT("MIN")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
+ m_pCMD->AddOption(GET_ID2(pParameter, wxT("MAX")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
+ break;
+
+ case PARAMETER_TYPE_String:
+ case PARAMETER_TYPE_Text:
+ case PARAMETER_TYPE_FilePath:
+ m_pCMD->AddOption(GET_ID1(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
+ break;
+
+ case PARAMETER_TYPE_FixedTable:
+ m_pCMD->AddOption(GET_ID1(pParameter), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
+ break;
+
+ case PARAMETER_TYPE_Grid_System:
+ if( pParameter->Get_Children_Count() == 0 )
+ {
+ m_pCMD->AddOption(GET_ID2(pParameter, wxT("NX")), wxEmptyString, Description, wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
+ m_pCMD->AddOption(GET_ID2(pParameter, wxT("NY")), wxEmptyString, Description, wxCMD_LINE_VAL_NUMBER, wxCMD_LINE_PARAM_OPTIONAL);
+ m_pCMD->AddOption(GET_ID2(pParameter, wxT( "X")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
+ m_pCMD->AddOption(GET_ID2(pParameter, wxT( "Y")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
+ m_pCMD->AddOption(GET_ID2(pParameter, wxT( "D")), wxEmptyString, Description, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
+ }
+ break;
+
+ case PARAMETER_TYPE_Parameters:
+ _Set_CMD(pParameter->asParameters(), true);
+ break;
+ }
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
+bool CModule_Library::_Get_CMD(CSG_Parameters *pParameters)
+{
+ //-----------------------------------------------------
+ if( m_pCMD == NULL || pParameters == NULL )
+ {
+ Print_Error(LNG("[ERR] Internal system error"));
+
+ return( false );
+ }
+
+ if( m_pCMD->Parse(false) != 0 || _Create_DataObjects(pParameters) == false )
+ {
+ m_pCMD->Usage();
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ for(int i=0; i<pParameters->Get_Count(); i++)
+ {
+ long l;
+ double d;
+ wxString s;
+
+ CSG_Parameter *pParameter = pParameters->Get_Parameter(i);
+
+ if( !pParameter->is_Information() || pParameter->is_DataObject() )
+ {
+ switch( pParameter->Get_Type() )
+ {
+ default:
+ break;
+
+ case PARAMETER_TYPE_Bool:
+ pParameter->Set_Value(m_pCMD->Found(GET_ID1(pParameter)) ? 1 : 0);
+ break;
+
+ case PARAMETER_TYPE_Int:
+ if( m_pCMD->Found(GET_ID1(pParameter), &l) )
+ {
+ pParameter->Set_Value((int)l);
+ }
+ break;
+
+ case PARAMETER_TYPE_Choice:
+ case PARAMETER_TYPE_Table_Field:
+ if( m_pCMD->Found(GET_ID1(pParameter), &s) )
+ {
+ if( s.ToLong(&l) )
+ {
+ pParameter->Set_Value((int)l);
+ }
+ else
+ {
+ pParameter->Set_Value(s.c_str());
+ }
+ }
+ break;
+
+ case PARAMETER_TYPE_Double:
+ case PARAMETER_TYPE_Degree:
+ if( m_pCMD->Found(GET_ID1(pParameter), &s) && s.ToDouble(&d) )
+ {
+ pParameter->Set_Value(d);
+ }
+ break;
+
+ case PARAMETER_TYPE_Range:
+ if( m_pCMD->Found(GET_ID2(pParameter, wxT("MIN")), &s) && s.ToDouble(&d) )
+ {
+ pParameter->asRange()->Set_LoVal(d);
+ }
+
+ if( m_pCMD->Found(GET_ID2(pParameter, wxT("MAX")), &s) && s.ToDouble(&d) )
+ {
+ pParameter->asRange()->Set_HiVal(d);
+ }
+ break;
+
+ case PARAMETER_TYPE_String:
+ if( m_pCMD->Found(GET_ID1(pParameter), &s) )
+ {
+ pParameter->Set_Value(s.c_str());
+ }
+ break;
+
+ case PARAMETER_TYPE_Text:
+ if( m_pCMD->Found(GET_ID1(pParameter), &s) )
+ {
+ CSG_File Stream;
+
+ if( Stream.Open(s.c_str()) )
+ {
+ CSG_String t;
+
+ Stream.Read(t, Stream.Length());
+
+ pParameter->Set_Value(t.c_str());
+ }
+ else
+ {
+ pParameter->Set_Value(s.c_str());
+ }
+ }
+ break;
+
+ case PARAMETER_TYPE_FilePath:
+ if( m_pCMD->Found(GET_ID1(pParameter), &s) )
+ {
+ if( pParameter->asFilePath()->is_Multiple() )
+ {
+ s.Prepend(wxT("\""));
+ s.Replace(wxT(";"), wxT("\" \""));
+ s.Append (wxT("\""));
+ }
+
+ pParameter->Set_Value(s.c_str());
+ }
+ break;
+
+ case PARAMETER_TYPE_FixedTable:
+ if( m_pCMD->Found(GET_ID1(pParameter), &s) )
+ {
+ CSG_Table Table(s.c_str());
+ pParameter->asTable()->Assign_Values(&Table);
+ }
+ break;
+
+ case PARAMETER_TYPE_Grid_System:
+ if( pParameter->Get_Children_Count() == 0 )
+ {
+ long nx, ny;
+ double d, x, y;
+
+ if( !m_pCMD->Found(GET_ID2(pParameter, wxT("NX")), &nx)
+ || !m_pCMD->Found(GET_ID2(pParameter, wxT("NY")), &ny)
+ || !m_pCMD->Found(GET_ID2(pParameter, wxT( "X")), &s) || !s.ToDouble(&x)
+ || !m_pCMD->Found(GET_ID2(pParameter, wxT( "Y")), &s) || !s.ToDouble(&y)
+ || !m_pCMD->Found(GET_ID2(pParameter, wxT( "D")), &s) || !s.ToDouble(&d) )
+ {
+ d = -1.0;
+ }
+
+ pParameter->asGrid_System()->Assign(d, x, y, (int)nx, (int)ny);
+ }
+ break;
+
+ case PARAMETER_TYPE_Parameters:
+ _Get_CMD(pParameter->asParameters());
+ break;
+ }
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CModule_Library::_Create_DataObjects(CSG_Parameters *pParameters)
+{
+ //-----------------------------------------------------
+ if( m_pCMD == NULL || pParameters == NULL )
+ {
+ Print_Error(LNG("[ERR] Internal system error"));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ bool bObjects = false;
+ int nObjects = 0;
+
+ for(int i=0; i<pParameters->Get_Count(); i++)
+ {
+ wxString FileName;
+
+ CSG_Parameter *pParameter = pParameters->Get_Parameter(i);
+
+ if( pParameter->is_DataObject() || pParameter->is_DataObject_List() )
+ {
+ bObjects = true;
+
+ if( m_pCMD->Found(GET_ID1(pParameter), &FileName) )
+ {
+ if( pParameter->is_Input() )
+ {
+ if( pParameter->is_DataObject() )
+ {
+ if( !_Create_DataObject(pParameter, FileName) && !pParameter->is_Optional() )
+ {
+ Print_Error(LNG("input file"), FileName);
+
+ return( false );
+ }
+
+ nObjects++;
+ }
+ else if( pParameter->is_DataObject_List() )
+ {
+ if( !_Create_DataObject_List(pParameter, FileName) && !pParameter->is_Optional() )
+ {
+ Print_Error(LNG("empty input list"), GET_ID1(pParameter));
+
+ return( false );
+ }
+
+ nObjects++;
+ }
+ }
+ else if( pParameter->is_Output() )
+ {
+ if( !_Create_DataObject(pParameter, FileName) )
+ {
+ pParameter->Set_Value(DATAOBJECT_CREATE);
+ }
+
+ nObjects++;
+ }
+ }
+ else if( !pParameter->is_Optional() )
{
- pParameter->Set_Value(s.c_str());
+ return( false );
}
- break;
+ }
+ }
- case PARAMETER_TYPE_FilePath:
- if( m_pCMD->Found(GET_ID1(pParameter), &s) )
+ return( bObjects == false || nObjects > 0 );
+}
+
+//---------------------------------------------------------
+bool CModule_Library::_Create_DataObject(CSG_Parameter *pParameter, const wxChar *FileName)
+{
+ if( !SG_File_Exists(FileName) )
+ {
+ return( false );
+ }
+
+ CSG_Data_Object *pObject;
+
+ switch( pParameter->Get_Type() )
+ {
+ default: pObject = NULL; break;
+ case PARAMETER_TYPE_TIN: pObject = new CSG_TIN (FileName); break;
+ case PARAMETER_TYPE_PointCloud: pObject = new CSG_PointCloud (FileName); break;
+ case PARAMETER_TYPE_Shapes: pObject = new CSG_Shapes (FileName); break;
+ case PARAMETER_TYPE_Table: pObject = new CSG_Table (FileName); break;
+ case PARAMETER_TYPE_Grid: pObject = new CSG_Grid (FileName); break;
+ }
+
+ if( pObject )
+ {
+ if( pObject->is_Valid() && pParameter->Get_Type() == PARAMETER_TYPE_Grid )
+ {
+ if( !pParameter->Get_Parent()->asGrid_System()->is_Valid() )
{
- if( pParameter->asFilePath()->is_Multiple() )
+ pParameter->Get_Parent()->asGrid_System()->Assign(((CSG_Grid *)pObject)->Get_System());
+ }
+ else if( !pParameter->Get_Parent()->asGrid_System()->is_Equal(((CSG_Grid *)pObject)->Get_System()) )
+ {
+ delete(pObject);
+
+ return( false );
+ }
+ }
+
+ if( pObject->is_Valid() )
+ {
+ pParameter->Set_Value(pObject);
+
+ return( true );
+ }
+
+ delete(pObject);
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CModule_Library::_Create_DataObject_List(CSG_Parameter *pParameter, wxString FileNames)
+{
+ CSG_Data_Object *pObject;
+ wxString FileName;
+
+ if( pParameter && pParameter->is_DataObject_List() )
+ {
+ do
+ {
+ FileName = FileNames.BeforeFirst (';');
+ FileNames = FileNames.AfterFirst (';');
+
+ switch( pParameter->Get_Type() )
+ {
+ default: pObject = NULL; break;
+ case PARAMETER_TYPE_Grid_List: pObject = new CSG_Grid (FileName.c_str()); break;
+ case PARAMETER_TYPE_TIN_List: pObject = new CSG_TIN (FileName.c_str()); break;
+ case PARAMETER_TYPE_PointCloud_List: pObject = new CSG_PointCloud(FileName.c_str()); break;
+ case PARAMETER_TYPE_Shapes_List: pObject = new CSG_Shapes (FileName.c_str()); break;
+ case PARAMETER_TYPE_Table_List: pObject = new CSG_Table (FileName.c_str()); break;
+ }
+
+ if( pObject && pObject->is_Valid() )
+ {
+ if( pParameter->Get_Type() == PARAMETER_TYPE_Grid_List && (pParameter->Get_Parent() && pParameter->Get_Parent()->Get_Type() == PARAMETER_TYPE_Grid_System) )
+ { // grid system dependent grid list: first grid defines the grid system to be used!
+ if( pParameter->asList()->Get_Count() == 0 )
+ {
+ pParameter->Get_Parent()->asGrid_System()->Assign (((CSG_Grid *)pObject)->Get_System());
+ }
+
+ if( pParameter->Get_Parent()->asGrid_System()->is_Equal(((CSG_Grid *)pObject)->Get_System()) )
+ {
+ pParameter->asList()->Add_Item(pObject);
+ }
+ }
+ else
{
- s.Prepend(wxT("\""));
- s.Replace(wxT(";"), wxT("\" \""));
- s.Append (wxT("\""));
+ pParameter->asList()->Add_Item(pObject);
}
+ }
+ else if( pObject )
+ {
+ delete(pObject);
- pParameter->Set_Value(s.c_str());
+ Print_Error(LNG("input file"), FileName);
}
- break;
-
- case PARAMETER_TYPE_FixedTable:
- if( m_pCMD->Found(GET_ID1(pParameter), &s) )
- {
- CSG_Table Table(s.c_str());
- pParameter->asTable()->Assign_Values(&Table);
- }
- break;
-
- case PARAMETER_TYPE_Grid_System:
- if( pParameter->Get_Children_Count() == 0 )
- {
- long nx, ny;
- double d, x, y;
-
- if( !m_pCMD->Found(GET_ID2(pParameter, wxT("NX")), &nx)
- || !m_pCMD->Found(GET_ID2(pParameter, wxT("NY")), &ny)
- || !m_pCMD->Found(GET_ID2(pParameter, wxT( "X")), &s) || !s.ToDouble(&x)
- || !m_pCMD->Found(GET_ID2(pParameter, wxT( "Y")), &s) || !s.ToDouble(&y)
- || !m_pCMD->Found(GET_ID2(pParameter, wxT( "D")), &s) || !s.ToDouble(&d) )
- {
- d = -1.0;
- }
-
- pParameter->asGrid_System()->Assign(d, x, y, (int)nx, (int)ny);
- }
- break;
- }
- }
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CModule_Library::_Create_DataObjects(CSG_Parameters *pParameters)
-{
- //-----------------------------------------------------
- if( m_pCMD == NULL || pParameters == NULL )
- {
- Print_Error(LNG("[ERR] Internal system error"));
-
- return( false );
- }
-
- //-----------------------------------------------------
- bool bObjects = false;
- int nObjects = 0;
-
- for(int i=0; i<pParameters->Get_Count(); i++)
- {
- wxString s;
- CSG_Data_Object *pObject;
-
- CSG_Parameter *pParameter = pParameters->Get_Parameter(i);
-
- if( pParameter->is_DataObject() || pParameter->is_DataObject_List() )
- {
- bObjects = true;
-
- if( m_pCMD->Found(GET_ID1(pParameter), &s) )
- {
- if( pParameter->is_Input() )
- {
- if( pParameter->is_DataObject() )
- {
- switch( pParameter->Get_Type() )
- {
- default:
- pObject = NULL;
- break;
-
- case PARAMETER_TYPE_Grid:
- pObject = new CSG_Grid (s.c_str());
- if( pObject && pObject->is_Valid() )
- {
- pParameter->Get_Parent()->asGrid_System()->Assign(((CSG_Grid *)pObject)->Get_System());
- pParameter->Set_Value(pObject);
- }
- break;
-
- case PARAMETER_TYPE_TIN:
- pParameter->Set_Value(pObject = new CSG_TIN (s.c_str()));
- break;
-
- case PARAMETER_TYPE_Shapes:
- pParameter->Set_Value(pObject = new CSG_Shapes(s.c_str()));
- break;
-
- case PARAMETER_TYPE_Table:
- pParameter->Set_Value(pObject = new CSG_Table (s.c_str()));
- break;
- }
-
- if( !pObject || !pObject->is_Valid() )
- {
- Print_Error(LNG("input file"), s);
-
- return( false );
- }
-
- nObjects++;
- }
- else if( pParameter->is_DataObject_List() )
- {
- if( !_Create_DataObject_List(pParameter, s) && !pParameter->is_Optional() )
- {
- Print_Error(LNG("empty input list"), GET_ID1(pParameter));
-
- return( false );
- }
-
- nObjects++;
- }
- }
- else if( pParameter->is_Output() )
- {
- pParameter->Set_Value(DATAOBJECT_CREATE);
-
- nObjects++;
- }
- }
- else if( !pParameter->is_Optional() )
- {
- return( false );
- }
- }
- }
-
- return( bObjects == false || nObjects > 0 );
-}
-
-//---------------------------------------------------------
-bool CModule_Library::_Create_DataObject_List(CSG_Parameter *pParameter, wxString sList)
-{
- CSG_Data_Object *pObject;
- wxString s;
-
- if( pParameter && pParameter->is_DataObject_List() )
- {
- do
- {
- s = sList.BeforeFirst (';');
- sList = sList.AfterFirst (';');
-
- switch( pParameter->Get_Type() )
- {
- default: pObject = NULL; break;
- case PARAMETER_TYPE_Grid_List: pObject = new CSG_Grid (s.c_str()); break;
- case PARAMETER_TYPE_TIN_List: pObject = new CSG_TIN (s.c_str()); break;
- case PARAMETER_TYPE_PointCloud_List: pObject = new CSG_PointCloud(s.c_str()); break;
- case PARAMETER_TYPE_Shapes_List: pObject = new CSG_Shapes (s.c_str()); break;
- case PARAMETER_TYPE_Table_List: pObject = new CSG_Table (s.c_str()); break;
- }
-
- if( pObject && pObject->is_Valid() )
- {
- if( pParameter->Get_Type() == PARAMETER_TYPE_Grid_List && (pParameter->Get_Parent() && pParameter->Get_Parent()->Get_Type() == PARAMETER_TYPE_Grid_System) )
- { // grid system dependent grid list: first grid defines the grid system to be used!
- if( pParameter->asList()->Get_Count() == 0 )
- {
- pParameter->Get_Parent()->asGrid_System()->Assign (((CSG_Grid *)pObject)->Get_System());
- }
-
- if( pParameter->Get_Parent()->asGrid_System()->is_Equal(((CSG_Grid *)pObject)->Get_System()) )
- {
- pParameter->asList()->Add_Item(pObject);
- }
- }
- else
- {
- pParameter->asList()->Add_Item(pObject);
- }
- }
- else if( pObject )
- {
- delete(pObject);
-
- Print_Error(LNG("input file"), s);
- }
- }
- while( sList.Length() > 0 );
-
- return( pParameter->asList()->Get_Count() > 0 );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CModule_Library::Add_DataObject(CSG_Data_Object *pObject)
-{
- // leaves unsaved data and a memory leak, if <pObject> is not kept in parameters list either !!!
- // to be done...
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CModule_Library::_Destroy_DataObjects(bool bSave)
-{
- if( m_pSelected && m_pCMD )
- {
- _Destroy_DataObjects(bSave, m_pSelected->Get_Parameters());
-
- for(int i=0; i<m_pSelected->Get_Parameters_Count(); i++)
- {
- // to be done...
- _Destroy_DataObjects(bSave, m_pSelected->Get_Parameters(i));
- }
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CModule_Library::_Destroy_DataObjects(bool bSave, CSG_Parameters *pParameters)
-{
- int i, j;
- CSG_Parameter *pParameter;
- wxString s;
-
- if( pParameters && m_pCMD )
- {
- for(j=0; j<pParameters->Get_Count(); j++)
- {
- pParameter = pParameters->Get_Parameter(j);
-
- if( bSave && pParameter->is_Output() && m_pCMD->Found(GET_ID1(pParameter), &s) )
- {
- if( pParameter->is_DataObject() )
- {
- if( pParameter->asDataObject() )
- {
- pParameter->asDataObject()->Save(s.c_str());
- }
- }
- else if( pParameter->is_DataObject_List() )
- {
- if( pParameter->asList()->Get_Count() == 1 )
- {
- pParameter->asList()->asDataObject(0)->Save(s.c_str());
- }
- else
- {
- for(i=0; i<pParameter->asList()->Get_Count(); i++)
- {
- pParameter->asList()->asDataObject(i)->Save(CSG_String::Format(SG_T("%s_%02d"), s.c_str(), i + 1));
- }
- }
- }
- }
-
- if( pParameter->is_DataObject() )
- {
- if( pParameter->asDataObject() )
- {
- delete(pParameter->asDataObject());
- pParameter->Set_Value(DATAOBJECT_NOTSET);
- }
- }
- else if( pParameter->is_DataObject_List() )
- {
- for(i=pParameter->asList()->Get_Count()-1; i>=0; i--)
- {
- delete(pParameter->asList()->asDataObject(i));
- }
-
- pParameter->asList()->Del_Items();
- }
- }
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+ }
+ while( FileNames.Length() > 0 );
+
+ return( pParameter->asList()->Get_Count() > 0 );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CModule_Library::Add_DataObject(CSG_Data_Object *pObject)
+{
+ m_Data_Objects.Add(pObject);
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CModule_Library::_Destroy_DataObjects(bool bSave)
+{
+ if( m_pSelected && m_pCMD )
+ {
+ _Destroy_DataObjects(bSave, m_pSelected->Get_Parameters());
+
+ for(int i=0; i<m_pSelected->Get_Parameters_Count(); i++)
+ {
+ _Destroy_DataObjects(bSave, m_pSelected->Get_Parameters(i));
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CModule_Library::_Destroy_DataObjects(bool bSave, CSG_Parameters *pParameters)
+{
+ if( !pParameters || !m_pCMD )
+ {
+ return( false );
+ }
+
+ for(int j=0; j<pParameters->Get_Count(); j++)
+ {
+ CSG_Parameter *pParameter = pParameters->Get_Parameter(j);
+
+ wxString FileName;
+
+ if( !bSave || !pParameter->is_Output() || !m_pCMD->Found(GET_ID1(pParameter), &FileName) )
+ {
+ FileName.Clear();
+ }
+
+ //-------------------------------------------------
+ if( pParameter->is_DataObject() && pParameter->asDataObject() )
+ {
+ m_Data_Objects.Add(pParameter->asDataObject());
+
+ if( FileName.Length() > 0 )
+ {
+ pParameter->asDataObject()->Save(FileName.c_str());
+ }
+
+ pParameter->Set_Value(DATAOBJECT_NOTSET);
+ }
+
+ //-------------------------------------------------
+ else if( pParameter->is_DataObject_List() )
+ {
+ for(int i=0; i<pParameter->asList()->Get_Count(); i++)
+ {
+ m_Data_Objects.Add(pParameter->asList()->asDataObject(i));
+
+ if( FileName.Length() > 0 )
+ {
+ if( pParameter->asList()->Get_Count() == 1 )
+ {
+ pParameter->asList()->asDataObject(i)->Save(FileName.c_str());
+ }
+ else
+ {
+ pParameter->asList()->asDataObject(i)->Save(CSG_String::Format(SG_T("%s_%02d"), FileName.c_str(), i + 1));
+ }
+ }
+ }
+
+ pParameter->asList()->Del_Items();
+ }
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CData_Objects::CData_Objects(void)
+{
+ m_pObjects = NULL;
+ m_nObjects = 0;
+}
+
+//---------------------------------------------------------
+CData_Objects::~CData_Objects(void)
+{
+ Clear(false);
+}
+
+//---------------------------------------------------------
+void CData_Objects::Clear(bool bDelete)
+{
+ if( m_pObjects )
+ {
+ if( bDelete )
+ {
+ for(int i=0; i<m_nObjects; i++)
+ {
+ delete(m_pObjects[i]);
+ }
+ }
+
+ SG_Free(m_pObjects);
+
+ m_pObjects = NULL;
+ m_nObjects = 0;
+ }
+}
+
+//---------------------------------------------------------
+void CData_Objects::Add(class CSG_Data_Object *pObject)
+{
+ if( pObject != DATAOBJECT_NOTSET && pObject != DATAOBJECT_CREATE )
+ {
+ for(int i=0; i<m_nObjects; i++)
+ {
+ if( m_pObjects[i] == pObject )
+ {
+ return;
+ }
+ }
+
+ m_pObjects = (CSG_Data_Object **)SG_Realloc(m_pObjects, (m_nObjects + 1) * sizeof(CSG_Data_Object *));
+ m_pObjects[m_nObjects++] = pObject;
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_cmd/module_library.h b/src/saga_core/saga_cmd/module_library.h
index 1da0caa..8f3b56c 100644
--- a/src/saga_core/saga_cmd/module_library.h
+++ b/src/saga_core/saga_cmd/module_library.h
@@ -79,6 +79,33 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+class CData_Objects
+{
+public:
+ CData_Objects(void);
+ virtual ~CData_Objects(void);
+
+ void Clear (bool bDelete = true);
+
+ void Add (class CSG_Data_Object *pObject);
+
+
+private:
+
+ int m_nObjects;
+
+ class CSG_Data_Object **m_pObjects;
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
class CModule_Library
{
public:
@@ -116,11 +143,14 @@ private:
class wxCmdLineParser *m_pCMD;
+ CData_Objects m_Data_Objects;
+
void _Set_CMD (class CSG_Parameters *pParameters, bool bExtra);
bool _Get_CMD (class CSG_Parameters *pParameters);
bool _Create_DataObjects (class CSG_Parameters *pParameters);
+ bool _Create_DataObject (class CSG_Parameter *pParameter, const wxChar *FileName);
bool _Create_DataObject_List (class CSG_Parameter *pParameter, wxString sList);
bool _Destroy_DataObjects (bool bSave);
diff --git a/src/saga_core/saga_cmd/saga_cmd.cpp b/src/saga_core/saga_cmd/saga_cmd.cpp
index e583e14..16df054 100644
--- a/src/saga_core/saga_cmd/saga_cmd.cpp
+++ b/src/saga_core/saga_cmd/saga_cmd.cpp
@@ -61,6 +61,7 @@
#include <wx/app.h>
#include <wx/utils.h>
#include <wx/dir.h>
+#include <wx/filename.h>
#include <saga_api/saga_api.h>
@@ -76,13 +77,14 @@
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define SAGA_CMD_VERSION SG_T("2.0")
-#define SAGA_ENV_LIBPATH SG_T("SAGA_MLB")
+#define SAGA_CMD_VERSION SG_T("2.0.5")
#define SYS_ENV_PATH SG_T("PATH")
-#define OPT_CREATE_BATCH SG_T("-create_batch")
-#define OPT_SILENT SG_T("-silent")
+#define FLAG_SILENT SG_T("s")
+#define FLAG_INTERACT SG_T("i")
+#define FLAG_PROJ SG_T("p")
+#define FLAG_LANGUAGE SG_T("l")
///////////////////////////////////////////////////////////
@@ -97,7 +99,7 @@ bool Execute (const SG_Char *MLB_Path, const SG_Char *FileName, const SG_Char
void Error_Library (const SG_Char *MLB_Path);
void Error_Module (const SG_Char *MLB_Path, const SG_Char *FileName);
-void Print_Logo (const SG_Char *MLB_Path);
+void Print_Logo (void);
void Print_Execution (const SG_Char *MLB_Path, const SG_Char *FileName, const SG_Char *ModuleName, const SG_Char *Author);
void Print_Help (void);
@@ -121,61 +123,117 @@ _try
#endif
//---------------------------------------------------------
- bool bResult = false;
+ if( !wxInitialize() )
+ {
+ Print_Error(SG_T("initialisation failed"));
+
+ return( 1 );
+ }
- if( wxInitialize() )
+ //-----------------------------------------------------
+ wxString Flags, CMD_Path, MLB_Path, ENV_Path;
+
+ if( argc > 1 )
{
- wxString MLB_Path, ENV_Path;
+ CSG_String s(argv[1]);
+
+ if( !s.CmpNoCase(SG_T("-h")) || !s.CmpNoCase(SG_T("--help")) )
+ {
+ Print_Help();
- MLB_Path = wxGetenv(SAGA_ENV_LIBPATH) ? wxGetenv(SAGA_ENV_LIBPATH) : wxGetCwd();
+ return( 0 );
+ }
- if( wxGetEnv(SYS_ENV_PATH, &ENV_Path) && ENV_Path.Length() > 0 )
+ if( !s.CmpNoCase(SG_T("-b")) || !s.CmpNoCase(SG_T("--batch")) )
{
- wxSetEnv(SYS_ENV_PATH, wxString::Format(wxT("%s;%s"), ENV_Path.c_str(), MLB_Path.c_str()));
+ Create_Example();
+
+ return( 0 );
}
- else
+
+ s = s.BeforeFirst(SG_T('='));
+
+ if( !s.CmpNoCase(SG_T("-f")) || !s.CmpNoCase(SG_T("--flags")) )
{
- wxSetEnv(SYS_ENV_PATH, MLB_Path);
+ Flags = CSG_String(argv[1]).AfterFirst(SG_T('=')).c_str();
+
+ argc--;
+ argv++;
}
+ }
+
+ //-----------------------------------------------------
+ CMD_Path = SG_File_Get_Path(SG_UI_Get_Application_Path()).c_str();
- Print_Logo(MLB_Path);
+ if( !wxGetEnv(SG_T("SAGA_MLB"), &MLB_Path) || MLB_Path.Length() == 0 )
+ {
+ MLB_Path = SG_File_Make_Path(CMD_Path, SG_T("modules")) .c_str();
+ #if defined( _SAGA_LINUX)
+ MLB_Path = wxT(MODULE_LIBRARY_PATH);
+ #endif
+ }
- SG_Set_UI_Callback(Get_Callback());
- SG_Get_Translator() .Create(SG_File_Make_Path(wxGetCwd(), wxT("saga"), wxT("lng")), false);
- SG_Get_Projections().Create(SG_File_Make_Path(wxGetCwd(), wxT("saga"), wxT("srs")));
+ if( wxGetEnv(SYS_ENV_PATH, &ENV_Path) && ENV_Path.Length() > 0 )
+ {
+ wxSetEnv(SYS_ENV_PATH, wxString::Format(wxT(";%s;%s"), MLB_Path.c_str(), SG_File_Make_Path(CMD_Path, SG_T("dll")).c_str()));
+ }
+ else
+ {
+ wxSetEnv(SYS_ENV_PATH, wxString::Format(wxT( "%s;%s"), MLB_Path.c_str(), SG_File_Make_Path(CMD_Path, SG_T("dll")).c_str()));
+ }
- //-------------------------------------------------
- switch( argc )
- {
- case 1:
- Error_Library (MLB_Path);
- break;
+ //-----------------------------------------------------
+ SG_Set_UI_Callback(Get_Callback());
- case 2:
- Error_Module (MLB_Path, SG_STR_MBTOSG(argv[1]));
- break;
+ Set_Silent (Flags.Find(FLAG_SILENT ) >= 0 ? true : false);
+ Set_Interactive (Flags.Find(FLAG_INTERACT) >= 0 ? true : false);
- default:
- bResult = Execute (MLB_Path, SG_STR_MBTOSG(argv[1]), SG_STR_MBTOSG(argv[2]), argc, argv);
- break;
- }
+ Print_Logo();
- //-------------------------------------------------
- if( ENV_Path.Length() > 0 )
- {
- wxSetEnv(SYS_ENV_PATH, ENV_Path);
- }
- else
- {
- wxUnsetEnv(SYS_ENV_PATH);
- }
+ if( Flags.Find(FLAG_LANGUAGE) > 0 )
+ {
+ SG_Get_Translator() .Create(SG_File_Make_Path(CMD_Path, SG_T("saga"), SG_T("lng")), false);
+ }
+
+ if( Flags.Find(FLAG_PROJ) > 0 )
+ {
+ SG_Get_Projections().Create(SG_File_Make_Path(CMD_Path, SG_T("saga"), SG_T("srs")));
+ }
+
+ //-----------------------------------------------------
+ bool bResult = false;
+
+ switch( argc )
+ {
+ case 1:
+ Error_Library (MLB_Path);
+ break;
+
+ case 2:
+ Error_Module (MLB_Path, SG_STR_MBTOSG(argv[1]));
+ break;
+
+ default:
+ bResult = Execute (MLB_Path, SG_STR_MBTOSG(argv[1]), SG_STR_MBTOSG(argv[2]), argc - 2, argv + 2);
+ break;
+ }
- wxUninitialize();
+ //-----------------------------------------------------
+ if( ENV_Path.Length() > 0 )
+ {
+ wxSetEnv(SYS_ENV_PATH, ENV_Path);
+ }
+ else
+ {
+ wxUnsetEnv(SYS_ENV_PATH);
}
+ wxUninitialize();
+
//---------------------------------------------------------
#ifdef _DEBUG
+ Set_Interactive(true);
Get_Pause();
#endif
@@ -201,8 +259,6 @@ _except(1)
//---------------------------------------------------------
bool Execute(const SG_Char *MLB_Path, const SG_Char *FileName, const SG_Char *ModuleName, int argc, char *argv[])
{
- bool bResult = false;
- int i;
CModule_Library Library;
if( !Library.Create(FileName, MLB_Path) )
@@ -211,16 +267,12 @@ bool Execute(const SG_Char *MLB_Path, const SG_Char *FileName, const SG_Char *M
}
else if( !Library.Select(ModuleName) )
{
- Library.Destroy();
-
Print_Error(LNG("module not found"), ModuleName);
Error_Module(MLB_Path, FileName);
}
else if( Library.Get_Selected()->is_Interactive() )
{
- Library.Destroy();
-
Print_Error(LNG("cannot execute interactive module"), ModuleName);
Error_Module(MLB_Path, FileName);
@@ -229,23 +281,19 @@ bool Execute(const SG_Char *MLB_Path, const SG_Char *FileName, const SG_Char *M
{
Print_Execution(MLB_Path, FileName, Library.Get_Selected()->Get_Name(), Library.Get_Selected()->Get_Author());
- if( argc > 3 && !SG_STR_CMP(OPT_SILENT, SG_STR_MBTOSG(argv[3])) )
- {
- i = 3;
+ Set_Library(&Library);
- Set_Silent(true);
- }
- else
+ if( Library.Execute(argc, argv) )
{
- i = 2;
+ Set_Library(NULL);
+
+ return( true );
}
- Set_Library(&Library);
- bResult = Library.Execute(argc - i, argv + i);
Set_Library(NULL);
}
- return( bResult );
+ return( false );
}
@@ -268,7 +316,8 @@ void Error_Library (const SG_Char *MLB_Path)
Print_Error(LNG("invalid module libraries path"), MLB_Path);
}
else if( !Dir.GetFirst(&FileName, wxT("*.dll"), wxDIR_FILES|wxDIR_HIDDEN)
- && !Dir.GetFirst(&FileName, wxT("*.so" ), wxDIR_FILES|wxDIR_HIDDEN) )
+ && !Dir.GetFirst(&FileName, wxT("*.so" ), wxDIR_FILES|wxDIR_HIDDEN)
+ && !Dir.GetFirst(&FileName, wxT("*.dylib" ), wxDIR_FILES|wxDIR_HIDDEN))
{
Print_Error(LNG("no valid module library found in path"), MLB_Path);
}
@@ -276,26 +325,32 @@ void Error_Library (const SG_Char *MLB_Path)
{
Print_Error(LNG("module library"));
- SG_PRINTF(SG_T("\n%s:\n"), LNG("available module libraries"));
+ if( !Get_Silent() )
+ {
+ SG_PRINTF(SG_T("\n%s:\n"), LNG("available module libraries"));
- nLibraries = 0;
+ nLibraries = 0;
- do
- {
- if( Library.Create(FileName, Dir.GetName()) )
+ do
{
- SG_PRINTF(SG_T("- %s\n"), FileName.c_str());
- nLibraries++;
+ if( Library.Create(FileName, Dir.GetName()) )
+ {
+ SG_PRINTF(SG_T("- %s\n"), FileName.c_str());
+ nLibraries++;
+ }
}
- }
- while( Dir.GetNext(&FileName) );
+ while( Dir.GetNext(&FileName) );
- SG_PRINTF(SG_T("\n%d %s\n"), nLibraries, LNG("SAGA Module Libraries"));
+ SG_PRINTF(SG_T("\n%d %s\n"), nLibraries, LNG("SAGA Module Libraries"));
+ }
}
- SG_PRINTF(SG_T("\n"));
- SG_PRINTF(LNG("type -h or --help for further information"));
- SG_PRINTF(SG_T("\n"));
+ if( !Get_Silent() )
+ {
+ SG_PRINTF(SG_T("\n"));
+ SG_PRINTF(LNG("type -h or --help for further information"));
+ SG_PRINTF(SG_T("\n"));
+ }
}
//---------------------------------------------------------
@@ -303,40 +358,32 @@ void Error_Module (const SG_Char *MLB_Path, const SG_Char *FileName)
{
CModule_Library Library;
- if( !SG_STR_CMP(SG_T("-h"), FileName) || !SG_STR_CMP(SG_T("--help"), FileName) )
- {
- Print_Help();
- }
- else if( !SG_STR_CMP(OPT_CREATE_BATCH, FileName) )
- {
- Create_Example();
- }
- else
+ if( !Library.Create(FileName, MLB_Path) )
{
- if( !Library.Create(FileName, MLB_Path) )
- {
- Library.Destroy();
+ Library.Destroy();
- Print_Error(LNG("module library not found"), FileName);
+ Print_Error(LNG("module library not found"), FileName);
- Error_Library(MLB_Path);
- }
- else
- {
- Print_Error(LNG("module"));
+ Error_Library(MLB_Path);
+
+ return;
+ }
+
+ Print_Error(LNG("module"));
- SG_PRINTF(SG_T("\n%s:\n"), LNG("available modules"));
+ if( !Get_Silent() )
+ {
+ SG_PRINTF(SG_T("\n%s:\n"), LNG("available modules"));
- for(int i=0; i<Library.Get_Count(); i++)
+ for(int i=0; i<Library.Get_Count(); i++)
+ {
+ if( Library.Get_Module(i)->is_Interactive() )
{
- if( Library.Get_Module(i)->is_Interactive() )
- {
- SG_PRINTF(SG_T("[%d]\t- [%s] %s\n"), i, LNG("interactive"), Library.Get_Module(i)->Get_Name());
- }
- else
- {
- SG_PRINTF(SG_T(" %d\t- %s\n"), i, Library.Get_Module(i)->Get_Name());
- }
+ SG_PRINTF(SG_T("[%d]\t- [%s] %s\n"), i, LNG("interactive"), Library.Get_Module(i)->Get_Name());
+ }
+ else
+ {
+ SG_PRINTF(SG_T(" %d\t- %s\n"), i, Library.Get_Module(i)->Get_Name());
}
}
@@ -354,22 +401,27 @@ void Error_Module (const SG_Char *MLB_Path, const SG_Char *FileName)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-void Print_Logo (const SG_Char *MLB_Path)
+void Print_Logo (void)
{
+ if( Get_Silent() )
+ return;
+
SG_PRINTF(SG_T("_____________________________________________\n"));
SG_PRINTF(SG_T(" ##### ## ##### ##\n"));
SG_PRINTF(SG_T(" ### ### ## ###\n"));
SG_PRINTF(SG_T(" ### # ## ## #### # ##\n"));
SG_PRINTF(SG_T(" ### ##### ## # #####\n"));
SG_PRINTF(SG_T("##### # ## ##### # ##\n"));
- SG_PRINTF(SG_T("\n"));
- SG_PRINTF(SG_T("SAGA CMD ") SAGA_API_VERSION SG_T("\n"));
SG_PRINTF(SG_T("_____________________________________________\n"));
+ SG_PRINTF(SG_T("\n"));
}
//---------------------------------------------------------
void Print_Execution (const SG_Char *MLB_Path, const SG_Char *FileName, const SG_Char *ModuleName, const SG_Char *Author)
{
+ if( Get_Silent() )
+ return;
+
SG_PRINTF(SG_T("%s:\t%s\n"), LNG("library path"), MLB_Path);
SG_PRINTF(SG_T("%s:\t%s\n"), LNG("library name"), FileName);
SG_PRINTF(SG_T("%s:\t%s\n"), LNG("module name "), ModuleName);
@@ -381,24 +433,32 @@ void Print_Execution (const SG_Char *MLB_Path, const SG_Char *FileName, const S
//---------------------------------------------------------
void Print_Help (void)
{
+ Print_Logo();
+
SG_PRINTF(
- SG_T("(C) 2005-08 by O.Conrad\n")
+ SG_T("SAGA API ") SAGA_API_VERSION SG_T("\n")
+ SG_T("SAGA CMD ") SAGA_CMD_VERSION SG_T("\n")
SG_T("under GNU General Public License (GPL)\n")
+ SG_T("O.Conrad (C) 2005-10\n")
SG_T("\n")
SG_T("Usage:\n")
SG_T("\n")
SG_T("saga_cmd [-h, --help]\n")
- SG_T("saga_cmd [") OPT_CREATE_BATCH SG_T("]\n")
- SG_T("saga_cmd <LIBRARY> <MODULE> [") OPT_SILENT SG_T("] <module specific options...>\n")
+ SG_T("saga_cmd [-b, --batch]\n")
+ SG_T("saga_cmd [-f, --flags][=silp] <LIBRARY> <MODULE> <module specific options...>\n")
SG_T("\n")
- SG_T("[-h], [--help]\t") SG_T(": help on usage\n")
- SG_T("[") OPT_CREATE_BATCH SG_T("]\t") SG_T(": create a batch file example\n")
- SG_T("[") OPT_SILENT SG_T("]\t") SG_T(": don't wait for user response on errors\n")
- SG_T("<LIBRARY>\t") SG_T(": file name of the library\n")
- SG_T("<MODULE>\t") SG_T(": either name or index of the module\n")
+ SG_T("[-h], [--help ]: help on usage\n")
+ SG_T("[-b], [--batch]: create a batch file example\n")
+ SG_T("[-f], [--flags]: various flags for general usage\n")
+ SG_T(" s: silent mode\n")
+ SG_T(" i: allow user interaction\n")
+ SG_T(" l: load translation dictionary\n")
+ SG_T(" p: load projections dictionary\n")
+ SG_T("<LIBRARY>\t") SG_T(": file name of the library\n")
+ SG_T("<MODULE>\t") SG_T(": either name or index of the module\n")
SG_T("\n")
SG_T("example:\n")
- SG_T(" saga_cmd ta_morphometry \n")
+ SG_T(" saga_cmd -f=sp ta_morphometry \n")
SG_T(" \"Local Morphometry\"\n")
SG_T(" -ELEVATION c:\\dem.sgrd\n")
SG_T(" -SLOPE d:\\slope.sgrd\n")
@@ -406,15 +466,16 @@ void Print_Help (void)
SG_T(" -METHOD 1\n")
SG_T("\n")
SG_T("_____________________________________________\n")
- SG_T("Module libraries are expected to be located in\n")
- SG_T("the directory, that is specified by the environment\n")
- SG_T("variable \'") SAGA_ENV_LIBPATH SG_T("\'. If this is not found the\n")
- SG_T("current working directory will be searched for instead.\n")
+ SG_T("Module libraries are expected to be in the SAGA installation\n")
+ SG_T("directory or its \'modules\' subdirectory. If this is not found\n")
+ SG_T("the current working directory will be searched for instead.\n")
+ SG_T("Alternatively you can add the environment variable \'SAGA_MLB\'\n")
+ SG_T("and let it point to the desired directory\n")
SG_T("\n")
SG_T("SAGA CMD is particularly useful for the automated\n")
SG_T("execution of a series of analysis steps, because it\n")
SG_T("allows you to execute modules using batch files.\n")
- SG_T("Calling saga_cmd with the option \'") OPT_CREATE_BATCH SG_T("\'\n")
+ SG_T("Calling saga_cmd with the option \'-b\' or \'--batch\'\n")
SG_T("creates a batch file example. You probably have to edit\n")
SG_T("the path definitions to make the batch file run on your\n")
SG_T("computer.\n")
@@ -436,61 +497,61 @@ void Create_Example (void)
SG_PRINTF(SG_T("\n%s...\n"), LNG("creating batch file example"));
- if( Stream.Open(FileName, SG_FILE_W, false) )
- {
- Stream.Printf(
- SG_T("@echo off\n")
- SG_T("\n")
- SG_T("set SAGA=.\n")
- SG_T("set SAGA_MLB=%%SAGA%%\\modules\n")
- SG_T("PATH=PATH;%%SAGA%%;%%SAGA_MLB%%\n")
- SG_T("\n")
- SG_T("if exist .\\srtm.asc goto :SRTM\n")
- SG_T("echo _____________________________________________\n")
- SG_T("echo import SRTM-DEM from ESRI ASCII grid\n")
- SG_T("saga_cmd.exe recreations_fractals 5 -GRID .\\dem.sgrd -NX 400 -NY 400 -H 0.75\n")
- SG_T("\n")
- SG_T("goto :GO\n")
- SG_T("\n")
- SG_T(":SRTM\n")
- SG_T("echo _____________________________________________\n")
- SG_T("echo import SRTM-DEM from ESRI ASCII grid\n")
- SG_T("saga_cmd.exe io_grid 1 -FILE .\\srtm.asc -GRID .\\srtm.sgrd\n")
- SG_T("\n")
- SG_T("echo _____________________________________________\n")
- SG_T("echo projection from geodetic to UTM zone 32\n")
- SG_T("\n")
- SG_T("saga_cmd.exe pj_proj4 1 -SOURCE .\\srtm.sgrd -OUT_GRID .\\dem.sgrd -PROJ_TYPE 109 -utm_zone 32 -TARGET_TYPE 1 -GET_AUTOFIT_GRIDSIZE 90.0\n")
- SG_T("\n")
- SG_T(":GO\n")
- SG_T("echo _____________________________________________\n")
- SG_T("echo create contour lines from DEM\n")
- SG_T("\n")
- SG_T("saga_cmd.exe shapes_grid 5 -INPUT .\\dem.sgrd -CONTOUR .\\contour.shp -ZSTEP 25.0\n")
- SG_T("\n")
- SG_T("echo _____________________________________________\n")
- SG_T("echo do some terrain analysis\n")
- SG_T("\n")
- SG_T("saga_cmd.exe ta_preprocessor 1 -DEM .\\dem.sgrd -DEM_PREPROC .\\dem.sgrd\n")
- SG_T("saga_cmd.exe ta_lighting 0 -ELEVATION .\\dem.sgrd -SHADE .\\shade.sgrd -METHOD 0 -AZIMUTH -45 -DECLINATION 45\n")
- SG_T("saga_cmd.exe ta_morphometry 0 -ELEVATION .\\dem.sgrd -SLOPE .\\slope.sgrd -ASPECT .\\aspect.sgrd -HCURV .\\hcurv.sgrd -VCURV .\\vcurv.sgrd\n")
- SG_T("saga_cmd.exe ta_hydrology 0 -ELEVATION .\\dem.sgrd -CAREA .\\carea.sgrd\n")
- SG_T("saga_cmd.exe ta_hydrology 14 -SLOPE .\\slope.sgrd -AREA .\\carea.sgrd -WETNESS .\\wetness.sgrd -STREAMPOW .\\streampow.sgrd -LSFACTOR .\\lsfactor.sgrd\n")
- SG_T("\n")
- SG_T("echo _____________________________________________\n")
- SG_T("echo perform cluster analysis\n")
- SG_T("\n")
- SG_T("saga_cmd.exe grid_discretisation 1 -INPUT .\\dem.sgrd;.\\slope.sgrd;.\\hcurv.sgrd;.\\vcurv.sgrd -RESULT .\\cluster.sgrd -STATISTICS .\\cluster.txt -NORMALISE -NCLUSTER 10\n")
- SG_T("\n")
- SG_T("pause\n")
- );
-
- SG_PRINTF(SG_T("%s\n"), LNG("okay"));
- }
- else
+ if( !Stream.Open(FileName, SG_FILE_W, false) )
{
SG_PRINTF(SG_T("%s\n"), LNG("failed"));
+
+ return;
}
+
+ Stream.Printf(
+ SG_T("@echo off\n")
+ SG_T("\n")
+ SG_T("set SAGA=.\n")
+ SG_T("set SAGA_MLB=%%SAGA%%\\modules\n")
+ SG_T("PATH=PATH;%%SAGA%%;%%SAGA_MLB%%\n")
+ SG_T("\n")
+ SG_T("if exist .\\srtm.asc goto :SRTM\n")
+ SG_T("echo _____________________________________________\n")
+ SG_T("echo import SRTM-DEM from ESRI ASCII grid\n")
+ SG_T("saga_cmd.exe recreations_fractals 5 -GRID .\\dem.sgrd -NX 400 -NY 400 -H 0.75\n")
+ SG_T("\n")
+ SG_T("goto :GO\n")
+ SG_T("\n")
+ SG_T(":SRTM\n")
+ SG_T("echo _____________________________________________\n")
+ SG_T("echo import SRTM-DEM from ESRI ASCII grid\n")
+ SG_T("saga_cmd.exe io_grid 1 -FILE .\\srtm.asc -GRID .\\srtm.sgrd\n")
+ SG_T("\n")
+ SG_T("echo _____________________________________________\n")
+ SG_T("echo projection from geodetic to UTM zone 32\n")
+ SG_T("\n")
+ SG_T("saga_cmd.exe pj_proj4 1 -SOURCE .\\srtm.sgrd -OUT_GRID .\\dem.sgrd -PROJ_TYPE 109 -utm_zone 32 -TARGET_TYPE 1 -GET_AUTOFIT_GRIDSIZE 90.0\n")
+ SG_T("\n")
+ SG_T(":GO\n")
+ SG_T("echo _____________________________________________\n")
+ SG_T("echo create contour lines from DEM\n")
+ SG_T("\n")
+ SG_T("saga_cmd.exe shapes_grid 5 -INPUT .\\dem.sgrd -CONTOUR .\\contour.shp -ZSTEP 25.0\n")
+ SG_T("\n")
+ SG_T("echo _____________________________________________\n")
+ SG_T("echo do some terrain analysis\n")
+ SG_T("\n")
+ SG_T("saga_cmd.exe ta_preprocessor 1 -DEM .\\dem.sgrd -DEM_PREPROC .\\dem.sgrd\n")
+ SG_T("saga_cmd.exe ta_lighting 0 -ELEVATION .\\dem.sgrd -SHADE .\\shade.sgrd -METHOD 0 -AZIMUTH -45 -DECLINATION 45\n")
+ SG_T("saga_cmd.exe ta_morphometry 0 -ELEVATION .\\dem.sgrd -SLOPE .\\slope.sgrd -ASPECT .\\aspect.sgrd -HCURV .\\hcurv.sgrd -VCURV .\\vcurv.sgrd\n")
+ SG_T("saga_cmd.exe ta_hydrology 0 -ELEVATION .\\dem.sgrd -CAREA .\\carea.sgrd\n")
+ SG_T("saga_cmd.exe ta_hydrology 14 -SLOPE .\\slope.sgrd -AREA .\\carea.sgrd -WETNESS .\\wetness.sgrd -STREAMPOW .\\streampow.sgrd -LSFACTOR .\\lsfactor.sgrd\n")
+ SG_T("\n")
+ SG_T("echo _____________________________________________\n")
+ SG_T("echo perform cluster analysis\n")
+ SG_T("\n")
+ SG_T("saga_cmd.exe grid_discretisation 1 -INPUT .\\dem.sgrd;.\\slope.sgrd;.\\hcurv.sgrd;.\\vcurv.sgrd -RESULT .\\cluster.sgrd -STATISTICS .\\cluster.txt -NORMALISE -NCLUSTER 10\n")
+ SG_T("\n")
+ SG_T("pause\n")
+ );
+
+ SG_PRINTF(SG_T("%s\n"), LNG("okay"));
}
diff --git a/src/saga_core/saga_gdi/Makefile.am b/src/saga_core/saga_gdi/Makefile.am
index 72ccdeb..59c9adc 100644
--- a/src/saga_core/saga_gdi/Makefile.am
+++ b/src/saga_core/saga_gdi/Makefile.am
@@ -12,7 +12,8 @@ DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
AM_LDFLAGS = $(DEP_LFLG)
-pkglib_LTLIBRARIES = libsaga_gdi.la
+lib_LTLIBRARIES = libsaga_gdi.la
+libsaga_gdi_la_LDFLAGS=$(AM_LDFLAGS) -release $(VERSION)
libsaga_gdi_la_SOURCES =\
sgdi_diagram.cpp\
sgdi_dialog.cpp\
diff --git a/src/saga_core/saga_gdi/Makefile.in b/src/saga_core/saga_gdi/Makefile.in
index fb9edab..d3e60d8 100644
--- a/src/saga_core/saga_gdi/Makefile.in
+++ b/src/saga_core/saga_gdi/Makefile.in
@@ -41,7 +41,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
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'`;
@@ -65,14 +64,17 @@ am__nobase_list = $(am__nobase_strip_setup); \
am__base_list = \
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-am__installdirs = "$(DESTDIR)$(pkglibdir)"
-LTLIBRARIES = $(pkglib_LTLIBRARIES)
+am__installdirs = "$(DESTDIR)$(libdir)"
+LTLIBRARIES = $(lib_LTLIBRARIES)
libsaga_gdi_la_DEPENDENCIES = \
$(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
am_libsaga_gdi_la_OBJECTS = sgdi_diagram.lo sgdi_dialog.lo \
sgdi_helper.lo saga_gdi.lo
libsaga_gdi_la_OBJECTS = $(am_libsaga_gdi_la_OBJECTS)
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+libsaga_gdi_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(libsaga_gdi_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -118,6 +120,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -127,6 +130,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -224,7 +228,8 @@ DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
CXX_INCS = -I$(top_srcdir)/src/saga_core
AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
AM_LDFLAGS = $(DEP_LFLG)
-pkglib_LTLIBRARIES = libsaga_gdi.la
+lib_LTLIBRARIES = libsaga_gdi.la
+libsaga_gdi_la_LDFLAGS = $(AM_LDFLAGS) -release $(VERSION)
libsaga_gdi_la_SOURCES = \
sgdi_diagram.cpp\
sgdi_dialog.cpp\
@@ -270,39 +275,39 @@ $(top_srcdir)/configure: $(am__configure_deps)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
-install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
- test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
- @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
list2="$$list2 $$p"; \
else :; fi; \
done; \
test -z "$$list2" || { \
- echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \
- $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
}
-uninstall-pkglibLTLIBRARIES:
+uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
- @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
for p in $$list; do \
$(am__strip_dir) \
- echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \
- $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
done
-clean-pkglibLTLIBRARIES:
- -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
- @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libsaga_gdi.la: $(libsaga_gdi_la_OBJECTS) $(libsaga_gdi_la_DEPENDENCIES)
- $(CXXLINK) -rpath $(pkglibdir) $(libsaga_gdi_la_OBJECTS) $(libsaga_gdi_la_LIBADD) $(LIBS)
+ $(libsaga_gdi_la_LINK) -rpath $(libdir) $(libsaga_gdi_la_OBJECTS) $(libsaga_gdi_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -428,7 +433,7 @@ check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES)
installdirs:
- for dir in "$(DESTDIR)$(pkglibdir)"; do \
+ for dir in "$(DESTDIR)$(libdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
@@ -458,7 +463,7 @@ maintainer-clean-generic:
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
-clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
mostlyclean-am
distclean: distclean-am
@@ -485,7 +490,7 @@ install-dvi: install-dvi-am
install-dvi-am:
-install-exec-am: install-pkglibLTLIBRARIES
+install-exec-am: install-libLTLIBRARIES
install-html: install-html-am
@@ -525,23 +530,23 @@ ps: ps-am
ps-am:
-uninstall-am: uninstall-pkglibLTLIBRARIES
+uninstall-am: uninstall-libLTLIBRARIES
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
+ clean-libLTLIBRARIES clean-libtool ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \
install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf install-pdf-am install-pkglibLTLIBRARIES \
+ install-html-am install-info install-info-am \
+ install-libLTLIBRARIES install-man install-pdf 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 uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+ tags uninstall uninstall-am uninstall-libLTLIBRARIES
# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/src/saga_core/saga_gui/Makefile.am b/src/saga_core/saga_gui/Makefile.am
index 4642d88..ffee122 100644
--- a/src/saga_core/saga_gui/Makefile.am
+++ b/src/saga_core/saga_gui/Makefile.am
@@ -1,13 +1,14 @@
#
-# $Id: Makefile.am,v 1.17 2009/09/01 14:12:31 oconrad Exp $
+# $Id: Makefile.am,v 1.20 2010/07/22 12:47:13 johanvdw Exp $
#
INCS = -I.. -I.
if DEBUG
DBGFLAGS = -g -DDEBUG
endif
MLIBPATH = "MODULE_LIBRARY_PATH=\"$(prefix)/lib/saga\""
+MSHAREPATH = "SHARE_PATH=\"$(prefix)/share/saga\""
-BASEFLAGS = -fPIC -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_DONOTUSE_HARU -D$(MLIBPATH) $(DBGFLAGS) $(INCS)
+BASEFLAGS = -fPIC -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_DONOTUSE_HARU -D$(MLIBPATH) -D$(MSHAREPATH) $(DBGFLAGS) $(INCS)
if SAGA_UNICODE
AM_CXXFLAGS = $(BASEFLAGS) `wx-config --unicode=yes --cxxflags` -D_SAGA_UNICODE
AM_LDFLAGS = -fPIC `wx-config --unicode=yes --libs` -lm
@@ -218,8 +219,10 @@ wx/propgrid/propgrid.h\
wx/propgrid/props.cpp\
wx/propgrid/props.h
-saga_gui_LDADD = ../saga_api/libsaga_api.la
+saga_gui_LDADD = ../saga_api/libsaga_api.la ../saga_odbc/libsaga_odbc.la
dist-hook:
mkdir $(distdir)/res
cp -Rp $(srcdir)/res/* $(distdir)/res/
+
+SUBDIRS=man
diff --git a/src/saga_core/saga_gui/Makefile.in b/src/saga_core/saga_gui/Makefile.in
index 7d617b1..a93ec78 100644
--- a/src/saga_core/saga_gui/Makefile.in
+++ b/src/saga_core/saga_gui/Makefile.in
@@ -42,7 +42,6 @@ am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
@@ -96,8 +95,9 @@ am_saga_gui_OBJECTS = active.$(OBJEXT) active_attributes.$(OBJEXT) \
manager.$(OBJEXT) odcombo.$(OBJEXT) propgrid.$(OBJEXT) \
props.$(OBJEXT)
saga_gui_OBJECTS = $(am_saga_gui_OBJECTS)
-saga_gui_DEPENDENCIES = ../saga_api/libsaga_api.la
-DEFAULT_INCLUDES = -I. at am__isrc@ -I$(top_builddir)
+saga_gui_DEPENDENCIES = ../saga_api/libsaga_api.la \
+ ../saga_odbc/libsaga_odbc.la
+DEFAULT_INCLUDES = -I. at am__isrc@
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
am__mv = mv -f
@@ -121,9 +121,47 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(saga_gui_SOURCES)
DIST_SOURCES = $(saga_gui_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+ distdir
ETAGS = etags
CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
@@ -143,6 +181,7 @@ CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
ECHO_C = @ECHO_C@
@@ -152,6 +191,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
+HARU_LIB = @HARU_LIB@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -242,12 +282,13 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
#
-# $Id: Makefile.am,v 1.17 2009/09/01 14:12:31 oconrad Exp $
+# $Id: Makefile.am,v 1.20 2010/07/22 12:47:13 johanvdw Exp $
#
INCS = -I.. -I.
@DEBUG_TRUE at DBGFLAGS = -g -DDEBUG
MLIBPATH = "MODULE_LIBRARY_PATH=\"$(prefix)/lib/saga\""
-BASEFLAGS = -fPIC -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_DONOTUSE_HARU -D$(MLIBPATH) $(DBGFLAGS) $(INCS)
+MSHAREPATH = "SHARE_PATH=\"$(prefix)/share/saga\""
+BASEFLAGS = -fPIC -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_DONOTUSE_HARU -D$(MLIBPATH) -D$(MSHAREPATH) $(DBGFLAGS) $(INCS)
@SAGA_UNICODE_FALSE at AM_CXXFLAGS = $(BASEFLAGS) `wx-config --unicode=no --cxxflags`
@SAGA_UNICODE_TRUE at AM_CXXFLAGS = $(BASEFLAGS) `wx-config --unicode=yes --cxxflags` -D_SAGA_UNICODE
@SAGA_UNICODE_FALSE at AM_LDFLAGS = -fPIC `wx-config --unicode=no --libs` -lm
@@ -452,8 +493,9 @@ wx/propgrid/propgrid.h\
wx/propgrid/props.cpp\
wx/propgrid/props.h
-saga_gui_LDADD = ../saga_api/libsaga_api.la
-all: all-am
+saga_gui_LDADD = ../saga_api/libsaga_api.la ../saga_odbc/libsaga_odbc.la
+SUBDIRS = man
+all: all-recursive
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
@@ -765,6 +807,76 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
@@ -775,10 +887,23 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
mkid -fID $$unique
tags: TAGS
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
set x; \
here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
@@ -797,7 +922,7 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
fi; \
fi
ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
@@ -847,25 +972,54 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$(top_distdir)" distdir="$(distdir)" \
dist-hook
check-am: all-am
-check: check-am
+check: check-recursive
all-am: Makefile $(PROGRAMS)
-installdirs:
+installdirs: installdirs-recursive
+installdirs-am:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-installcheck: installcheck-am
+installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
@@ -882,91 +1036,94 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
+clean: clean-recursive
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
-distclean: distclean-am
+distclean: distclean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
-dvi: dvi-am
+dvi: dvi-recursive
dvi-am:
-html: html-am
+html: html-recursive
html-am:
-info: info-am
+info: info-recursive
info-am:
install-data-am:
-install-dvi: install-dvi-am
+install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am: install-binPROGRAMS
-install-html: install-html-am
+install-html: install-html-recursive
install-html-am:
-install-info: install-info-am
+install-info: install-info-recursive
install-info-am:
install-man:
-install-pdf: install-pdf-am
+install-pdf: install-pdf-recursive
install-pdf-am:
-install-ps: install-ps-am
+install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
-maintainer-clean: maintainer-clean-am
+maintainer-clean: maintainer-clean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
-mostlyclean: mostlyclean-am
+mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
-pdf: pdf-am
+pdf: pdf-recursive
pdf-am:
-ps: ps-am
+ps: ps-recursive
ps-am:
uninstall-am: uninstall-binPROGRAMS
-.MAKE: install-am install-strip
-
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
- clean-generic clean-libtool ctags dist-hook distclean \
- distclean-compile distclean-generic distclean-libtool \
- distclean-tags distdir dvi dvi-am html html-am info info-am \
- install install-am install-binPROGRAMS install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-pdf 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 uninstall uninstall-am uninstall-binPROGRAMS
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+ install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+ all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-libtool ctags ctags-recursive dist-hook \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-binPROGRAMS \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am 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 tags tags-recursive uninstall uninstall-am \
+ uninstall-binPROGRAMS
dist-hook:
diff --git a/src/saga_core/saga_gui/callback.cpp b/src/saga_core/saga_gui/callback.cpp
index 4e74a8e..fd79560 100644
--- a/src/saga_core/saga_gui/callback.cpp
+++ b/src/saga_core/saga_gui/callback.cpp
@@ -62,6 +62,7 @@
#include "helper.h"
#include "wksp_data_manager.h"
+#include "wksp_module.h"
#include "callback.h"
@@ -141,6 +142,23 @@ int Callback(TSG_UI_Callback_ID ID, long Param_1, long Param_2)
///////////////////////////////////////////////////////
//-----------------------------------------------------
+ case CALLBACK_STOP_EXECUTION:
+
+ if( g_pModule && g_pModule->is_Executing() )
+ {
+ Result = g_pModule->Execute(false) ? 1 : 0;
+ }
+
+ break;
+
+
+ ///////////////////////////////////////////////////////
+ // //
+ // //
+ // //
+ ///////////////////////////////////////////////////////
+
+ //-----------------------------------------------------
case CALLBACK_MESSAGE_ADD:
iArray = (int *)Param_2;
@@ -323,6 +341,15 @@ int Callback(TSG_UI_Callback_ID ID, long Param_1, long Param_2)
Result = (long)MDI_Get_Frame();
break;
+
+
+ ///////////////////////////////////////////////////////
+ // //
+ // //
+ // //
+ ///////////////////////////////////////////////////////
+
+ //-----------------------------------------------------
}
return( Result );
diff --git a/src/saga_core/saga_gui/dc_helper.cpp b/src/saga_core/saga_gui/dc_helper.cpp
index 426bf13..ec0fc77 100644
--- a/src/saga_core/saga_gui/dc_helper.cpp
+++ b/src/saga_core/saga_gui/dc_helper.cpp
@@ -338,8 +338,18 @@ void Draw_Scale(wxDC &dc, wxRect r, double zMin, double zMax, bool bHorizontal,
//-------------------------------------------------
z = dz * floor(zMin / dz);
- if( Style != 0 && z < zMin ) z += dz;
+ if( Style != 0 && z < zMin )
+ {
+ z += dz;
+ }
+
+ if( z == z + dz )
+ {
+ return;
+ }
+
+ //-------------------------------------------------
for(; z<=zMax; z+=dz)
{
s.Printf(wxT("%.*f"), Decimals, z);
diff --git a/src/saga_core/saga_gui/dlg_about.cpp b/src/saga_core/saga_gui/dlg_about.cpp
index 51f3ee3..d24a7ed 100644
--- a/src/saga_core/saga_gui/dlg_about.cpp
+++ b/src/saga_core/saga_gui/dlg_about.cpp
@@ -209,7 +209,7 @@ wxString CDLG_About::_Get_Version(void)
s.Append(wxString::Format(
wxT("SAGA GUI\nSAGA Graphical User Interface - Version: %s\n")
wxT("\n")
- wxT("Copyrights (c) 2005-2008 by Olaf Conrad\n")
+ wxT("Copyrights (c) 2005-2009 by Olaf Conrad\n")
wxT("\n")
wxT("GNU General Public License (GPL)\n"),
SAGA_GUI_Get_Version()
@@ -342,6 +342,7 @@ wxString CDLG_About::_Get_Acknowledgements(void)
"Olaf Conrad\n"
"Frank Haselein\n"
"Tobias Heckmann\n"
+ "Philipp J. Hess\n"
"Ruediger Koethe\n"
"Angela Kreikemeyer\n"
"Stefan Liersch\n"
diff --git a/src/saga_core/saga_gui/dlg_list_base.cpp b/src/saga_core/saga_gui/dlg_list_base.cpp
index 5d1bce6..1d4e617 100644
--- a/src/saga_core/saga_gui/dlg_list_base.cpp
+++ b/src/saga_core/saga_gui/dlg_list_base.cpp
@@ -63,6 +63,11 @@
#include "res_controls.h"
#include "wksp_data_manager.h"
+#include "wksp_grid.h"
+#include "wksp_table.h"
+#include "wksp_shapes.h"
+#include "wksp_tin.h"
+#include "wksp_pointcloud.h"
#include "dlg_list_base.h"
@@ -100,8 +105,8 @@ CDLG_List_Base::CDLG_List_Base(CSG_Parameter_List *pList, wxString Caption)
{
m_pList = pList;
- m_pSelect = new wxListBox (this, ID_LISTBOX_SELECT, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_MULTIPLE|wxLB_NEEDED_SB|wxLB_SORT); // |wxLB_EXTENDED
- m_pAdd = new wxListBox (this, ID_LISTBOX_ADD , wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_MULTIPLE|wxLB_NEEDED_SB);
+ m_pSelect = new wxListBox (this, ID_LISTBOX_SELECT, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_NEEDED_SB|wxLB_SORT); // |wxLB_EXTENDED
+ m_pAdd = new wxListBox (this, ID_LISTBOX_ADD , wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_NEEDED_SB);
m_pBtn_Add = new wxButton (this, ID_BTN_ADD , wxT(">>"));
m_pBtn_Del = new wxButton (this, ID_BTN_DELETE, wxT("<<"));
@@ -115,9 +120,11 @@ CDLG_List_Base::CDLG_List_Base(CSG_Parameter_List *pList, wxString Caption)
switch( m_pList->Get_Type() )
{
- case PARAMETER_TYPE_Grid_List: Type = DATAOBJECT_TYPE_Grid; break;
- case PARAMETER_TYPE_Table_List: Type = DATAOBJECT_TYPE_Table; break;
- case PARAMETER_TYPE_Shapes_List: Type = DATAOBJECT_TYPE_Shapes; break;
+ case PARAMETER_TYPE_Grid_List: Type = DATAOBJECT_TYPE_Grid; break;
+ case PARAMETER_TYPE_Table_List: Type = DATAOBJECT_TYPE_Table; break;
+ case PARAMETER_TYPE_Shapes_List: Type = DATAOBJECT_TYPE_Shapes; break;
+ case PARAMETER_TYPE_TIN_List: Type = DATAOBJECT_TYPE_TIN; break;
+ case PARAMETER_TYPE_PointCloud_List: Type = DATAOBJECT_TYPE_PointCloud; break;
default: return;
}
@@ -179,7 +186,15 @@ void CDLG_List_Base::Save_Changes(void)
for(unsigned int i=0; i<m_pAdd->GetCount(); i++)
{
- m_pList->Add_Item((CSG_Data_Object *)m_pAdd->GetClientData(i));
+ switch( m_pList->Get_Type() )
+ {
+ case PARAMETER_TYPE_Grid_List: m_pList->Add_Item(((CWKSP_Grid *)m_pAdd->GetClientData(i))->Get_Grid ()); break;
+ case PARAMETER_TYPE_Table_List: m_pList->Add_Item(((CWKSP_Table *)m_pAdd->GetClientData(i))->Get_Table ()); break;
+ case PARAMETER_TYPE_Shapes_List: m_pList->Add_Item(((CWKSP_Shapes *)m_pAdd->GetClientData(i))->Get_Shapes ()); break;
+ case PARAMETER_TYPE_TIN_List: m_pList->Add_Item(((CWKSP_TIN *)m_pAdd->GetClientData(i))->Get_TIN ()); break;
+ case PARAMETER_TYPE_PointCloud_List: m_pList->Add_Item(((CWKSP_PointCloud *)m_pAdd->GetClientData(i))->Get_PointCloud()); break;
+ default: return;
+ }
}
}
@@ -263,7 +278,7 @@ void CDLG_List_Base::_Add(void)
{
j = Selections.Item(i);
- m_pAdd->Append(m_pSelect->GetString(j), m_pSelect->GetClientData(j));
+ m_pAdd->Insert(m_pSelect->GetString(j), 0, m_pSelect->GetClientData(j));
m_pSelect->Delete(j);
}
}
diff --git a/src/saga_core/saga_gui/dlg_list_grid.cpp b/src/saga_core/saga_gui/dlg_list_grid.cpp
index 19e3887..6ada7c6 100644
--- a/src/saga_core/saga_gui/dlg_list_grid.cpp
+++ b/src/saga_core/saga_gui/dlg_list_grid.cpp
@@ -181,7 +181,12 @@ void CDLG_List_Grid::_Set_Objects(void)
//-----------------------------------------------------
for(int i=0; i<m_pList->Get_Count(); i++)
{
- m_pAdd->Append(m_pList->asDataObject(i)->Get_Name(), m_pList->asDataObject(i));
+ CWKSP_Base_Item *pItem = g_pData->Get_Grids()->Get_Grid(m_pList->asDataObject(i)->asGrid());
+
+ if( pItem )
+ {
+ m_pAdd->Append(pItem->Get_Name(), (void *)pItem);
+ }
}
//-----------------------------------------------------
@@ -223,17 +228,14 @@ void CDLG_List_Grid::_Set_Grids(void)
//---------------------------------------------------------
void CDLG_List_Grid::_Set_Grids(CWKSP_Grid_System *pSystem)
{
- bool bList;
- int i, j;
- CSG_Grid *pGrid;
-
if( pSystem )
{
- for(i=0; i<pSystem->Get_Count(); i++)
+ for(int i=0; i<pSystem->Get_Count(); i++)
{
- pGrid = pSystem->Get_Grid(i)->Get_Grid();
+ bool bList = true;
+ CWKSP_Grid *pGrid = pSystem->Get_Grid(i);
- for(j=0, bList=true; j<(int)m_pAdd->GetCount() && bList; j++)
+ for(int j=0; j<(int)m_pAdd->GetCount() && bList; j++)
{
if( pGrid == m_pAdd->GetClientData(j) )
{
@@ -243,7 +245,7 @@ void CDLG_List_Grid::_Set_Grids(CWKSP_Grid_System *pSystem)
if( bList )
{
- m_pSelect->Append(pGrid->Get_Name(), pGrid);
+ m_pSelect->Append(pGrid->Get_Name(), (void *)pGrid);
}
}
}
diff --git a/src/saga_core/saga_gui/dlg_list_pointcloud.cpp b/src/saga_core/saga_gui/dlg_list_pointcloud.cpp
index 2480d66..37061fb 100644
--- a/src/saga_core/saga_gui/dlg_list_pointcloud.cpp
+++ b/src/saga_core/saga_gui/dlg_list_pointcloud.cpp
@@ -112,20 +112,25 @@ void CDLG_List_PointCloud::_Set_Objects(void)
bool bList;
int i, j;
CWKSP_PointCloud_Manager *pPointClouds;
- CSG_PointCloud *pPointCloud;
+ CWKSP_PointCloud *pPointCloud;
//-----------------------------------------------------
if( (pPointClouds = g_pData->Get_PointClouds()) != NULL )
{
for(i=0; i<m_pList->Get_Count(); i++)
{
- m_pAdd->Append(m_pList->asDataObject(i)->Get_Name(), m_pList->asDataObject(i));
+ CWKSP_Base_Item *pItem = g_pData->Get_PointClouds()->Get_PointCloud(m_pList->asDataObject(i)->asPointCloud());
+
+ if( pItem )
+ {
+ m_pAdd->Append(pItem->Get_Name(), (void *)pItem);
+ }
}
//-------------------------------------------------
for(i=0; i<pPointClouds->Get_Count(); i++)
{
- pPointCloud = pPointClouds->Get_PointCloud(i)->Get_PointCloud();
+ pPointCloud = pPointClouds->Get_PointCloud(i);
for(j=0, bList=true; j<(int)m_pAdd->GetCount() && bList; j++)
{
@@ -137,7 +142,7 @@ void CDLG_List_PointCloud::_Set_Objects(void)
if( bList )
{
- m_pSelect->Append(pPointCloud->Get_Name(), pPointCloud);
+ m_pSelect->Append(pPointCloud->Get_Name(), (void *)pPointCloud);
}
}
}
diff --git a/src/saga_core/saga_gui/dlg_list_shapes.cpp b/src/saga_core/saga_gui/dlg_list_shapes.cpp
index 9e12f6a..cbdb7ce 100644
--- a/src/saga_core/saga_gui/dlg_list_shapes.cpp
+++ b/src/saga_core/saga_gui/dlg_list_shapes.cpp
@@ -120,7 +120,12 @@ void CDLG_List_Shapes::_Set_Objects(void)
{
for(i=0; i<m_pList->Get_Count(); i++)
{
- m_pAdd->Append(m_pList->asDataObject(i)->Get_Name(), m_pList->asDataObject(i));
+ CWKSP_Base_Item *pItem = g_pData->Get_Shapes()->Get_Shapes(m_pList->asDataObject(i)->asShapes());
+
+ if( pItem )
+ {
+ m_pAdd->Append(pItem->Get_Name(), (void *)pItem);
+ }
}
//-------------------------------------------------
@@ -141,17 +146,14 @@ void CDLG_List_Shapes::_Set_Objects(void)
//---------------------------------------------------------
void CDLG_List_Shapes::_Set_Shapes(CWKSP_Shapes_Type *pType)
{
- bool bList;
- int i, j;
- CSG_Shapes *pShapes;
-
if( pType )
{
- for(i=0; i<pType->Get_Count(); i++)
+ for(int i=0; i<pType->Get_Count(); i++)
{
- pShapes = pType->Get_Shapes(i)->Get_Shapes();
+ bool bList = true;
+ CWKSP_Shapes *pShapes = pType->Get_Shapes(i);
- for(j=0, bList=true; j<(int)m_pAdd->GetCount() && bList; j++)
+ for(int j=0; j<(int)m_pAdd->GetCount() && bList; j++)
{
if( pShapes == m_pAdd->GetClientData(j) )
{
@@ -161,7 +163,7 @@ void CDLG_List_Shapes::_Set_Shapes(CWKSP_Shapes_Type *pType)
if( bList )
{
- m_pSelect->Append(pShapes->Get_Name(), pShapes);
+ m_pSelect->Append(pShapes->Get_Name(), (void *)pShapes);
}
}
}
diff --git a/src/saga_core/saga_gui/dlg_list_table.cpp b/src/saga_core/saga_gui/dlg_list_table.cpp
index 3a4c36a..7156191 100644
--- a/src/saga_core/saga_gui/dlg_list_table.cpp
+++ b/src/saga_core/saga_gui/dlg_list_table.cpp
@@ -112,20 +112,25 @@ void CDLG_List_Table::_Set_Objects(void)
bool bList;
int i, j;
CWKSP_Table_Manager *pTables;
- CSG_Table *pTable;
+ CWKSP_Table *pTable;
//-----------------------------------------------------
if( (pTables = g_pData->Get_Tables()) != NULL )
{
for(i=0; i<m_pList->Get_Count(); i++)
{
- m_pAdd->Append(m_pList->asDataObject(i)->Get_Name(), m_pList->asDataObject(i));
+ CWKSP_Base_Item *pItem = g_pData->Get_Tables()->Get_Table(m_pList->asDataObject(i)->asTable());
+
+ if( pItem )
+ {
+ m_pAdd->Append(pItem->Get_Name(), (void *)pItem);
+ }
}
//-------------------------------------------------
for(i=0; i<pTables->Get_Count(); i++)
{
- pTable = pTables->Get_Table(i)->Get_Table();
+ pTable = pTables->Get_Table(i);
for(j=0, bList=true; j<(int)m_pAdd->GetCount() && bList; j++)
{
@@ -137,7 +142,7 @@ void CDLG_List_Table::_Set_Objects(void)
if( bList )
{
- m_pSelect->Append(pTable->Get_Name(), pTable);
+ m_pSelect->Append(pTable->Get_Name(), (void *)pTable);
}
}
}
diff --git a/src/saga_core/saga_gui/dlg_list_tin.cpp b/src/saga_core/saga_gui/dlg_list_tin.cpp
index cd59e73..60f9faa 100644
--- a/src/saga_core/saga_gui/dlg_list_tin.cpp
+++ b/src/saga_core/saga_gui/dlg_list_tin.cpp
@@ -112,20 +112,25 @@ void CDLG_List_TIN::_Set_Objects(void)
bool bList;
int i, j;
CWKSP_TIN_Manager *pTINs;
- CSG_TIN *pTIN;
+ CWKSP_TIN *pTIN;
//-----------------------------------------------------
if( (pTINs = g_pData->Get_TINs()) != NULL )
{
for(i=0; i<m_pList->Get_Count(); i++)
{
- m_pAdd->Append(m_pList->asDataObject(i)->Get_Name(), m_pList->asDataObject(i));
+ CWKSP_Base_Item *pItem = g_pData->Get_TINs()->Get_TIN(m_pList->asDataObject(i)->asTIN());
+
+ if( pItem )
+ {
+ m_pAdd->Append(pItem->Get_Name(), (void *)pItem);
+ }
}
//-------------------------------------------------
for(i=0; i<pTINs->Get_Count(); i++)
{
- pTIN = pTINs->Get_TIN(i)->Get_TIN();
+ pTIN = pTINs->Get_TIN(i);
for(j=0, bList=true; j<(int)m_pAdd->GetCount() && bList; j++)
{
@@ -137,7 +142,7 @@ void CDLG_List_TIN::_Set_Objects(void)
if( bList )
{
- m_pSelect->Append(pTIN->Get_Name(), pTIN);
+ m_pSelect->Append(pTIN->Get_Name(), (void *)pTIN);
}
}
}
diff --git a/src/saga_core/saga_gui/man/Makefile.am b/src/saga_core/saga_gui/man/Makefile.am
new file mode 100644
index 0000000..d194e2f
--- /dev/null
+++ b/src/saga_core/saga_gui/man/Makefile.am
@@ -0,0 +1 @@
+dist_man_MANS = saga_gui.1
diff --git a/src/saga_core/saga_gui/man/Makefile.in b/src/saga_core/saga_gui/man/Makefile.in
new file mode 100644
index 0000000..ba3507b
--- /dev/null
+++ b/src/saga_core/saga_gui/man/Makefile.in
@@ -0,0 +1,437 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/saga_core/saga_gui/man
+DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+man1dir = $(mandir)/man1
+am__installdirs = "$(DESTDIR)$(man1dir)"
+NROFF = nroff
+MANS = $(dist_man_MANS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+HARU_LIB = @HARU_LIB@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POW_LIB = @POW_LIB@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+dist_man_MANS = saga_gui.1
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/saga_core/saga_gui/man/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/saga_core/saga_gui/man/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-man1: $(dist_man_MANS)
+ @$(NORMAL_INSTALL)
+ test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
+ @list=''; test -n "$(man1dir)" || exit 0; \
+ { for i in $$list; do echo "$$i"; done; \
+ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.1[a-z]*$$/p'; \
+ } | while read p; do \
+ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; echo "$$p"; \
+ done | \
+ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+ sed 'N;N;s,\n, ,g' | { \
+ list=; while read file base inst; do \
+ if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
+ fi; \
+ done; \
+ for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+ while read files; do \
+ test -z "$$files" || { \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
+ done; }
+
+uninstall-man1:
+ @$(NORMAL_UNINSTALL)
+ @list=''; test -n "$(man1dir)" || exit 0; \
+ files=`{ for i in $$list; do echo "$$i"; done; \
+ l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+ sed -n '/\.1[a-z]*$$/p'; \
+ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+ test -z "$$files" || { \
+ echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+ @list='$(MANS)'; if test -n "$$list"; then \
+ list=`for p in $$list; do \
+ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
+ if test -n "$$list" && \
+ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
+ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
+ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \
+ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \
+ echo " typically \`make maintainer-clean' will remove them" >&2; \
+ exit 1; \
+ else :; fi; \
+ else :; fi
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(MANS)
+installdirs:
+ for dir in "$(DESTDIR)$(man1dir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man1
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-man
+
+uninstall-man: uninstall-man1
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ distclean distclean-generic distclean-libtool distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-man1 \
+ 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 \
+ uninstall uninstall-am uninstall-man uninstall-man1
+
+
+# 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:
diff --git a/src/saga_core/saga_gui/man/saga_gui.1 b/src/saga_core/saga_gui/man/saga_gui.1
new file mode 100644
index 0000000..31883fc
--- /dev/null
+++ b/src/saga_core/saga_gui/man/saga_gui.1
@@ -0,0 +1,148 @@
+.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.07)
+.\"
+.\" Standard preamble:
+.\" ========================================================================
+.de Sp \" Vertical space (when we can't use .PP)
+.if t .sp .5v
+.if n .sp
+..
+.de Vb \" Begin verbatim text
+.ft CW
+.nf
+.ne \\$1
+..
+.de Ve \" End verbatim text
+.ft R
+.fi
+..
+.\" Set up some character translations and predefined strings. \*(-- will
+.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
+.\" double quote, and \*(R" will give a right double quote. \*(C+ will
+.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
+.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
+.\" nothing in troff, for use with C<>.
+.tr \(*W-
+.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
+.ie n \{\
+. ds -- \(*W-
+. ds PI pi
+. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
+. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
+. ds L" ""
+. ds R" ""
+. ds C` ""
+. ds C' ""
+'br\}
+.el\{\
+. ds -- \|\(em\|
+. ds PI \(*p
+. ds L" ``
+. ds R" ''
+'br\}
+.\"
+.\" Escape single quotes in literal strings from groff's Unicode transform.
+.ie \n(.g .ds Aq \(aq
+.el .ds Aq '
+.\"
+.\" If the F register is turned on, we'll generate index entries on stderr for
+.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
+.\" entries marked with X<> in POD. Of course, you'll have to process the
+.\" output yourself in some meaningful fashion.
+.ie \nF \{\
+. de IX
+. tm Index:\\$1\t\\n%\t"\\$2"
+..
+. nr % 0
+. rr F
+.\}
+.el \{\
+. de IX
+..
+.\}
+.\"
+.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
+.\" Fear. Run. Save yourself. No user-serviceable parts.
+. \" fudge factors for nroff and troff
+.if n \{\
+. ds #H 0
+. ds #V .8m
+. ds #F .3m
+. ds #[ \f1
+. ds #] \fP
+.\}
+.if t \{\
+. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
+. ds #V .6m
+. ds #F 0
+. ds #[ \&
+. ds #] \&
+.\}
+. \" simple accents for nroff and troff
+.if n \{\
+. ds ' \&
+. ds ` \&
+. ds ^ \&
+. ds , \&
+. ds ~ ~
+. ds /
+.\}
+.if t \{\
+. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
+. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
+. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
+. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
+. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
+. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
+.\}
+. \" troff and (daisy-wheel) nroff accents
+.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
+.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
+.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
+.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
+.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
+.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
+.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
+.ds ae a\h'-(\w'a'u*4/10)'e
+.ds Ae A\h'-(\w'A'u*4/10)'E
+. \" corrections for vroff
+.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
+.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
+. \" for low resolution devices (crt and lpr)
+.if \n(.H>23 .if \n(.V>19 \
+\{\
+. ds : e
+. ds 8 ss
+. ds o a
+. ds d- d\h'-1'\(ga
+. ds D- D\h'-1'\(hy
+. ds th \o'bp'
+. ds Th \o'LP'
+. ds ae ae
+. ds Ae AE
+.\}
+.rm #[ #] #H #V #F C
+.\" ========================================================================
+.\"
+.IX Title "SAGA_GUI 1"
+.TH SAGA_GUI 1 "2010-03-08" "2.0.4" " "
+.\" For nroff, turn off justification. Always turn off hyphenation; it makes
+.\" way too many mistakes in technical documents.
+.if n .ad l
+.nh
+.SH "NAME"
+\&\fBsaga_gui\fR \- graphical user interface to the System for Automated Geoscientific Analyses
+.SH "SYNOPSIS"
+.IX Header "SYNOPSIS"
+\&\fBsaga_gui\fR [\fIfilename(.sprj,.sgrd,.shp)\fR]
+.SH "DESCRIPTION"
+.IX Header "DESCRIPTION"
+Graphical user interface to the System for Automated Geoscientific Analyses, a free and open source geographic information system used for editing and analysing spatial data. It includes a large number of modules for the analysis of vector, table, grid and image data.
+.SH "BUGS"
+.IX Header "BUGS"
+On the project website: \fIhttp://www.saga\-gis.org\fR, a list of known bugs can be found and new bug reports can be submitted.
+.SH "AUTHORS"
+.IX Header "AUTHORS"
+\&\fB\s-1SAGA\s0\fR was written by Olaf Conrad with help from a large number of contributers. This manual page was written by Johan Van de Wauw.
+Both are released under the \s-1GNU\s0 General Public License v2.
+.PP
+More info \fIhttp://www.saga\-gis.org\fR
diff --git a/src/saga_core/saga_gui/parameters_control.cpp b/src/saga_core/saga_gui/parameters_control.cpp
index a623424..f9ec8b4 100644
--- a/src/saga_core/saga_gui/parameters_control.cpp
+++ b/src/saga_core/saga_gui/parameters_control.cpp
@@ -247,7 +247,10 @@ bool CParameters_Control::Load(void)
if( DLG_Open(File_Path, ID_DLG_PARAMETERS_OPEN) )
{
- if( m_pParameters->Serialize(File_Path.c_str(), false) )
+ CSG_File File(File_Path.c_str());
+
+ if( m_pParameters->Serialize_Compatibility(File)
+ || m_pParameters->Serialize(File_Path.c_str(), false) )
{
// m_pPG->Freeze();
m_pPG->Clear();
@@ -377,20 +380,28 @@ void CParameters_Control::_Add_Properties(CSG_Parameters *pParameters)
{
if( pParameters->Get_Parameter(i)->Get_Parent() == NULL )
{
+ pRoot = NULL;
+
switch( pParameters->Get_Parameter(i)->Get_Type() )
{
case PARAMETER_TYPE_DataObject_Output:
- pRoot = NULL;
break;
case PARAMETER_TYPE_Grid_System:
- if(1|| pParameters->Get_Parameter(i)->Get_Children_Count() > 0 )
+ if( pParameters->Get_Parameter(i)->Get_Children_Count() == 0 )
{
CHECK_DATA_NODE( pGrids , LNG("[PRM] Grids"), wxT("_DATAOBJECT_GRIDS") );
}
else
{
- pRoot = NULL;
+ for(int j=0; j<pParameters->Get_Parameter(i)->Get_Children_Count() && !pRoot; j++)
+ {
+ if( pParameters->Get_Parameter(i)->Get_Child(j)->Get_Type() != PARAMETER_TYPE_Grid_List
+ || pParameters->Get_Parameter(i)->Get_Child(j)->is_Input() )
+ {
+ CHECK_DATA_NODE( pGrids , LNG("[PRM] Grids"), wxT("_DATAOBJECT_GRIDS") );
+ }
+ }
}
break;
@@ -449,22 +460,9 @@ void CParameters_Control::_Add_Property(wxPGProperty *pParent, CSG_Parameter *pP
if( pParameter->Get_Children_Count() > 0 )
{
- int i;
-
- for(i=0; i<pParameter->Get_Children_Count(); i++)
- {
- if( pParameter->Get_Child(i)->Get_Children_Count() == 0 )
- {
- _Add_Property(pProperty, pParameter->Get_Child(i));
- }
- }
-
- for(i=0; i<pParameter->Get_Children_Count(); i++)
+ for(int i=0; i<pParameter->Get_Children_Count(); i++)
{
- if( pParameter->Get_Child(i)->Get_Children_Count() > 0 )
- {
- _Add_Property(pProperty, pParameter->Get_Child(i));
- }
+ _Add_Property(pProperty, pParameter->Get_Child(i));
}
m_pPG->Expand(pProperty);
@@ -522,13 +520,19 @@ wxPGProperty * CParameters_Control::_Get_Property(wxPGProperty *pParent, CSG_Par
case PARAMETER_TYPE_FilePath:
case PARAMETER_TYPE_Font:
case PARAMETER_TYPE_FixedTable:
+ case PARAMETER_TYPE_Parameters:
+ pProperty = new CParameters_PG_Dialog (Name, ID, pParameter);
+ break;
+
case PARAMETER_TYPE_Grid_List:
case PARAMETER_TYPE_Table_List:
case PARAMETER_TYPE_Shapes_List:
case PARAMETER_TYPE_TIN_List:
case PARAMETER_TYPE_PointCloud_List:
- case PARAMETER_TYPE_Parameters:
- pProperty = new CParameters_PG_Dialog (Name, ID, pParameter);
+ if( !pParameter->is_Output() )
+ {
+ pProperty = new CParameters_PG_Dialog (Name, ID, pParameter);
+ }
break;
case PARAMETER_TYPE_Choice:
diff --git a/src/saga_core/saga_gui/parameters_properties.cpp b/src/saga_core/saga_gui/parameters_properties.cpp
index 6abc0bc..16237b1 100644
--- a/src/saga_core/saga_gui/parameters_properties.cpp
+++ b/src/saga_core/saga_gui/parameters_properties.cpp
@@ -1,954 +1,962 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// User Interface //
-// //
-// Program: SAGA //
-// //
-//-------------------------------------------------------//
-// //
-// Parameters_Properties.cpp //
-// //
-// Copyright (C) 2005 by Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include <saga_api/saga_api.h>
-
-#include "res_dialogs.h"
-
-#include "helper.h"
-#include "dc_helper.h"
-
-#include "wksp_data_manager.h"
-
-#include "wksp_grid_manager.h"
-#include "wksp_grid_system.h"
-#include "wksp_grid.h"
-
-#include "wksp_table_manager.h"
-#include "wksp_table.h"
-
-#include "wksp_shapes_manager.h"
-#include "wksp_shapes_type.h"
-#include "wksp_shapes.h"
-
-#include "wksp_tin_manager.h"
-#include "wksp_tin.h"
-
-#include "wksp_pointcloud_manager.h"
-#include "wksp_pointcloud.h"
-
-#include "parameters_properties.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#define GET_DATAOBJECT_LABEL(p) (p->is_Option() ? wxString::Format(p->Get_Name()) : wxString::Format(wxT("%s %s"), p->is_Input() ? (p->is_Optional() ? wxT(">") : wxT(">>")) : (p->is_Optional() ? wxT("<") : wxT("<<")), p->Get_Name()))
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CParameters_PG_Choice::CParameters_PG_Choice(CSG_Parameter *pParameter)
- : wxEnumProperty(GET_DATAOBJECT_LABEL(pParameter), pParameter->Get_Identifier(), NULL)
-{
- m_pParameter = pParameter;
-
- _Create();
-}
-
-//---------------------------------------------------------
-CParameters_PG_Choice::~CParameters_PG_Choice(void)
-{
- _Destroy();
-}
-
-//---------------------------------------------------------
-void CParameters_PG_Choice::_Create(void)
-{
- _Destroy();
-
- if( m_pParameter )
- {
- switch( m_pParameter->Get_Type() )
- {
- default: SetIndex(0); break;
- case PARAMETER_TYPE_Choice: SetIndex(_Set_Choice()); break;
- case PARAMETER_TYPE_Grid_System: SetIndex(_Set_Grid_System()); break;
- case PARAMETER_TYPE_Table_Field: SetIndex(_Set_Table_Field()); break;
- case PARAMETER_TYPE_Grid: SetIndex(_Set_Grid()); break;
- case PARAMETER_TYPE_Table: SetIndex(_Set_Table()); break;
- case PARAMETER_TYPE_Shapes: SetIndex(_Set_Shapes()); break;
- case PARAMETER_TYPE_TIN: SetIndex(_Set_TIN()); break;
- case PARAMETER_TYPE_PointCloud: SetIndex(_Set_PointCloud()); break;
- }
-
- if( GetGrid() )
- {
- RecreateEditor();
- }
- }
-}
-
-//---------------------------------------------------------
-void CParameters_PG_Choice::_Destroy(void)
-{
- m_choices .Clear();
- m_choices_data .Clear();
-
- SetIndex(0);
-}
-
-//---------------------------------------------------------
-void CParameters_PG_Choice::_Append(const wxChar *Label, long Value)
-{
- m_choices .Add(Label, Value);
- m_choices_data .Add((void *)NULL);
-}
-
-void CParameters_PG_Choice::_Append(const wxChar *Label, void *Value)
-{
- m_choices .Add(Label, m_choices_data.Count());
- m_choices_data .Add(Value);
-}
-
-//---------------------------------------------------------
-bool CParameters_PG_Choice::Update(void)
-{
- _Create();
-
- return( true );
-}
-
-//---------------------------------------------------------
-int CParameters_PG_Choice::_Set_Choice(void)
-{
- for(int i=0; i<m_pParameter->asChoice()->Get_Count(); i++)
- {
- _Append(m_pParameter->asChoice()->Get_Item(i), i);
- }
-
- return( m_pParameter->asInt() );
-}
-
-//---------------------------------------------------------
-int CParameters_PG_Choice::_Set_Table_Field(void)
-{
- CSG_Parameter *pParent;
- CSG_Table *pTable;
-
- if( (pParent = m_pParameter->Get_Parent()) != NULL)
- {
- switch( pParent->Get_Type() )
- {
- default: pTable = NULL; break;
- case PARAMETER_TYPE_Table: pTable = pParent->asTable(); break;
- case PARAMETER_TYPE_Shapes: pTable = pParent->asShapes(); break;
- case PARAMETER_TYPE_TIN: pTable = pParent->asTIN(); break;
- }
-
- if( pTable )
- {
- for(int i=0; i<pTable->Get_Field_Count(); i++)
- {
- _Append(pTable->Get_Field_Name(i));
- }
-
- if( m_pParameter->is_Optional() || pTable->Get_Field_Count() == 0 )
- {
- _Append( LNG("[VAL] [not set]") );
- }
-
- return( m_pParameter->asInt() >= 0 ? m_pParameter->asInt() : GetItemCount() - 1);
- }
- }
-
- _Append( LNG("[VAL] [not set]") );
-
- return( GetItemCount() - 1 );
-}
-
-//---------------------------------------------------------
-int CParameters_PG_Choice::_Set_Table(void)
-{
- CWKSP_Table_Manager *pTables;
-
- if( (pTables = g_pData->Get_Tables()) != NULL )
- {
- for(int i=0; i<pTables->Get_Count(); i++)
- {
- _Append(pTables->Get_Table(i)->Get_Name(), pTables->Get_Table(i)->Get_Table());
- }
- }
-
- CWKSP_Shapes_Manager *pManager;
-
- if( (pManager = g_pData->Get_Shapes()) != NULL )
- {
- for(int i=0; i<pManager->Get_Count(); i++)
- {
- CWKSP_Shapes_Type *pShapes = (CWKSP_Shapes_Type *)pManager->Get_Item(i);
-
- for(int j=0; j<pShapes->Get_Count(); j++)
- {
- _Append(pShapes->Get_Shapes(j)->Get_Name(), pShapes->Get_Shapes(j)->Get_Shapes());
- }
- }
- }
-
- return( _DataObject_Init() );
-}
-
-//---------------------------------------------------------
-int CParameters_PG_Choice::_Set_Shapes(void)
-{
- CWKSP_Shapes_Manager *pManager;
-
- if( (pManager = g_pData->Get_Shapes()) != NULL )
- {
- int Shape_Type = ((CSG_Parameter_Shapes *)m_pParameter->Get_Data())->Get_Shape_Type();
-
- for(int i=0; i<pManager->Get_Count(); i++)
- {
- CWKSP_Shapes_Type *pShapes = (CWKSP_Shapes_Type *)pManager->Get_Item(i);
-
- if( Shape_Type == SHAPE_TYPE_Undefined || Shape_Type == pShapes->Get_Shapes_Type() )
- {
- for(int j=0; j<pShapes->Get_Count(); j++)
- {
- _Append(pShapes->Get_Shapes(j)->Get_Name(), pShapes->Get_Shapes(j)->Get_Shapes());
- }
- }
- }
- }
-
- return( _DataObject_Init() );
-}
-
-//---------------------------------------------------------
-int CParameters_PG_Choice::_Set_TIN(void)
-{
- CWKSP_TIN_Manager *pTINs;
-
- if( (pTINs = g_pData->Get_TINs()) != NULL )
- {
- for(int i=0; i<pTINs->Get_Count(); i++)
- {
- _Append(pTINs->Get_TIN(i)->Get_Name(), pTINs->Get_TIN(i)->Get_TIN());
- }
- }
-
- return( _DataObject_Init() );
-}
-
-//---------------------------------------------------------
-int CParameters_PG_Choice::_Set_PointCloud(void)
-{
- CWKSP_PointCloud_Manager *pManager;
-
- if( (pManager = g_pData->Get_PointClouds()) != NULL )
- {
- for(int i=0; i<pManager->Get_Count(); i++)
- {
- _Append(pManager->Get_PointCloud(i)->Get_Name(), pManager->Get_PointCloud(i)->Get_PointCloud());
- }
- }
-
- return( _DataObject_Init() );
-}
-
-//---------------------------------------------------------
-int CParameters_PG_Choice::_Set_Grid_System(void)
-{
- g_pData->Check_Parameter(m_pParameter);
-
- CWKSP_Grid_Manager *pSystems = g_pData->Get_Grids();
-
- if( pSystems && pSystems->Get_Count() > 0 )
- {
- int index = pSystems->Get_Count();
-
- for(int i=0; i<pSystems->Get_Count(); i++)
- {
- _Append(pSystems->Get_System(i)->Get_Name(), pSystems->Get_System(i)->Get_System());
-
- if( m_pParameter->asGrid_System()->is_Equal(*pSystems->Get_System(i)->Get_System()) )
- {
- index = i;
- }
- }
-
- _Append(LNG("[VAL] [not set]"));
-
- return( index );
- }
-
- _Append( LNG("[VAL] [no choice available]"));
-
- return( 0 );
-}
-
-//---------------------------------------------------------
-int CParameters_PG_Choice::_Set_Grid(void)
-{
- CSG_Parameter *pParent = m_pParameter->Get_Parent();
- CWKSP_Grid_Manager *pManager = g_pData->Get_Grids();
- CWKSP_Grid_System *pSystem = NULL;
-
- if( pManager && pParent && pParent->Get_Type() == PARAMETER_TYPE_Grid_System && pParent->asGrid_System()->is_Valid() )
- {
- for(int i=0; i<pManager->Get_Count() && !pSystem; i++)
- {
- if( pParent->asGrid_System()->is_Equal(*pManager->Get_System(i)->Get_System()) )
- {
- pSystem = pManager->Get_System(i);
- }
- }
- }
-
- if( pSystem )
- {
- for(int i=0; i<pSystem->Get_Count(); i++)
- {
- _Append(pSystem->Get_Grid(i)->Get_Name(), pSystem->Get_Grid(i)->Get_Grid());
- }
- }
-
- return( _DataObject_Init() );
-}
-
-//---------------------------------------------------------
-int CParameters_PG_Choice::_DataObject_Init(void)
-{
- if( m_pParameter->is_Output() )
- {
- _Append(LNG("[VAL] [create]"), DATAOBJECT_CREATE);
- }
-
- if( !m_pParameter->is_Output() || (m_pParameter->is_Output() && m_pParameter->is_Optional()) )
- {
- _Append(LNG("[VAL] [not set]"), DATAOBJECT_NOTSET);
- }
-
- g_pData->Check_Parameter(m_pParameter);
-
- for(int i=0; i<(int)GetItemCount(); i++)
- {
- if( m_pParameter->asDataObject() == (void *)m_choices_data.Item(m_choices.GetValue(i)) )
- {
- return( i );
- }
- }
-
- return( GetItemCount() - 1 );
-}
-
-//---------------------------------------------------------
-bool CParameters_PG_Choice::OnEvent(wxPropertyGrid *pPG, wxWindow *pPGCtrl, wxEvent &event)
-{
- if( event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED )
- {
- if( m_pParameter && m_choices.IsOk() && GetIndex() >= 0 && GetIndex() < (int)GetItemCount() )
- {
- switch( m_pParameter->Get_Type() )
- {
- default:
- break;
-
- case PARAMETER_TYPE_Choice:
- case PARAMETER_TYPE_Table_Field:
- m_pParameter->Set_Value(GetIndex());
- break;
-
- case PARAMETER_TYPE_Grid_System:
- m_pParameter->Set_Value((void *)m_choices_data.Item(m_choices.GetValue(GetIndex())));
- _Update_Grids(pPG);
- break;
-
- case PARAMETER_TYPE_Grid:
- m_pParameter->Set_Value((void *)m_choices_data.Item(m_choices.GetValue(GetIndex())));
- break;
-
- case PARAMETER_TYPE_Table:
- case PARAMETER_TYPE_Shapes:
- case PARAMETER_TYPE_TIN:
- case PARAMETER_TYPE_PointCloud:
- m_pParameter->Set_Value((void *)m_choices_data.Item(m_choices.GetValue(GetIndex())));
- _Update_TableFields(pPG);
- break;
- }
-
- pPG->EditorsValueWasModified();
-
- return( true );
- }
- }
-
- event.Skip();
-
- return( false );
-}
-
-//---------------------------------------------------------
-void CParameters_PG_Choice::_Update_Grids(wxPropertyGrid *pPG)
-{
- if( m_pParameter && m_pParameter->Get_Type() == PARAMETER_TYPE_Grid_System )
- {
- for(int i=0; i<m_pParameter->Get_Children_Count(); i++)
- {
- wxPGProperty *pProperty;
- CSG_Parameter *pChild = m_pParameter->Get_Child(i);
-
- switch( pChild->Get_Type() )
- {
- default:
- break;
-
- case PARAMETER_TYPE_Grid_List:
- break;
-
- case PARAMETER_TYPE_Grid:
- if( (pProperty = pPG->GetProperty(wxString::Format(wxT("%s.%s"), m_pParameter->Get_Identifier(), pChild->Get_Identifier()))) != NULL )
- {
- ((CParameters_PG_Choice *)pProperty)->Update();
- }
- }
- }
- }
-}
-
-//---------------------------------------------------------
-void CParameters_PG_Choice::_Update_TableFields(wxPropertyGrid *pPG)
-{
- if( m_pParameter )
- {
- for(int i=0; i<m_pParameter->Get_Children_Count(); i++)
- {
- CSG_Parameter *pChild = m_pParameter->Get_Child(i);
-
- if( pChild->Get_Type() == PARAMETER_TYPE_Table_Field )
- {
- wxPGProperty *pProperty = pPG->GetProperty(wxString::Format(wxT("%s.%s"), m_pParameter->Get_Identifier(), pChild->Get_Identifier()));
-
- if( pProperty )
- {
- ((CParameters_PG_Choice *)pProperty)->Update();
- }
- }
- }
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-WX_PG_IMPLEMENT_VARIANT_DATA(CParameters_PG_Parameter_Variant, CParameters_PG_Parameter_Value)
-
-//---------------------------------------------------------
-bool CParameters_PG_Parameter_Value::from_String(const wxString &String)
-{
- switch( m_pParameter->Get_Type() )
- {
- default:
- return( false );
-
- case PARAMETER_TYPE_Text:
- case PARAMETER_TYPE_FilePath:
- m_pParameter->Set_Value(String.c_str());
- return( true );
- }
-}
-
-//---------------------------------------------------------
-wxString CParameters_PG_Parameter_Value::to_String(void) const
-{
- wxString s;
-
- if( m_pParameter && Check() )
- {
- s = m_pParameter->asString();
- }
-
- return( s );
-}
-
-//---------------------------------------------------------
-bool CParameters_PG_Parameter_Value::Check(void) const
-{
- if( m_pParameter )
- {
- switch( m_pParameter->Get_Type() )
- {
- default:
- break;
-
- case PARAMETER_TYPE_Table_List:
- case PARAMETER_TYPE_Shapes_List:
- case PARAMETER_TYPE_TIN_List:
- case PARAMETER_TYPE_PointCloud_List:
- case PARAMETER_TYPE_Grid_List:
- CSG_Parameter_List *pList = (CSG_Parameter_Grid_List *)m_pParameter->Get_Data();
-
- for(int i=pList->Get_Count()-1; i>=0; i--)
- {
- if( !g_pData->Exists(pList->asDataObject(i)) )
- {
- pList->Del_Item(i);
- }
- }
-
- break;
- }
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CParameters_PG_Parameter_Value::Do_Dialog(void)
-{
- bool bModified = false;
- long Color;
- wxString Text;
-
- if( m_pParameter )
- {
- switch( m_pParameter->Get_Type() )
- {
- default:
- break;
-
- case PARAMETER_TYPE_Font:
- bModified = DLG_Font (m_pParameter->asFont(), Color = m_pParameter->asColor());
-
- if( bModified )
- {
- m_pParameter->Set_Value((int)Color);
-
- return( true );
- }
- break;
-
- case PARAMETER_TYPE_Text:
- bModified = DLG_Text (m_pParameter->Get_Name(), Text = m_pParameter->asString());
-
- if( bModified )
- {
- m_pParameter->Set_Value(Text.c_str());
-
- return( true );
- }
- break;
-
- case PARAMETER_TYPE_FilePath:
- Text = m_pParameter->asString();
-
- if( m_pParameter->asFilePath()->is_Directory() )
- {
- bModified = DLG_Directory (Text, LNG("[CAP] Choose Directory"));
- }
- else if( m_pParameter->asFilePath()->is_Save() )
- {
- bModified = DLG_Save (Text, LNG("[CAP] Save"), m_pParameter->asFilePath()->Get_Filter());
- }
- else if( m_pParameter->asFilePath()->is_Multiple() == false )
- {
- bModified = DLG_Open (Text, LNG("[CAP] Open"), m_pParameter->asFilePath()->Get_Filter());
- }
- else
- {
- wxArrayString Files;
-
- bModified = DLG_Open (Files, LNG("[CAP] Open"), m_pParameter->asFilePath()->Get_Filter());
-
- if( bModified )
- {
- if( Files.GetCount() > 0 )
- {
- Text.Clear();
-
- for(size_t i=0; i<Files.GetCount(); i++)
- {
- Text.Append(i > 0 ? wxT(" \"") : wxT("\""));
- Text.Append(Files.Item(i));
- Text.Append(wxT("\""));
- }
- }
- else
- {
- Text = Files.Item(0);
- }
- }
- }
-
- if( bModified )
- {
- m_pParameter->Set_Value(Text.c_str());
-
- return( true );
- }
- break;
-
- case PARAMETER_TYPE_FixedTable:
- bModified = DLG_Table (m_pParameter->Get_Name(), m_pParameter->asTable());
- break;
-
- case PARAMETER_TYPE_Grid_List:
- case PARAMETER_TYPE_Table_List:
- case PARAMETER_TYPE_Shapes_List:
- case PARAMETER_TYPE_TIN_List:
- case PARAMETER_TYPE_PointCloud_List:
- bModified = DLG_List (m_pParameter->Get_Name(), m_pParameter->asList());
- break;
-
- case PARAMETER_TYPE_Colors:
- bModified = DLG_Colors (m_pParameter->asColors());
- break;
-
- case PARAMETER_TYPE_Parameters:
- bModified = DLG_Parameters (m_pParameter->asParameters());
- break;
- }
- }
-
- if( bModified )
- {
- m_pParameter->has_Changed();
- }
-
- return( bModified );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-WX_PG_IMPLEMENT_PROPERTY_CLASS(CParameters_PG_Range, wxPGProperty, CParameters_PG_Parameter_Value, const &CParameters_PG_Parameter_Value, TextCtrl)
-
-//---------------------------------------------------------
-CParameters_PG_Range::CParameters_PG_Range(const wxString &label, const wxString &name, CSG_Parameter *pParameter)
- : wxPGProperty(label, name)
-{
- if( pParameter && pParameter->Get_Type() == PARAMETER_TYPE_Range )
- {
- m_value = CParameters_PG_Parameter_ValueToVariant(CParameters_PG_Parameter_Value(pParameter));
-
- AddPrivateChild( new wxFloatProperty(wxT("Minimum") , wxPG_LABEL, pParameter->asRange()->Get_LoVal()) );
- AddPrivateChild( new wxFloatProperty(wxT("Maximum") , wxPG_LABEL, pParameter->asRange()->Get_HiVal()) );
- }
-}
-
-//---------------------------------------------------------
-void CParameters_PG_Range::RefreshChildren(void)
-{
- const CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(m_value);
-
- if( GetCount() == 2 && value.m_pParameter && value.m_pParameter->Get_Type() == PARAMETER_TYPE_Range )
- {
- Item(0)->SetValue( value.m_pParameter->asRange()->Get_LoVal() );
- Item(1)->SetValue( value.m_pParameter->asRange()->Get_HiVal() );
- }
-}
-
-//---------------------------------------------------------
-void CParameters_PG_Range::ChildChanged(wxVariant &thisValue, int childIndex, wxVariant &childValue) const
-{
- CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(thisValue);
-
- if( GetCount() == 2 && value.m_pParameter && value.m_pParameter->Get_Type() == PARAMETER_TYPE_Range )
- {
- double v;
-
- if( wxPGVariantToDouble(childValue, &v) )
- {
- switch( childIndex )
- {
- case 0: value.m_pParameter->asRange()->Set_LoVal(v); break;
- case 1: value.m_pParameter->asRange()->Set_HiVal(v); break;
- }
- }
- }
-}
-
-//---------------------------------------------------------
-bool CParameters_PG_Range::Update(void)
-{
- SetValue(m_value);
-
- return( true );
-
-// s.Printf( SG_T("%f; %f"), pParameter->asRange()->Get_LoVal(), pParameter->asRange()->Get_HiVal());
-// m_pPG->SetPropertyValue(pProperty, s.c_str());
-// RefreshChildren();
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-WX_PG_IMPLEMENT_PROPERTY_CLASS(CParameters_PG_Degree, wxPGProperty, CParameters_PG_Parameter_Value, const &CParameters_PG_Parameter_Value, TextCtrl)
-
-//---------------------------------------------------------
-CParameters_PG_Degree::CParameters_PG_Degree(const wxString &label, const wxString &name, CSG_Parameter *pParameter)
- : wxPGProperty(label, name)
-{
- if( pParameter && pParameter->Get_Type() == PARAMETER_TYPE_Degree )
- {
- m_value = CParameters_PG_Parameter_ValueToVariant(CParameters_PG_Parameter_Value(pParameter));
-
- double d, m, s;
-
- Decimal_To_Degree(pParameter->asDouble(), d, m, s);
-
- AddPrivateChild( new wxIntProperty (wxT("Degree") , wxPG_LABEL, (int)d) );
- AddPrivateChild( new wxIntProperty (wxT("Minute") , wxPG_LABEL, (int)m) );
- AddPrivateChild( new wxFloatProperty(wxT("Second") , wxPG_LABEL, s) );
- }
-}
-
-//---------------------------------------------------------
-void CParameters_PG_Degree::RefreshChildren(void)
-{
- const CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(m_value);
-
- if( GetCount() == 3 && value.m_pParameter && value.m_pParameter->Get_Type() == PARAMETER_TYPE_Degree )
- {
- double d, m, s;
-
- Decimal_To_Degree(value.m_pParameter->asDouble(), d, m, s);
-
- Item(0)->SetValue((int)d);
- Item(1)->SetValue((int)m);
- Item(2)->SetValue( s);
- }
-}
-
-//---------------------------------------------------------
-void CParameters_PG_Degree::ChildChanged(wxVariant &thisValue, int childIndex, wxVariant &childValue) const
-{
- CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(thisValue);
-
- if( GetCount() == 3 && value.m_pParameter && value.m_pParameter->Get_Type() == PARAMETER_TYPE_Degree )
- {
- double v, d, m, s;
-
- if( wxPGVariantToDouble(childValue, &v) )
- {
- Decimal_To_Degree(value.m_pParameter->asDouble(), d, m, s);
-
- switch( childIndex )
- {
- case 0: d = (int)v; break;
- case 1: m = (int)v; break;
- case 2: s = v; break;
- }
-
- value.m_pParameter->Set_Value(Degree_To_Decimal(d, m, s));
- }
- }
-}
-
-//---------------------------------------------------------
-bool CParameters_PG_Degree::Update(void)
-{
- SetValue(m_value);
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-WX_PG_IMPLEMENT_PROPERTY_CLASS(CParameters_PG_Dialog, wxPGProperty, CParameters_PG_Parameter_Value, const CParameters_PG_Parameter_Value &, TextCtrlAndButton)
-
-//---------------------------------------------------------
-CParameters_PG_Dialog::CParameters_PG_Dialog(const wxString &label, const wxString &name, CSG_Parameter *pParameter)
- : wxPGProperty(pParameter ? GET_DATAOBJECT_LABEL(pParameter) : label, name)
-{
- m_value = CParameters_PG_Parameter_ValueToVariant(CParameters_PG_Parameter_Value(pParameter));
-}
-
-//---------------------------------------------------------
-wxString CParameters_PG_Dialog::GetValueAsString(int flags) const
-{
- const CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(m_value);
-
- if( value.m_pParameter )
- {
- return( value.to_String() );
- }
-
- return( wxT("---") );
-}
-
-//---------------------------------------------------------
-bool CParameters_PG_Dialog::OnEvent(wxPropertyGrid *propgrid, wxWindow *primary, wxEvent &event)
-{
- if( propgrid->IsMainButtonEvent(event) )
- {
- PrepareValueForDialogEditing(propgrid);
-
- CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(m_value);
-
- if( value.m_pParameter && value.Do_Dialog() )
- {
- propgrid->EditorsValueWasModified();
-
- SetValueInEvent(m_value);
-
- return( true );
- }
- }
- else if( event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER && primary && propgrid->IsEditorsValueModified() )
- {
- CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(m_value);
-
- if( value.m_pParameter && value.m_pParameter->Get_Type() == PARAMETER_TYPE_FilePath )
- {
- value.m_pParameter->Set_Value(((wxTextCtrl *)primary)->GetValue().c_str());
-
- propgrid->EditorsValueWasModified();
-
- SetValueInEvent(m_value);
-
- return( true );
- }
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CParameters_PG_Dialog::Update(void)
-{
- SetValue(m_value);
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-WX_PG_IMPLEMENT_PROPERTY_CLASS(CParameters_PG_Colors, wxPGProperty, CParameters_PG_Parameter_Value, const CParameters_PG_Parameter_Value &, TextCtrlAndButton)
-
-//---------------------------------------------------------
-CParameters_PG_Colors::CParameters_PG_Colors(const wxString &label, const wxString &name, CSG_Parameter *pParameter)
- : CParameters_PG_Dialog(label, name, pParameter)
-{}
-
-//---------------------------------------------------------
-void CParameters_PG_Colors::OnCustomPaint(wxDC &dc, const wxRect &r, wxPGPaintData &pd)
-{
- const CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(m_value);
-
- if( value.m_pParameter && value.m_pParameter->Get_Type() == PARAMETER_TYPE_Colors )
- {
- int i, ax, bx;
-
- CSG_Colors *pColors = value.m_pParameter->asColors();
- double dx = r.GetWidth() / (double)pColors->Get_Count();
-
- for(i=0, bx=r.GetLeft(); i<pColors->Get_Count(); i++)
- {
- ax = bx;
- bx = r.GetLeft() + (int)(dx * (i + 1.0));
-
- Draw_FillRect(dc, Get_Color_asWX(pColors->Get_Color(i)), ax, r.GetTop(), bx, r.GetBottom());
- }
- }
-}
-
-//---------------------------------------------------------
-wxSize CParameters_PG_Colors::OnMeasureImage(int item = -1) const
-{
- return( wxSize(-1, -1) );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// User Interface //
+// //
+// Program: SAGA //
+// //
+//-------------------------------------------------------//
+// //
+// Parameters_Properties.cpp //
+// //
+// Copyright (C) 2005 by Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include <saga_api/saga_api.h>
+
+#include "res_dialogs.h"
+
+#include "helper.h"
+#include "dc_helper.h"
+
+#include "wksp_data_manager.h"
+
+#include "wksp_grid_manager.h"
+#include "wksp_grid_system.h"
+#include "wksp_grid.h"
+
+#include "wksp_table_manager.h"
+#include "wksp_table.h"
+
+#include "wksp_shapes_manager.h"
+#include "wksp_shapes_type.h"
+#include "wksp_shapes.h"
+
+#include "wksp_tin_manager.h"
+#include "wksp_tin.h"
+
+#include "wksp_pointcloud_manager.h"
+#include "wksp_pointcloud.h"
+
+#include "parameters_properties.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define GET_DATAOBJECT_LABEL(p) (p->is_Option() ? wxString::Format(p->Get_Name()) : wxString::Format(wxT("%s %s"), p->is_Input() ? (p->is_Optional() ? wxT(">") : wxT(">>")) : (p->is_Optional() ? wxT("<") : wxT("<<")), p->Get_Name()))
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CParameters_PG_Choice::CParameters_PG_Choice(CSG_Parameter *pParameter)
+ : wxEnumProperty(GET_DATAOBJECT_LABEL(pParameter), pParameter->Get_Identifier(), NULL)
+{
+ m_pParameter = pParameter;
+
+ _Create();
+}
+
+//---------------------------------------------------------
+CParameters_PG_Choice::~CParameters_PG_Choice(void)
+{
+ _Destroy();
+}
+
+//---------------------------------------------------------
+void CParameters_PG_Choice::_Create(void)
+{
+ _Destroy();
+
+ if( m_pParameter )
+ {
+ switch( m_pParameter->Get_Type() )
+ {
+ default: SetIndex(0); break;
+ case PARAMETER_TYPE_Choice: SetIndex(_Set_Choice()); break;
+ case PARAMETER_TYPE_Grid_System: SetIndex(_Set_Grid_System()); break;
+ case PARAMETER_TYPE_Table_Field: SetIndex(_Set_Table_Field()); break;
+ case PARAMETER_TYPE_Grid: SetIndex(_Set_Grid()); break;
+ case PARAMETER_TYPE_Table: SetIndex(_Set_Table()); break;
+ case PARAMETER_TYPE_Shapes: SetIndex(_Set_Shapes()); break;
+ case PARAMETER_TYPE_TIN: SetIndex(_Set_TIN()); break;
+ case PARAMETER_TYPE_PointCloud: SetIndex(_Set_PointCloud()); break;
+ }
+
+ if( GetGrid() )
+ {
+ RecreateEditor();
+ }
+ }
+}
+
+//---------------------------------------------------------
+void CParameters_PG_Choice::_Destroy(void)
+{
+ m_choices .Clear();
+ m_choices_data .Clear();
+
+ SetIndex(0);
+}
+
+//---------------------------------------------------------
+void CParameters_PG_Choice::_Append(const wxChar *Label, long Value)
+{
+ m_choices .Add(Label, Value);
+ m_choices_data .Add((void *)NULL);
+}
+
+void CParameters_PG_Choice::_Append(const wxChar *Label, void *Value)
+{
+ m_choices .Add(Label, m_choices_data.Count());
+ m_choices_data .Add(Value);
+}
+
+//---------------------------------------------------------
+bool CParameters_PG_Choice::Update(void)
+{
+ _Create();
+
+ return( true );
+}
+
+//---------------------------------------------------------
+int CParameters_PG_Choice::_Set_Choice(void)
+{
+ for(int i=0; i<m_pParameter->asChoice()->Get_Count(); i++)
+ {
+ _Append(m_pParameter->asChoice()->Get_Item(i), i);
+ }
+
+ return( m_pParameter->asInt() );
+}
+
+//---------------------------------------------------------
+int CParameters_PG_Choice::_Set_Table_Field(void)
+{
+ CSG_Parameter *pParent;
+ CSG_Table *pTable;
+
+ if( (pParent = m_pParameter->Get_Parent()) != NULL)
+ {
+ switch( pParent->Get_Type() )
+ {
+ default: pTable = NULL; break;
+ case PARAMETER_TYPE_Table: pTable = pParent->asTable(); break;
+ case PARAMETER_TYPE_Shapes: pTable = pParent->asShapes(); break;
+ case PARAMETER_TYPE_TIN: pTable = pParent->asTIN(); break;
+ case PARAMETER_TYPE_PointCloud: pTable = pParent->asPointCloud(); break;
+ }
+
+ if( pTable && pTable != DATAOBJECT_CREATE )
+ {
+ for(int i=0; i<pTable->Get_Field_Count(); i++)
+ {
+ _Append(pTable->Get_Field_Name(i));
+ }
+
+ if( m_pParameter->is_Optional() || pTable->Get_Field_Count() == 0 )
+ {
+ _Append( LNG("[VAL] [not set]") );
+ }
+
+ return( m_pParameter->asInt() >= 0 ? m_pParameter->asInt() : GetItemCount() - 1);
+ }
+ }
+
+ _Append( LNG("[VAL] [not set]") );
+
+ return( GetItemCount() - 1 );
+}
+
+//---------------------------------------------------------
+int CParameters_PG_Choice::_Set_Table(void)
+{
+ CWKSP_Table_Manager *pTables;
+
+ if( (pTables = g_pData->Get_Tables()) != NULL )
+ {
+ for(int i=0; i<pTables->Get_Count(); i++)
+ {
+ _Append(pTables->Get_Table(i)->Get_Name(), pTables->Get_Table(i)->Get_Table());
+ }
+ }
+
+ CWKSP_Shapes_Manager *pManager;
+
+ if( (pManager = g_pData->Get_Shapes()) != NULL )
+ {
+ for(int i=0; i<pManager->Get_Count(); i++)
+ {
+ CWKSP_Shapes_Type *pShapes = (CWKSP_Shapes_Type *)pManager->Get_Item(i);
+
+ for(int j=0; j<pShapes->Get_Count(); j++)
+ {
+ _Append(pShapes->Get_Shapes(j)->Get_Name(), pShapes->Get_Shapes(j)->Get_Shapes());
+ }
+ }
+ }
+
+ return( _DataObject_Init() );
+}
+
+//---------------------------------------------------------
+int CParameters_PG_Choice::_Set_Shapes(void)
+{
+ CWKSP_Shapes_Manager *pManager;
+
+ if( (pManager = g_pData->Get_Shapes()) != NULL )
+ {
+ int Shape_Type = ((CSG_Parameter_Shapes *)m_pParameter->Get_Data())->Get_Shape_Type();
+
+ for(int i=0; i<pManager->Get_Count(); i++)
+ {
+ CWKSP_Shapes_Type *pShapes = (CWKSP_Shapes_Type *)pManager->Get_Item(i);
+
+ if( Shape_Type == SHAPE_TYPE_Undefined || Shape_Type == pShapes->Get_Shapes_Type() )
+ {
+ for(int j=0; j<pShapes->Get_Count(); j++)
+ {
+ _Append(pShapes->Get_Shapes(j)->Get_Name(), pShapes->Get_Shapes(j)->Get_Shapes());
+ }
+ }
+ }
+ }
+
+ if( m_pParameter->is_Input()
+ && ( ((CSG_Parameter_Shapes *)m_pParameter->Get_Data())->Get_Shape_Type() == SHAPE_TYPE_Point
+ || ((CSG_Parameter_Shapes *)m_pParameter->Get_Data())->Get_Shape_Type() == SHAPE_TYPE_Undefined ) )
+ {
+ return( _Set_PointCloud() );
+ }
+
+ return( _DataObject_Init() );
+}
+
+//---------------------------------------------------------
+int CParameters_PG_Choice::_Set_TIN(void)
+{
+ CWKSP_TIN_Manager *pTINs;
+
+ if( (pTINs = g_pData->Get_TINs()) != NULL )
+ {
+ for(int i=0; i<pTINs->Get_Count(); i++)
+ {
+ _Append(pTINs->Get_TIN(i)->Get_Name(), pTINs->Get_TIN(i)->Get_TIN());
+ }
+ }
+
+ return( _DataObject_Init() );
+}
+
+//---------------------------------------------------------
+int CParameters_PG_Choice::_Set_PointCloud(void)
+{
+ CWKSP_PointCloud_Manager *pManager;
+
+ if( (pManager = g_pData->Get_PointClouds()) != NULL )
+ {
+ for(int i=0; i<pManager->Get_Count(); i++)
+ {
+ _Append(pManager->Get_PointCloud(i)->Get_Name(), pManager->Get_PointCloud(i)->Get_PointCloud());
+ }
+ }
+
+ return( _DataObject_Init() );
+}
+
+//---------------------------------------------------------
+int CParameters_PG_Choice::_Set_Grid_System(void)
+{
+ g_pData->Check_Parameter(m_pParameter);
+
+ CWKSP_Grid_Manager *pSystems = g_pData->Get_Grids();
+
+ if( pSystems && pSystems->Get_Count() > 0 )
+ {
+ int index = pSystems->Get_Count();
+
+ for(int i=0; i<pSystems->Get_Count(); i++)
+ {
+ _Append(pSystems->Get_System(i)->Get_Name(), pSystems->Get_System(i)->Get_System());
+
+ if( m_pParameter->asGrid_System()->is_Equal(*pSystems->Get_System(i)->Get_System()) )
+ {
+ index = i;
+ }
+ }
+
+ _Append(LNG("[VAL] [not set]"));
+
+ return( index );
+ }
+
+ _Append( LNG("[VAL] [no choice available]"));
+
+ return( 0 );
+}
+
+//---------------------------------------------------------
+int CParameters_PG_Choice::_Set_Grid(void)
+{
+ CSG_Parameter *pParent = m_pParameter->Get_Parent();
+ CWKSP_Grid_Manager *pManager = g_pData->Get_Grids();
+ CWKSP_Grid_System *pSystem = NULL;
+
+ if( pManager && pParent && pParent->Get_Type() == PARAMETER_TYPE_Grid_System && pParent->asGrid_System()->is_Valid() )
+ {
+ for(int i=0; i<pManager->Get_Count() && !pSystem; i++)
+ {
+ if( pParent->asGrid_System()->is_Equal(*pManager->Get_System(i)->Get_System()) )
+ {
+ pSystem = pManager->Get_System(i);
+ }
+ }
+ }
+
+ if( pSystem )
+ {
+ for(int i=0; i<pSystem->Get_Count(); i++)
+ {
+ _Append(pSystem->Get_Grid(i)->Get_Name(), pSystem->Get_Grid(i)->Get_Grid());
+ }
+ }
+
+ return( _DataObject_Init() );
+}
+
+//---------------------------------------------------------
+int CParameters_PG_Choice::_DataObject_Init(void)
+{
+ if( m_pParameter->is_Output() )
+ {
+ _Append(LNG("[VAL] [create]"), DATAOBJECT_CREATE);
+ }
+
+ if( !m_pParameter->is_Output() || (m_pParameter->is_Output() && m_pParameter->is_Optional()) )
+ {
+ _Append(LNG("[VAL] [not set]"), DATAOBJECT_NOTSET);
+ }
+
+ g_pData->Check_Parameter(m_pParameter);
+
+ for(int i=0; i<(int)GetItemCount(); i++)
+ {
+ if( m_pParameter->asDataObject() == (void *)m_choices_data.Item(m_choices.GetValue(i)) )
+ {
+ return( i );
+ }
+ }
+
+ return( GetItemCount() - 1 );
+}
+
+//---------------------------------------------------------
+bool CParameters_PG_Choice::OnEvent(wxPropertyGrid *pPG, wxWindow *pPGCtrl, wxEvent &event)
+{
+ if( event.GetEventType() == wxEVT_COMMAND_COMBOBOX_SELECTED )
+ {
+ if( m_pParameter && m_choices.IsOk() && GetIndex() >= 0 && GetIndex() < (int)GetItemCount() )
+ {
+ switch( m_pParameter->Get_Type() )
+ {
+ default:
+ break;
+
+ case PARAMETER_TYPE_Choice:
+ case PARAMETER_TYPE_Table_Field:
+ m_pParameter->Set_Value(GetIndex());
+ break;
+
+ case PARAMETER_TYPE_Grid_System:
+ m_pParameter->Set_Value((void *)m_choices_data.Item(m_choices.GetValue(GetIndex())));
+ _Update_Grids(pPG);
+ break;
+
+ case PARAMETER_TYPE_Grid:
+ m_pParameter->Set_Value((void *)m_choices_data.Item(m_choices.GetValue(GetIndex())));
+ break;
+
+ case PARAMETER_TYPE_Table:
+ case PARAMETER_TYPE_Shapes:
+ case PARAMETER_TYPE_TIN:
+ case PARAMETER_TYPE_PointCloud:
+ m_pParameter->Set_Value((void *)m_choices_data.Item(m_choices.GetValue(GetIndex())));
+ _Update_TableFields(pPG);
+ break;
+ }
+
+ pPG->EditorsValueWasModified();
+
+ return( true );
+ }
+ }
+
+ event.Skip();
+
+ return( false );
+}
+
+//---------------------------------------------------------
+void CParameters_PG_Choice::_Update_Grids(wxPropertyGrid *pPG)
+{
+ if( m_pParameter && m_pParameter->Get_Type() == PARAMETER_TYPE_Grid_System )
+ {
+ for(int i=0; i<m_pParameter->Get_Children_Count(); i++)
+ {
+ wxPGProperty *pProperty;
+ CSG_Parameter *pChild = m_pParameter->Get_Child(i);
+
+ switch( pChild->Get_Type() )
+ {
+ default:
+ break;
+
+ case PARAMETER_TYPE_Grid_List:
+ break;
+
+ case PARAMETER_TYPE_Grid:
+ if( (pProperty = pPG->GetProperty(wxString::Format(wxT("%s.%s"), m_pParameter->Get_Identifier(), pChild->Get_Identifier()))) != NULL )
+ {
+ ((CParameters_PG_Choice *)pProperty)->Update();
+ }
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
+void CParameters_PG_Choice::_Update_TableFields(wxPropertyGrid *pPG)
+{
+ if( m_pParameter )
+ {
+ for(int i=0; i<m_pParameter->Get_Children_Count(); i++)
+ {
+ CSG_Parameter *pChild = m_pParameter->Get_Child(i);
+
+ if( pChild->Get_Type() == PARAMETER_TYPE_Table_Field )
+ {
+ wxPGProperty *pProperty = pPG->GetProperty(wxString::Format(wxT("%s.%s"), m_pParameter->Get_Identifier(), pChild->Get_Identifier()));
+
+ if( pProperty )
+ {
+ ((CParameters_PG_Choice *)pProperty)->Update();
+ }
+ }
+ }
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+WX_PG_IMPLEMENT_VARIANT_DATA(CParameters_PG_Parameter_Variant, CParameters_PG_Parameter_Value)
+
+//---------------------------------------------------------
+bool CParameters_PG_Parameter_Value::from_String(const wxString &String)
+{
+ switch( m_pParameter->Get_Type() )
+ {
+ default:
+ return( false );
+
+ case PARAMETER_TYPE_Text:
+ case PARAMETER_TYPE_FilePath:
+ m_pParameter->Set_Value(String.c_str());
+ return( true );
+ }
+}
+
+//---------------------------------------------------------
+wxString CParameters_PG_Parameter_Value::to_String(void) const
+{
+ wxString s;
+
+ if( m_pParameter && Check() )
+ {
+ s = m_pParameter->asString();
+ }
+
+ return( s );
+}
+
+//---------------------------------------------------------
+bool CParameters_PG_Parameter_Value::Check(void) const
+{
+ if( m_pParameter )
+ {
+ switch( m_pParameter->Get_Type() )
+ {
+ default:
+ break;
+
+ case PARAMETER_TYPE_Table_List:
+ case PARAMETER_TYPE_Shapes_List:
+ case PARAMETER_TYPE_TIN_List:
+ case PARAMETER_TYPE_PointCloud_List:
+ case PARAMETER_TYPE_Grid_List:
+ CSG_Parameter_List *pList = (CSG_Parameter_Grid_List *)m_pParameter->Get_Data();
+
+ for(int i=pList->Get_Count()-1; i>=0; i--)
+ {
+ if( !g_pData->Exists(pList->asDataObject(i)) )
+ {
+ pList->Del_Item(i);
+ }
+ }
+
+ break;
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CParameters_PG_Parameter_Value::Do_Dialog(void)
+{
+ bool bModified = false;
+ long Color;
+ wxString Text;
+
+ if( m_pParameter )
+ {
+ switch( m_pParameter->Get_Type() )
+ {
+ default:
+ break;
+
+ case PARAMETER_TYPE_Font:
+ bModified = DLG_Font (m_pParameter->asFont(), Color = m_pParameter->asColor());
+
+ if( bModified )
+ {
+ m_pParameter->Set_Value((int)Color);
+
+ return( true );
+ }
+ break;
+
+ case PARAMETER_TYPE_Text:
+ bModified = DLG_Text (m_pParameter->Get_Name(), Text = m_pParameter->asString());
+
+ if( bModified )
+ {
+ m_pParameter->Set_Value(Text.c_str());
+
+ return( true );
+ }
+ break;
+
+ case PARAMETER_TYPE_FilePath:
+ Text = m_pParameter->asString();
+
+ if( m_pParameter->asFilePath()->is_Directory() )
+ {
+ bModified = DLG_Directory (Text, LNG("[CAP] Choose Directory"));
+ }
+ else if( m_pParameter->asFilePath()->is_Save() )
+ {
+ bModified = DLG_Save (Text, LNG("[CAP] Save"), m_pParameter->asFilePath()->Get_Filter());
+ }
+ else if( m_pParameter->asFilePath()->is_Multiple() == false )
+ {
+ bModified = DLG_Open (Text, LNG("[CAP] Open"), m_pParameter->asFilePath()->Get_Filter());
+ }
+ else
+ {
+ wxArrayString Files;
+
+ bModified = DLG_Open (Files, LNG("[CAP] Open"), m_pParameter->asFilePath()->Get_Filter());
+
+ if( bModified )
+ {
+ if( Files.GetCount() > 0 )
+ {
+ Text.Clear();
+
+ for(size_t i=0; i<Files.GetCount(); i++)
+ {
+ Text.Append(i > 0 ? wxT(" \"") : wxT("\""));
+ Text.Append(Files.Item(i));
+ Text.Append(wxT("\""));
+ }
+ }
+ else
+ {
+ Text = Files.Item(0);
+ }
+ }
+ }
+
+ if( bModified )
+ {
+ m_pParameter->Set_Value(Text.c_str());
+
+ return( true );
+ }
+ break;
+
+ case PARAMETER_TYPE_FixedTable:
+ bModified = DLG_Table (m_pParameter->Get_Name(), m_pParameter->asTable());
+ break;
+
+ case PARAMETER_TYPE_Grid_List:
+ case PARAMETER_TYPE_Table_List:
+ case PARAMETER_TYPE_Shapes_List:
+ case PARAMETER_TYPE_TIN_List:
+ case PARAMETER_TYPE_PointCloud_List:
+ bModified = DLG_List (m_pParameter->Get_Name(), m_pParameter->asList());
+ break;
+
+ case PARAMETER_TYPE_Colors:
+ bModified = DLG_Colors (m_pParameter->asColors());
+ break;
+
+ case PARAMETER_TYPE_Parameters:
+ bModified = DLG_Parameters (m_pParameter->asParameters());
+ break;
+ }
+ }
+
+ if( bModified )
+ {
+ m_pParameter->has_Changed();
+ }
+
+ return( bModified );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+WX_PG_IMPLEMENT_PROPERTY_CLASS(CParameters_PG_Range, wxPGProperty, CParameters_PG_Parameter_Value, const &CParameters_PG_Parameter_Value, TextCtrl)
+
+//---------------------------------------------------------
+CParameters_PG_Range::CParameters_PG_Range(const wxString &label, const wxString &name, CSG_Parameter *pParameter)
+ : wxPGProperty(label, name)
+{
+ if( pParameter && pParameter->Get_Type() == PARAMETER_TYPE_Range )
+ {
+ m_value = CParameters_PG_Parameter_ValueToVariant(CParameters_PG_Parameter_Value(pParameter));
+
+ AddPrivateChild( new wxFloatProperty(wxT("Minimum") , wxPG_LABEL, pParameter->asRange()->Get_LoVal()) );
+ AddPrivateChild( new wxFloatProperty(wxT("Maximum") , wxPG_LABEL, pParameter->asRange()->Get_HiVal()) );
+ }
+}
+
+//---------------------------------------------------------
+void CParameters_PG_Range::RefreshChildren(void)
+{
+ const CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(m_value);
+
+ if( GetCount() == 2 && value.m_pParameter && value.m_pParameter->Get_Type() == PARAMETER_TYPE_Range )
+ {
+ Item(0)->SetValue( value.m_pParameter->asRange()->Get_LoVal() );
+ Item(1)->SetValue( value.m_pParameter->asRange()->Get_HiVal() );
+ }
+}
+
+//---------------------------------------------------------
+void CParameters_PG_Range::ChildChanged(wxVariant &thisValue, int childIndex, wxVariant &childValue) const
+{
+ CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(thisValue);
+
+ if( GetCount() == 2 && value.m_pParameter && value.m_pParameter->Get_Type() == PARAMETER_TYPE_Range )
+ {
+ double v;
+
+ if( wxPGVariantToDouble(childValue, &v) )
+ {
+ switch( childIndex )
+ {
+ case 0: value.m_pParameter->asRange()->Set_LoVal(v); break;
+ case 1: value.m_pParameter->asRange()->Set_HiVal(v); break;
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
+bool CParameters_PG_Range::Update(void)
+{
+ SetValue(m_value);
+
+ return( true );
+
+// s.Printf( SG_T("%f; %f"), pParameter->asRange()->Get_LoVal(), pParameter->asRange()->Get_HiVal());
+// m_pPG->SetPropertyValue(pProperty, s.c_str());
+// RefreshChildren();
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+WX_PG_IMPLEMENT_PROPERTY_CLASS(CParameters_PG_Degree, wxPGProperty, CParameters_PG_Parameter_Value, const &CParameters_PG_Parameter_Value, TextCtrl)
+
+//---------------------------------------------------------
+CParameters_PG_Degree::CParameters_PG_Degree(const wxString &label, const wxString &name, CSG_Parameter *pParameter)
+ : wxPGProperty(label, name)
+{
+ if( pParameter && pParameter->Get_Type() == PARAMETER_TYPE_Degree )
+ {
+ m_value = CParameters_PG_Parameter_ValueToVariant(CParameters_PG_Parameter_Value(pParameter));
+
+ double d, m, s;
+
+ Decimal_To_Degree(pParameter->asDouble(), d, m, s);
+
+ AddPrivateChild( new wxIntProperty (wxT("Degree") , wxPG_LABEL, (int)d) );
+ AddPrivateChild( new wxIntProperty (wxT("Minute") , wxPG_LABEL, (int)m) );
+ AddPrivateChild( new wxFloatProperty(wxT("Second") , wxPG_LABEL, s) );
+ }
+}
+
+//---------------------------------------------------------
+void CParameters_PG_Degree::RefreshChildren(void)
+{
+ const CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(m_value);
+
+ if( GetCount() == 3 && value.m_pParameter && value.m_pParameter->Get_Type() == PARAMETER_TYPE_Degree )
+ {
+ double d, m, s;
+
+ Decimal_To_Degree(value.m_pParameter->asDouble(), d, m, s);
+
+ Item(0)->SetValue((int)d);
+ Item(1)->SetValue((int)m);
+ Item(2)->SetValue( s);
+ }
+}
+
+//---------------------------------------------------------
+void CParameters_PG_Degree::ChildChanged(wxVariant &thisValue, int childIndex, wxVariant &childValue) const
+{
+ CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(thisValue);
+
+ if( GetCount() == 3 && value.m_pParameter && value.m_pParameter->Get_Type() == PARAMETER_TYPE_Degree )
+ {
+ double v, d, m, s;
+
+ if( wxPGVariantToDouble(childValue, &v) )
+ {
+ Decimal_To_Degree(value.m_pParameter->asDouble(), d, m, s);
+
+ switch( childIndex )
+ {
+ case 0: d = (int)v; break;
+ case 1: m = (int)v; break;
+ case 2: s = v; break;
+ }
+
+ value.m_pParameter->Set_Value(Degree_To_Decimal(d, m, s));
+ }
+ }
+}
+
+//---------------------------------------------------------
+bool CParameters_PG_Degree::Update(void)
+{
+ SetValue(m_value);
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+WX_PG_IMPLEMENT_PROPERTY_CLASS(CParameters_PG_Dialog, wxPGProperty, CParameters_PG_Parameter_Value, const CParameters_PG_Parameter_Value &, TextCtrlAndButton)
+
+//---------------------------------------------------------
+CParameters_PG_Dialog::CParameters_PG_Dialog(const wxString &label, const wxString &name, CSG_Parameter *pParameter)
+ : wxPGProperty(pParameter ? GET_DATAOBJECT_LABEL(pParameter) : label, name)
+{
+ m_value = CParameters_PG_Parameter_ValueToVariant(CParameters_PG_Parameter_Value(pParameter));
+}
+
+//---------------------------------------------------------
+wxString CParameters_PG_Dialog::GetValueAsString(int flags) const
+{
+ const CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(m_value);
+
+ if( value.m_pParameter )
+ {
+ return( value.to_String() );
+ }
+
+ return( wxT("---") );
+}
+
+//---------------------------------------------------------
+bool CParameters_PG_Dialog::OnEvent(wxPropertyGrid *propgrid, wxWindow *primary, wxEvent &event)
+{
+ if( propgrid->IsMainButtonEvent(event) )
+ {
+ PrepareValueForDialogEditing(propgrid);
+
+ CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(m_value);
+
+ if( value.m_pParameter && value.Do_Dialog() )
+ {
+ propgrid->EditorsValueWasModified();
+
+ SetValueInEvent(m_value);
+
+ return( true );
+ }
+ }
+ else if( event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER && primary && propgrid->IsEditorsValueModified() )
+ {
+ CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(m_value);
+
+ if( value.m_pParameter && value.m_pParameter->Get_Type() == PARAMETER_TYPE_FilePath )
+ {
+ value.m_pParameter->Set_Value(((wxTextCtrl *)primary)->GetValue().c_str());
+
+ propgrid->EditorsValueWasModified();
+
+ SetValueInEvent(m_value);
+
+ return( true );
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CParameters_PG_Dialog::Update(void)
+{
+ SetValue(m_value);
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+WX_PG_IMPLEMENT_PROPERTY_CLASS(CParameters_PG_Colors, wxPGProperty, CParameters_PG_Parameter_Value, const CParameters_PG_Parameter_Value &, TextCtrlAndButton)
+
+//---------------------------------------------------------
+CParameters_PG_Colors::CParameters_PG_Colors(const wxString &label, const wxString &name, CSG_Parameter *pParameter)
+ : CParameters_PG_Dialog(label, name, pParameter)
+{}
+
+//---------------------------------------------------------
+void CParameters_PG_Colors::OnCustomPaint(wxDC &dc, const wxRect &r, wxPGPaintData &pd)
+{
+ const CParameters_PG_Parameter_Value &value = CParameters_PG_Parameter_ValueFromVariant(m_value);
+
+ if( value.m_pParameter && value.m_pParameter->Get_Type() == PARAMETER_TYPE_Colors )
+ {
+ int i, ax, bx;
+
+ CSG_Colors *pColors = value.m_pParameter->asColors();
+ double dx = r.GetWidth() / (double)pColors->Get_Count();
+
+ for(i=0, bx=r.GetLeft(); i<pColors->Get_Count(); i++)
+ {
+ ax = bx;
+ bx = r.GetLeft() + (int)(dx * (i + 1.0));
+
+ Draw_FillRect(dc, Get_Color_asWX(pColors->Get_Color(i)), ax, r.GetTop(), bx, r.GetBottom());
+ }
+ }
+}
+
+//---------------------------------------------------------
+wxSize CParameters_PG_Colors::OnMeasureImage(int item = -1) const
+{
+ return( wxSize(-1, -1) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_gui/project.cpp b/src/saga_core/saga_gui/project.cpp
index b1b6d1b..1591a2d 100644
--- a/src/saga_core/saga_gui/project.cpp
+++ b/src/saga_core/saga_gui/project.cpp
@@ -279,11 +279,18 @@ bool CWKSP_Project::_Load(const wxChar *FileName, bool bAdd, bool bUpdateMenu)
bSuccess = true;
//-------------------------------------------------
+ int i;
+
g_pData->Get_FileMenus()->Set_Update(false);
- for(int i=0; i<pNode->Get_Children_Count(); i++)
+ for(i=0; i<pNode->Get_Children_Count(); i++)
{
- _Load_Data(*pNode->Get_Child(i), SG_File_Get_Path(FileName));
+ _Load_Data(*pNode->Get_Child(i), SG_File_Get_Path(FileName), true);
+ }
+
+ for(i=0; i<pNode->Get_Children_Count(); i++)
+ {
+ _Load_Data(*pNode->Get_Child(i), SG_File_Get_Path(FileName), false);
}
g_pData->Get_FileMenus()->Set_Update(true);
@@ -460,7 +467,7 @@ bool CWKSP_Project::_Save(const wxChar *FileName, bool bSaveModified, bool bUpda
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-bool CWKSP_Project::_Load_Data(CSG_MetaData &Entry, const wxChar *ProjectDir)
+bool CWKSP_Project::_Load_Data(CSG_MetaData &Entry, const wxChar *ProjectDir, bool bLoad)
{
int Type;
wxString File;
@@ -495,7 +502,9 @@ bool CWKSP_Project::_Load_Data(CSG_MetaData &Entry, const wxChar *ProjectDir)
return( false );
}
- if( (pItem = g_pData->Open(Type, File)) == NULL )
+ pItem = bLoad ? g_pData->Open(Type, File) : _Get_byFileName(File);
+
+ if( !pItem )
{
return( false );
}
diff --git a/src/saga_core/saga_gui/project.h b/src/saga_core/saga_gui/project.h
index 7129b53..d63c243 100644
--- a/src/saga_core/saga_gui/project.h
+++ b/src/saga_core/saga_gui/project.h
@@ -98,7 +98,7 @@ private:
bool _Load (const wxChar *FileName, bool bAdd, bool bUpdateMenu);
bool _Save (const wxChar *FileName, bool bSaveModified, bool bUpdateMenu);
- bool _Load_Data (CSG_MetaData &Entry, const wxChar *ProjectDir);
+ bool _Load_Data (CSG_MetaData &Entry, const wxChar *ProjectDir, bool bLoad);
bool _Save_Data (CSG_MetaData &Entry, const wxChar *ProjectDir, class CSG_Data_Object *pDataObject, class CSG_Parameters *pParameters);
bool _Load_Map (CSG_MetaData &Entry, const wxChar *ProjectDir);
diff --git a/src/saga_core/saga_gui/res/CVS/Entries b/src/saga_core/saga_gui/res/CVS/Entries
index bd12479..ec52eb3 100644
--- a/src/saga_core/saga_gui/res/CVS/Entries
+++ b/src/saga_core/saga_gui/res/CVS/Entries
@@ -1,8 +1,8 @@
/colours.bmp/1.1.1.1/Mon Jun 26 15:42:58 2006/-kb/
/resource.h/1.1.1.1/Mon Jun 26 15:42:59 2006//
-/saga.ger.txt/1.1/Fri Mar 7 16:36:13 2008//
+/saga.ger.txt/1.2/Wed Apr 28 23:32:08 2010//
/saga.ico/1.1.1.1/Mon Jun 26 15:42:59 2006/-kb/
-/saga.lng.txt/1.1/Fri Mar 7 16:36:13 2008//
+/saga.lng.txt/1.2/Wed Apr 28 23:32:08 2010//
/saga_gui.rc/1.1.1.1/Mon Jun 26 15:43:00 2006//
/saga_srs.txt/1.1/Thu Oct 1 14:01:33 2009//
/saga_tip.txt/1.2/Thu Mar 22 17:01:17 2007//
diff --git a/src/saga_core/saga_gui/res/saga.ger.txt b/src/saga_core/saga_gui/res/saga.ger.txt
index c89b36e..0a669eb 100644
--- a/src/saga_core/saga_gui/res/saga.ger.txt
+++ b/src/saga_core/saga_gui/res/saga.ger.txt
@@ -1,834 +1,1027 @@
-ORIGINAL TRANSLATION
-1 byte integer 1 Byte Ganzzahl
-2 byte integer 2 Byte Ganzzahl
-20 seconds 20 Sekunden
-4 byte floating point 4 Byte Fließkommazahl
-4 byte integer 4 Byte Ganzzahl
-8 byte floating point 8 Byte Fließkommazahl
-A3 Landscape
-A3 Portrait
-A4 Landscape
-A4 Portrait
-About SAGA Über SAGA
-Acknowledgements Danksagungen
-Activate Grid File Cache? Dateipuffer für Raster aktivieren?
-Activate file caching automatically, if memory size exceeds the threshold value. Dateipuffer für Raster automatisch aktivieren, wenn Speicherbedarf Schwellenwert überschreitet.
-Add Field Feld hinzufügen
-All Files Alle Dateien
-All Recognised Files Alle erkannten Dateitypen
-Area Fläche
-Attribute Attribut
-Automatic mode Automatisch
-Available Choices Auswahlmöglichkeiten
-Bars Balken
-Buffer Size [MB] Puffergröße
-CLASS KLASSE
-COLOR FARBE
-COUNT ANZAHL
-Chart Type Diagrammtyp
-Choose Attribute Wähle Attribut
-Class 1 Klasse 1
-Class 2 Klasse 2
-Clear Löschen
-Colors file could not be exported. Farbdatei konnte nicht erstellt werden.
-Colors file could not be imported. Farbdatei konnte nicht geladen werden.
-CompuServe Graphics Interchange
-Confirm file caching Dateipufferaktivierung jedesmal bestätigen
-Constraints Einschränkungen
-Copy Kopieren
-Create Lookup Table Nachschlagetabelle erstellen
-Create index Index erstellen
-Creating module documentation files Dateien zur Moduldokumentation erstellen
-Currently no help files exist for SAGA.\nIt depends on your support, if you will find any help at this place in future!\nThanks a lot... Zur Zeit existiert keine Programmhilfe für SAGA\nEs hängt auch von Deiner/Ihrer Unterstützung ab, ob hier in Zukunft eine Hilfe zur Verfügung stehen wird.\nVielen Dank im voraus...
-DBase
-DESCRIPTION BESCHREIBUNG
-Data Table Datentabelle
-Delete Fields Felder löschen
-Description Beschreibung
-Descriptive name for the grid system Anschaulicher Name für das Rastersystem
-Direction Richtung
-Directory, where temporary cache files shall be saved. Verzeichnis, in dem temporäre Dateipuffer gespeichert werden sollen.
-ESRI Shape Files
-Error Fehler
-Error in Trend Calculation Fehler in Trendberechnung
-Error in formula Fehler in Formel
-Exit SAGA SAGA beenden
-Field Feld
-Field Colors Farbe für Attribut
-Field Type Datentyp
-Fields Felder
-First Class Erste Klasse
-Function failed because no attributes are available Funktion schlug fehl, weil keine Attribute verfügbar sind.
-General Allgemein
-Grid File Caching Dateipufferung für Raster
-Grids Raster
-Height Höhe
-I1: unrecognizable operator
-I2: too many parameters
-I3: corrupted buffer
-I4: size estimate too small
-Identifier Bezeichner
-Image Files Bilddateien
-Image Resolution Bildauflösung
-In/Out Eingabe/Ausgabe
-Input Eingabe
-Insert Method Einfügemethode
-Insert Position Einfügeposition
-JPEG - JFIF Compliant
-JPG Files JPG Dateien
-Layers Schichten
-Left/Right Links/Rechts
-Legend: Save Legende: Speichern
-Legend: Zoom Legende: Vergrößerung
-Length Länge
-Lines Linien
-Lines and Points Linien und Punkte
-Load Colors Lade Farben
-Load Parameters Lade Parameter
-Logo
-MAXIMUM
-MINIMUM
-Map Karte
-Maps Karten
-Maximum
-Menu Menü
-Minimum
-Module Modul
-NAME
-Name
-Neon
-Options Optionen
-Options for Data Thumbnails Optionen für Daten-Vorschaubilder
-Options for Map Thumbnails Optionen für Karten-Vorschaubilder
-Output Ausgabe
-PDF Files
-PNG Files
-Parameters Parameterliste
-Parameters file could not be exported. Parameterdatei konnte nicht erstellt werden.
-Parameters file could not be imported. Parameterdatei konnte nicht geladen werden.
-Parts Teile
-Perimeter Umfang
-Please stop module execution before exiting SAGA. Um SAGA zu beenden, muß erst das laufende Modul angehalten werden.
-Points Punkte
-Portable Network Graphics
-Position
-Rainbow Regenbogen
-Resolution Auflösung
-Row Reihe
-SAGA Colors SAGA Farben
-SAGA Help SAGA Hilfe
-SAGA Module Libraries
-SAGA Module Library Descriptions
-SAGA Parameter Files
-SAGA Project
-SAGA Projects
-SAGA: Print Map
-SVG - Scalable Vector Graphics Files (*.svg)
-Save 3D Image Options
-Save Colors
-Save Georeference
-Save Parameters
-Save all
-Scale
-Second Class
-Selection Color
-Shall I activate file caching for new grid.
-Show Categories
-Show Logo at Start Up
-Sort Table
-Sort by
-South-North
-Start Project
-Table
-Tables
-Tagged Image File Format
-Temporary files
-Text
-Text Files
-This is a Test!!!
-Threshold for automatic mode [MB]
-Thumbnail Size
-Thumbnails
-Total memory size
-Tree
-Type
-Up/Down
-Value Range
-Version
-West-East
-Width Breite
-Windows or OS/2 Bitmap
-X
-X11 Pixel Map
-Y
-Z
-Zsoft Paintbrush
-[BTN] Add Hinzufügen
-[BTN] Apply Anwenden
-[BTN] Button
-[BTN] Cancel Abbrechen
-[BTN] Clear Alles löschen
-[BTN] Count Anzahl
-[BTN] Delete Löschen
-[BTN] Down Ab
-[BTN] Execute Ausführen
-[BTN] Insert Einfügen
-[BTN] Invert Invertieren
-[BTN] Load Laden
-[BTN] Mirror Spiegeln
-[BTN] Okay
-[BTN] Presets
-[BTN] Random Zufall
-[BTN] Restore Wiederherstellen
-[BTN] Save Speichern
-[BTN] Up Auf
-[CAP] 3D-View 3D-Ansicht
-[CAP] 3D-View: Player Sequence 3D-Ansicht: Abspielsequenz
-[CAP] About SAGA Über SAGA
-[CAP] Anaglyph
-[CAP] Arithmetic Mean Mittelwert
-[CAP] Attribute Attribut
-[CAP] Attribute (Size)
-[CAP] Attributes Attribute
-[CAP] Author Autor
-[CAP] Background Color Hintergrundfarbe
-[CAP] Beep when finished
-[CAP] Buffer Size MB
-[CAP] Cell Size Zellgröße
-[CAP] Cell size Zellgröße
-[CAP] Chart
-[CAP] Chart Properties
-[CAP] Choose Directory
-[CAP] Circles Kreise
-[CAP] Close
-[CAP] Close and save modified data sets...
-[CAP] Color Farbe
-[CAP] Colors Farben
-[CAP] Create Script Command File
-[CAP] Data Daten
-[CAP] Data History
-[CAP] Decimals Dezimalstellen
-[CAP] Default Size
-[CAP] Defaults
-[CAP] Delete Löschen
-[CAP] Description Beschreibung
-[CAP] Diagram Diagramm
-[CAP] Display Darstellung
-[CAP] Display Resolution Auflösung
-[CAP] Display Type Darstellungsart
-[CAP] Display: Cell Values
-[CAP] Display: Color Classification
-[CAP] Display: Label
-[CAP] Display: Size
-[CAP] Display: Visibility
-[CAP] Edit
-[CAP] Edit Shapes Vektordaten editieren
-[CAP] Elevation Höhe
-[CAP] Errors Fehler
-[CAP] Exaggeration Überhöhung
-[CAP] Execution Modulausführung
-[CAP] Exit Beenden
-[CAP] Eye Distance [Degree]
-[CAP] Field Feld
-[CAP] Fields
-[CAP] Figure
-[CAP] File Datei
-[CAP] File cache activated
-[CAP] Fill Style Füllstil
-[CAP] Fit Map Scale Maßstab anpassen
-[CAP] Font Schriftart
-[CAP] Frame
-[CAP] General Allgemein
-[CAP] Graduated Color Abgestufte Farben
-[CAP] Grid Raster
-[CAP] Grid System Raster System
-[CAP] Grid Systems Raster Systeme
-[CAP] Grids Raster
-[CAP] Histogram Histogramm
-[CAP] Html Extra Info
-[CAP] Index
-[CAP] Info
-[CAP] Input Eingabe
-[CAP] Interpolated Interpoliert
-[CAP] Interpolation
-[CAP] Layers
-[CAP] Legend
-[CAP] Load
-[CAP] Load Colors Lade Farben
-[CAP] Load Grid Lade Raster
-[CAP] Load Module Library Lade Modulbibliothek
-[CAP] Load Project Lade Projekt
-[CAP] Load Settings
-[CAP] Load Shapes Lade Vektordaten
-[CAP] Load TIN
-[CAP] Load Table Lade Tabelle
-[CAP] Load Text Lade Text
-[CAP] Logarithmic Stretch Factor Logarithmische Streckung
-[CAP] Lookup Table Nachschlagetabelle
-[CAP] Map Karte
-[CAP] Map Extent
-[CAP] Map Scale Maßstab
-[CAP] Map Selection Kartenauswahl
-[CAP] Map-Layout
-[CAP] Maps Karten
-[CAP] Memory Speicher
-[CAP] Memory Compression
-[CAP] Memory Handling Speicherverwaltung
-[CAP] Memory Size Speicherbedarf
-[CAP] Messages Nachrichten
-[CAP] Mode Modus
-[CAP] Modified Modifiziert
-[CAP] Module Execution Modulausführung
-[CAP] Module Libraries Modulbibliotheken
-[CAP] Module Library Modulbibliothek
-[CAP] Modules Module
-[CAP] Name
-[CAP] No Data Keine Daten
-[CAP] Number Of Cells Anzahl der Zellen
-[CAP] Number Of Grids Anzahl der Rasterdatensätze
-[CAP] Number Of Shapes Anzahl der Vektordatensätze
-[CAP] Number of cells Anzahl der Zellen
-[CAP] Object Properties
-[CAP] Open
-[CAP] Options Optionen
-[CAP] Outline Umrandung
-[CAP] Outline Color
-[CAP] Outline Size
-[CAP] Parameters Parameter
-[CAP] Perspectivic Distance Perspektivischer Abstand
-[CAP] Points Punkte
-[CAP] Preset Selection
-[CAP] Print Layout
-[CAP] Print Preview Druckvorschau
-[CAP] Project File
-[CAP] Projection Projektion
-[CAP] Properties Eigenschaften
-[CAP] Records
-[CAP] Regression Details Regressionsdetails
-[CAP] Regression Formula Regressionsformel
-[CAP] Rotation
-[CAP] Save
-[CAP] Save As Image Als Bild speichern...
-[CAP] Save As Interactive SVG
-[CAP] Save Colors Farben speichern
-[CAP] Save Grid Raster speichern
-[CAP] Save Grid as Image...
-[CAP] Save Map as Image...
-[CAP] Save Project Projekt speichern
-[CAP] Save Settings
-[CAP] Save Shapes Vektordaten speichern
-[CAP] Save TIN
-[CAP] Save Table Tabelle speichern
-[CAP] Save Text Text speichern
-[CAP] Save to PDF
-[CAP] Scale Dependent
-[CAP] Scatterplot
-[CAP] Select File Datei wählen
-[CAP] Settings
-[CAP] Shapes Vektordaten
-[CAP] Shift
-[CAP] Show Anzeigen
-[CAP] Show Always
-[CAP] Show Edges Kanten anzeigen
-[CAP] Show Filled
-[CAP] Show Legend Legende anzeigen
-[CAP] Show Nodes
-[CAP] Show Regression Curve Regressionskurve anzeigen
-[CAP] Show Vertices
-[CAP] Size
-[CAP] Size Range Größenspanne
-[CAP] Size relates to...
-[CAP] Snap Distance
-[CAP] Snap to...
-[CAP] South-North
-[CAP] Standard
-[CAP] Standard Deviation Standardabweichung
-[CAP] Symbol Image
-[CAP] Symbol Type
-[CAP] TIN
-[CAP] Table Tabelle
-[CAP] Table Description
-[CAP] Tables Tabellen
-[CAP] This Is Not A Caption!
-[CAP] Transparency [%]
-[CAP] Type Typ
-[CAP] Unique Symbol Einheitliches Symbol
-[CAP] Unit Einheit
-[CAP] Value Wert
-[CAP] Value Range Wertebereich
-[CAP] Value Type
-[CAP] Version
-[CAP] Weight
-[CAP] West-East
-[CAP] Width
-[CAP] Workspace Arbeitsumgebung
-[CAP] X Axis
-[CAP] X Label
-[CAP] Z-Factor Z-Faktor
-[CAP] Zoom to added layer
-[CAP] [no items] [keine Objekte]
-[CAP] [none] [nicht gesetzt]
-[CMD] About SAGA Über SAGA
-[CMD] Action Aktion
-[CMD] Add Field Feld hinzufügen
-[CMD] Add Part Segment hinzufügen
-[CMD] Add Position [A] Position hinzufügen [A]
-[CMD] Add Project Projekt hinzufügen
-[CMD] Add Record Datensatz hinzufügen
-[CMD] Add Shape Objekt hinzufügen
-[CMD] Anaglyph [S]
-[CMD] Arrange Icons Ikonen anordnen
-[CMD] Backward Zurück
-[CMD] Cascade Überlappend
-[CMD] Central Projection Zentralprojektion
-[CMD] Clear Löschen
-[CMD] Close Schließen
-[CMD] Close All Alle schliessen
-[CMD] Convert To Table In Tabelle umwandeln
-[CMD] Copy Kopieren
-[CMD] Create HTML Documentation
-[CMD] Create Lookup Table Nachschlagetabelle erstellen
-[CMD] Create Normalised Classification Normalisierte Klassifikation erstellen
-[CMD] Create Script Command File
-[CMD] Cumulative Kumulativ
-[CMD] Decrease Exaggeration [F1] Überhöhung verringern [F1]
-[CMD] Decrease Eye Distance
-[CMD] Decrease Perspectivic Distance [F5]
-[CMD] Delete All Positions Alle Positionen löschen
-[CMD] Delete All Records
-[CMD] Delete Fields
-[CMD] Delete Last Position [D] Letzte Position löschen [D]
-[CMD] Delete Record
-[CMD] Delete Selected Part Ausgewähltes Segment löschen
-[CMD] Delete Selected Point Ausgewählten Punkt löschen
-[CMD] Delete Selected Shape(s)
-[CMD] Down Ab
-[CMD] Edit Positions Positionen editieren
-[CMD] Edit Selected Shape Ausgewähltes Vektorobjekt editieren
-[CMD] Execute Ausführen
-[CMD] Exit Beenden
-[CMD] Exit SAGA SAGA beenden
-[CMD] Fit Column Sizes
-[CMD] Fit Grid Colors To Map Extent Rasterfarben an Ausschnitt anpassen
-[CMD] Fit Row Sizes
-[CMD] Fit Scale... Maßstab anpassen...
-[CMD] Forward Vorwärts
-[CMD] Help Hilfe
-[CMD] Increase Exaggeration [F2] Überhöhung verstärken [F2]
-[CMD] Increase Eye Distance
-[CMD] Increase Perspectivic Distance [F6]
-[CMD] Insert Record
-[CMD] Interpolated Colors Interpolierte Farben
-[CMD] Invert Selection
-[CMD] Left Links
-[CMD] Left [F3]
-[CMD] Load
-[CMD] Load Grid Lade Raster
-[CMD] Load Module Library Lade Modulbibliothek
-[CMD] Load Project Lade Projekt
-[CMD] Load Shapes Lade Vektordaten
-[CMD] Load TIN
-[CMD] Load Table Lade Tabelle
-[CMD] Measure Distance
-[CMD] Move Down
-[CMD] Move To Bottom Ganz nach unten
-[CMD] Move To Top Ganz nach oben
-[CMD] Move Up
-[CMD] Next Nächstes
-[CMD] Page Setup Seite einrichten
-[CMD] Pan Verschieben
-[CMD] Play And Save As Images... Abspielen und als Bilder speichern
-[CMD] Play Loop [L] Wiederholt abspielen
-[CMD] Play Once [P] Apspielen
-[CMD] Previous Voriges
-[CMD] Print Drucken
-[CMD] Print Preview Druckvorschau
-[CMD] Print Setup Drucker einrichten
-[CMD] Properties Eigenschaften
-[CMD] Right Rechts
-[CMD] Right [F4]
-[CMD] Save As Image when changed
-[CMD] Save As Image... Als Bild speichern...
-[CMD] Save As PDF Als PDF speichern...
-[CMD] Save Grid Raster speichern
-[CMD] Save Grid As Image... Raster als Bilddatei speichern...
-[CMD] Save Grid As... Raster speichern unter...
-[CMD] Save Project Projekt speichern
-[CMD] Save Project As... Projekt speichern unter
-[CMD] Save Shapes Vektordaten speichern
-[CMD] Save Shapes As... Vektordaten speichern unter...
-[CMD] Save TIN TIN speichern
-[CMD] Save TIN As... TIN speichern unter...
-[CMD] Save Table Tabelle speichern
-[CMD] Save Table As... Tabelle speichern unter...
-[CMD] Save as Interactive SVG Als interaktive Scalable Vector Graphic Dateien speichern
-[CMD] Show 3D-View 3D-Ansicht anzeigen
-[CMD] Show Diagram Diagramm anzeigen
-[CMD] Show Grid Raster anzeigen
-[CMD] Show Histogram Histogramm anzeigen
-[CMD] Show Horizontal Legend Legende horizontal anzeigen
-[CMD] Show Layer Schicht anzeigen
-[CMD] Show Map Karte anzeigen
-[CMD] Show Message Window Nachrichten anzeigen
-[CMD] Show Object Properties Objekteigenschaften anzeigen
-[CMD] Show Print Layout Kartenlayout anzeigen
-[CMD] Show Scatterplot Scatterplot anzeigen
-[CMD] Show Shapes Vektordaten anzeigen
-[CMD] Show TIN TIN anzeigen
-[CMD] Show Table Tabelle anzeigen
-[CMD] Show Toolbar Werkzeugleiste anzeigen
-[CMD] Show Vertical Legend Legende vertikal anzeigen
-[CMD] Show Workspace Arbeitsumgebung anzeigen
-[CMD] Sort Fields Felder sortieren
-[CMD] Synchronise Map Extents Kartenausschnitte synchronisieren
-[CMD] Tile Horizontally Horizontal anordnen
-[CMD] Tile Vertically Vertikal anordnen
-[CMD] Tip of the Day... Tipp des Tages...
-[CMD] UNRECOGNISED COMMAND ID
-[CMD] Up Auf
-[CMD] Update Data
-[CMD] Zoom Vergrößerung
-[CMD] Zoom To Active Layer Auf ausgewählte Schicht zoomen
-[CMD] Zoom To Extent Auf Erstreckung zoomen
-[CMD] Zoom To Full Extent Auf volle Erstreckung zoomen
-[CMD] Zoom To Next Extent Auf nächste Erstreckung zoomen
-[CMD] Zoom To Previous Extent Auf vorige Erstreckung zoomen
-[CMD] Zoom To Selection Auf ausgewählte Elemente zoomen
-[DAT] Cell size Zellgröße
-[DAT] Grid Raster
-[DAT] Line Linie
-[DAT] Lower left corner Linke untere Ecke
-[DAT] Number of cells Anzahl der Zellen
-[DAT] Point Punkt
-[DAT] Points Punkte
-[DAT] Polygon
-[DAT] Resampling
-[DAT] Save shapes Vektordaten speichern
-[DAT] Shapes Vektordaten
-[DAT] TIN
-[DAT] Table Tabelle
-[DAT] Undefined Undefiniert
-[DAT] [not set] [nicht gesetzt]
-[DAT] new neu
-[DLG] Add layer to selected map Datensatz zu ausgewählter Karte hinzufügen
-[DLG] Delete selected shape(s). Ausgewählte Vektordatenelemente löschen
-[DLG] Invalid parameters! Ungültige Parameter
-[DLG] Please enter a numeric value: Bitte geben Sie einen Zahlenwert ein:
-[DLG] Save changes? Änderungen speichern?
-[DLG] Scale 1 : Maßstab 1 :
-[DLG] Set selected values to no data. Auswahl als \'Keine Daten\' markieren.
-[ERR] Access Violation Speicher-Zugriffsverletzung
-[ERR] Calculation Error
-[ERR] Can't execute a module while another runs Modul kann nicht ausgeführt werden, während ein anderes läuft
-[ERR] Corrupted shape file.
-[ERR] Could not save PDF file.
-[ERR] DBase file could not be opened or it did not contain any records.
-[ERR] Error: Continue anyway ?
-[ERR] Grid file could not be opened. Rasterdatei konnte nicht geöffnet werden
-[ERR] Grid file could not be saved. Raster konnte nicht gespeichert werden
-[ERR] Invalid data set! Ungültiger Datensatz!
-[ERR] Invalid data! Ungültige Daten!
-[ERR] Invalid display size! Ungültiger Ausgabebereich!
-[ERR] Invalid library Ungültige Bibliothek
-[ERR] Library could not be loaded Bibliothek konnte nicht geöffnet werden
-[ERR] Library does not contain any modules Bibliothek enthält keine Module
-[ERR] Library has already been loaded Bibliothek wurde bereits geladen
-[ERR] Shape file could not be opened. Vektordatei konnte nicht geöffnet werden
-[ERR] Shape file invalid or of unsupported type.
-[ERR] Shape file is corrupted. Vektordatei ist korrumpiert
-[ERR] Shape index file could not be opened. Vektor-Indexdatei konnte nicht geöffnet werden
-[ERR] There was a problem printing.\nPerhaps your current printer is not set correctly? Es gab ein Druckproblem.\nVielleicht ist Ihr Drucker nicht korrekt eingestellt?
-[ERR] Unknown Error
-[ERR] You canceled printing Sie haben den Druckvorgang abgebrochen
-[FLD] Attribute
-[FLD] Central Projection Zentralprojektion
-[FLD] Exaggeration Überhöhung
-[FLD] Grid Raster
-[FLD] Icon
-[FLD] Index Layer Index Schicht
-[FLD] Name
-[FLD] PDF Document
-[FLD] Paper Format
-[FLD] Rotate X Drehung X
-[FLD] Rotate Y Drehung Y
-[FLD] Rotate Z Drehung Z
-[FLD] Round Scale
-[FLD] SVG File
-[FLD] Shapes Vektordaten
-[FLD] Shift X Verschiebung X
-[FLD] Shift Y Verschiebung Y
-[FLD] Shift Z Verschiebung Z
-[FLD] Steps to Next Anzahl der Schritte
-[FLD] Title Titel
-[FLD] Value Wert
-[HLP] Execute Module Modul ausführen
-[HST] Created from file Von Datei geladen
-[HST] Created with module Von Modul erstellt
-[HST] Grid addition Raster Addition
-[HST] Grid denormalisation Raster Denormalisierung
-[HST] Grid division Raster Division
-[HST] Grid multiplication Raster Multiplikation
-[HST] Grid normalisation Raster Normalisierung
-[HST] Grid operation Raster Operation
-[HST] Grid subtraction Raster Subtraktion
-[HST] Horizontally mirrored Horizontale Spiegelung
-[HST] Inversion Invertierung
-[HST] Loaded from file Von Datei geladen
-[HST] Value addition Addition eines Wertes
-[HST] Value assigned to grid Zuweisung eines Wertes
-[HST] Value division Division durch einen Wert
-[HST] Value multiplication Multiplikation eines Wertes
-[HST] Value subtraction Subtraktion eines Wertes
-[HST] Vertically mirrored Vertikale Spiegelung
-[MNU] ?
-[MNU] Edit Editieren
-[MNU] File Datei
-[MNU] Grid Rasterdaten
-[MNU] Modules Module
-[MNU] Project Projekt
-[MNU] Rotation
-[MNU] Sequencer Sequenzer
-[MNU] Shapes Vektordaten
-[MNU] Shift Verschiebung
-[MNU] TIN
-[MNU] Table Tabelle
-[MNU] Window Fenster
-[MSG] Build Histogram... Histogramm erstellen...
-[MSG] Close Schließe
-[MSG] Close Library Schließe Bibliothek
-[MSG] Close table Schließe Tabelle
-[MSG] Could not load project. Projekt konnte nicht geladen werden
-[MSG] Could not save project. Projekt konnte nicht gespeichert werden
-[MSG] Create TIN from shapes TIN aus Vektordatensatz erstellen
-[MSG] Executing module Modul ausführen
-[MSG] Execution has been stopped by user! Modulausführung von Benutzer abgebrochen!
-[MSG] Interactive module execution failed Ausführung des interaktiven Moduls schlug fehl
-[MSG] Interactive module execution has been started Ausführung des interaktiven Moduls wurde gestartet
-[MSG] Interactive module execution has been stopped Ausführung des interaktiven Moduls wurde beendet
-[MSG] Load grid Lade Rasterdaten
-[MSG] Load library Lade Bibliothek
-[MSG] Load project Lade Projekt
-[MSG] Load shapes Lade Vektordaten
-[MSG] Load table Lade Tabelle
-[MSG] Module execution failed Modulausführung schlug fehl
-[MSG] Module execution succeeded Modul wurde erfolgreich ausgeführt
-[MSG] Project has been saved. Projekt wurde gespeichert
-[MSG] Project has been successfully loaded. Projekt wurde erfolgreich geladen
-[MSG] Save as Interactive SVG
-[MSG] Save grid Rasterdaten speichern
-[MSG] Save shapes Vektordaten speichern
-[MSG] Save table Tabelle speichern
-[MSG] Save to PDF Als PDF speichern
-[MSG] Shall execution be stopped? Soll die Ausführung abgebrochen werden?
-[MSG] failed fehlgeschlagen
-[MSG] has already been loaded bereits geladen
-[MSG] okay erfolgreich
-[PRM] Boolean Wahrheitswert
-[PRM] Choice Auswahl
-[PRM] Color Farbe
-[PRM] Colors Farben
-[PRM] Data Object Datensatz
-[PRM] Data Objects Datensätze
-[PRM] Degree Grad
-[PRM] File path Dateipfad
-[PRM] Floating point Fließkommazahl
-[PRM] Font Schrift
-[PRM] Frame Width [Pixels] Rahmenbreite (Pixel)
-[PRM] Grid Raster
-[PRM] Grid list Liste von Rastern
-[PRM] Grid system Rastersystem
-[PRM] Grids Raster
-[PRM] Integer Ganzzahl
-[PRM] Legend Legende
-[PRM] Long text Langer Text
-[PRM] Map Height [Pixels] Kartenhöhen (Pixel)
-[PRM] Map Width [Pixels] Kartenbreite (Pixel)
-[PRM] Node Knoten
-[PRM] Options Optionen
-[PRM] Parameter
-[PRM] Parameters Parameterliste
-[PRM] Save Speichern
-[PRM] Save Georeference (world file) Georeferenz speichern
-[PRM] Shapes Vektordaten
-[PRM] Shapes list Liste von Vektordaten
-[PRM] Static table Statische Tabelle
-[PRM] TIN
-[PRM] TIN list TIN Liste
-[PRM] Table Tabelle
-[PRM] Table field Tabellenfeld
-[PRM] Table list Liste von Tabellen
-[PRM] Tables Tabellen
-[PRM] Text
-[PRM] Value range Wertebereich
-[PRM] Zoom
-[TXT] Close all data sets Alle Datensätze schliessen
-[TXT] Do you want to delete the selection? Wollen Sie die Auswahl entfernen?
-[TXT] Do you want to exit SAGA? Wollen Sie SAGA beenden?
-[TXT] No data loaded. Keine Daten geladen.
-[TXT] No description available Keine Beschreibung verfügbar
-[TXT] No parameters available. Keine Parameter verfügbar
-[TXT] SAGA\nSystem for Automated Geoscientific Analyses\nVersion 2.0 SAGA\nSystem für Automatisierte Geowissenschaftliche Analysen\nVersion 2.0
-[TXT] This is not a text!
-[TXT] grid system Rastersystem
-[TXT] grid systems Rastersysteme
-[VAL] B-Spline
-[VAL] Backward Diagonal Schräg nach links
-[VAL] Bicubic Spline Bikubischer Spline
-[VAL] Bilinear
-[VAL] Cross Gekreuzt
-[VAL] Cross Diagonal Schräg gekreuzt
-[VAL] Dot And Dash Punkt und Strich
-[VAL] Dotted Gepunktet
-[VAL] File Cache Dateipuffer
-[VAL] Forward Diagonal Schräg nach rechts
-[VAL] Graduated Color Abgestufter Farbverlauf
-[VAL] Horizontal
-[VAL] Inverse Distance Umgekehrte Distanz
-[VAL] Linear
-[VAL] Logarithmic (down) Logarithmisch (nach rechts)
-[VAL] Logarithmic (up) Logarihmisch (nach links)
-[VAL] Long Dashed Lange Striche
-[VAL] Lookup Table Nachschlagetabelle
-[VAL] Map Units Karteneinheiten
-[VAL] New Neu
-[VAL] No objects Keine Objekte
-[VAL] None Nicht vorhanden
-[VAL] Normal
-[VAL] Opaque Undurchsichtig
-[VAL] RGB
-[VAL] RTL Compression RTL Komprimierung
-[VAL] Screen Bildschirm
-[VAL] Shade Schummerung
-[VAL] Short Dashed Kurze Striche
-[VAL] Solid Solide
-[VAL] Transparent
-[VAL] Unique Symbol Einheitliches Symbol
-[VAL] Vertical Vertikal
-[VAL] [all grid systems] [alle Rastersysteme]
-[VAL] [create] [erstellen]
-[VAL] [default] [Standardwert]
-[VAL] [no choice available] [keine Auswahl verfügbar]
-[VAL] [no fields] [keine Felder verfügbar]
-[VAL] [none] [nicht vorhanden]
-[VAL] [not set] [nicht gesetzt]
-[VAL] no nein
-[VAL] object Objekt
-[VAL] objects Objekte
-[VAL] ready fertig
-[VAL] yes ja
-access violation Fehlerhafter Speicherzugriff
-after nach
-ascending aufsteigend
-author Autor
-automatically save and load automatisch speichern und laden
-available module libraries verfügbare Modulbibliotheken
-available modules verfügbare Module
-ball Ball
-bar Balken
-bar (not outlined) Balken (nicht umrandet)
-before vor
-black > blue schwarz > blau
-black > green schwarz > grün
-black > red schwarz > rot
-buffer size Größe des Puffers
-cannot execute interactive module interaktives Modul kann nicht ausgeführt werden
-central zentral
-character string Zeichenkette
-circle Kreis
-circle in rhombus Kreis in Rhombus
-circle in square Kreis in Quadrat
-circle in triangle (down) Kreis in Dreieck (Spitze abwärts)
-circle in triangle (up) Kreis in Dreieck (Spitze aufwärts)
-circle with rhombus Kreis mit Rhombus
-circle with square Kreis mit Quadrat
-circle with triangle (down) Kreis mit Dreieck (Spitze abwärts)
-circle with triangle (up) Kreis mit Dreieck (Spitze aufwärts)
-color (rgb) Farbe (RGB)
-colors Farben
-columns Spalten
-confirm Bestätige
-confirm with options Bestätige mit Optionen
-continue fortsetzen
-creating batch file example
-cylinder Zylinder
-date (dd.mm.yyyy) Datum (dd.mm.yyyy)
-default Standard
-default (same brightness) Standard (gleiche Helligkeit)
-descending absteigend
-do not confirm nicht bestätigen
-do not show nicht anzeigen
-empty leer
-empty coded function leere Funktion
-empty input list
-error Fehler
-executing module Modulausführung
-failed fehlgeschlagen
-function not found Funktion nicht gefunden
-function table full
-green > blue
-green > grey > blue
-green > red > blue
-greyscale Graustufen
-image Bild
-improper function syntax
-index out of bounds
-input Eingabe
-input file Eingabedatei
-interactive interaktiv
-interactive execution interaktive Ausführung
-invalid module libraries path
-invalid number of parameters
-last opened zuletzt geöffnet
-library name
-library path
-missing operand
-module Modul
-module library Modulbibliothek
-module library not found Modulbibliothek nicht gefunden
-module name Modulname
-module not found Modul nicht gefunden
-no nein
-no memory kein Speicher
-no valid module library found in path
-okay
-only during start up phase nur während der Programminitialisierung
-optional
-optional input optionale Eingabe
-optional output optionale Ausgabe
-original functions may not be deleted
-output Ausgabe
-panorama Panorama
-parallel
-parameters Parameter
-pie Torte
-pie (not outlined) Torte (nicht umrandet)
-plain
-press any key
-ready fertig
-red > blue
-red > blue > green
-red > green
-red > green > blue
-red > grey > blue
-red > grey > green
-rhombus Rhombus
-rows Reihen
-square Quadrat
-syntax error Syntaxfehler
-too few parameters Zu wenige Parameter
-too many constants Zu wenige Konstanten
-too many parameters Zu viele Parameter
-triangle (down) Dreieck (Spitze abwärts)
-triangle (up) Dreieck (Spitze aufwärts)
-type -h or --help for further information
-undeclared parameter
-unmatched parentheses
-unsorted unsortiert
-until user closes it bis Mausklick
-white > blue
-white > green
-white > red
-yellow > blue
-yellow > green
-yellow > red
-yes ja
+ORIGINAL TRANSLATION
+1 byte integer 1 Byte Ganzzahl
+1.5 * Standard Deviation
+2 byte integer 2 Byte Ganzzahl
+2.0 * Standard Deviation
+20 seconds 20 Sekunden
+4 byte floating point 4 Byte Fließkommazahl
+4 byte floating point number
+4 byte integer 4 Byte Ganzzahl
+8 byte floating point 8 Byte Fließkommazahl
+8 byte floating point number
+A3 Landscape
+A3 Portrait
+A4 Landscape
+A4 Portrait
+AREA
+About SAGA Über SAGA
+Acknowledgements Danksagungen
+Activate Grid File Cache? Dateipuffer für Raster aktivieren?
+Activate file caching automatically, if memory size exceeds the threshold value. Dateipuffer für Raster automatisch aktivieren, wenn Speicherbedarf Schwellenwert überschreitet.
+Add Field Feld hinzufügen
+Addition
+All Files Alle Dateien
+All Recognised Files Alle erkannten Dateitypen
+Area Fläche
+Assign
+Attribute Attribut
+Automatic mode Automatisch
+Available Choices Auswahlmöglichkeiten
+Available Connections
+Backward diagonal hatch
+Bars Balken
+Bottom
+Buffer Size [MB] Puffergröße
+CENTER
+CLASS KLASSE
+COLOR FARBE
+COUNT ANZAHL
+Cellsize
+Chart Type Diagrammtyp
+Choose Attribute Wähle Attribut
+Choose Documentation Folder
+Choose ODBC Connection
+Class 1 Klasse 1
+Class 2 Klasse 2
+Clear Löschen
+Colors
+Colors file could not be exported. Farbdatei konnte nicht erstellt werden.
+Colors file could not be imported. Farbdatei konnte nicht geladen werden.
+Columns
+Compare with...
+CompuServe Graphics Interchange
+Confirm file caching Dateipufferaktivierung jedesmal bestätigen
+Constraints Einschränkungen
+Copy Kopieren
+Copy Settings from...
+Create HTML Documentation
+Create Lookup Table Nachschlagetabelle erstellen
+Create index Index erstellen
+Creating module documentation files Dateien zur Moduldokumentation erstellen
+Cross hatch
+Cross-diagonal hatch
+Currently no help files exist for SAGA.\nIt depends on your support, if you will find any help at this place in future!\nThanks a lot... Zur Zeit existiert keine Programmhilfe für SAGA\nEs hängt auch von Deiner/Ihrer Unterstützung ab, ob hier in Zukunft eine Hilfe zur Verfügung stehen wird.\nVielen Dank im voraus...
+DBase
+DESCRIPTION BESCHREIBUNG
+DSN
+Data
+Data Source Name
+Data Table Datentabelle
+Delete Fields Felder löschen
+Denormalisation
+Description Beschreibung
+Descriptive name for the grid system Anschaulicher Name für das Rastersystem
+Direction Richtung
+Directory
+Directory (DBase, Excel)
+Directory, where temporary cache files shall be saved. Verzeichnis, in dem temporäre Dateipuffer gespeichert werden sollen.
+Display Range
+Division
+Dot and dash style
+Dotted style
+ESRI Shape Files
+Error Fehler
+Error in Trend Calculation Fehler in Trendberechnung
+Error in formula Fehler in Formel
+Exit SAGA SAGA beenden
+Field Feld
+Field Type Datentyp
+Fields Felder
+First Class Erste Klasse
+Forward diagonal hatch
+Function failed because no attributes are available Funktion schlug fehl, weil keine Attribute verfügbar sind.
+General Allgemein
+Geocentric Coordinate System
+Geographic Coordinate System
+Grid
+Grid Display Defaults
+Grid File Caching Dateipufferung für Raster
+Grids Raster
+Height Höhe
+Horizontal hatch
+Horizontally mirrored
+I1: unrecognizable operator
+I2: too many parameters
+I3: corrupted buffer
+I4: size estimate too small
+Identifier Bezeichner
+Image Files Bilddateien
+Image Resolution Bildauflösung
+In/Out Eingabe/Ausgabe
+Input Eingabe
+Insert Method Einfügemethode
+Insert Position Einfügeposition
+Inversion
+JPEG - JFIF Compliant
+JPG Files JPG Dateien
+Layers Schichten
+Left
+Left/Right Links/Rechts
+Legend: Save Legende: Speichern
+Legend: Zoom Legende: Vergrößerung
+Length Länge
+Library Overview
+Lines Linien
+Lines and Points Linien und Punkte
+Load Colors Lade Farben
+Load Parameters Lade Parameter
+Logo
+Long dashed style
+MAX
+MAXIMUM
+MIN
+MINIMUM
+Map Karte
+Maps Karten
+Maximum
+Menu Menü
+Minimum
+Minimum/Maximum
+Module Modul
+Module Library Descriptions
+Multiplication
+NAME
+Name
+Neon
+No ODBC connection available!
+No history available
+No pen is used
+Normalisation
+ODBC Database Connection Error
+Option
+Options Optionen
+Options for Data Thumbnails Optionen für Daten-Vorschaubilder
+Options for Map Thumbnails Optionen für Karten-Vorschaubilder
+Output Ausgabe
+PDF Files
+PNG Files
+Parameters Parameterliste
+Parameters file could not be exported. Parameterdatei konnte nicht erstellt werden.
+Parameters file could not be imported. Parameterdatei konnte nicht geladen werden.
+Parts Teile
+Password
+Perimeter Umfang
+Please stop module execution before exiting SAGA. Um SAGA zu beenden, muß erst das laufende Modul angehalten werden.
+Point Clouds
+Points Punkte
+Portable Network Graphics
+Position
+Process Update Frequency [milliseconds]
+Projected Coordinate System
+Rainbow Regenbogen
+Rename Fields
+Resampling
+Resolution Auflösung
+Right
+Rows
+SAGA Colors SAGA Farben
+SAGA Help SAGA Hilfe
+SAGA Module Libraries
+SAGA Parameter Files
+SAGA Point Clouds
+SAGA Project
+SAGA Projects
+SAGA: Print Map
+SVG - Scalable Vector Graphics Files (*.svg)
+Save 3D Image Options
+Save Colors
+Save Georeference
+Save Parameters
+Save all
+Scale
+Scatterplot
+Second Class
+Selection Color
+Shall I activate file caching for new grid.
+Short dashed style
+Show Categories
+Show Logo at Start Up
+Solid style
+Sort Table
+Sort first by
+Sort second by
+Sort third by
+South-North
+Start Project
+Subtraction
+Table
+Tables
+Tagged Image File Format
+Temporary files
+Text
+Text Files
+Thin Plate Spline: solving matrix
+This is a Test!!!
+Threshold for automatic mode [MB]
+Thumbnail Size
+Thumbnails
+Top
+Total memory size
+Tree
+Type
+Undefined Coordinate System
+Up/Down
+Use the stipple bitmap
+Use the user dashes
+User
+User Name
+Value Range
+Version
+Vertical hatch
+Vertically mirrored
+West-East
+Width Breite
+Windows or OS/2 Bitmap
+X
+X11 Pixel Map
+Y
+You have to choose a grid for comparison
+You have to choose a shapes layer for comparison
+Z
+Zsoft Paintbrush
+[BTN] Add Hinzufügen
+[BTN] Apply Anwenden
+[BTN] Button
+[BTN] Cancel Abbrechen
+[BTN] Clear Alles löschen
+[BTN] Count Anzahl
+[BTN] Delete Löschen
+[BTN] Down Ab
+[BTN] Execute Ausführen
+[BTN] Insert Einfügen
+[BTN] Invert Invertieren
+[BTN] Load Laden
+[BTN] Mirror Spiegeln
+[BTN] Okay
+[BTN] Presets
+[BTN] Random Zufall
+[BTN] Restore Wiederherstellen
+[BTN] Save Speichern
+[BTN] Up Auf
+[CAP] 3D-View 3D-Ansicht
+[CAP] 3D-View: Player Sequence 3D-Ansicht: Abspielsequenz
+[CAP] About SAGA Über SAGA
+[CAP] Anaglyph
+[CAP] Arithmetic Mean Mittelwert
+[CAP] Attribute Attribut
+[CAP] Attribute (Size)
+[CAP] Attributes Attribute
+[CAP] Author Autor
+[CAP] Background Color Hintergrundfarbe
+[CAP] Beep when finished
+[CAP] Buffer Size MB
+[CAP] Cell Size Zellgröße
+[CAP] Cell size Zellgröße
+[CAP] Chart
+[CAP] Chart Properties
+[CAP] Choose Directory
+[CAP] Circles Kreise
+[CAP] Clipboard
+[CAP] Close
+[CAP] Close and save modified data sets...
+[CAP] Color Farbe
+[CAP] Color by Attribute
+[CAP] Coloring
+[CAP] Colors Farben
+[CAP] Create Script Command File
+[CAP] Data Daten
+[CAP] Data History
+[CAP] Decimals Dezimalstellen
+[CAP] Default Size
+[CAP] Defaults
+[CAP] Delete Löschen
+[CAP] Description Beschreibung
+[CAP] Diagram Diagramm
+[CAP] Display Darstellung
+[CAP] Display Resolution Auflösung
+[CAP] Display Type Darstellungsart
+[CAP] Display: Cell Values
+[CAP] Display: Color Classification
+[CAP] Display: Label
+[CAP] Display: Size
+[CAP] Display: Visibility
+[CAP] Edit
+[CAP] Edit Shapes Vektordaten editieren
+[CAP] Elevation Höhe
+[CAP] Errors Fehler
+[CAP] Exaggeration Überhöhung
+[CAP] Execution Modulausführung
+[CAP] Exit Beenden
+[CAP] Eye Distance [Degree]
+[CAP] Field Feld
+[CAP] Fields
+[CAP] Figure
+[CAP] File Datei
+[CAP] File cache activated
+[CAP] Fill Color
+[CAP] Fill Style Füllstil
+[CAP] Fit Map Scale Maßstab anpassen
+[CAP] Fit Size to Window
+[CAP] Fixed Maximum
+[CAP] Fixed Minimum
+[CAP] Font Schriftart
+[CAP] Frame
+[CAP] Frame Width
+[CAP] General Allgemein
+[CAP] Graduated Color Abgestufte Farben
+[CAP] Grid Raster
+[CAP] Grid System Raster System
+[CAP] Grid Systems Raster Systeme
+[CAP] Grids Raster
+[CAP] Height
+[CAP] Histogram Histogramm
+[CAP] History
+[CAP] Horizontal Align
+[CAP] Html Extra Info
+[CAP] Index
+[CAP] Input Eingabe
+[CAP] Interpolated Interpoliert
+[CAP] Interpolation
+[CAP] Label
+[CAP] Layers
+[CAP] Legend
+[CAP] Legend Border Colour
+[CAP] Legend Frame Width
+[CAP] Legend Scale
+[CAP] Line Style
+[CAP] Load
+[CAP] Load Colors Lade Farben
+[CAP] Load Grid Lade Raster
+[CAP] Load Module Library Lade Modulbibliothek
+[CAP] Load Point Cloud
+[CAP] Load Project Lade Projekt
+[CAP] Load Settings
+[CAP] Load Shapes Lade Vektordaten
+[CAP] Load TIN
+[CAP] Load Table Lade Tabelle
+[CAP] Load Text Lade Text
+[CAP] Logarithmic Stretch Factor Logarithmische Streckung
+[CAP] Lookup Table Nachschlagetabelle
+[CAP] Map Karte
+[CAP] Map Extent
+[CAP] Map Scale Maßstab
+[CAP] Map Selection Kartenauswahl
+[CAP] Map-Layout
+[CAP] Maps Karten
+[CAP] Maximum
+[CAP] Maximum Value
+[CAP] Mean
+[CAP] Memory Speicher
+[CAP] Memory Compression
+[CAP] Memory Handling Speicherverwaltung
+[CAP] Memory Size Speicherbedarf
+[CAP] Messages Nachrichten
+[CAP] Minimum
+[CAP] Minimum Value
+[CAP] Mode Modus
+[CAP] Modified Modifiziert
+[CAP] Module Execution Modulausführung
+[CAP] Module Libraries Modulbibliotheken
+[CAP] Module Library Modulbibliothek
+[CAP] Modules Module
+[CAP] Name
+[CAP] No Data Keine Daten
+[CAP] Number Of Cells Anzahl der Zellen
+[CAP] Number Of Grids Anzahl der Rasterdatensätze
+[CAP] Number Of Shapes Anzahl der Vektordatensätze
+[CAP] Number of Points
+[CAP] Number of cells Anzahl der Zellen
+[CAP] Object Properties
+[CAP] Open
+[CAP] Options Optionen
+[CAP] Outline Umrandung
+[CAP] Outline Color
+[CAP] Outline Size
+[CAP] Overlay 1
+[CAP] Overlay 2
+[CAP] Parameters Parameter
+[CAP] Perspectivic Distance Perspektivischer Abstand
+[CAP] Point Cloud
+[CAP] Point Clouds
+[CAP] Point Size
+[CAP] PointCloud
+[CAP] Points Punkte
+[CAP] Preset Selection
+[CAP] Print Layout
+[CAP] Print Preview Druckvorschau
+[CAP] Project File
+[CAP] Projection Projektion
+[CAP] Properties Eigenschaften
+[CAP] RGB Overlay
+[CAP] Records
+[CAP] Regression Details Regressionsdetails
+[CAP] Regression Formula Regressionsformel
+[CAP] Rotation
+[CAP] Rotation (Degree)
+[CAP] Rotation by Attribute
+[CAP] Save
+[CAP] Save As Image Als Bild speichern...
+[CAP] Save As Interactive SVG
+[CAP] Save Colors Farben speichern
+[CAP] Save Grid Raster speichern
+[CAP] Save Grid as Image...
+[CAP] Save Map as Image...
+[CAP] Save Point Cloud
+[CAP] Save Project Projekt speichern
+[CAP] Save Settings
+[CAP] Save Shapes Vektordaten speichern
+[CAP] Save TIN
+[CAP] Save Table Tabelle speichern
+[CAP] Save Text Text speichern
+[CAP] Save to PDF
+[CAP] Scale Dependent
+[CAP] Scatterplot
+[CAP] Select File Datei wählen
+[CAP] Selection
+[CAP] Settings
+[CAP] Shade
+[CAP] Shapes Vektordaten
+[CAP] Shift
+[CAP] Show Anzeigen
+[CAP] Show Always
+[CAP] Show Centroid
+[CAP] Show Edges Kanten anzeigen
+[CAP] Show Filled
+[CAP] Show Legend Legende anzeigen
+[CAP] Show Nodes
+[CAP] Show Regression Curve Regressionskurve anzeigen
+[CAP] Show Scale
+[CAP] Show Vertices
+[CAP] Size
+[CAP] Size Range Größenspanne
+[CAP] Size by Attribute
+[CAP] Size relates to...
+[CAP] Snap Distance
+[CAP] Snap to...
+[CAP] South-North
+[CAP] Standard
+[CAP] Standard Deviation Standardabweichung
+[CAP] Symbol Image
+[CAP] Symbol Type
+[CAP] TIN
+[CAP] Table Tabelle
+[CAP] Table Description
+[CAP] Tables Tabellen
+[CAP] This Is Not A Caption!
+[CAP] Transparency [%]
+[CAP] Type Typ
+[CAP] Unique Symbol Einheitliches Symbol
+[CAP] Unit Einheit
+[CAP] Value Wert
+[CAP] Value Aggregation
+[CAP] Value Range Wertebereich
+[CAP] Value Type
+[CAP] Values
+[CAP] Version
+[CAP] Vertical Align
+[CAP] Weight
+[CAP] West-East
+[CAP] Width
+[CAP] Workspace Arbeitsumgebung
+[CAP] X Axis
+[CAP] Y Axis
+[CAP] Z-Factor Z-Faktor
+[CAP] Zoom to added layer
+[CAP] [no items] [keine Objekte]
+[CAP] [none] [nicht gesetzt]
+[CMD] About SAGA Über SAGA
+[CMD] Action Aktion
+[CMD] Add Field Feld hinzufügen
+[CMD] Add Part Segment hinzufügen
+[CMD] Add Position [A] Position hinzufügen [A]
+[CMD] Add Project Projekt hinzufügen
+[CMD] Add Record Datensatz hinzufügen
+[CMD] Add Shape Objekt hinzufügen
+[CMD] Anaglyph [S]
+[CMD] Arrange Icons Ikonen anordnen
+[CMD] Backward Zurück
+[CMD] Cascade Überlappend
+[CMD] Central Projection Zentralprojektion
+[CMD] Clear Löschen
+[CMD] Close Schließen
+[CMD] Close All Alle schliessen
+[CMD] Convert To Table In Tabelle umwandeln
+[CMD] Copy Kopieren
+[CMD] Copy Settings from other Layer
+[CMD] Create HTML Documentation
+[CMD] Create Lookup Table Nachschlagetabelle erstellen
+[CMD] Create Normalised Classification Normalisierte Klassifikation erstellen
+[CMD] Create Script Command File
+[CMD] Cumulative Kumulativ
+[CMD] Decrease Diagram Size
+[CMD] Decrease Exaggeration [F1] Überhöhung verringern [F1]
+[CMD] Decrease Eye Distance
+[CMD] Decrease Perspectivic Distance [F5]
+[CMD] Delete All Positions Alle Positionen löschen
+[CMD] Delete All Records
+[CMD] Delete Fields
+[CMD] Delete Last Position [D] Letzte Position löschen [D]
+[CMD] Delete Selected Part Ausgewähltes Segment löschen
+[CMD] Delete Selected Point Ausgewählten Punkt löschen
+[CMD] Delete Selected Record(s)
+[CMD] Delete Selected Shape(s)
+[CMD] Down Ab
+[CMD] Edit Positions Positionen editieren
+[CMD] Edit Selected Shape Ausgewähltes Vektorobjekt editieren
+[CMD] Execute Ausführen
+[CMD] Exit Beenden
+[CMD] Exit SAGA SAGA beenden
+[CMD] Fit Column Sizes
+[CMD] Fit Diagram to Window
+[CMD] Fit Grid Colors To Map Extent Rasterfarben an Ausschnitt anpassen
+[CMD] Fit Row Sizes
+[CMD] Fit Scale... Maßstab anpassen...
+[CMD] Forward Vorwärts
+[CMD] Help Hilfe
+[CMD] Increase Diagram Size
+[CMD] Increase Exaggeration [F2] Überhöhung verstärken [F2]
+[CMD] Increase Eye Distance
+[CMD] Increase Perspectivic Distance [F6]
+[CMD] Insert Record
+[CMD] Interpolated Colors Interpolierte Farben
+[CMD] Invert Selection
+[CMD] Left Links
+[CMD] Left [F3]
+[CMD] Load
+[CMD] Load Grid Lade Raster
+[CMD] Load Module Library Lade Modulbibliothek
+[CMD] Load Point Cloud
+[CMD] Load Project Lade Projekt
+[CMD] Load Settings
+[CMD] Load Shapes Lade Vektordaten
+[CMD] Load TIN
+[CMD] Load Table Lade Tabelle
+[CMD] Measure Distance
+[CMD] Move Down
+[CMD] Move To Bottom Ganz nach unten
+[CMD] Move To Top Ganz nach oben
+[CMD] Move Up
+[CMD] New Project
+[CMD] Next Nächstes
+[CMD] Page Setup Seite einrichten
+[CMD] Pan Verschieben
+[CMD] Play And Save As Images... Abspielen und als Bilder speichern
+[CMD] Play Loop [L] Wiederholt abspielen
+[CMD] Play Once [P] Apspielen
+[CMD] Previous Voriges
+[CMD] Print Drucken
+[CMD] Print Preview Druckvorschau
+[CMD] Print Setup Drucker einrichten
+[CMD] Properties Eigenschaften
+[CMD] Rename Fields
+[CMD] Right Rechts
+[CMD] Right [F4]
+[CMD] Save As Image when changed
+[CMD] Save As Image... Als Bild speichern...
+[CMD] Save As PDF Als PDF speichern...
+[CMD] Save Grid Raster speichern
+[CMD] Save Grid As Image... Raster als Bilddatei speichern...
+[CMD] Save Grid As... Raster speichern unter...
+[CMD] Save Legend to Clipboard [Ctrl+L]
+[CMD] Save Point Cloud
+[CMD] Save Point Cloud As...
+[CMD] Save Project Projekt speichern
+[CMD] Save Project As... Projekt speichern unter
+[CMD] Save Shapes Vektordaten speichern
+[CMD] Save Shapes As... Vektordaten speichern unter...
+[CMD] Save TIN TIN speichern
+[CMD] Save TIN As... TIN speichern unter...
+[CMD] Save Table Tabelle speichern
+[CMD] Save Table As... Tabelle speichern unter...
+[CMD] Save as Interactive SVG Als interaktive Scalable Vector Graphic Dateien speichern
+[CMD] Save to Clipboard [Ctrl+C]
+[CMD] Set Range to Minmum/Maximum
+[CMD] Set Range to Standard Deviation (1.5)
+[CMD] Set Range to Standard Deviation (2.0)
+[CMD] Show
+[CMD] Show 3D-View 3D-Ansicht anzeigen
+[CMD] Show Diagram Diagramm anzeigen
+[CMD] Show Grid Raster anzeigen
+[CMD] Show Histogram Histogramm anzeigen
+[CMD] Show Horizontal Legend Legende horizontal anzeigen
+[CMD] Show Layer Schicht anzeigen
+[CMD] Show Map Karte anzeigen
+[CMD] Show Message Window Nachrichten anzeigen
+[CMD] Show Object Properties Objekteigenschaften anzeigen
+[CMD] Show Point Cloud
+[CMD] Show Print Layout Kartenlayout anzeigen
+[CMD] Show Scatterplot Scatterplot anzeigen
+[CMD] Show Shapes Vektordaten anzeigen
+[CMD] Show TIN TIN anzeigen
+[CMD] Show Table Tabelle anzeigen
+[CMD] Show Toolbar Werkzeugleiste anzeigen
+[CMD] Show Vertical Legend Legende vertikal anzeigen
+[CMD] Show Workspace Arbeitsumgebung anzeigen
+[CMD] Sort Fields Felder sortieren
+[CMD] Sort Selection to Top
+[CMD] Synchronise Map Extents Kartenausschnitte synchronisieren
+[CMD] Tile Horizontally Horizontal anordnen
+[CMD] Tile Vertically Vertikal anordnen
+[CMD] Tip of the Day... Tipp des Tages...
+[CMD] UNRECOGNISED COMMAND ID
+[CMD] Up Auf
+[CMD] Update Data
+[CMD] Zoom Vergrößerung
+[CMD] Zoom To Active Layer Auf ausgewählte Schicht zoomen
+[CMD] Zoom To Extent Auf Erstreckung zoomen
+[CMD] Zoom To Full Extent Auf volle Erstreckung zoomen
+[CMD] Zoom To Next Extent Auf nächste Erstreckung zoomen
+[CMD] Zoom To Previous Extent Auf vorige Erstreckung zoomen
+[CMD] Zoom To Selection Auf ausgewählte Elemente zoomen
+[DAT] Cell size Zellgröße
+[DAT] Grid Raster
+[DAT] Line Linie
+[DAT] Lower left corner Linke untere Ecke
+[DAT] Number of cells Anzahl der Zellen
+[DAT] Point Punkt
+[DAT] Point Cloud
+[DAT] Points Punkte
+[DAT] Polygon
+[DAT] Shapes Vektordaten
+[DAT] TIN
+[DAT] Table Tabelle
+[DAT] Undefined Undefiniert
+[DAT] [not set] [nicht gesetzt]
+[DAT] new neu
+[DLG] Add layer to selected map Datensatz zu ausgewählter Karte hinzufügen
+[DLG] Delete selected shape(s). Ausgewählte Vektordatenelemente löschen
+[DLG] Invalid parameters! Ungültige Parameter
+[DLG] Please enter a numeric value: Bitte geben Sie einen Zahlenwert ein:
+[DLG] Save changes? Änderungen speichern?
+[DLG] Scale 1 : Maßstab 1 :
+[DLG] Select a layer to copy settings from it.
+[DLG] Set selected values to no data. Auswahl als \'Keine Daten\' markieren.
+[ERR] Calculation Error
+[ERR] Can't execute a module while another runs Modul kann nicht ausgeführt werden, während ein anderes läuft
+[ERR] Could not save PDF file.
+[ERR] DBase file could not be opened.
+[ERR] DBase file does not contain any records.
+[ERR] Error: Continue anyway ?
+[ERR] Grid file could not be opened. Rasterdatei konnte nicht geöffnet werden
+[ERR] Grid file could not be saved. Raster konnte nicht gespeichert werden
+[ERR] Internal system error
+[ERR] Invalid data set! Ungültiger Datensatz!
+[ERR] Invalid data! Ungültige Daten!
+[ERR] Invalid display size! Ungültiger Ausgabebereich!
+[ERR] Invalid library Ungültige Bibliothek
+[ERR] Library could not be loaded Bibliothek konnte nicht geöffnet werden
+[ERR] Library does not contain any modules Bibliothek enthält keine Module
+[ERR] Library has already been loaded Bibliothek wurde bereits geladen
+[ERR] Module caused access violation!
+[ERR] Shape file could not be opened. Vektordatei konnte nicht geöffnet werden
+[ERR] There was a problem printing.\nPerhaps your current printer is not set correctly? Es gab ein Druckproblem.\nVielleicht ist Ihr Drucker nicht korrekt eingestellt?
+[ERR] Unknown Error
+[ERR] You canceled printing Sie haben den Druckvorgang abgebrochen
+[ERR] corrupted file header
+[ERR] corrupted record header
+[ERR] corrupted shapefile.
+[ERR] dbase file could not be opened
+[ERR] file could not be opened.
+[ERR] incompatible file.
+[ERR] index file could not be opened
+[ERR] invalid file code
+[ERR] memory allocation error.
+[ERR] no records in file.
+[ERR] shape file could not be opened.
+[ERR] unable to create file.
+[ERR] unsupported file version
+[ERR] unsupported shape type.
+[FLD] Attribute
+[FLD] Central Projection Zentralprojektion
+[FLD] Exaggeration Überhöhung
+[FLD] Grid Raster
+[FLD] Icon
+[FLD] Index Layer Index Schicht
+[FLD] Name
+[FLD] PDF Document
+[FLD] Paper Format
+[FLD] Rotate X Drehung X
+[FLD] Rotate Y Drehung Y
+[FLD] Rotate Z Drehung Z
+[FLD] Round Scale
+[FLD] SVG File
+[FLD] Shapes Vektordaten
+[FLD] Shift X Verschiebung X
+[FLD] Shift Y Verschiebung Y
+[FLD] Shift Z Verschiebung Z
+[FLD] Steps to Next Anzahl der Schritte
+[FLD] Title Titel
+[FLD] Value Wert
+[HLP] Execute Module Modul ausführen
+[HST] Created from file Von Datei geladen
+[MNU] ?
+[MNU] Attributes
+[MNU] Classification
+[MNU] Classificaton
+[MNU] Edit Editieren
+[MNU] File Datei
+[MNU] Grid Rasterdaten
+[MNU] Modules Module
+[MNU] Point Cloud
+[MNU] Project Projekt
+[MNU] Rotation
+[MNU] Sequencer Sequenzer
+[MNU] Shapes Vektordaten
+[MNU] Shift Verschiebung
+[MNU] TIN
+[MNU] Table Tabelle
+[MNU] Window Fenster
+[MSG] Build Histogram... Histogramm erstellen...
+[MSG] Close Schließe
+[MSG] Close Library Schließe Bibliothek
+[MSG] Close table Schließe Tabelle
+[MSG] Could not load project. Projekt konnte nicht geladen werden
+[MSG] Could not save project. Projekt konnte nicht gespeichert werden
+[MSG] Create TIN from shapes TIN aus Vektordatensatz erstellen
+[MSG] Executing module Modul ausführen
+[MSG] Execution has been stopped by user! Modulausführung von Benutzer abgebrochen!
+[MSG] Interactive module execution failed Ausführung des interaktiven Moduls schlug fehl
+[MSG] Interactive module execution has been started Ausführung des interaktiven Moduls wurde gestartet
+[MSG] Interactive module execution has been stopped Ausführung des interaktiven Moduls wurde beendet
+[MSG] Load grid Lade Rasterdaten
+[MSG] Load library Lade Bibliothek
+[MSG] Load point cloud
+[MSG] Load project Lade Projekt
+[MSG] Load shapes Lade Vektordaten
+[MSG] Load table Lade Tabelle
+[MSG] Module execution failed Modulausführung schlug fehl
+[MSG] Module execution succeeded Modul wurde erfolgreich ausgeführt
+[MSG] Project has been saved. Projekt wurde gespeichert
+[MSG] Project has been successfully loaded. Projekt wurde erfolgreich geladen
+[MSG] Save as Interactive SVG
+[MSG] Save grid Rasterdaten speichern
+[MSG] Save point cloud
+[MSG] Save shapes Vektordaten speichern
+[MSG] Save table Tabelle speichern
+[MSG] Save to PDF Als PDF speichern
+[MSG] Shall execution be stopped? Soll die Ausführung abgebrochen werden?
+[MSG] could not read project file.
+[MSG] failed fehlgeschlagen
+[MSG] file does not exist.
+[MSG] has already been loaded bereits geladen
+[MSG] invalid project file.
+[MSG] no data entries in project file.
+[MSG] okay erfolgreich
+[PRM] Boolean Wahrheitswert
+[PRM] Choice Auswahl
+[PRM] Color Farbe
+[PRM] Colors Farben
+[PRM] Data Object Datensatz
+[PRM] Data Objects Datensätze
+[PRM] Degree Grad
+[PRM] File path Dateipfad
+[PRM] Floating point Fließkommazahl
+[PRM] Font Schrift
+[PRM] Frame Width [Pixels] Rahmenbreite (Pixel)
+[PRM] Grid Raster
+[PRM] Grid list Liste von Rastern
+[PRM] Grid system Rastersystem
+[PRM] Grids Raster
+[PRM] Integer Ganzzahl
+[PRM] Legend Legende
+[PRM] Long text Langer Text
+[PRM] Map Height [Pixels] Kartenhöhen (Pixel)
+[PRM] Map Width [Pixels] Kartenbreite (Pixel)
+[PRM] Node Knoten
+[PRM] Options Optionen
+[PRM] Parameter
+[PRM] Parameters Parameterliste
+[PRM] Point Cloud
+[PRM] Point Cloud list
+[PRM] Point Clouds
+[PRM] Save Speichern
+[PRM] Save Georeference (world file) Georeferenz speichern
+[PRM] Save KML file
+[PRM] Shapes Vektordaten
+[PRM] Shapes list Liste von Vektordaten
+[PRM] Static table Statische Tabelle
+[PRM] TIN
+[PRM] TIN list TIN Liste
+[PRM] Table Tabelle
+[PRM] Table field Tabellenfeld
+[PRM] Table list Liste von Tabellen
+[PRM] Tables Tabellen
+[PRM] Text
+[PRM] Value range Wertebereich
+[PRM] Zoom
+[TXT] Close all data sets Alle Datensätze schliessen
+[TXT] Do you want to delete the selection? Wollen Sie die Auswahl entfernen?
+[TXT] Do you want to exit SAGA? Wollen Sie SAGA beenden?
+[TXT] No data loaded. Keine Daten geladen.
+[TXT] No description available Keine Beschreibung verfügbar
+[TXT] No parameters available. Keine Parameter verfügbar
+[TXT] SAGA\nSystem for Automated Geoscientific Analyses\nVersion 2.0 SAGA\nSystem für Automatisierte Geowissenschaftliche Analysen\nVersion 2.0
+[TXT] This is not a text!
+[TXT] grid system Rastersystem
+[TXT] grid systems Rastersysteme
+[VAL] B-Spline
+[VAL] Backward Diagonal Schräg nach links
+[VAL] Bicubic Spline Bikubischer Spline
+[VAL] Bilinear
+[VAL] Cross Gekreuzt
+[VAL] Cross Diagonal Schräg gekreuzt
+[VAL] Dot And Dash Punkt und Strich
+[VAL] Dotted Gepunktet
+[VAL] File Cache Dateipuffer
+[VAL] Forward Diagonal Schräg nach rechts
+[VAL] Graduated Color Abgestufter Farbverlauf
+[VAL] Horizontal
+[VAL] Inverse Distance Umgekehrte Distanz
+[VAL] Linear
+[VAL] Logarithmic (down) Logarithmisch (nach rechts)
+[VAL] Logarithmic (up) Logarihmisch (nach links)
+[VAL] Long Dashed Lange Striche
+[VAL] Lookup Table Nachschlagetabelle
+[VAL] Map Units Karteneinheiten
+[VAL] New Neu
+[VAL] No objects Keine Objekte
+[VAL] None Nicht vorhanden
+[VAL] Normal
+[VAL] Opaque Undurchsichtig
+[VAL] RGB
+[VAL] RGB Overlay
+[VAL] RTL Compression RTL Komprimierung
+[VAL] Screen Bildschirm
+[VAL] Shade Schummerung
+[VAL] Short Dashed Kurze Striche
+[VAL] Solid Solide
+[VAL] Transparent
+[VAL] Unique Symbol Einheitliches Symbol
+[VAL] Vertical Vertikal
+[VAL] [all grid systems] [alle Rastersysteme]
+[VAL] [create] [erstellen]
+[VAL] [default] [Standardwert]
+[VAL] [no choice available] [keine Auswahl verfügbar]
+[VAL] [no fields] [keine Felder verfügbar]
+[VAL] [none] [nicht vorhanden]
+[VAL] [not set] [nicht gesetzt]
+[VAL] no nein
+[VAL] object Objekt
+[VAL] objects Objekte
+[VAL] ready fertig
+[VAL] yes ja
+access violation Fehlerhafter Speicherzugriff
+after nach
+another grid
+ascending aufsteigend
+author Autor
+automatically save and load automatisch speichern und laden
+available module libraries verfügbare Modulbibliotheken
+available modules verfügbare Module
+ball Ball
+bar Balken
+bar (not outlined) Balken (nicht umrandet)
+before vor
+binary
+bit
+black > blue schwarz > blau
+black > green schwarz > grün
+black > red schwarz > rot
+bottom
+bright - dark
+buffer size Größe des Puffers
+cannot execute interactive module interaktives Modul kann nicht ausgeführt werden
+center
+central zentral
+character string Zeichenkette
+circle Kreis
+circle in rhombus Kreis in Rhombus
+circle in square Kreis in Quadrat
+circle in triangle (down) Kreis in Dreieck (Spitze abwärts)
+circle in triangle (up) Kreis in Dreieck (Spitze aufwärts)
+circle with rhombus Kreis mit Rhombus
+circle with square Kreis mit Quadrat
+circle with triangle (down) Kreis mit Dreieck (Spitze abwärts)
+circle with triangle (up) Kreis mit Dreieck (Spitze aufwärts)
+color
+color (rgb) Farbe (RGB)
+colors Farben
+columns Spalten
+confirm Bestätige
+confirm with options Bestätige mit Optionen
+continue fortsetzen
+could not create index: insufficient memory
+creating batch file example
+cyan - white
+cylinder Zylinder
+dark - bright
+database table does not exist
+date
+date (dd.mm.yyyy) Datum (dd.mm.yyyy)
+default Standard
+default (same brightness) Standard (gleiche Helligkeit)
+descending absteigend
+do not confirm nicht bestätigen
+do not show nicht anzeigen
+empty leer
+empty coded function leere Funktion
+empty input list
+error Fehler
+executing module Modulausführung
+failed fehlgeschlagen
+field cannot be mapped to binary object
+first value
+function not found Funktion nicht gefunden
+function table full
+green > blue
+green > grey > blue
+green > red > blue
+greyscale Graustufen
+highest z
+image Bild
+improper function syntax
+index out of bounds
+input Eingabe
+input file Eingabedatei
+interactive interaktiv
+interactive execution interaktive Ausführung
+invalid module libraries path
+invalid number of parameters
+last opened zuletzt geöffnet
+last value
+left
+library name
+library path
+lowest z
+magenta - white
+missing operand
+module Modul
+module library Modulbibliothek
+module library not found Modulbibliothek nicht gefunden
+module name Modulname
+module not found Modul nicht gefunden
+more than one field in selection
+no nein
+no attributes in table
+no database connection
+no fields in selection
+no histogram for unclassified data
+no memory kein Speicher
+no valid module library found in path
+okay
+only during start up phase nur während der Programminitialisierung
+optional
+optional input optionale Eingabe
+optional output optionale Ausgabe
+original functions may not be deleted
+output Ausgabe
+panorama Panorama
+parallel
+parameters Parameter
+pie Torte
+pie (not outlined) Torte (nicht umrandet)
+plain
+press any key
+ready fertig
+red > blue
+red > blue > green
+red > green
+red > green > blue
+red > grey > blue
+red > grey > green
+red=1, green=2, blue=this
+red=1, green=this, blue=2
+red=2, green=1, blue=this
+red=2, green=this, blue=1
+red=this, green=1, blue=2
+red=this, green=2, blue=1
+rhombus Rhombus
+right
+rows Reihen
+shapes
+signed 1 byte integer
+signed 2 byte integer
+signed 4 byte integer
+signed 8 byte integer
+sql excution error
+square Quadrat
+string
+syntax error Syntaxfehler
+too few parameters Zu wenige Parameter
+too many constants Zu wenige Konstanten
+too many parameters Zu viele Parameter
+top
+triangle (down) Dreieck (Spitze abwärts)
+triangle (up) Dreieck (Spitze aufwärts)
+type -h or --help for further information
+undeclared parameter
+undefined
+unknown type
+unmatched parentheses
+unsigned 1 byte integer
+unsigned 2 byte integer
+unsigned 4 byte integer
+unsigned 8 byte integer
+unsorted unsortiert
+until user closes it bis Mausklick
+white - cyan
+white - magenta
+white - yellow
+white > blue
+white > green
+white > red
+yellow - white
+yellow > blue
+yellow > green
+yellow > red
+yes ja
diff --git a/src/saga_core/saga_gui/res/saga.lng.txt b/src/saga_core/saga_gui/res/saga.lng.txt
index b054351..06a319f 100644
--- a/src/saga_core/saga_gui/res/saga.lng.txt
+++ b/src/saga_core/saga_gui/res/saga.lng.txt
@@ -1,834 +1,1027 @@
-ORIGINAL TRANSLATION
-1 byte integer
-2 byte integer
-20 seconds
-4 byte floating point
-4 byte integer
-8 byte floating point
-A3 Landscape
-A3 Portrait
-A4 Landscape
-A4 Portrait
-About SAGA
-Acknowledgements
-Activate Grid File Cache?
-Activate file caching automatically, if memory size exceeds the threshold value.
-Add Field
-All Files
-All Recognised Files
-Area
-Attribute
-Automatic mode
-Available Choices
-Bars
-Buffer Size [MB]
-CLASS
-COLOR
-COUNT
-Chart Type
-Choose Attribute
-Class 1
-Class 2
-Clear
-Colors file could not be exported.
-Colors file could not be imported.
-CompuServe Graphics Interchange
-Confirm file caching
-Constraints
-Copy
-Create Lookup Table
-Create index
-Creating module documentation files
-Currently no help files exist for SAGA.\nIt depends on your support, if you will find any help at this place in future!\nThanks a lot...
-DBase
-DESCRIPTION
-Data Table
-Delete Fields
-Description
-Descriptive name for the grid system
-Direction
-Directory, where temporary cache files shall be saved.
-ESRI Shape Files
-Error
-Error in Trend Calculation
-Error in formula
-Exit SAGA
-Field
-Field Colors
-Field Type
-Fields
-First Class
-Function failed because no attributes are available
-General
-Grid File Caching
-Grids
-Height
-I1: unrecognizable operator
-I2: too many parameters
-I3: corrupted buffer
-I4: size estimate too small
-Identifier
-Image Files
-Image Resolution
-In/Out
-Input
-Insert Method
-Insert Position
-JPEG - JFIF Compliant
-JPG Files
-Layers
-Left/Right
-Legend: Save
-Legend: Zoom
-Length
-Lines
-Lines and Points
-Load Colors
-Load Parameters
-Logo
-MAXIMUM
-MINIMUM
-Map
-Maps
-Maximum
-Menu
-Minimum
-Module
-NAME
-Name
-Neon
-Options
-Options for Data Thumbnails
-Options for Map Thumbnails
-Output
-PDF Files
-PNG Files
-Parameters
-Parameters file could not be exported.
-Parameters file could not be imported.
-Parts
-Perimeter
-Please stop module execution before exiting SAGA.
-Points
-Portable Network Graphics
-Position
-Rainbow
-Resolution
-Row
-SAGA Colors
-SAGA Help
-SAGA Module Libraries
-SAGA Module Library Descriptions
-SAGA Parameter Files
-SAGA Project
-SAGA Projects
-SAGA: Print Map
-SVG - Scalable Vector Graphics Files (*.svg)
-Save 3D Image Options
-Save Colors
-Save Georeference
-Save Parameters
-Save all
-Scale
-Second Class
-Selection Color
-Shall I activate file caching for new grid.
-Show Categories
-Show Logo at Start Up
-Sort Table
-Sort by
-South-North
-Start Project
-Table
-Tables
-Tagged Image File Format
-Temporary files
-Text
-Text Files
-This is a Test!!!
-Threshold for automatic mode [MB]
-Thumbnail Size
-Thumbnails
-Total memory size
-Tree
-Type
-Up/Down
-Value Range
-Version
-West-East
-Width
-Windows or OS/2 Bitmap
-X
-X11 Pixel Map
-Y
-Z
-Zsoft Paintbrush
-[BTN] Add
-[BTN] Apply
-[BTN] Button
-[BTN] Cancel
-[BTN] Clear
-[BTN] Count
-[BTN] Delete
-[BTN] Down
-[BTN] Execute
-[BTN] Insert
-[BTN] Invert
-[BTN] Load
-[BTN] Mirror
-[BTN] Okay
-[BTN] Presets
-[BTN] Random
-[BTN] Restore
-[BTN] Save
-[BTN] Up
-[CAP] 3D-View
-[CAP] 3D-View: Player Sequence
-[CAP] About SAGA
-[CAP] Anaglyph
-[CAP] Arithmetic Mean
-[CAP] Attribute
-[CAP] Attribute (Size)
-[CAP] Attributes
-[CAP] Author
-[CAP] Background Color
-[CAP] Beep when finished
-[CAP] Buffer Size MB
-[CAP] Cell Size
-[CAP] Cell size
-[CAP] Chart
-[CAP] Chart Properties
-[CAP] Choose Directory
-[CAP] Circles
-[CAP] Close
-[CAP] Close and save modified data sets...
-[CAP] Color
-[CAP] Colors
-[CAP] Create Script Command File
-[CAP] Data
-[CAP] Data History
-[CAP] Decimals
-[CAP] Default Size
-[CAP] Defaults
-[CAP] Delete
-[CAP] Description
-[CAP] Diagram
-[CAP] Display
-[CAP] Display Resolution
-[CAP] Display Type
-[CAP] Display: Cell Values
-[CAP] Display: Color Classification
-[CAP] Display: Label
-[CAP] Display: Size
-[CAP] Display: Visibility
-[CAP] Edit
-[CAP] Edit Shapes
-[CAP] Elevation
-[CAP] Errors
-[CAP] Exaggeration
-[CAP] Execution
-[CAP] Exit
-[CAP] Eye Distance [Degree]
-[CAP] Field
-[CAP] Fields
-[CAP] Figure
-[CAP] File
-[CAP] File cache activated
-[CAP] Fill Style
-[CAP] Fit Map Scale
-[CAP] Font
-[CAP] Frame
-[CAP] General
-[CAP] Graduated Color
-[CAP] Grid
-[CAP] Grid System
-[CAP] Grid Systems
-[CAP] Grids
-[CAP] Histogram
-[CAP] Html Extra Info
-[CAP] Index
-[CAP] Info
-[CAP] Input
-[CAP] Interpolated
-[CAP] Interpolation
-[CAP] Layers
-[CAP] Legend
-[CAP] Load
-[CAP] Load Colors
-[CAP] Load Grid
-[CAP] Load Module Library
-[CAP] Load Project
-[CAP] Load Settings
-[CAP] Load Shapes
-[CAP] Load TIN
-[CAP] Load Table
-[CAP] Load Text
-[CAP] Logarithmic Stretch Factor
-[CAP] Lookup Table
-[CAP] Map
-[CAP] Map Extent
-[CAP] Map Scale
-[CAP] Map Selection
-[CAP] Map-Layout
-[CAP] Maps
-[CAP] Memory
-[CAP] Memory Compression
-[CAP] Memory Handling
-[CAP] Memory Size
-[CAP] Messages
-[CAP] Mode
-[CAP] Modified
-[CAP] Module Execution
-[CAP] Module Libraries
-[CAP] Module Library
-[CAP] Modules
-[CAP] Name
-[CAP] No Data
-[CAP] Number Of Cells
-[CAP] Number Of Grids
-[CAP] Number Of Shapes
-[CAP] Number of cells
-[CAP] Object Properties
-[CAP] Open
-[CAP] Options
-[CAP] Outline
-[CAP] Outline Color
-[CAP] Outline Size
-[CAP] Parameters
-[CAP] Perspectivic Distance
-[CAP] Points
-[CAP] Preset Selection
-[CAP] Print Layout
-[CAP] Print Preview
-[CAP] Project File
-[CAP] Projection
-[CAP] Properties
-[CAP] Records
-[CAP] Regression Details
-[CAP] Regression Formula
-[CAP] Rotation
-[CAP] Save
-[CAP] Save As Image
-[CAP] Save As Interactive SVG
-[CAP] Save Colors
-[CAP] Save Grid
-[CAP] Save Grid as Image...
-[CAP] Save Map as Image...
-[CAP] Save Project
-[CAP] Save Settings
-[CAP] Save Shapes
-[CAP] Save TIN
-[CAP] Save Table
-[CAP] Save Text
-[CAP] Save to PDF
-[CAP] Scale Dependent
-[CAP] Scatterplot
-[CAP] Select File
-[CAP] Settings
-[CAP] Shapes
-[CAP] Shift
-[CAP] Show
-[CAP] Show Always
-[CAP] Show Edges
-[CAP] Show Filled
-[CAP] Show Legend
-[CAP] Show Nodes
-[CAP] Show Regression Curve
-[CAP] Show Vertices
-[CAP] Size
-[CAP] Size Range
-[CAP] Size relates to...
-[CAP] Snap Distance
-[CAP] Snap to...
-[CAP] South-North
-[CAP] Standard
-[CAP] Standard Deviation
-[CAP] Symbol Image
-[CAP] Symbol Type
-[CAP] TIN
-[CAP] Table
-[CAP] Table Description
-[CAP] Tables
-[CAP] This Is Not A Caption!
-[CAP] Transparency [%]
-[CAP] Type
-[CAP] Unique Symbol
-[CAP] Unit
-[CAP] Value
-[CAP] Value Range
-[CAP] Value Type
-[CAP] Version
-[CAP] Weight
-[CAP] West-East
-[CAP] Width
-[CAP] Workspace
-[CAP] X Axis
-[CAP] X Label
-[CAP] Z-Factor
-[CAP] Zoom to added layer
-[CAP] [no items]
-[CAP] [none]
-[CMD] About SAGA
-[CMD] Action
-[CMD] Add Field
-[CMD] Add Part
-[CMD] Add Position [A]
-[CMD] Add Project
-[CMD] Add Record
-[CMD] Add Shape
-[CMD] Anaglyph [S]
-[CMD] Arrange Icons
-[CMD] Backward
-[CMD] Cascade
-[CMD] Central Projection
-[CMD] Clear
-[CMD] Close
-[CMD] Close All
-[CMD] Convert To Table
-[CMD] Copy
-[CMD] Create HTML Documentation
-[CMD] Create Lookup Table
-[CMD] Create Normalised Classification
-[CMD] Create Script Command File
-[CMD] Cumulative
-[CMD] Decrease Exaggeration [F1]
-[CMD] Decrease Eye Distance
-[CMD] Decrease Perspectivic Distance [F5]
-[CMD] Delete All Positions
-[CMD] Delete All Records
-[CMD] Delete Fields
-[CMD] Delete Last Position [D]
-[CMD] Delete Record
-[CMD] Delete Selected Part
-[CMD] Delete Selected Point
-[CMD] Delete Selected Shape(s)
-[CMD] Down
-[CMD] Edit Positions
-[CMD] Edit Selected Shape
-[CMD] Execute
-[CMD] Exit
-[CMD] Exit SAGA
-[CMD] Fit Column Sizes
-[CMD] Fit Grid Colors To Map Extent
-[CMD] Fit Row Sizes
-[CMD] Fit Scale...
-[CMD] Forward
-[CMD] Help
-[CMD] Increase Exaggeration [F2]
-[CMD] Increase Eye Distance
-[CMD] Increase Perspectivic Distance [F6]
-[CMD] Insert Record
-[CMD] Interpolated Colors
-[CMD] Invert Selection
-[CMD] Left
-[CMD] Left [F3]
-[CMD] Load
-[CMD] Load Grid
-[CMD] Load Module Library
-[CMD] Load Project
-[CMD] Load Shapes
-[CMD] Load TIN
-[CMD] Load Table
-[CMD] Measure Distance
-[CMD] Move Down
-[CMD] Move To Bottom
-[CMD] Move To Top
-[CMD] Move Up
-[CMD] Next
-[CMD] Page Setup
-[CMD] Pan
-[CMD] Play And Save As Images...
-[CMD] Play Loop [L]
-[CMD] Play Once [P]
-[CMD] Previous
-[CMD] Print
-[CMD] Print Preview
-[CMD] Print Setup
-[CMD] Properties
-[CMD] Right
-[CMD] Right [F4]
-[CMD] Save As Image when changed
-[CMD] Save As Image...
-[CMD] Save As PDF
-[CMD] Save Grid
-[CMD] Save Grid As Image...
-[CMD] Save Grid As...
-[CMD] Save Project
-[CMD] Save Project As...
-[CMD] Save Shapes
-[CMD] Save Shapes As...
-[CMD] Save TIN
-[CMD] Save TIN As...
-[CMD] Save Table
-[CMD] Save Table As...
-[CMD] Save as Interactive SVG
-[CMD] Show 3D-View
-[CMD] Show Diagram
-[CMD] Show Grid
-[CMD] Show Histogram
-[CMD] Show Horizontal Legend
-[CMD] Show Layer
-[CMD] Show Map
-[CMD] Show Message Window
-[CMD] Show Object Properties
-[CMD] Show Print Layout
-[CMD] Show Scatterplot
-[CMD] Show Shapes
-[CMD] Show TIN
-[CMD] Show Table
-[CMD] Show Toolbar
-[CMD] Show Vertical Legend
-[CMD] Show Workspace
-[CMD] Sort Fields
-[CMD] Synchronise Map Extents
-[CMD] Tile Horizontally
-[CMD] Tile Vertically
-[CMD] Tip of the Day...
-[CMD] UNRECOGNISED COMMAND ID
-[CMD] Up
-[CMD] Update Data
-[CMD] Zoom
-[CMD] Zoom To Active Layer
-[CMD] Zoom To Extent
-[CMD] Zoom To Full Extent
-[CMD] Zoom To Next Extent
-[CMD] Zoom To Previous Extent
-[CMD] Zoom To Selection
-[DAT] Cell size
-[DAT] Grid
-[DAT] Line
-[DAT] Lower left corner
-[DAT] Number of cells
-[DAT] Point
-[DAT] Points
-[DAT] Polygon
-[DAT] Resampling
-[DAT] Save shapes
-[DAT] Shapes
-[DAT] TIN
-[DAT] Table
-[DAT] Undefined
-[DAT] [not set]
-[DAT] new
-[DLG] Add layer to selected map
-[DLG] Delete selected shape(s).
-[DLG] Invalid parameters!
-[DLG] Please enter a numeric value:
-[DLG] Save changes?
-[DLG] Scale 1 :
-[DLG] Set selected values to no data.
-[ERR] Access Violation
-[ERR] Calculation Error
-[ERR] Can't execute a module while another runs
-[ERR] Corrupted shape file.
-[ERR] Could not save PDF file.
-[ERR] DBase file could not be opened or it did not contain any records.
-[ERR] Error: Continue anyway ?
-[ERR] Grid file could not be opened.
-[ERR] Grid file could not be saved.
-[ERR] Invalid data set!
-[ERR] Invalid data!
-[ERR] Invalid display size!
-[ERR] Invalid library
-[ERR] Library could not be loaded
-[ERR] Library does not contain any modules
-[ERR] Library has already been loaded
-[ERR] Shape file could not be opened.
-[ERR] Shape file invalid or of unsupported type.
-[ERR] Shape file is corrupted.
-[ERR] Shape index file could not be opened.
-[ERR] There was a problem printing.\nPerhaps your current printer is not set correctly?
-[ERR] Unknown Error
-[ERR] You canceled printing
-[FLD] Attribute
-[FLD] Central Projection
-[FLD] Exaggeration
-[FLD] Grid
-[FLD] Icon
-[FLD] Index Layer
-[FLD] Name
-[FLD] PDF Document
-[FLD] Paper Format
-[FLD] Rotate X
-[FLD] Rotate Y
-[FLD] Rotate Z
-[FLD] Round Scale
-[FLD] SVG File
-[FLD] Shapes
-[FLD] Shift X
-[FLD] Shift Y
-[FLD] Shift Z
-[FLD] Steps to Next
-[FLD] Title
-[FLD] Value
-[HLP] Execute Module
-[HST] Created from file
-[HST] Created with module
-[HST] Grid addition
-[HST] Grid denormalisation
-[HST] Grid division
-[HST] Grid multiplication
-[HST] Grid normalisation
-[HST] Grid operation
-[HST] Grid subtraction
-[HST] Horizontally mirrored
-[HST] Inversion
-[HST] Loaded from file
-[HST] Value addition
-[HST] Value assigned to grid
-[HST] Value division
-[HST] Value multiplication
-[HST] Value subtraction
-[HST] Vertically mirrored
-[MNU] ?
-[MNU] Edit
-[MNU] File
-[MNU] Grid
-[MNU] Modules
-[MNU] Project
-[MNU] Rotation
-[MNU] Sequencer
-[MNU] Shapes
-[MNU] Shift
-[MNU] TIN
-[MNU] Table
-[MNU] Window
-[MSG] Build Histogram...
-[MSG] Close
-[MSG] Close Library
-[MSG] Close table
-[MSG] Could not load project.
-[MSG] Could not save project.
-[MSG] Create TIN from shapes
-[MSG] Executing module
-[MSG] Execution has been stopped by user!
-[MSG] Interactive module execution failed
-[MSG] Interactive module execution has been started
-[MSG] Interactive module execution has been stopped
-[MSG] Load grid
-[MSG] Load library
-[MSG] Load project
-[MSG] Load shapes
-[MSG] Load table
-[MSG] Module execution failed
-[MSG] Module execution succeeded
-[MSG] Project has been saved.
-[MSG] Project has been successfully loaded.
-[MSG] Save as Interactive SVG
-[MSG] Save grid
-[MSG] Save shapes
-[MSG] Save table
-[MSG] Save to PDF
-[MSG] Shall execution be stopped?
-[MSG] failed
-[MSG] has already been loaded
-[MSG] okay
-[PRM] Boolean
-[PRM] Choice
-[PRM] Color
-[PRM] Colors
-[PRM] Data Object
-[PRM] Data Objects
-[PRM] Degree
-[PRM] File path
-[PRM] Floating point
-[PRM] Font
-[PRM] Frame Width [Pixels]
-[PRM] Grid
-[PRM] Grid list
-[PRM] Grid system
-[PRM] Grids
-[PRM] Integer
-[PRM] Legend
-[PRM] Long text
-[PRM] Map Height [Pixels]
-[PRM] Map Width [Pixels]
-[PRM] Node
-[PRM] Options
-[PRM] Parameter
-[PRM] Parameters
-[PRM] Save
-[PRM] Save Georeference (world file)
-[PRM] Shapes
-[PRM] Shapes list
-[PRM] Static table
-[PRM] TIN
-[PRM] TIN list
-[PRM] Table
-[PRM] Table field
-[PRM] Table list
-[PRM] Tables
-[PRM] Text
-[PRM] Value range
-[PRM] Zoom
-[TXT] Close all data sets
-[TXT] Do you want to delete the selection?
-[TXT] Do you want to exit SAGA?
-[TXT] No data loaded.
-[TXT] No description available
-[TXT] No parameters available.
-[TXT] SAGA\nSystem for Automated Geoscientific Analyses\nVersion 2.0
-[TXT] This is not a text!
-[TXT] grid system
-[TXT] grid systems
-[VAL] B-Spline
-[VAL] Backward Diagonal
-[VAL] Bicubic Spline
-[VAL] Bilinear
-[VAL] Cross
-[VAL] Cross Diagonal
-[VAL] Dot And Dash
-[VAL] Dotted
-[VAL] File Cache
-[VAL] Forward Diagonal
-[VAL] Graduated Color
-[VAL] Horizontal
-[VAL] Inverse Distance
-[VAL] Linear
-[VAL] Logarithmic (down)
-[VAL] Logarithmic (up)
-[VAL] Long Dashed
-[VAL] Lookup Table
-[VAL] Map Units
-[VAL] New
-[VAL] No objects
-[VAL] None
-[VAL] Normal
-[VAL] Opaque
-[VAL] RGB
-[VAL] RTL Compression
-[VAL] Screen
-[VAL] Shade
-[VAL] Short Dashed
-[VAL] Solid
-[VAL] Transparent
-[VAL] Unique Symbol
-[VAL] Vertical
-[VAL] [all grid systems]
-[VAL] [create]
-[VAL] [default]
-[VAL] [no choice available]
-[VAL] [no fields]
-[VAL] [none]
-[VAL] [not set]
-[VAL] no
-[VAL] object
-[VAL] objects
-[VAL] ready
-[VAL] yes
-access violation
-after
-ascending
-author
-automatically save and load
-available module libraries
-available modules
-ball
-bar
-bar (not outlined)
-before
-black > blue
-black > green
-black > red
-buffer size
-cannot execute interactive module
-central
-character string
-circle
-circle in rhombus
-circle in square
-circle in triangle (down)
-circle in triangle (up)
-circle with rhombus
-circle with square
-circle with triangle (down)
-circle with triangle (up)
-color (rgb)
-colors
-columns
-confirm
-confirm with options
-continue
-creating batch file example
-cylinder
-date (dd.mm.yyyy)
-default
-default (same brightness)
-descending
-do not confirm
-do not show
-empty
-empty coded function
-empty input list
-error
-executing module
-failed
-function not found
-function table full
-green > blue
-green > grey > blue
-green > red > blue
-greyscale
-image
-improper function syntax
-index out of bounds
-input
-input file
-interactive
-interactive execution
-invalid module libraries path
-invalid number of parameters
-last opened
-library name
-library path
-missing operand
-module
-module library
-module library not found
-module name
-module not found
-no
-no memory
-no valid module library found in path
-okay
-only during start up phase
-optional
-optional input
-optional output
-original functions may not be deleted
-output
-panorama
-parallel
-parameters
-pie
-pie (not outlined)
-plain
-press any key
-ready
-red > blue
-red > blue > green
-red > green
-red > green > blue
-red > grey > blue
-red > grey > green
-rhombus
-rows
-square
-syntax error
-too few parameters
-too many constants
-too many parameters
-triangle (down)
-triangle (up)
-type -h or --help for further information
-undeclared parameter
-unmatched parentheses
-unsorted
-until user closes it
-white > blue
-white > green
-white > red
-yellow > blue
-yellow > green
-yellow > red
-yes
+ORIGINAL TRANSLATION
+1 byte integer
+1.5 * Standard Deviation
+2 byte integer
+2.0 * Standard Deviation
+20 seconds
+4 byte floating point
+4 byte floating point number
+4 byte integer
+8 byte floating point
+8 byte floating point number
+A3 Landscape
+A3 Portrait
+A4 Landscape
+A4 Portrait
+AREA
+About SAGA
+Acknowledgements
+Activate Grid File Cache?
+Activate file caching automatically, if memory size exceeds the threshold value.
+Add Field
+Addition
+All Files
+All Recognised Files
+Area
+Assign
+Attribute
+Automatic mode
+Available Choices
+Available Connections
+Backward diagonal hatch
+Bars
+Bottom
+Buffer Size [MB]
+CENTER
+CLASS
+COLOR
+COUNT
+Cellsize
+Chart Type
+Choose Attribute
+Choose Documentation Folder
+Choose ODBC Connection
+Class 1
+Class 2
+Clear
+Colors
+Colors file could not be exported.
+Colors file could not be imported.
+Columns
+Compare with...
+CompuServe Graphics Interchange
+Confirm file caching
+Constraints
+Copy
+Copy Settings from...
+Create HTML Documentation
+Create Lookup Table
+Create index
+Creating module documentation files
+Cross hatch
+Cross-diagonal hatch
+Currently no help files exist for SAGA.\nIt depends on your support, if you will find any help at this place in future!\nThanks a lot...
+DBase
+DESCRIPTION
+DSN
+Data
+Data Source Name
+Data Table
+Delete Fields
+Denormalisation
+Description
+Descriptive name for the grid system
+Direction
+Directory
+Directory (DBase, Excel)
+Directory, where temporary cache files shall be saved.
+Display Range
+Division
+Dot and dash style
+Dotted style
+ESRI Shape Files
+Error
+Error in Trend Calculation
+Error in formula
+Exit SAGA
+Field
+Field Type
+Fields
+First Class
+Forward diagonal hatch
+Function failed because no attributes are available
+General
+Geocentric Coordinate System
+Geographic Coordinate System
+Grid
+Grid Display Defaults
+Grid File Caching
+Grids
+Height
+Horizontal hatch
+Horizontally mirrored
+I1: unrecognizable operator
+I2: too many parameters
+I3: corrupted buffer
+I4: size estimate too small
+Identifier
+Image Files
+Image Resolution
+In/Out
+Input
+Insert Method
+Insert Position
+Inversion
+JPEG - JFIF Compliant
+JPG Files
+Layers
+Left
+Left/Right
+Legend: Save
+Legend: Zoom
+Length
+Library Overview
+Lines
+Lines and Points
+Load Colors
+Load Parameters
+Logo
+Long dashed style
+MAX
+MAXIMUM
+MIN
+MINIMUM
+Map
+Maps
+Maximum
+Menu
+Minimum
+Minimum/Maximum
+Module
+Module Library Descriptions
+Multiplication
+NAME
+Name
+Neon
+No ODBC connection available!
+No history available
+No pen is used
+Normalisation
+ODBC Database Connection Error
+Option
+Options
+Options for Data Thumbnails
+Options for Map Thumbnails
+Output
+PDF Files
+PNG Files
+Parameters
+Parameters file could not be exported.
+Parameters file could not be imported.
+Parts
+Password
+Perimeter
+Please stop module execution before exiting SAGA.
+Point Clouds
+Points
+Portable Network Graphics
+Position
+Process Update Frequency [milliseconds]
+Projected Coordinate System
+Rainbow
+Rename Fields
+Resampling
+Resolution
+Right
+Rows
+SAGA Colors
+SAGA Help
+SAGA Module Libraries
+SAGA Parameter Files
+SAGA Point Clouds
+SAGA Project
+SAGA Projects
+SAGA: Print Map
+SVG - Scalable Vector Graphics Files (*.svg)
+Save 3D Image Options
+Save Colors
+Save Georeference
+Save Parameters
+Save all
+Scale
+Scatterplot
+Second Class
+Selection Color
+Shall I activate file caching for new grid.
+Short dashed style
+Show Categories
+Show Logo at Start Up
+Solid style
+Sort Table
+Sort first by
+Sort second by
+Sort third by
+South-North
+Start Project
+Subtraction
+Table
+Tables
+Tagged Image File Format
+Temporary files
+Text
+Text Files
+Thin Plate Spline: solving matrix
+This is a Test!!!
+Threshold for automatic mode [MB]
+Thumbnail Size
+Thumbnails
+Top
+Total memory size
+Tree
+Type
+Undefined Coordinate System
+Up/Down
+Use the stipple bitmap
+Use the user dashes
+User
+User Name
+Value Range
+Version
+Vertical hatch
+Vertically mirrored
+West-East
+Width
+Windows or OS/2 Bitmap
+X
+X11 Pixel Map
+Y
+You have to choose a grid for comparison
+You have to choose a shapes layer for comparison
+Z
+Zsoft Paintbrush
+[BTN] Add
+[BTN] Apply
+[BTN] Button
+[BTN] Cancel
+[BTN] Clear
+[BTN] Count
+[BTN] Delete
+[BTN] Down
+[BTN] Execute
+[BTN] Insert
+[BTN] Invert
+[BTN] Load
+[BTN] Mirror
+[BTN] Okay
+[BTN] Presets
+[BTN] Random
+[BTN] Restore
+[BTN] Save
+[BTN] Up
+[CAP] 3D-View
+[CAP] 3D-View: Player Sequence
+[CAP] About SAGA
+[CAP] Anaglyph
+[CAP] Arithmetic Mean
+[CAP] Attribute
+[CAP] Attribute (Size)
+[CAP] Attributes
+[CAP] Author
+[CAP] Background Color
+[CAP] Beep when finished
+[CAP] Buffer Size MB
+[CAP] Cell Size
+[CAP] Cell size
+[CAP] Chart
+[CAP] Chart Properties
+[CAP] Choose Directory
+[CAP] Circles
+[CAP] Clipboard
+[CAP] Close
+[CAP] Close and save modified data sets...
+[CAP] Color
+[CAP] Color by Attribute
+[CAP] Coloring
+[CAP] Colors
+[CAP] Create Script Command File
+[CAP] Data
+[CAP] Data History
+[CAP] Decimals
+[CAP] Default Size
+[CAP] Defaults
+[CAP] Delete
+[CAP] Description
+[CAP] Diagram
+[CAP] Display
+[CAP] Display Resolution
+[CAP] Display Type
+[CAP] Display: Cell Values
+[CAP] Display: Color Classification
+[CAP] Display: Label
+[CAP] Display: Size
+[CAP] Display: Visibility
+[CAP] Edit
+[CAP] Edit Shapes
+[CAP] Elevation
+[CAP] Errors
+[CAP] Exaggeration
+[CAP] Execution
+[CAP] Exit
+[CAP] Eye Distance [Degree]
+[CAP] Field
+[CAP] Fields
+[CAP] Figure
+[CAP] File
+[CAP] File cache activated
+[CAP] Fill Color
+[CAP] Fill Style
+[CAP] Fit Map Scale
+[CAP] Fit Size to Window
+[CAP] Fixed Maximum
+[CAP] Fixed Minimum
+[CAP] Font
+[CAP] Frame
+[CAP] Frame Width
+[CAP] General
+[CAP] Graduated Color
+[CAP] Grid
+[CAP] Grid System
+[CAP] Grid Systems
+[CAP] Grids
+[CAP] Height
+[CAP] Histogram
+[CAP] History
+[CAP] Horizontal Align
+[CAP] Html Extra Info
+[CAP] Index
+[CAP] Input
+[CAP] Interpolated
+[CAP] Interpolation
+[CAP] Label
+[CAP] Layers
+[CAP] Legend
+[CAP] Legend Border Colour
+[CAP] Legend Frame Width
+[CAP] Legend Scale
+[CAP] Line Style
+[CAP] Load
+[CAP] Load Colors
+[CAP] Load Grid
+[CAP] Load Module Library
+[CAP] Load Point Cloud
+[CAP] Load Project
+[CAP] Load Settings
+[CAP] Load Shapes
+[CAP] Load TIN
+[CAP] Load Table
+[CAP] Load Text
+[CAP] Logarithmic Stretch Factor
+[CAP] Lookup Table
+[CAP] Map
+[CAP] Map Extent
+[CAP] Map Scale
+[CAP] Map Selection
+[CAP] Map-Layout
+[CAP] Maps
+[CAP] Maximum
+[CAP] Maximum Value
+[CAP] Mean
+[CAP] Memory
+[CAP] Memory Compression
+[CAP] Memory Handling
+[CAP] Memory Size
+[CAP] Messages
+[CAP] Minimum
+[CAP] Minimum Value
+[CAP] Mode
+[CAP] Modified
+[CAP] Module Execution
+[CAP] Module Libraries
+[CAP] Module Library
+[CAP] Modules
+[CAP] Name
+[CAP] No Data
+[CAP] Number Of Cells
+[CAP] Number Of Grids
+[CAP] Number Of Shapes
+[CAP] Number of Points
+[CAP] Number of cells
+[CAP] Object Properties
+[CAP] Open
+[CAP] Options
+[CAP] Outline
+[CAP] Outline Color
+[CAP] Outline Size
+[CAP] Overlay 1
+[CAP] Overlay 2
+[CAP] Parameters
+[CAP] Perspectivic Distance
+[CAP] Point Cloud
+[CAP] Point Clouds
+[CAP] Point Size
+[CAP] PointCloud
+[CAP] Points
+[CAP] Preset Selection
+[CAP] Print Layout
+[CAP] Print Preview
+[CAP] Project File
+[CAP] Projection
+[CAP] Properties
+[CAP] RGB Overlay
+[CAP] Records
+[CAP] Regression Details
+[CAP] Regression Formula
+[CAP] Rotation
+[CAP] Rotation (Degree)
+[CAP] Rotation by Attribute
+[CAP] Save
+[CAP] Save As Image
+[CAP] Save As Interactive SVG
+[CAP] Save Colors
+[CAP] Save Grid
+[CAP] Save Grid as Image...
+[CAP] Save Map as Image...
+[CAP] Save Point Cloud
+[CAP] Save Project
+[CAP] Save Settings
+[CAP] Save Shapes
+[CAP] Save TIN
+[CAP] Save Table
+[CAP] Save Text
+[CAP] Save to PDF
+[CAP] Scale Dependent
+[CAP] Scatterplot
+[CAP] Select File
+[CAP] Selection
+[CAP] Settings
+[CAP] Shade
+[CAP] Shapes
+[CAP] Shift
+[CAP] Show
+[CAP] Show Always
+[CAP] Show Centroid
+[CAP] Show Edges
+[CAP] Show Filled
+[CAP] Show Legend
+[CAP] Show Nodes
+[CAP] Show Regression Curve
+[CAP] Show Scale
+[CAP] Show Vertices
+[CAP] Size
+[CAP] Size Range
+[CAP] Size by Attribute
+[CAP] Size relates to...
+[CAP] Snap Distance
+[CAP] Snap to...
+[CAP] South-North
+[CAP] Standard
+[CAP] Standard Deviation
+[CAP] Symbol Image
+[CAP] Symbol Type
+[CAP] TIN
+[CAP] Table
+[CAP] Table Description
+[CAP] Tables
+[CAP] This Is Not A Caption!
+[CAP] Transparency [%]
+[CAP] Type
+[CAP] Unique Symbol
+[CAP] Unit
+[CAP] Value
+[CAP] Value Aggregation
+[CAP] Value Range
+[CAP] Value Type
+[CAP] Values
+[CAP] Version
+[CAP] Vertical Align
+[CAP] Weight
+[CAP] West-East
+[CAP] Width
+[CAP] Workspace
+[CAP] X Axis
+[CAP] Y Axis
+[CAP] Z-Factor
+[CAP] Zoom to added layer
+[CAP] [no items]
+[CAP] [none]
+[CMD] About SAGA
+[CMD] Action
+[CMD] Add Field
+[CMD] Add Part
+[CMD] Add Position [A]
+[CMD] Add Project
+[CMD] Add Record
+[CMD] Add Shape
+[CMD] Anaglyph [S]
+[CMD] Arrange Icons
+[CMD] Backward
+[CMD] Cascade
+[CMD] Central Projection
+[CMD] Clear
+[CMD] Close
+[CMD] Close All
+[CMD] Convert To Table
+[CMD] Copy
+[CMD] Copy Settings from other Layer
+[CMD] Create HTML Documentation
+[CMD] Create Lookup Table
+[CMD] Create Normalised Classification
+[CMD] Create Script Command File
+[CMD] Cumulative
+[CMD] Decrease Diagram Size
+[CMD] Decrease Exaggeration [F1]
+[CMD] Decrease Eye Distance
+[CMD] Decrease Perspectivic Distance [F5]
+[CMD] Delete All Positions
+[CMD] Delete All Records
+[CMD] Delete Fields
+[CMD] Delete Last Position [D]
+[CMD] Delete Selected Part
+[CMD] Delete Selected Point
+[CMD] Delete Selected Record(s)
+[CMD] Delete Selected Shape(s)
+[CMD] Down
+[CMD] Edit Positions
+[CMD] Edit Selected Shape
+[CMD] Execute
+[CMD] Exit
+[CMD] Exit SAGA
+[CMD] Fit Column Sizes
+[CMD] Fit Diagram to Window
+[CMD] Fit Grid Colors To Map Extent
+[CMD] Fit Row Sizes
+[CMD] Fit Scale...
+[CMD] Forward
+[CMD] Help
+[CMD] Increase Diagram Size
+[CMD] Increase Exaggeration [F2]
+[CMD] Increase Eye Distance
+[CMD] Increase Perspectivic Distance [F6]
+[CMD] Insert Record
+[CMD] Interpolated Colors
+[CMD] Invert Selection
+[CMD] Left
+[CMD] Left [F3]
+[CMD] Load
+[CMD] Load Grid
+[CMD] Load Module Library
+[CMD] Load Point Cloud
+[CMD] Load Project
+[CMD] Load Settings
+[CMD] Load Shapes
+[CMD] Load TIN
+[CMD] Load Table
+[CMD] Measure Distance
+[CMD] Move Down
+[CMD] Move To Bottom
+[CMD] Move To Top
+[CMD] Move Up
+[CMD] New Project
+[CMD] Next
+[CMD] Page Setup
+[CMD] Pan
+[CMD] Play And Save As Images...
+[CMD] Play Loop [L]
+[CMD] Play Once [P]
+[CMD] Previous
+[CMD] Print
+[CMD] Print Preview
+[CMD] Print Setup
+[CMD] Properties
+[CMD] Rename Fields
+[CMD] Right
+[CMD] Right [F4]
+[CMD] Save As Image when changed
+[CMD] Save As Image...
+[CMD] Save As PDF
+[CMD] Save Grid
+[CMD] Save Grid As Image...
+[CMD] Save Grid As...
+[CMD] Save Legend to Clipboard [Ctrl+L]
+[CMD] Save Point Cloud
+[CMD] Save Point Cloud As...
+[CMD] Save Project
+[CMD] Save Project As...
+[CMD] Save Shapes
+[CMD] Save Shapes As...
+[CMD] Save TIN
+[CMD] Save TIN As...
+[CMD] Save Table
+[CMD] Save Table As...
+[CMD] Save as Interactive SVG
+[CMD] Save to Clipboard [Ctrl+C]
+[CMD] Set Range to Minmum/Maximum
+[CMD] Set Range to Standard Deviation (1.5)
+[CMD] Set Range to Standard Deviation (2.0)
+[CMD] Show
+[CMD] Show 3D-View
+[CMD] Show Diagram
+[CMD] Show Grid
+[CMD] Show Histogram
+[CMD] Show Horizontal Legend
+[CMD] Show Layer
+[CMD] Show Map
+[CMD] Show Message Window
+[CMD] Show Object Properties
+[CMD] Show Point Cloud
+[CMD] Show Print Layout
+[CMD] Show Scatterplot
+[CMD] Show Shapes
+[CMD] Show TIN
+[CMD] Show Table
+[CMD] Show Toolbar
+[CMD] Show Vertical Legend
+[CMD] Show Workspace
+[CMD] Sort Fields
+[CMD] Sort Selection to Top
+[CMD] Synchronise Map Extents
+[CMD] Tile Horizontally
+[CMD] Tile Vertically
+[CMD] Tip of the Day...
+[CMD] UNRECOGNISED COMMAND ID
+[CMD] Up
+[CMD] Update Data
+[CMD] Zoom
+[CMD] Zoom To Active Layer
+[CMD] Zoom To Extent
+[CMD] Zoom To Full Extent
+[CMD] Zoom To Next Extent
+[CMD] Zoom To Previous Extent
+[CMD] Zoom To Selection
+[DAT] Cell size
+[DAT] Grid
+[DAT] Line
+[DAT] Lower left corner
+[DAT] Number of cells
+[DAT] Point
+[DAT] Point Cloud
+[DAT] Points
+[DAT] Polygon
+[DAT] Shapes
+[DAT] TIN
+[DAT] Table
+[DAT] Undefined
+[DAT] [not set]
+[DAT] new
+[DLG] Add layer to selected map
+[DLG] Delete selected shape(s).
+[DLG] Invalid parameters!
+[DLG] Please enter a numeric value:
+[DLG] Save changes?
+[DLG] Scale 1 :
+[DLG] Select a layer to copy settings from it.
+[DLG] Set selected values to no data.
+[ERR] Calculation Error
+[ERR] Can't execute a module while another runs
+[ERR] Could not save PDF file.
+[ERR] DBase file could not be opened.
+[ERR] DBase file does not contain any records.
+[ERR] Error: Continue anyway ?
+[ERR] Grid file could not be opened.
+[ERR] Grid file could not be saved.
+[ERR] Internal system error
+[ERR] Invalid data set!
+[ERR] Invalid data!
+[ERR] Invalid display size!
+[ERR] Invalid library
+[ERR] Library could not be loaded
+[ERR] Library does not contain any modules
+[ERR] Library has already been loaded
+[ERR] Module caused access violation!
+[ERR] Shape file could not be opened.
+[ERR] There was a problem printing.\nPerhaps your current printer is not set correctly?
+[ERR] Unknown Error
+[ERR] You canceled printing
+[ERR] corrupted file header
+[ERR] corrupted record header
+[ERR] corrupted shapefile.
+[ERR] dbase file could not be opened
+[ERR] file could not be opened.
+[ERR] incompatible file.
+[ERR] index file could not be opened
+[ERR] invalid file code
+[ERR] memory allocation error.
+[ERR] no records in file.
+[ERR] shape file could not be opened.
+[ERR] unable to create file.
+[ERR] unsupported file version
+[ERR] unsupported shape type.
+[FLD] Attribute
+[FLD] Central Projection
+[FLD] Exaggeration
+[FLD] Grid
+[FLD] Icon
+[FLD] Index Layer
+[FLD] Name
+[FLD] PDF Document
+[FLD] Paper Format
+[FLD] Rotate X
+[FLD] Rotate Y
+[FLD] Rotate Z
+[FLD] Round Scale
+[FLD] SVG File
+[FLD] Shapes
+[FLD] Shift X
+[FLD] Shift Y
+[FLD] Shift Z
+[FLD] Steps to Next
+[FLD] Title
+[FLD] Value
+[HLP] Execute Module
+[HST] Created from file
+[MNU] ?
+[MNU] Attributes
+[MNU] Classification
+[MNU] Classificaton
+[MNU] Edit
+[MNU] File
+[MNU] Grid
+[MNU] Modules
+[MNU] Point Cloud
+[MNU] Project
+[MNU] Rotation
+[MNU] Sequencer
+[MNU] Shapes
+[MNU] Shift
+[MNU] TIN
+[MNU] Table
+[MNU] Window
+[MSG] Build Histogram...
+[MSG] Close
+[MSG] Close Library
+[MSG] Close table
+[MSG] Could not load project.
+[MSG] Could not save project.
+[MSG] Create TIN from shapes
+[MSG] Executing module
+[MSG] Execution has been stopped by user!
+[MSG] Interactive module execution failed
+[MSG] Interactive module execution has been started
+[MSG] Interactive module execution has been stopped
+[MSG] Load grid
+[MSG] Load library
+[MSG] Load point cloud
+[MSG] Load project
+[MSG] Load shapes
+[MSG] Load table
+[MSG] Module execution failed
+[MSG] Module execution succeeded
+[MSG] Project has been saved.
+[MSG] Project has been successfully loaded.
+[MSG] Save as Interactive SVG
+[MSG] Save grid
+[MSG] Save point cloud
+[MSG] Save shapes
+[MSG] Save table
+[MSG] Save to PDF
+[MSG] Shall execution be stopped?
+[MSG] could not read project file.
+[MSG] failed
+[MSG] file does not exist.
+[MSG] has already been loaded
+[MSG] invalid project file.
+[MSG] no data entries in project file.
+[MSG] okay
+[PRM] Boolean
+[PRM] Choice
+[PRM] Color
+[PRM] Colors
+[PRM] Data Object
+[PRM] Data Objects
+[PRM] Degree
+[PRM] File path
+[PRM] Floating point
+[PRM] Font
+[PRM] Frame Width [Pixels]
+[PRM] Grid
+[PRM] Grid list
+[PRM] Grid system
+[PRM] Grids
+[PRM] Integer
+[PRM] Legend
+[PRM] Long text
+[PRM] Map Height [Pixels]
+[PRM] Map Width [Pixels]
+[PRM] Node
+[PRM] Options
+[PRM] Parameter
+[PRM] Parameters
+[PRM] Point Cloud
+[PRM] Point Cloud list
+[PRM] Point Clouds
+[PRM] Save
+[PRM] Save Georeference (world file)
+[PRM] Save KML file
+[PRM] Shapes
+[PRM] Shapes list
+[PRM] Static table
+[PRM] TIN
+[PRM] TIN list
+[PRM] Table
+[PRM] Table field
+[PRM] Table list
+[PRM] Tables
+[PRM] Text
+[PRM] Value range
+[PRM] Zoom
+[TXT] Close all data sets
+[TXT] Do you want to delete the selection?
+[TXT] Do you want to exit SAGA?
+[TXT] No data loaded.
+[TXT] No description available
+[TXT] No parameters available.
+[TXT] SAGA\nSystem for Automated Geoscientific Analyses\nVersion 2.0
+[TXT] This is not a text!
+[TXT] grid system
+[TXT] grid systems
+[VAL] B-Spline
+[VAL] Backward Diagonal
+[VAL] Bicubic Spline
+[VAL] Bilinear
+[VAL] Cross
+[VAL] Cross Diagonal
+[VAL] Dot And Dash
+[VAL] Dotted
+[VAL] File Cache
+[VAL] Forward Diagonal
+[VAL] Graduated Color
+[VAL] Horizontal
+[VAL] Inverse Distance
+[VAL] Linear
+[VAL] Logarithmic (down)
+[VAL] Logarithmic (up)
+[VAL] Long Dashed
+[VAL] Lookup Table
+[VAL] Map Units
+[VAL] New
+[VAL] No objects
+[VAL] None
+[VAL] Normal
+[VAL] Opaque
+[VAL] RGB
+[VAL] RGB Overlay
+[VAL] RTL Compression
+[VAL] Screen
+[VAL] Shade
+[VAL] Short Dashed
+[VAL] Solid
+[VAL] Transparent
+[VAL] Unique Symbol
+[VAL] Vertical
+[VAL] [all grid systems]
+[VAL] [create]
+[VAL] [default]
+[VAL] [no choice available]
+[VAL] [no fields]
+[VAL] [none]
+[VAL] [not set]
+[VAL] no
+[VAL] object
+[VAL] objects
+[VAL] ready
+[VAL] yes
+access violation
+after
+another grid
+ascending
+author
+automatically save and load
+available module libraries
+available modules
+ball
+bar
+bar (not outlined)
+before
+binary
+bit
+black > blue
+black > green
+black > red
+bottom
+bright - dark
+buffer size
+cannot execute interactive module
+center
+central
+character string
+circle
+circle in rhombus
+circle in square
+circle in triangle (down)
+circle in triangle (up)
+circle with rhombus
+circle with square
+circle with triangle (down)
+circle with triangle (up)
+color
+color (rgb)
+colors
+columns
+confirm
+confirm with options
+continue
+could not create index: insufficient memory
+creating batch file example
+cyan - white
+cylinder
+dark - bright
+database table does not exist
+date
+date (dd.mm.yyyy)
+default
+default (same brightness)
+descending
+do not confirm
+do not show
+empty
+empty coded function
+empty input list
+error
+executing module
+failed
+field cannot be mapped to binary object
+first value
+function not found
+function table full
+green > blue
+green > grey > blue
+green > red > blue
+greyscale
+highest z
+image
+improper function syntax
+index out of bounds
+input
+input file
+interactive
+interactive execution
+invalid module libraries path
+invalid number of parameters
+last opened
+last value
+left
+library name
+library path
+lowest z
+magenta - white
+missing operand
+module
+module library
+module library not found
+module name
+module not found
+more than one field in selection
+no
+no attributes in table
+no database connection
+no fields in selection
+no histogram for unclassified data
+no memory
+no valid module library found in path
+okay
+only during start up phase
+optional
+optional input
+optional output
+original functions may not be deleted
+output
+panorama
+parallel
+parameters
+pie
+pie (not outlined)
+plain
+press any key
+ready
+red > blue
+red > blue > green
+red > green
+red > green > blue
+red > grey > blue
+red > grey > green
+red=1, green=2, blue=this
+red=1, green=this, blue=2
+red=2, green=1, blue=this
+red=2, green=this, blue=1
+red=this, green=1, blue=2
+red=this, green=2, blue=1
+rhombus
+right
+rows
+shapes
+signed 1 byte integer
+signed 2 byte integer
+signed 4 byte integer
+signed 8 byte integer
+sql excution error
+square
+string
+syntax error
+too few parameters
+too many constants
+too many parameters
+top
+triangle (down)
+triangle (up)
+type -h or --help for further information
+undeclared parameter
+undefined
+unknown type
+unmatched parentheses
+unsigned 1 byte integer
+unsigned 2 byte integer
+unsigned 4 byte integer
+unsigned 8 byte integer
+unsorted
+until user closes it
+white - cyan
+white - magenta
+white - yellow
+white > blue
+white > green
+white > red
+yellow - white
+yellow > blue
+yellow > green
+yellow > red
+yes
diff --git a/src/saga_core/saga_gui/res_commands.cpp b/src/saga_core/saga_gui/res_commands.cpp
index bd33931..9e276e7 100644
--- a/src/saga_core/saga_gui/res_commands.cpp
+++ b/src/saga_core/saga_gui/res_commands.cpp
@@ -1,452 +1,457 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// User Interface //
-// //
-// Program: SAGA //
-// //
-//-------------------------------------------------------//
-// //
-// RES_Commands.cpp //
-// //
-// Copyright (C) 2005 by Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include <wx/event.h>
-#include <wx/menu.h>
-
-#include <saga_api/saga_api.h>
-
-#include "res_commands.h"
-#include "res_images.h"
-
-#include "saga_frame.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-const wxChar * CMD_Get_Name(int Cmd_ID)
-{
- switch( Cmd_ID )
- {
- case ID_CMD_FRAME_QUIT: return( LNG("[CMD] Exit") );
-
- case ID_CMD_FRAME_HELP: return( LNG("[CMD] Help") );
- case ID_CMD_FRAME_ABOUT: return( LNG("[CMD] About SAGA") );
- case ID_CMD_FRAME_TIPS: return( LNG("[CMD] Tip of the Day...") );
-
- case ID_CMD_FRAME_CASCADE: return( LNG("[CMD] Cascade") );
- case ID_CMD_FRAME_TILE_HORZ: return( LNG("[CMD] Tile Horizontally") );
- case ID_CMD_FRAME_TILE_VERT: return( LNG("[CMD] Tile Vertically") );
- case ID_CMD_FRAME_ARRANGEICONS: return( LNG("[CMD] Arrange Icons") );
- case ID_CMD_FRAME_NEXT: return( LNG("[CMD] Next") );
- case ID_CMD_FRAME_PREVIOUS: return( LNG("[CMD] Previous") );
- case ID_CMD_FRAME_CLOSE: return( LNG("[CMD] Close") );
- case ID_CMD_FRAME_CLOSE_ALL: return( LNG("[CMD] Close All") );
-
- case ID_CMD_FRAME_INFO_SHOW: return( LNG("[CMD] Show Message Window") );
- case ID_CMD_FRAME_WKSP_SHOW: return( LNG("[CMD] Show Workspace") );
- case ID_CMD_FRAME_ACTIVE_SHOW: return( LNG("[CMD] Show Object Properties") );
-
-
- //-----------------------------------------------------
- // Workspace...
-
- case ID_CMD_WKSP_ITEM_CLOSE: return( LNG("[CMD] Close") );
- case ID_CMD_WKSP_ITEM_SHOW: return( LNG("[CMD] Show") );
- case ID_CMD_WKSP_ITEM_SETTINGS_LOAD:return( LNG("[CMD] Load Settings") );
- case ID_CMD_WKSP_ITEM_SETTINGS_COPY:return( LNG("[CMD] Copy Settings from other Layer") );
-
- case ID_CMD_WKSP_OPEN: return( LNG("[CMD] Load") );
-
- case ID_CMD_INFO_CLEAR: return( LNG("[CMD] Clear") );
- case ID_CMD_INFO_COPY: return( LNG("[CMD] Copy") );
-
- case ID_CMD_MODULES_OPEN: return( LNG("[CMD] Load Module Library") );
- case ID_CMD_MODULES_SAVE_HTML: return( LNG("[CMD] Create HTML Documentation") );
- case ID_CMD_MODULES_SAVE_SCRIPT: return( LNG("[CMD] Create Script Command File") );
-
- case ID_CMD_DATA_PROJECT_NEW: return( LNG("[CMD] New Project") );
- case ID_CMD_DATA_PROJECT_OPEN: return( LNG("[CMD] Load Project") );
- case ID_CMD_DATA_PROJECT_OPEN_ADD: return( LNG("[CMD] Add Project") );
- case ID_CMD_DATA_PROJECT_SAVE: return( LNG("[CMD] Save Project") );
- case ID_CMD_DATA_PROJECT_SAVE_AS: return( LNG("[CMD] Save Project As...") );
-
- case ID_CMD_GRIDS_OPEN: return( LNG("[CMD] Load Grid") );
- case ID_CMD_GRIDS_SAVE: return( LNG("[CMD] Save Grid") );
- case ID_CMD_GRIDS_SAVEAS: return( LNG("[CMD] Save Grid As...") );
- case ID_CMD_GRIDS_SAVEAS_IMAGE: return( LNG("[CMD] Save Grid As Image...") );
- case ID_CMD_GRIDS_SHOW: return( LNG("[CMD] Show Grid") );
- case ID_CMD_GRIDS_HISTOGRAM: return( LNG("[CMD] Show Histogram") );
- case ID_CMD_GRIDS_SCATTERPLOT: return( LNG("[CMD] Show Scatterplot") );
- case ID_CMD_GRIDS_EQUALINTERVALS: return( LNG("[CMD] Create Normalised Classification") );
- case ID_CMD_GRIDS_RANGE_MINMAX: return( LNG("[CMD] Set Range to Minmum/Maximum") );
- case ID_CMD_GRIDS_RANGE_STDDEV150: return( LNG("[CMD] Set Range to Standard Deviation (1.5)") );
- case ID_CMD_GRIDS_RANGE_STDDEV200: return( LNG("[CMD] Set Range to Standard Deviation (2.0)") );
- case ID_CMD_GRIDS_SET_LUT: return( LNG("[CMD] Create Lookup Table") );
-
- case ID_CMD_SHAPES_OPEN: return( LNG("[CMD] Load Shapes") );
- case ID_CMD_SHAPES_SAVE: return( LNG("[CMD] Save Shapes") );
- case ID_CMD_SHAPES_SAVEAS: return( LNG("[CMD] Save Shapes As...") );
- case ID_CMD_SHAPES_SHOW: return( LNG("[CMD] Show Shapes") );
- case ID_CMD_SHAPES_HISTOGRAM: return( LNG("[CMD] Show Histogram") );
- case ID_CMD_SHAPES_SET_LUT: return( LNG("[CMD] Create Lookup Table") );
- case ID_CMD_SHAPES_EDIT_SHAPE: return( LNG("[CMD] Edit Selected Shape") );
- case ID_CMD_SHAPES_EDIT_SEL_INVERT: return( LNG("[CMD] Invert Selection") );
- case ID_CMD_SHAPES_EDIT_ADD_SHAPE: return( LNG("[CMD] Add Shape") );
- case ID_CMD_SHAPES_EDIT_ADD_PART: return( LNG("[CMD] Add Part") );
- case ID_CMD_SHAPES_EDIT_DEL_SHAPE: return( LNG("[CMD] Delete Selected Shape(s)") );
- case ID_CMD_SHAPES_EDIT_DEL_PART: return( LNG("[CMD] Delete Selected Part") );
- case ID_CMD_SHAPES_EDIT_DEL_POINT: return( LNG("[CMD] Delete Selected Point") );
-
- case ID_CMD_TABLES_OPEN: return( LNG("[CMD] Load Table") );
- case ID_CMD_TABLES_SAVE: return( LNG("[CMD] Save Table") );
- case ID_CMD_TABLES_SAVEAS: return( LNG("[CMD] Save Table As...") );
- case ID_CMD_TABLES_SHOW: return( LNG("[CMD] Show Table") );
- case ID_CMD_TABLES_DIAGRAM: return( LNG("[CMD] Show Diagram") );
- case ID_CMD_TABLES_SCATTERPLOT: return( LNG("[CMD] Show Scatterplot") );
-
- case ID_CMD_TIN_OPEN: return( LNG("[CMD] Load TIN") );
- case ID_CMD_TIN_SAVE: return( LNG("[CMD] Save TIN") );
- case ID_CMD_TIN_SAVEAS: return( LNG("[CMD] Save TIN As...") );
- case ID_CMD_TIN_SHOW: return( LNG("[CMD] Show TIN") );
-
- case ID_CMD_POINTCLOUD_OPEN: return( LNG("[CMD] Load Point Cloud") );
- case ID_CMD_POINTCLOUD_SAVE: return( LNG("[CMD] Save Point Cloud") );
- case ID_CMD_POINTCLOUD_SAVEAS: return( LNG("[CMD] Save Point Cloud As...") );
- case ID_CMD_POINTCLOUD_SHOW: return( LNG("[CMD] Show Point Cloud") );
-
- case ID_CMD_MAP_3D_SHOW:
- case ID_CMD_MAPS_3D_SHOW: return( LNG("[CMD] Show 3D-View") );
- case ID_CMD_MAP_LAYOUT_SHOW:
- case ID_CMD_MAPS_LAYOUT_SHOW: return( LNG("[CMD] Show Print Layout") );
- case ID_CMD_MAP_SAVE_IMAGE_ON_CHANGE:
- case ID_CMD_MAPS_SAVE_IMAGE_ON_CHANGE: return( LNG("[CMD] Save As Image when changed") );
- case ID_CMD_MAP_SAVE_IMAGE:
- case ID_CMD_MAPS_SAVE_IMAGE: return( LNG("[CMD] Save As Image...") );
- case ID_CMD_MAPS_SAVE_TO_CLIPBOARD: return( LNG("[CMD] Save to Clipboard [Ctrl+C]") );
- case ID_CMD_MAPS_SAVE_TO_CLIPBOARD_LEGEND: return( LNG("[CMD] Save Legend to Clipboard [Ctrl+L]") );
- case ID_CMD_MAP_SAVE_PDF_INDEXED:
- case ID_CMD_MAPS_SAVE_PDF_INDEXED: return( LNG("[CMD] Save As PDF") );
- case ID_CMD_MAP_SAVE_INTERACTIVE_SVG:
- case ID_CMD_MAPS_SAVE_INTERACTIVE_SVG: return( LNG("[CMD] Save as Interactive SVG") );
- case ID_CMD_MAP_SYNCHRONIZE:
- case ID_CMD_MAPS_SYNCHRONIZE: return( LNG("[CMD] Synchronise Map Extents") );
-
- case ID_CMD_MAPS_SHOW: return( LNG("[CMD] Show Map") );
- case ID_CMD_MAPS_LAYER_SHOW: return( LNG("[CMD] Show Layer") );
- case ID_CMD_MAPS_MOVE_TOP: return( LNG("[CMD] Move To Top") );
- case ID_CMD_MAPS_MOVE_BOTTOM: return( LNG("[CMD] Move To Bottom") );
- case ID_CMD_MAPS_MOVE_UP: return( LNG("[CMD] Move Up") );
- case ID_CMD_MAPS_MOVE_DOWN: return( LNG("[CMD] Move Down") );
- case ID_CMD_MAPS_GRID_FITCOLORS: return( LNG("[CMD] Fit Grid Colors To Map Extent") );
-
- //-----------------------------------------------------
- // Views...
-
- case ID_CMD_MAP_MODE_ZOOM: return( LNG("[CMD] Zoom") );
- case ID_CMD_MAP_MODE_PAN: return( LNG("[CMD] Pan") );
- case ID_CMD_MAP_MODE_SELECT: return( LNG("[CMD] Action") );
- case ID_CMD_MAP_MODE_DISTANCE: return( LNG("[CMD] Measure Distance") );
- case ID_CMD_MAP_CLOSE: return( LNG("[CMD] Close") );
- case ID_CMD_MAP_TOOLBAR: return( LNG("[CMD] Show Toolbar") );
- case ID_CMD_MAP_LEGEND_VERTICAL: return( LNG("[CMD] Show Vertical Legend") );
- case ID_CMD_MAP_LEGEND_HORIZONTAL: return( LNG("[CMD] Show Horizontal Legend") );
- case ID_CMD_MAP_ZOOM_BACK: return( LNG("[CMD] Zoom To Previous Extent") );
- case ID_CMD_MAP_ZOOM_FORWARD: return( LNG("[CMD] Zoom To Next Extent") );
- case ID_CMD_MAP_ZOOM_FULL: return( LNG("[CMD] Zoom To Full Extent") );
- case ID_CMD_MAP_ZOOM_ACTIVE: return( LNG("[CMD] Zoom To Active Layer") );
- case ID_CMD_MAP_ZOOM_SELECTION: return( LNG("[CMD] Zoom To Selection") );
- case ID_CMD_MAP_ZOOM_EXTENT: return( LNG("[CMD] Zoom To Extent") );
-
- case ID_CMD_MAP3D_PARAMETERS: return( LNG("[CMD] Properties") );
- case ID_CMD_MAP3D_ROTATE_X_LESS: return( LNG("[CMD] Up") );
- case ID_CMD_MAP3D_ROTATE_X_MORE: return( LNG("[CMD] Down") );
- case ID_CMD_MAP3D_ROTATE_Y_LESS: return( LNG("[CMD] Left [F3]") );
- case ID_CMD_MAP3D_ROTATE_Y_MORE: return( LNG("[CMD] Right [F4]") );
- case ID_CMD_MAP3D_ROTATE_Z_LESS: return( LNG("[CMD] Left") );
- case ID_CMD_MAP3D_ROTATE_Z_MORE: return( LNG("[CMD] Right") );
- case ID_CMD_MAP3D_SHIFT_X_LESS: return( LNG("[CMD] Left") );
- case ID_CMD_MAP3D_SHIFT_X_MORE: return( LNG("[CMD] Right") );
- case ID_CMD_MAP3D_SHIFT_Y_LESS: return( LNG("[CMD] Down") );
- case ID_CMD_MAP3D_SHIFT_Y_MORE: return( LNG("[CMD] Up") );
- case ID_CMD_MAP3D_SHIFT_Z_LESS: return( LNG("[CMD] Forward") );
- case ID_CMD_MAP3D_SHIFT_Z_MORE: return( LNG("[CMD] Backward") );
- case ID_CMD_MAP3D_EXAGGERATE_LESS: return( LNG("[CMD] Decrease Exaggeration [F1]") );
- case ID_CMD_MAP3D_EXAGGERATE_MORE: return( LNG("[CMD] Increase Exaggeration [F2]") );
- case ID_CMD_MAP3D_CENTRAL_LESS: return( LNG("[CMD] Decrease Perspectivic Distance [F5]") );
- case ID_CMD_MAP3D_CENTRAL_MORE: return( LNG("[CMD] Increase Perspectivic Distance [F6]") );
- case ID_CMD_MAP3D_CENTRAL: return( LNG("[CMD] Central Projection") );
- case ID_CMD_MAP3D_STEREO_LESS: return( LNG("[CMD] Decrease Eye Distance") );
- case ID_CMD_MAP3D_STEREO_MORE: return( LNG("[CMD] Increase Eye Distance") );
- case ID_CMD_MAP3D_STEREO: return( LNG("[CMD] Anaglyph [S]") );
- case ID_CMD_MAP3D_INTERPOLATED: return( LNG("[CMD] Interpolated Colors") );
- case ID_CMD_MAP3D_SAVE: return( LNG("[CMD] Save As Image...") );
- case ID_CMD_MAP3D_SEQ_POS_ADD: return( LNG("[CMD] Add Position [A]") );
- case ID_CMD_MAP3D_SEQ_POS_DEL: return( LNG("[CMD] Delete Last Position [D]") );
- case ID_CMD_MAP3D_SEQ_POS_DEL_ALL: return( LNG("[CMD] Delete All Positions") );
- case ID_CMD_MAP3D_SEQ_POS_EDIT: return( LNG("[CMD] Edit Positions") );
- case ID_CMD_MAP3D_SEQ_PLAY: return( LNG("[CMD] Play Once [P]") );
- case ID_CMD_MAP3D_SEQ_PLAY_LOOP: return( LNG("[CMD] Play Loop [L]") );
- case ID_CMD_MAP3D_SEQ_SAVE: return( LNG("[CMD] Play And Save As Images...") );
-
- case ID_CMD_LAYOUT_PRINT_SETUP: return( LNG("[CMD] Print Setup") );
- case ID_CMD_LAYOUT_PAGE_SETUP: return( LNG("[CMD] Page Setup") );
- case ID_CMD_LAYOUT_PRINT: return( LNG("[CMD] Print") );
- case ID_CMD_LAYOUT_PRINT_PREVIEW: return( LNG("[CMD] Print Preview") );
- case ID_CMD_LAYOUT_FIT_SCALE: return( LNG("[CMD] Fit Scale...") );
-
- case ID_CMD_TABLE_FIELD_ADD: return( LNG("[CMD] Add Field") );
- case ID_CMD_TABLE_FIELD_DEL: return( LNG("[CMD] Delete Fields") );
- case ID_CMD_TABLE_FIELD_SORT: return( LNG("[CMD] Sort Fields") );
- case ID_CMD_TABLE_FIELD_RENAME: return( LNG("[CMD] Rename Fields") );
- case ID_CMD_TABLE_RECORD_ADD: return( LNG("[CMD] Add Record") );
- case ID_CMD_TABLE_RECORD_INS: return( LNG("[CMD] Insert Record") );
- case ID_CMD_TABLE_RECORD_DEL: return( LNG("[CMD] Delete Selected Record(s)") );
- case ID_CMD_TABLE_RECORD_DEL_ALL: return( LNG("[CMD] Delete All Records") );
- case ID_CMD_TABLE_AUTOSIZE_COLS: return( LNG("[CMD] Fit Column Sizes") );
- case ID_CMD_TABLE_AUTOSIZE_ROWS: return( LNG("[CMD] Fit Row Sizes") );
-
- case ID_CMD_DIAGRAM_PARAMETERS: return( LNG("[CMD] Properties") );
- case ID_CMD_DIAGRAM_SIZE_FIT: return( LNG("[CMD] Fit Diagram to Window") );
- case ID_CMD_DIAGRAM_SIZE_INC: return( LNG("[CMD] Increase Diagram Size") );
- case ID_CMD_DIAGRAM_SIZE_DEC: return( LNG("[CMD] Decrease Diagram Size") );
-
- case ID_CMD_SCATTERPLOT_PARAMETERS: return( LNG("[CMD] Properties") );
- case ID_CMD_SCATTERPLOT_UPDATE: return( LNG("[CMD] Update Data") );
-
- case ID_CMD_HISTOGRAM_CUMULATIVE: return( LNG("[CMD] Cumulative") );
- case ID_CMD_HISTOGRAM_AS_TABLE: return( LNG("[CMD] Convert To Table") );
- }
-
- //-----------------------------------------------------
- return( LNG("[CMD] UNRECOGNISED COMMAND ID") );
-}
-
-//---------------------------------------------------------
-const wxChar * CMD_Get_Help(int Cmd_ID)
-{
- switch( Cmd_ID )
- {
- case ID_CMD_FRAME_QUIT: return( LNG("[CMD] Exit SAGA") );
- case ID_CMD_FRAME_ABOUT: return( LNG("[CMD] About SAGA") );
- }
-
- return( CMD_Get_Name(Cmd_ID) );
-}
-
-//---------------------------------------------------------
-int CMD_Get_ImageID(int Cmd_ID)
-{
- switch( Cmd_ID )
- {
- case ID_CMD_FRAME_WKSP_SHOW: return( ID_IMG_TB_WKSP );
- case ID_CMD_FRAME_INFO_SHOW: return( ID_IMG_TB_INFO );
- case ID_CMD_FRAME_ACTIVE_SHOW: return( ID_IMG_TB_ACTIVE );
- case ID_CMD_FRAME_HELP: return( ID_IMG_TB_HELP );
- case ID_CMD_WKSP_OPEN: return( ID_IMG_TB_OPEN );
- case ID_CMD_MODULES_OPEN: return( ID_IMG_TB_OPEN_MODULE );
- case ID_CMD_TABLES_OPEN: return( ID_IMG_TB_OPEN_TABLE );
- case ID_CMD_SHAPES_OPEN: return( ID_IMG_TB_OPEN_SHAPES );
- case ID_CMD_GRIDS_OPEN: return( ID_IMG_TB_OPEN_GRID );
- case ID_CMD_TIN_OPEN: return( ID_IMG_TB_OPEN_TIN );
- case ID_CMD_POINTCLOUD_OPEN: return( ID_IMG_TB_OPEN_POINTCLOUD );
-
- case ID_CMD_MAP_MODE_DISTANCE: return( ID_IMG_TB_MAP_MODE_DISTANCE );
- case ID_CMD_MAP_MODE_SELECT: return( ID_IMG_TB_MAP_MODE_SELECT );
- case ID_CMD_MAP_MODE_ZOOM: return( ID_IMG_TB_MAP_MODE_ZOOM );
- case ID_CMD_MAP_MODE_PAN: return( ID_IMG_TB_MAP_MODE_PAN );
- case ID_CMD_MAP_ZOOM_FULL: return( ID_IMG_TB_MAP_ZOOM_FULL );
- case ID_CMD_MAP_ZOOM_BACK: return( ID_IMG_TB_MAP_ZOOM_LAST );
- case ID_CMD_MAP_ZOOM_FORWARD: return( ID_IMG_TB_MAP_ZOOM_NEXT );
- case ID_CMD_MAP_ZOOM_ACTIVE: return( ID_IMG_TB_MAP_ZOOM_ACTIVE );
- case ID_CMD_MAP_ZOOM_SELECTION: return( ID_IMG_TB_MAP_ZOOM_SELECTION );
- case ID_CMD_MAP_ZOOM_EXTENT: return( ID_IMG_TB_MAP_ZOOM_SELECTION );
- case ID_CMD_MAP_3D_SHOW: return( ID_IMG_TB_MAP_3D_SHOW );
- case ID_CMD_MAPS_3D_SHOW: return( ID_IMG_TB_MAP_3D_SHOW );
- case ID_CMD_MAP_LAYOUT_SHOW: return( ID_IMG_TB_MAP_LAYOUT_SHOW );
- case ID_CMD_MAPS_LAYOUT_SHOW: return( ID_IMG_TB_MAP_LAYOUT_SHOW );
- case ID_CMD_MAPS_SAVE_TO_CLIPBOARD:
- case ID_CMD_MAPS_SAVE_TO_CLIPBOARD_LEGEND:
- case ID_CMD_MAPS_SAVE_IMAGE:
- case ID_CMD_MAPS_SYNCHRONIZE: return( ID_IMG_TB_MAP_SYNCHRONIZE );
- case ID_CMD_MAP_LEGEND_VERTICAL: return( ID_IMG_TB_MAP_LEGEND_VERTICAL );
- case ID_CMD_MAP_LEGEND_HORIZONTAL: return( ID_IMG_TB_MAP_LEGEND_HORIZONTAL );
-
- case ID_CMD_MAP3D_PARAMETERS: return( ID_IMG_TB_MAP3D_PROPERTIES );
- case ID_CMD_MAP3D_CENTRAL_LESS: return( ID_IMG_TB_MAP3D_CENTRAL_LESS );
- case ID_CMD_MAP3D_CENTRAL_MORE: return( ID_IMG_TB_MAP3D_CENTRAL_MORE );
- case ID_CMD_MAP3D_EXAGGERATE_LESS: return( ID_IMG_TB_MAP3D_EXAGGERATE_LESS );
- case ID_CMD_MAP3D_EXAGGERATE_MORE: return( ID_IMG_TB_MAP3D_EXAGGERATE_MORE );
- case ID_CMD_MAP3D_INTERPOLATED: return( ID_IMG_TB_MAP3D_INTERPOLATED );
- case ID_CMD_MAP3D_ROTATE_X_LESS: return( ID_IMG_TB_MAP3D_ROTATE_X_LESS );
- case ID_CMD_MAP3D_ROTATE_X_MORE: return( ID_IMG_TB_MAP3D_ROTATE_X_MORE );
- case ID_CMD_MAP3D_ROTATE_Z_LESS: return( ID_IMG_TB_MAP3D_ROTATE_Z_LESS );
- case ID_CMD_MAP3D_ROTATE_Z_MORE: return( ID_IMG_TB_MAP3D_ROTATE_Z_MORE );
- case ID_CMD_MAP3D_SHIFT_X_LESS: return( ID_IMG_TB_MAP3D_SHIFT_X_LESS );
- case ID_CMD_MAP3D_SHIFT_X_MORE: return( ID_IMG_TB_MAP3D_SHIFT_X_MORE );
- case ID_CMD_MAP3D_SHIFT_Y_LESS: return( ID_IMG_TB_MAP3D_SHIFT_Y_LESS );
- case ID_CMD_MAP3D_SHIFT_Y_MORE: return( ID_IMG_TB_MAP3D_SHIFT_Y_MORE );
- case ID_CMD_MAP3D_SHIFT_Z_LESS: return( ID_IMG_TB_MAP3D_SHIFT_Z_LESS );
- case ID_CMD_MAP3D_SHIFT_Z_MORE: return( ID_IMG_TB_MAP3D_SHIFT_Z_MORE );
- case ID_CMD_MAP3D_STEREO: return( ID_IMG_TB_MAP3D_STEREO );
-
- case ID_CMD_LAYOUT_PRINT_SETUP: return( ID_IMG_TB_LAYOUT_PRINT_SETUP );
- case ID_CMD_LAYOUT_PAGE_SETUP: return( ID_IMG_TB_LAYOUT_PAGE_SETUP );
- case ID_CMD_LAYOUT_PRINT: return( ID_IMG_TB_LAYOUT_PRINT );
- case ID_CMD_LAYOUT_PRINT_PREVIEW: return( ID_IMG_TB_LAYOUT_PRINT_PREVIEW );
-
- case ID_CMD_HISTOGRAM_CUMULATIVE: return( ID_IMG_TB_HISTOGRAM_CUMULATIVE );
- case ID_CMD_HISTOGRAM_AS_TABLE: return( ID_IMG_TB_HISTOGRAM_AS_TABLE );
-
- case ID_CMD_TABLE_FIELD_ADD: return( ID_IMG_TB_TABLE_COL_ADD );
- case ID_CMD_TABLE_FIELD_DEL: return( ID_IMG_TB_TABLE_COL_DEL );
- case ID_CMD_TABLE_RECORD_ADD: return( ID_IMG_TB_TABLE_ROW_ADD );
- case ID_CMD_TABLE_RECORD_INS: return( ID_IMG_TB_TABLE_ROW_INS );
- case ID_CMD_TABLE_RECORD_DEL: return( ID_IMG_TB_TABLE_ROW_DEL );
- case ID_CMD_TABLE_RECORD_DEL_ALL: return( ID_IMG_TB_TABLE_ROW_DEL_ALL );
-
- case ID_CMD_SCATTERPLOT_PARAMETERS: return( ID_IMG_TB_SCATTERPLOT_PARAMETERS );
- case ID_CMD_SCATTERPLOT_UPDATE: return( ID_IMG_DEFAULT );
-
- case ID_CMD_DIAGRAM_PARAMETERS: return( ID_IMG_TB_DIAGRAM_PARAMETERS );
- case ID_CMD_DIAGRAM_SIZE_FIT: break;
- case ID_CMD_DIAGRAM_SIZE_INC: return( ID_IMG_TB_MAP3D_CENTRAL_MORE );
- case ID_CMD_DIAGRAM_SIZE_DEC: return( ID_IMG_TB_MAP3D_CENTRAL_LESS );
- }
-
- return( ID_IMG_DEFAULT );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CMD_Menu_Add_Item(wxMenu *pMenu, bool bCheck, int Cmd_ID)
-{
- if( bCheck )
- {
- pMenu->AppendCheckItem(Cmd_ID, CMD_Get_Name(Cmd_ID), CMD_Get_Help(Cmd_ID));
- }
- else
- {
- pMenu->Append (Cmd_ID, CMD_Get_Name(Cmd_ID), CMD_Get_Help(Cmd_ID));
- }
-}
-
-//---------------------------------------------------------
-void CMD_Menu_Ins_Item(wxMenu *pMenu, bool bCheck, int Cmd_ID, int Position)
-{
- if( bCheck )
- {
- pMenu->InsertCheckItem(Position, Cmd_ID, CMD_Get_Name(Cmd_ID), CMD_Get_Help(Cmd_ID));
- }
- else
- {
- pMenu->Insert (Position, Cmd_ID, CMD_Get_Name(Cmd_ID), CMD_Get_Help(Cmd_ID));
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-wxToolBarBase * CMD_ToolBar_Create(int ID)
-{
- return( g_pSAGA_Frame ? g_pSAGA_Frame->TB_Create(ID) : NULL );
-}
-
-//---------------------------------------------------------
-void CMD_ToolBar_Add(wxToolBarBase *pToolBar, const wxChar *Name)
-{
- if( g_pSAGA_Frame )
- {
- g_pSAGA_Frame->TB_Add(pToolBar, Name);
- }
-}
-
-//---------------------------------------------------------
-void CMD_ToolBar_Add_Item(wxToolBarBase *pToolBar, bool bCheck, int Cmd_ID)
-{
- if( g_pSAGA_Frame )
- {
- g_pSAGA_Frame->TB_Add_Item(pToolBar, bCheck, Cmd_ID);
- }
-}
-
-//---------------------------------------------------------
-void CMD_ToolBar_Add_Separator(wxToolBarBase *pToolBar)
-{
- if( g_pSAGA_Frame )
- {
- g_pSAGA_Frame->TB_Add_Separator(pToolBar);
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// User Interface //
+// //
+// Program: SAGA //
+// //
+//-------------------------------------------------------//
+// //
+// RES_Commands.cpp //
+// //
+// Copyright (C) 2005 by Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include <wx/event.h>
+#include <wx/menu.h>
+
+#include <saga_api/saga_api.h>
+
+#include "res_commands.h"
+#include "res_images.h"
+
+#include "saga_frame.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+const wxChar * CMD_Get_Name(int Cmd_ID)
+{
+ switch( Cmd_ID )
+ {
+ case ID_CMD_FRAME_QUIT: return( LNG("[CMD] Exit") );
+
+ case ID_CMD_FRAME_HELP: return( LNG("[CMD] Help") );
+ case ID_CMD_FRAME_ABOUT: return( LNG("[CMD] About SAGA") );
+ case ID_CMD_FRAME_TIPS: return( LNG("[CMD] Tip of the Day...") );
+
+ case ID_CMD_FRAME_CASCADE: return( LNG("[CMD] Cascade") );
+ case ID_CMD_FRAME_TILE_HORZ: return( LNG("[CMD] Tile Horizontally") );
+ case ID_CMD_FRAME_TILE_VERT: return( LNG("[CMD] Tile Vertically") );
+ case ID_CMD_FRAME_ARRANGEICONS: return( LNG("[CMD] Arrange Icons") );
+ case ID_CMD_FRAME_NEXT: return( LNG("[CMD] Next") );
+ case ID_CMD_FRAME_PREVIOUS: return( LNG("[CMD] Previous") );
+ case ID_CMD_FRAME_CLOSE: return( LNG("[CMD] Close") );
+ case ID_CMD_FRAME_CLOSE_ALL: return( LNG("[CMD] Close All") );
+
+ case ID_CMD_FRAME_INFO_SHOW: return( LNG("[CMD] Show Message Window") );
+ case ID_CMD_FRAME_WKSP_SHOW: return( LNG("[CMD] Show Workspace") );
+ case ID_CMD_FRAME_ACTIVE_SHOW: return( LNG("[CMD] Show Object Properties") );
+
+
+ //-----------------------------------------------------
+ // Workspace...
+
+ case ID_CMD_WKSP_ITEM_CLOSE: return( LNG("[CMD] Close") );
+ case ID_CMD_WKSP_ITEM_SHOW: return( LNG("[CMD] Show") );
+ case ID_CMD_WKSP_ITEM_SETTINGS_LOAD:return( LNG("[CMD] Load Settings") );
+ case ID_CMD_WKSP_ITEM_SETTINGS_COPY:return( LNG("[CMD] Copy Settings from other Layer") );
+ case ID_CMD_WKSP_ITEM_SEARCH: return( LNG("[CMD] Search for...") );
+
+ case ID_CMD_WKSP_OPEN: return( LNG("[CMD] Load") );
+
+ case ID_CMD_INFO_CLEAR: return( LNG("[CMD] Clear") );
+ case ID_CMD_INFO_COPY: return( LNG("[CMD] Copy") );
+
+ case ID_CMD_MODULES_OPEN: return( LNG("[CMD] Load Module Library") );
+ case ID_CMD_MODULES_SAVE_HTML: return( LNG("[CMD] Create HTML Documentation") );
+ case ID_CMD_MODULES_SAVE_SCRIPT: return( LNG("[CMD] Create Script Command File") );
+
+ case ID_CMD_DATA_PROJECT_NEW: return( LNG("[CMD] New Project") );
+ case ID_CMD_DATA_PROJECT_OPEN: return( LNG("[CMD] Load Project") );
+ case ID_CMD_DATA_PROJECT_OPEN_ADD: return( LNG("[CMD] Add Project") );
+ case ID_CMD_DATA_PROJECT_SAVE: return( LNG("[CMD] Save Project") );
+ case ID_CMD_DATA_PROJECT_SAVE_AS: return( LNG("[CMD] Save Project As...") );
+
+ case ID_CMD_GRIDS_OPEN: return( LNG("[CMD] Load Grid") );
+ case ID_CMD_GRIDS_SAVE: return( LNG("[CMD] Save Grid") );
+ case ID_CMD_GRIDS_SAVEAS: return( LNG("[CMD] Save Grid As...") );
+ case ID_CMD_GRIDS_SAVEAS_IMAGE: return( LNG("[CMD] Save Grid As Image...") );
+ case ID_CMD_GRIDS_SHOW: return( LNG("[CMD] Show Grid") );
+ case ID_CMD_GRIDS_HISTOGRAM: return( LNG("[CMD] Show Histogram") );
+ case ID_CMD_GRIDS_SCATTERPLOT: return( LNG("[CMD] Show Scatterplot") );
+ case ID_CMD_GRIDS_EQUALINTERVALS: return( LNG("[CMD] Create Normalised Classification") );
+ case ID_CMD_GRIDS_RANGE_MINMAX: return( LNG("[CMD] Set Range to Minmum/Maximum") );
+ case ID_CMD_GRIDS_RANGE_STDDEV150: return( LNG("[CMD] Set Range to Standard Deviation (1.5)") );
+ case ID_CMD_GRIDS_RANGE_STDDEV200: return( LNG("[CMD] Set Range to Standard Deviation (2.0)") );
+ case ID_CMD_GRIDS_SET_LUT: return( LNG("[CMD] Create Lookup Table") );
+
+ case ID_CMD_SHAPES_OPEN: return( LNG("[CMD] Load Shapes") );
+ case ID_CMD_SHAPES_SAVE: return( LNG("[CMD] Save Shapes") );
+ case ID_CMD_SHAPES_SAVEAS: return( LNG("[CMD] Save Shapes As...") );
+ case ID_CMD_SHAPES_SHOW: return( LNG("[CMD] Show Shapes") );
+ case ID_CMD_SHAPES_HISTOGRAM: return( LNG("[CMD] Show Histogram") );
+ case ID_CMD_SHAPES_SET_LUT: return( LNG("[CMD] Create Lookup Table") );
+ case ID_CMD_SHAPES_EDIT_SHAPE: return( LNG("[CMD] Edit Selected Shape") );
+ case ID_CMD_SHAPES_EDIT_SEL_INVERT: return( LNG("[CMD] Invert Selection") );
+ case ID_CMD_SHAPES_EDIT_ADD_SHAPE: return( LNG("[CMD] Add Shape") );
+ case ID_CMD_SHAPES_EDIT_ADD_PART: return( LNG("[CMD] Add Part") );
+ case ID_CMD_SHAPES_EDIT_DEL_SHAPE: return( LNG("[CMD] Delete Selected Shape(s)") );
+ case ID_CMD_SHAPES_EDIT_DEL_PART: return( LNG("[CMD] Delete Selected Part") );
+ case ID_CMD_SHAPES_EDIT_DEL_POINT: return( LNG("[CMD] Delete Selected Point") );
+
+ case ID_CMD_TABLES_OPEN: return( LNG("[CMD] Load Table") );
+ case ID_CMD_TABLES_SAVE: return( LNG("[CMD] Save Table") );
+ case ID_CMD_TABLES_SAVEAS: return( LNG("[CMD] Save Table As...") );
+ case ID_CMD_TABLES_SHOW: return( LNG("[CMD] Show Table") );
+ case ID_CMD_TABLES_DIAGRAM: return( LNG("[CMD] Show Diagram") );
+ case ID_CMD_TABLES_SCATTERPLOT: return( LNG("[CMD] Show Scatterplot") );
+
+ case ID_CMD_TIN_OPEN: return( LNG("[CMD] Load TIN") );
+ case ID_CMD_TIN_SAVE: return( LNG("[CMD] Save TIN") );
+ case ID_CMD_TIN_SAVEAS: return( LNG("[CMD] Save TIN As...") );
+ case ID_CMD_TIN_SHOW: return( LNG("[CMD] Show TIN") );
+
+ case ID_CMD_POINTCLOUD_OPEN: return( LNG("[CMD] Load Point Cloud") );
+ case ID_CMD_POINTCLOUD_SAVE: return( LNG("[CMD] Save Point Cloud") );
+ case ID_CMD_POINTCLOUD_SAVEAS: return( LNG("[CMD] Save Point Cloud As...") );
+ case ID_CMD_POINTCLOUD_SHOW: return( LNG("[CMD] Show Point Cloud") );
+ case ID_CMD_POINTCLOUD_RANGE_MINMAX: return( LNG("[CMD] Set Range to Minmum/Maximum") );
+ case ID_CMD_POINTCLOUD_RANGE_STDDEV150: return( LNG("[CMD] Set Range to Standard Deviation (1.5)") );
+ case ID_CMD_POINTCLOUD_RANGE_STDDEV200: return( LNG("[CMD] Set Range to Standard Deviation (2.0)") );
+
+ case ID_CMD_MAP_3D_SHOW:
+ case ID_CMD_MAPS_3D_SHOW: return( LNG("[CMD] Show 3D-View") );
+ case ID_CMD_MAP_LAYOUT_SHOW:
+ case ID_CMD_MAPS_LAYOUT_SHOW: return( LNG("[CMD] Show Print Layout") );
+ case ID_CMD_MAP_SAVE_IMAGE_ON_CHANGE:
+ case ID_CMD_MAPS_SAVE_IMAGE_ON_CHANGE: return( LNG("[CMD] Save As Image when changed") );
+ case ID_CMD_MAP_SAVE_IMAGE:
+ case ID_CMD_MAPS_SAVE_IMAGE: return( LNG("[CMD] Save As Image...") );
+ case ID_CMD_MAPS_SAVE_TO_CLIPBOARD: return( LNG("[CMD] Save to Clipboard [Ctrl+C]") );
+ case ID_CMD_MAPS_SAVE_TO_CLIPBOARD_LEGEND: return( LNG("[CMD] Save Legend to Clipboard [Ctrl+L]") );
+ case ID_CMD_MAP_SAVE_PDF_INDEXED:
+ case ID_CMD_MAPS_SAVE_PDF_INDEXED: return( LNG("[CMD] Save As PDF") );
+ case ID_CMD_MAP_SAVE_INTERACTIVE_SVG:
+ case ID_CMD_MAPS_SAVE_INTERACTIVE_SVG: return( LNG("[CMD] Save as Interactive SVG") );
+ case ID_CMD_MAP_SYNCHRONIZE:
+ case ID_CMD_MAPS_SYNCHRONIZE: return( LNG("[CMD] Synchronise Map Extents") );
+
+ case ID_CMD_MAPS_SHOW: return( LNG("[CMD] Show Map") );
+ case ID_CMD_MAPS_LAYER_SHOW: return( LNG("[CMD] Show Layer") );
+ case ID_CMD_MAPS_MOVE_TOP: return( LNG("[CMD] Move To Top") );
+ case ID_CMD_MAPS_MOVE_BOTTOM: return( LNG("[CMD] Move To Bottom") );
+ case ID_CMD_MAPS_MOVE_UP: return( LNG("[CMD] Move Up") );
+ case ID_CMD_MAPS_MOVE_DOWN: return( LNG("[CMD] Move Down") );
+ case ID_CMD_MAPS_GRID_FITCOLORS: return( LNG("[CMD] Fit Grid Colors To Map Extent") );
+
+ //-----------------------------------------------------
+ // Views...
+
+ case ID_CMD_MAP_MODE_ZOOM: return( LNG("[CMD] Zoom") );
+ case ID_CMD_MAP_MODE_PAN: return( LNG("[CMD] Pan") );
+ case ID_CMD_MAP_MODE_SELECT: return( LNG("[CMD] Action") );
+ case ID_CMD_MAP_MODE_DISTANCE: return( LNG("[CMD] Measure Distance") );
+ case ID_CMD_MAP_CLOSE: return( LNG("[CMD] Close") );
+ case ID_CMD_MAP_TOOLBAR: return( LNG("[CMD] Show Toolbar") );
+ case ID_CMD_MAP_LEGEND_VERTICAL: return( LNG("[CMD] Show Vertical Legend") );
+ case ID_CMD_MAP_LEGEND_HORIZONTAL: return( LNG("[CMD] Show Horizontal Legend") );
+ case ID_CMD_MAP_ZOOM_BACK: return( LNG("[CMD] Zoom To Previous Extent") );
+ case ID_CMD_MAP_ZOOM_FORWARD: return( LNG("[CMD] Zoom To Next Extent") );
+ case ID_CMD_MAP_ZOOM_FULL: return( LNG("[CMD] Zoom To Full Extent") );
+ case ID_CMD_MAP_ZOOM_ACTIVE: return( LNG("[CMD] Zoom To Active Layer") );
+ case ID_CMD_MAP_ZOOM_SELECTION: return( LNG("[CMD] Zoom To Selection") );
+ case ID_CMD_MAP_ZOOM_EXTENT: return( LNG("[CMD] Zoom To Extent") );
+
+ case ID_CMD_MAP3D_PARAMETERS: return( LNG("[CMD] Properties") );
+ case ID_CMD_MAP3D_ROTATE_X_LESS: return( LNG("[CMD] Up") );
+ case ID_CMD_MAP3D_ROTATE_X_MORE: return( LNG("[CMD] Down") );
+ case ID_CMD_MAP3D_ROTATE_Y_LESS: return( LNG("[CMD] Left [F3]") );
+ case ID_CMD_MAP3D_ROTATE_Y_MORE: return( LNG("[CMD] Right [F4]") );
+ case ID_CMD_MAP3D_ROTATE_Z_LESS: return( LNG("[CMD] Left") );
+ case ID_CMD_MAP3D_ROTATE_Z_MORE: return( LNG("[CMD] Right") );
+ case ID_CMD_MAP3D_SHIFT_X_LESS: return( LNG("[CMD] Left") );
+ case ID_CMD_MAP3D_SHIFT_X_MORE: return( LNG("[CMD] Right") );
+ case ID_CMD_MAP3D_SHIFT_Y_LESS: return( LNG("[CMD] Down") );
+ case ID_CMD_MAP3D_SHIFT_Y_MORE: return( LNG("[CMD] Up") );
+ case ID_CMD_MAP3D_SHIFT_Z_LESS: return( LNG("[CMD] Forward") );
+ case ID_CMD_MAP3D_SHIFT_Z_MORE: return( LNG("[CMD] Backward") );
+ case ID_CMD_MAP3D_EXAGGERATE_LESS: return( LNG("[CMD] Decrease Exaggeration [F1]") );
+ case ID_CMD_MAP3D_EXAGGERATE_MORE: return( LNG("[CMD] Increase Exaggeration [F2]") );
+ case ID_CMD_MAP3D_CENTRAL_LESS: return( LNG("[CMD] Decrease Perspectivic Distance [F5]") );
+ case ID_CMD_MAP3D_CENTRAL_MORE: return( LNG("[CMD] Increase Perspectivic Distance [F6]") );
+ case ID_CMD_MAP3D_CENTRAL: return( LNG("[CMD] Central Projection") );
+ case ID_CMD_MAP3D_STEREO_LESS: return( LNG("[CMD] Decrease Eye Distance") );
+ case ID_CMD_MAP3D_STEREO_MORE: return( LNG("[CMD] Increase Eye Distance") );
+ case ID_CMD_MAP3D_STEREO: return( LNG("[CMD] Anaglyph [S]") );
+ case ID_CMD_MAP3D_INTERPOLATED: return( LNG("[CMD] Interpolated Colors") );
+ case ID_CMD_MAP3D_SAVE: return( LNG("[CMD] Save As Image...") );
+ case ID_CMD_MAP3D_SEQ_POS_ADD: return( LNG("[CMD] Add Position [A]") );
+ case ID_CMD_MAP3D_SEQ_POS_DEL: return( LNG("[CMD] Delete Last Position [D]") );
+ case ID_CMD_MAP3D_SEQ_POS_DEL_ALL: return( LNG("[CMD] Delete All Positions") );
+ case ID_CMD_MAP3D_SEQ_POS_EDIT: return( LNG("[CMD] Edit Positions") );
+ case ID_CMD_MAP3D_SEQ_PLAY: return( LNG("[CMD] Play Once [P]") );
+ case ID_CMD_MAP3D_SEQ_PLAY_LOOP: return( LNG("[CMD] Play Loop [L]") );
+ case ID_CMD_MAP3D_SEQ_SAVE: return( LNG("[CMD] Play And Save As Images...") );
+
+ case ID_CMD_LAYOUT_PRINT_SETUP: return( LNG("[CMD] Print Setup") );
+ case ID_CMD_LAYOUT_PAGE_SETUP: return( LNG("[CMD] Page Setup") );
+ case ID_CMD_LAYOUT_PRINT: return( LNG("[CMD] Print") );
+ case ID_CMD_LAYOUT_PRINT_PREVIEW: return( LNG("[CMD] Print Preview") );
+ case ID_CMD_LAYOUT_FIT_SCALE: return( LNG("[CMD] Fit Scale...") );
+
+ case ID_CMD_TABLE_FIELD_ADD: return( LNG("[CMD] Add Field") );
+ case ID_CMD_TABLE_FIELD_DEL: return( LNG("[CMD] Delete Fields") );
+ case ID_CMD_TABLE_FIELD_SORT: return( LNG("[CMD] Sort Fields") );
+ case ID_CMD_TABLE_FIELD_RENAME: return( LNG("[CMD] Rename Fields") );
+ case ID_CMD_TABLE_RECORD_ADD: return( LNG("[CMD] Add Record") );
+ case ID_CMD_TABLE_RECORD_INS: return( LNG("[CMD] Insert Record") );
+ case ID_CMD_TABLE_RECORD_DEL: return( LNG("[CMD] Delete Selected Record(s)") );
+ case ID_CMD_TABLE_RECORD_DEL_ALL: return( LNG("[CMD] Delete All Records") );
+ case ID_CMD_TABLE_SELECTION_TO_TOP: return( LNG("[CMD] Sort Selection to Top") );
+ case ID_CMD_TABLE_AUTOSIZE_COLS: return( LNG("[CMD] Fit Column Sizes") );
+ case ID_CMD_TABLE_AUTOSIZE_ROWS: return( LNG("[CMD] Fit Row Sizes") );
+
+ case ID_CMD_DIAGRAM_PARAMETERS: return( LNG("[CMD] Properties") );
+ case ID_CMD_DIAGRAM_SIZE_FIT: return( LNG("[CMD] Fit Diagram to Window") );
+ case ID_CMD_DIAGRAM_SIZE_INC: return( LNG("[CMD] Increase Diagram Size") );
+ case ID_CMD_DIAGRAM_SIZE_DEC: return( LNG("[CMD] Decrease Diagram Size") );
+
+ case ID_CMD_SCATTERPLOT_PARAMETERS: return( LNG("[CMD] Properties") );
+ case ID_CMD_SCATTERPLOT_UPDATE: return( LNG("[CMD] Update Data") );
+
+ case ID_CMD_HISTOGRAM_CUMULATIVE: return( LNG("[CMD] Cumulative") );
+ case ID_CMD_HISTOGRAM_AS_TABLE: return( LNG("[CMD] Convert To Table") );
+ }
+
+ //-----------------------------------------------------
+ return( LNG("[CMD] UNRECOGNISED COMMAND ID") );
+}
+
+//---------------------------------------------------------
+const wxChar * CMD_Get_Help(int Cmd_ID)
+{
+ switch( Cmd_ID )
+ {
+ case ID_CMD_FRAME_QUIT: return( LNG("[CMD] Exit SAGA") );
+ case ID_CMD_FRAME_ABOUT: return( LNG("[CMD] About SAGA") );
+ }
+
+ return( CMD_Get_Name(Cmd_ID) );
+}
+
+//---------------------------------------------------------
+int CMD_Get_ImageID(int Cmd_ID)
+{
+ switch( Cmd_ID )
+ {
+ case ID_CMD_FRAME_WKSP_SHOW: return( ID_IMG_TB_WKSP );
+ case ID_CMD_FRAME_INFO_SHOW: return( ID_IMG_TB_INFO );
+ case ID_CMD_FRAME_ACTIVE_SHOW: return( ID_IMG_TB_ACTIVE );
+ case ID_CMD_FRAME_HELP: return( ID_IMG_TB_HELP );
+ case ID_CMD_WKSP_OPEN: return( ID_IMG_TB_OPEN );
+ case ID_CMD_MODULES_OPEN: return( ID_IMG_TB_OPEN_MODULE );
+ case ID_CMD_TABLES_OPEN: return( ID_IMG_TB_OPEN_TABLE );
+ case ID_CMD_SHAPES_OPEN: return( ID_IMG_TB_OPEN_SHAPES );
+ case ID_CMD_GRIDS_OPEN: return( ID_IMG_TB_OPEN_GRID );
+ case ID_CMD_TIN_OPEN: return( ID_IMG_TB_OPEN_TIN );
+ case ID_CMD_POINTCLOUD_OPEN: return( ID_IMG_TB_OPEN_POINTCLOUD );
+
+ case ID_CMD_MAP_MODE_DISTANCE: return( ID_IMG_TB_MAP_MODE_DISTANCE );
+ case ID_CMD_MAP_MODE_SELECT: return( ID_IMG_TB_MAP_MODE_SELECT );
+ case ID_CMD_MAP_MODE_ZOOM: return( ID_IMG_TB_MAP_MODE_ZOOM );
+ case ID_CMD_MAP_MODE_PAN: return( ID_IMG_TB_MAP_MODE_PAN );
+ case ID_CMD_MAP_ZOOM_FULL: return( ID_IMG_TB_MAP_ZOOM_FULL );
+ case ID_CMD_MAP_ZOOM_BACK: return( ID_IMG_TB_MAP_ZOOM_LAST );
+ case ID_CMD_MAP_ZOOM_FORWARD: return( ID_IMG_TB_MAP_ZOOM_NEXT );
+ case ID_CMD_MAP_ZOOM_ACTIVE: return( ID_IMG_TB_MAP_ZOOM_ACTIVE );
+ case ID_CMD_MAP_ZOOM_SELECTION: return( ID_IMG_TB_MAP_ZOOM_SELECTION );
+ case ID_CMD_MAP_ZOOM_EXTENT: return( ID_IMG_TB_MAP_ZOOM_SELECTION );
+ case ID_CMD_MAP_3D_SHOW: return( ID_IMG_TB_MAP_3D_SHOW );
+ case ID_CMD_MAPS_3D_SHOW: return( ID_IMG_TB_MAP_3D_SHOW );
+ case ID_CMD_MAP_LAYOUT_SHOW: return( ID_IMG_TB_MAP_LAYOUT_SHOW );
+ case ID_CMD_MAPS_LAYOUT_SHOW: return( ID_IMG_TB_MAP_LAYOUT_SHOW );
+ case ID_CMD_MAPS_SAVE_TO_CLIPBOARD:
+ case ID_CMD_MAPS_SAVE_TO_CLIPBOARD_LEGEND:
+ case ID_CMD_MAPS_SAVE_IMAGE:
+ case ID_CMD_MAPS_SYNCHRONIZE: return( ID_IMG_TB_MAP_SYNCHRONIZE );
+ case ID_CMD_MAP_LEGEND_VERTICAL: return( ID_IMG_TB_MAP_LEGEND_VERTICAL );
+ case ID_CMD_MAP_LEGEND_HORIZONTAL: return( ID_IMG_TB_MAP_LEGEND_HORIZONTAL );
+
+ case ID_CMD_MAP3D_PARAMETERS: return( ID_IMG_TB_MAP3D_PROPERTIES );
+ case ID_CMD_MAP3D_CENTRAL_LESS: return( ID_IMG_TB_MAP3D_CENTRAL_LESS );
+ case ID_CMD_MAP3D_CENTRAL_MORE: return( ID_IMG_TB_MAP3D_CENTRAL_MORE );
+ case ID_CMD_MAP3D_EXAGGERATE_LESS: return( ID_IMG_TB_MAP3D_EXAGGERATE_LESS );
+ case ID_CMD_MAP3D_EXAGGERATE_MORE: return( ID_IMG_TB_MAP3D_EXAGGERATE_MORE );
+ case ID_CMD_MAP3D_INTERPOLATED: return( ID_IMG_TB_MAP3D_INTERPOLATED );
+ case ID_CMD_MAP3D_ROTATE_X_LESS: return( ID_IMG_TB_MAP3D_ROTATE_X_LESS );
+ case ID_CMD_MAP3D_ROTATE_X_MORE: return( ID_IMG_TB_MAP3D_ROTATE_X_MORE );
+ case ID_CMD_MAP3D_ROTATE_Z_LESS: return( ID_IMG_TB_MAP3D_ROTATE_Z_LESS );
+ case ID_CMD_MAP3D_ROTATE_Z_MORE: return( ID_IMG_TB_MAP3D_ROTATE_Z_MORE );
+ case ID_CMD_MAP3D_SHIFT_X_LESS: return( ID_IMG_TB_MAP3D_SHIFT_X_LESS );
+ case ID_CMD_MAP3D_SHIFT_X_MORE: return( ID_IMG_TB_MAP3D_SHIFT_X_MORE );
+ case ID_CMD_MAP3D_SHIFT_Y_LESS: return( ID_IMG_TB_MAP3D_SHIFT_Y_LESS );
+ case ID_CMD_MAP3D_SHIFT_Y_MORE: return( ID_IMG_TB_MAP3D_SHIFT_Y_MORE );
+ case ID_CMD_MAP3D_SHIFT_Z_LESS: return( ID_IMG_TB_MAP3D_SHIFT_Z_LESS );
+ case ID_CMD_MAP3D_SHIFT_Z_MORE: return( ID_IMG_TB_MAP3D_SHIFT_Z_MORE );
+ case ID_CMD_MAP3D_STEREO: return( ID_IMG_TB_MAP3D_STEREO );
+
+ case ID_CMD_LAYOUT_PRINT_SETUP: return( ID_IMG_TB_LAYOUT_PRINT_SETUP );
+ case ID_CMD_LAYOUT_PAGE_SETUP: return( ID_IMG_TB_LAYOUT_PAGE_SETUP );
+ case ID_CMD_LAYOUT_PRINT: return( ID_IMG_TB_LAYOUT_PRINT );
+ case ID_CMD_LAYOUT_PRINT_PREVIEW: return( ID_IMG_TB_LAYOUT_PRINT_PREVIEW );
+
+ case ID_CMD_HISTOGRAM_CUMULATIVE: return( ID_IMG_TB_HISTOGRAM_CUMULATIVE );
+ case ID_CMD_HISTOGRAM_AS_TABLE: return( ID_IMG_TB_HISTOGRAM_AS_TABLE );
+
+ case ID_CMD_TABLE_FIELD_ADD: return( ID_IMG_TB_TABLE_COL_ADD );
+ case ID_CMD_TABLE_FIELD_DEL: return( ID_IMG_TB_TABLE_COL_DEL );
+ case ID_CMD_TABLE_RECORD_ADD: return( ID_IMG_TB_TABLE_ROW_ADD );
+ case ID_CMD_TABLE_RECORD_INS: return( ID_IMG_TB_TABLE_ROW_INS );
+ case ID_CMD_TABLE_RECORD_DEL: return( ID_IMG_TB_TABLE_ROW_DEL );
+ case ID_CMD_TABLE_RECORD_DEL_ALL: return( ID_IMG_TB_TABLE_ROW_DEL_ALL );
+
+ case ID_CMD_SCATTERPLOT_PARAMETERS: return( ID_IMG_TB_SCATTERPLOT_PARAMETERS );
+ case ID_CMD_SCATTERPLOT_UPDATE: return( ID_IMG_DEFAULT );
+
+ case ID_CMD_DIAGRAM_PARAMETERS: return( ID_IMG_TB_DIAGRAM_PARAMETERS );
+ case ID_CMD_DIAGRAM_SIZE_FIT: break;
+ case ID_CMD_DIAGRAM_SIZE_INC: return( ID_IMG_TB_MAP3D_CENTRAL_MORE );
+ case ID_CMD_DIAGRAM_SIZE_DEC: return( ID_IMG_TB_MAP3D_CENTRAL_LESS );
+ }
+
+ return( ID_IMG_DEFAULT );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CMD_Menu_Add_Item(wxMenu *pMenu, bool bCheck, int Cmd_ID)
+{
+ if( bCheck )
+ {
+ pMenu->AppendCheckItem(Cmd_ID, CMD_Get_Name(Cmd_ID), CMD_Get_Help(Cmd_ID));
+ }
+ else
+ {
+ pMenu->Append (Cmd_ID, CMD_Get_Name(Cmd_ID), CMD_Get_Help(Cmd_ID));
+ }
+}
+
+//---------------------------------------------------------
+void CMD_Menu_Ins_Item(wxMenu *pMenu, bool bCheck, int Cmd_ID, int Position)
+{
+ if( bCheck )
+ {
+ pMenu->InsertCheckItem(Position, Cmd_ID, CMD_Get_Name(Cmd_ID), CMD_Get_Help(Cmd_ID));
+ }
+ else
+ {
+ pMenu->Insert (Position, Cmd_ID, CMD_Get_Name(Cmd_ID), CMD_Get_Help(Cmd_ID));
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+wxToolBarBase * CMD_ToolBar_Create(int ID)
+{
+ return( g_pSAGA_Frame ? g_pSAGA_Frame->TB_Create(ID) : NULL );
+}
+
+//---------------------------------------------------------
+void CMD_ToolBar_Add(wxToolBarBase *pToolBar, const wxChar *Name)
+{
+ if( g_pSAGA_Frame )
+ {
+ g_pSAGA_Frame->TB_Add(pToolBar, Name);
+ }
+}
+
+//---------------------------------------------------------
+void CMD_ToolBar_Add_Item(wxToolBarBase *pToolBar, bool bCheck, int Cmd_ID)
+{
+ if( g_pSAGA_Frame )
+ {
+ g_pSAGA_Frame->TB_Add_Item(pToolBar, bCheck, Cmd_ID);
+ }
+}
+
+//---------------------------------------------------------
+void CMD_ToolBar_Add_Separator(wxToolBarBase *pToolBar)
+{
+ if( g_pSAGA_Frame )
+ {
+ g_pSAGA_Frame->TB_Add_Separator(pToolBar);
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_gui/res_commands.h b/src/saga_core/saga_gui/res_commands.h
index c596d34..845752b 100644
--- a/src/saga_core/saga_gui/res_commands.h
+++ b/src/saga_core/saga_gui/res_commands.h
@@ -114,6 +114,7 @@ enum ID_COMMANDS
ID_CMD_WKSP_ITEM_CLOSE,
ID_CMD_WKSP_ITEM_SETTINGS_LOAD,
ID_CMD_WKSP_ITEM_SETTINGS_COPY,
+ ID_CMD_WKSP_ITEM_SEARCH,
ID_CMD_WKSP_ITEM_SHOW,
ID_CMD_INFO_CLEAR,
@@ -299,6 +300,7 @@ enum ID_COMMANDS
ID_CMD_TABLE_RECORD_INS,
ID_CMD_TABLE_RECORD_DEL,
ID_CMD_TABLE_RECORD_DEL_ALL,
+ ID_CMD_TABLE_SELECTION_TO_TOP,
ID_CMD_TABLE_AUTOSIZE_COLS,
ID_CMD_TABLE_AUTOSIZE_ROWS,
ID_CMD_TABLE_LAST,
diff --git a/src/saga_core/saga_gui/res_dialogs.cpp b/src/saga_core/saga_gui/res_dialogs.cpp
index e8555d2..8a71e80 100644
--- a/src/saga_core/saga_gui/res_dialogs.cpp
+++ b/src/saga_core/saga_gui/res_dialogs.cpp
@@ -1,924 +1,930 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// User Interface //
-// //
-// Program: SAGA //
-// //
-//-------------------------------------------------------//
-// //
-// RES_Dialogs.cpp //
-// //
-// Copyright (C) 2005 by Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include <wx/utils.h>
-#include <wx/msgdlg.h>
-#include <wx/dirdlg.h>
-#include <wx/filedlg.h>
-#include <wx/fontdlg.h>
-#include <wx/textdlg.h>
-#include <wx/colordlg.h>
-#include <wx/choicdlg.h>
-
-#include <saga_api/saga_api.h>
-
-#include "res_dialogs.h"
-
-#include "helper.h"
-
-#include "dlg_parameters.h"
-#include "dlg_text.h"
-#include "dlg_table.h"
-#include "dlg_list_grid.h"
-#include "dlg_list_table.h"
-#include "dlg_list_shapes.h"
-#include "dlg_list_tin.h"
-#include "dlg_list_pointcloud.h"
-#include "dlg_colors.h"
-
-#include "wksp_map_manager.h"
-#include "wksp_map.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#define CONFIG_GROUP_FILE_DLG wxT("/FileDialogs")
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-const wxChar * DLG_Get_Text(int ID_DLG)
-{
- switch( ID_DLG )
- {
- case ID_DLG_ABOUT: return( LNG("[TXT] SAGA\nSystem for Automated Geoscientific Analyses\nVersion 2.0") );
- case ID_DLG_CLOSE: return( LNG("[TXT] Do you want to exit SAGA?") );
- case ID_DLG_DELETE: return( LNG("[TXT] Do you want to delete the selection?") );
- }
-
- return( LNG("[TXT] This is not a text!") );
-}
-
-//---------------------------------------------------------
-const wxChar * DLG_Get_Caption(int ID_DLG)
-{
- switch( ID_DLG )
- {
- case ID_DLG_CLOSE: return( LNG("[CAP] Exit") );
- case ID_DLG_ABOUT: return( LNG("[CAP] About SAGA") );
- case ID_DLG_DELETE: return( LNG("[CAP] Delete") );
- }
-
- return( LNG("[CAP] This Is Not A Caption!") );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-const wxChar * DLG_Get_FILE_Caption(int ID_DLG)
-{
- switch( ID_DLG )
- {
- case ID_DLG_WKSP_OPEN: return( LNG("[CAP] Load") );
-
- case ID_DLG_MODULES_OPEN: return( LNG("[CAP] Load Module Library") );
-
- case ID_DLG_PROJECT_OPEN: return( LNG("[CAP] Load Project") );
- case ID_DLG_PROJECT_SAVE: return( LNG("[CAP] Save Project") );
-
- case ID_DLG_GRIDS_OPEN: return( LNG("[CAP] Load Grid") );
- case ID_DLG_GRIDS_SAVE: return( LNG("[CAP] Save Grid") );
-
- case ID_DLG_SHAPES_OPEN: return( LNG("[CAP] Load Shapes") );
- case ID_DLG_SHAPES_SAVE: return( LNG("[CAP] Save Shapes") );
-
- case ID_DLG_TABLES_OPEN: return( LNG("[CAP] Load Table") );
- case ID_DLG_TABLES_SAVE: return( LNG("[CAP] Save Table") );
-
- case ID_DLG_TIN_OPEN: return( LNG("[CAP] Load TIN") );
- case ID_DLG_TIN_SAVE: return( LNG("[CAP] Save TIN") );
-
- case ID_DLG_POINTCLOUD_OPEN: return( LNG("[CAP] Load Point Cloud") );
- case ID_DLG_POINTCLOUD_SAVE: return( LNG("[CAP] Save Point Cloud") );
-
- case ID_DLG_TEXT_OPEN: return( LNG("[CAP] Load Text") );
- case ID_DLG_TEXT_SAVE: return( LNG("[CAP] Save Text") );
-
- case ID_DLG_PARAMETERS_OPEN: return( LNG("[CAP] Load Settings") );
- case ID_DLG_PARAMETERS_SAVE: return( LNG("[CAP] Save Settings") );
-
- case ID_DLG_COLORS_OPEN: return( LNG("[CAP] Load Colors") );
- case ID_DLG_COLORS_SAVE: return( LNG("[CAP] Save Colors") );
- }
-
- return( LNG("[CAP] Select File") );
-}
-
-//---------------------------------------------------------
-const wxString DLG_Get_FILE_Filter(int ID_DLG)
-{
- switch( ID_DLG )
- {
- case ID_DLG_WKSP_OPEN:
- return( wxString::Format(
- wxT("%s|*.sprj;*.mlb;*.dll;*.so;*sgrd;*.dgm;*.grd;*.shp;*.txt;*.dbf|")
- wxT("%s (*.sprj)|*.sprj|")
- wxT("%s (*.dll, *.so)|*.dll;*.so;*.mlb|")
- wxT("%s (*.sgrd)|*.sgrd;*.dgm;*.grd|")
- wxT("%s (*.shp)|*.shp|")
- wxT("%s (*.txt, *.dbf)|*.txt;*.dbf|")
- wxT("%s (*.spc)|*.spc|")
- wxT("%s|*.*"),
- LNG("All Recognised Files"),
- LNG("SAGA Project"),
- LNG("SAGA Module Libraries"),
- LNG("Grids"),
- LNG("ESRI Shape Files"),
- LNG("Tables"),
- LNG("Point Clouds"),
- LNG("All Files")
- ));
-
- case ID_DLG_MODULES_OPEN:
- return( wxString::Format(
- wxT("%s (*.dll, *.so)|*.mlb;*.dll;*.so|")
- wxT("%s|*.*"),
- LNG("SAGA Module Libraries"),
- LNG("All Files")
- ));
-
- case ID_DLG_PROJECT_OPEN:
- case ID_DLG_PROJECT_SAVE:
- return( wxString::Format(
- wxT("%s (*.sprj)|*.sprj|")
- wxT("%s|*.*"),
- LNG("SAGA Projects"),
- LNG("All Files")
- ));
-
- case ID_DLG_GRIDS_OPEN:
- return( wxString::Format(
- wxT("%s (*.sgrd)|*.sgrd;*.dgm;*.grd|")
- wxT("%s|*.*"),
- LNG("Grids"),
- LNG("All Files")
- ));
-
- case ID_DLG_GRIDS_SAVE:
- return( wxString::Format(
- wxT("%s (*.sgrd)|*.sgrd|")
- wxT("%s|*.*"),
- LNG("Grids"),
- LNG("All Files")
- ));
-
- case ID_DLG_SHAPES_OPEN:
- case ID_DLG_SHAPES_SAVE:
- return( wxString::Format(
- wxT("%s (*.shp)|*.shp|")
- wxT("%s|*.*"),
- LNG("ESRI Shape Files"),
- LNG("All Files")
- ));
-
- case ID_DLG_TABLES_OPEN:
- return( wxString::Format(
- wxT("%s (*.txt, *.dbf)|*.txt;*.dbf|")
- wxT("%s|*.*"),
- LNG("Tables"),
- LNG("All Files")
- ));
-
- case ID_DLG_TABLES_SAVE:
- return( wxString::Format(
- wxT("%s (*.txt)|*.txt|")
- wxT("%s (*.dbf)|*.dbf|")
- wxT("%s|*.*"),
- LNG("Text"),
- LNG("DBase"),
- LNG("All Files")
- ));
-
- case ID_DLG_TIN_OPEN:
- case ID_DLG_TIN_SAVE:
- return( wxString::Format(
- wxT("%s (*.shp)|*.shp|")
- wxT("%s|*.*"),
- LNG("ESRI Shape Files"),
- LNG("All Files")
- ));
-
- case ID_DLG_POINTCLOUD_OPEN:
- case ID_DLG_POINTCLOUD_SAVE:
- return( wxString::Format(
- wxT("%s (*.spc)|*.spc|")
- wxT("%s|*.*"),
- LNG("SAGA Point Clouds"),
- LNG("All Files")
- ));
-
- case ID_DLG_TEXT_OPEN:
- case ID_DLG_TEXT_SAVE:
- return( wxString::Format(
- wxT("%s (*.txt)|*.txt|")
- wxT("%s|*.*"),
- LNG("Text Files"),
- LNG("All Files")
- ));
-
- case ID_DLG_PARAMETERS_OPEN:
- case ID_DLG_PARAMETERS_SAVE:
- return( wxString::Format(
- wxT("%s (*.sprm)|*.sprm|")
- wxT("%s|*.*"),
- LNG("SAGA Parameter Files"),
- LNG("All Files")
- ));
-
- case ID_DLG_COLORS_OPEN:
- case ID_DLG_COLORS_SAVE:
- return( wxString::Format(
- wxT("%s (*.pal)|*.pal|")
- wxT("%s|*.*"),
- LNG("SAGA Colors"),
- LNG("All Files")
- ));
- }
-
- return( wxString::Format(wxT("%s|*.*"), LNG("All Files")) );
-}
-
-//---------------------------------------------------------
-const wxChar * DLG_Get_FILE_Config(int ID_DLG)
-{
- switch( ID_DLG )
- {
- case ID_DLG_WKSP_OPEN: return( wxT("ALL_LOAD") );
-
- case ID_DLG_MODULES_OPEN: return( wxT("MLB_LOAD") );
-
- case ID_DLG_PROJECT_OPEN: return( wxT("PRJ_LOAD") );
- case ID_DLG_PROJECT_SAVE: return( wxT("PRJ_SAVE") );
-
- case ID_DLG_GRIDS_OPEN: return( wxT("GRD_LOAD") );
- case ID_DLG_GRIDS_SAVE: return( wxT("GRD_SAVE") );
-
- case ID_DLG_SHAPES_OPEN: return( wxT("SHP_LOAD") );
- case ID_DLG_SHAPES_SAVE: return( wxT("SHP_SAVE") );
-
- case ID_DLG_TABLES_OPEN: return( wxT("TAB_LOAD") );
- case ID_DLG_TABLES_SAVE: return( wxT("TAB_SAVE") );
-
- case ID_DLG_TIN_OPEN: return( wxT("TIN_LOAD") );
- case ID_DLG_TIN_SAVE: return( wxT("TIN_SAVE") );
-
- case ID_DLG_POINTCLOUD_OPEN: return( wxT("PTS_LOAD") );
- case ID_DLG_POINTCLOUD_SAVE: return( wxT("PTS_SAVE") );
-
- case ID_DLG_TEXT_OPEN: return( wxT("TXT_LOAD") );
- case ID_DLG_TEXT_SAVE: return( wxT("TXT_SAVE") );
-
- case ID_DLG_PARAMETERS_OPEN: return( wxT("PRM_LOAD") );
- case ID_DLG_PARAMETERS_SAVE: return( wxT("PRM_SAVE") );
-
- case ID_DLG_COLORS_OPEN: return( wxT("COL_LOAD") );
- case ID_DLG_COLORS_SAVE: return( wxT("COL_SAVE") );
- }
-
- return( wxT("FILE") );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-wxRect DLG_Get_Def_Rect(void)
-{
- wxRect r(wxGetClientDisplayRect());
-
- r.Deflate((int)(0.15 * r.GetWidth()), (int)(0.15 * r.GetHeight()));
-
- return( r );
-}
-
-//---------------------------------------------------------
-wxPoint DLG_Get_Def_Position(void)
-{
- return( DLG_Get_Def_Rect().GetPosition() );
-}
-
-//---------------------------------------------------------
-wxSize DLG_Get_Def_Size(void)
-{
- return( DLG_Get_Def_Rect().GetSize() );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool DLG_Parameters(CSG_Parameters *pParameters)
-{
- if( pParameters && pParameters->Get_Count() > 0 )
- {
- CDLG_Parameters dlg(pParameters);
-
- return( dlg.ShowModal() == wxID_OK );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool DLG_Text(const wxChar *Caption, wxString &Text)
-{
- CDLG_Text dlg(&Text, Caption);
-
- return( dlg.ShowModal() == wxID_OK );
-}
-
-//---------------------------------------------------------
-bool DLG_Table(const wxChar *Caption, CSG_Table *pTable)
-{
- CDLG_Table dlg(pTable, Caption);
-
- return( dlg.ShowModal() == wxID_OK );
-}
-
-//---------------------------------------------------------
-bool DLG_List(const wxChar *Caption, CSG_Parameter_List *pList)
-{
- CDLG_List_Base *pDialog;
-
- switch( pList->Get_Type() )
- {
- default: pDialog = NULL; break;
- case PARAMETER_TYPE_Grid_List: pDialog = new CDLG_List_Grid ((CSG_Parameter_Grid_List *)pList, Caption); break;
- case PARAMETER_TYPE_Table_List: pDialog = new CDLG_List_Table ((CSG_Parameter_Table_List *)pList, Caption); break;
- case PARAMETER_TYPE_Shapes_List: pDialog = new CDLG_List_Shapes ((CSG_Parameter_Shapes_List *)pList, Caption); break;
- case PARAMETER_TYPE_TIN_List: pDialog = new CDLG_List_TIN ((CSG_Parameter_TIN_List *)pList, Caption); break;
- case PARAMETER_TYPE_PointCloud_List: pDialog = new CDLG_List_PointCloud((CSG_Parameter_PointCloud_List *)pList, Caption); break;
- }
-
- if( pDialog )
- {
- bool bResult = pDialog->ShowModal() == wxID_OK;
-
- delete(pDialog);
-
- return( bResult );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool DLG_Colors(CSG_Colors *pColors)
-{
- CDLG_Colors dlg(pColors);
-
- return( dlg.ShowModal() == wxID_OK );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool DLG_Colors(int &Palette)
-{
- wxString Palettes[SG_COLORS_COUNT];
-
- Palettes[SG_COLORS_DEFAULT] = LNG("default");
- Palettes[SG_COLORS_DEFAULT_BRIGHT] = LNG("default (same brightness)");
- Palettes[SG_COLORS_BLACK_WHITE] = LNG("greyscale");
- Palettes[SG_COLORS_BLACK_RED] = LNG("black > red");
- Palettes[SG_COLORS_BLACK_GREEN] = LNG("black > green");
- Palettes[SG_COLORS_BLACK_BLUE] = LNG("black > blue");
- Palettes[SG_COLORS_WHITE_RED] = LNG("white > red");
- Palettes[SG_COLORS_WHITE_GREEN] = LNG("white > green");
- Palettes[SG_COLORS_WHITE_BLUE] = LNG("white > blue");
- Palettes[SG_COLORS_YELLOW_RED] = LNG("yellow > red");
- Palettes[SG_COLORS_YELLOW_GREEN] = LNG("yellow > green");
- Palettes[SG_COLORS_YELLOW_BLUE] = LNG("yellow > blue");
- Palettes[SG_COLORS_RED_GREEN] = LNG("red > green");
- Palettes[SG_COLORS_RED_BLUE] = LNG("red > blue");
- Palettes[SG_COLORS_GREEN_BLUE] = LNG("green > blue");
- Palettes[SG_COLORS_RED_GREY_BLUE] = LNG("red > grey > blue");
- Palettes[SG_COLORS_RED_GREY_GREEN] = LNG("red > grey > green");
- Palettes[SG_COLORS_GREEN_GREY_BLUE] = LNG("green > grey > blue");
- Palettes[SG_COLORS_RED_GREEN_BLUE] = LNG("red > green > blue");
- Palettes[SG_COLORS_RED_BLUE_GREEN] = LNG("red > blue > green");
- Palettes[SG_COLORS_GREEN_RED_BLUE] = LNG("green > red > blue");
- Palettes[SG_COLORS_RAINBOW] = LNG("Rainbow");
- Palettes[SG_COLORS_NEON] = LNG("Neon");
-
- wxSingleChoiceDialog dlg(
- MDI_Get_Top_Window(),
- wxT(""),
- LNG("[CAP] Preset Selection"),
- SG_COLORS_COUNT, Palettes
- );
-
- if( dlg.ShowModal() == wxID_OK )
- {
- Palette = dlg.GetSelection();
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool DLG_Color(long &_Colour)
-{
- static wxColourData Colours;
-
- Colours.SetChooseFull(true);
-
- wxColour Colour(SG_GET_R(_Colour), SG_GET_G(_Colour), SG_GET_B(_Colour));
- wxColourDialog dlg(MDI_Get_Top_Window(), &Colours);
-
- dlg.GetColourData().SetColour(Colour);
-
- if( dlg.ShowModal() == wxID_OK )
- {
- Colours = dlg.GetColourData();
- Colour = dlg.GetColourData().GetColour();
- _Colour = Get_Color_asInt(Colour);
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool DLG_Font(wxFont *pFont, long &_Colour)
-{
- wxColour Colour(SG_GET_R(_Colour), SG_GET_G(_Colour), SG_GET_B(_Colour));
- wxFontDialog dlg(MDI_Get_Top_Window());
-
- dlg.GetFontData().SetInitialFont(*pFont);
- dlg.GetFontData().SetColour(Colour);
-
- if( dlg.ShowModal() == wxID_OK )
- {
- *pFont = dlg.GetFontData().GetChosenFont();
- Colour = dlg.GetFontData().GetColour();
- _Colour = Get_Color_asInt(Colour);
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool DLG_Get_Number(double &Number, const wxChar *Caption, const wxChar *Text)
-{
- wxTextEntryDialog dlg(MDI_Get_Top_Window(), Text, Caption, wxString::Format(wxT("%f"), Number));
-
- return( dlg.ShowModal() == wxID_OK && dlg.GetValue().ToDouble(&Number) );
-}
-
-bool DLG_Get_Number(double &Number)
-{
- return( DLG_Get_Number(Number, LNG("[CAP] Input"), LNG("[DLG] Please enter a numeric value:")) );
-}
-
-//---------------------------------------------------------
-bool DLG_Get_Number(int &Number, const wxChar *Caption, const wxChar *Text)
-{
- long lValue;
- wxTextEntryDialog dlg(MDI_Get_Top_Window(), Text, Caption, wxString::Format(wxT("%d"), Number));
-
- if( dlg.ShowModal() == wxID_OK && dlg.GetValue().ToLong(&lValue) )
- {
- Number = lValue;
-
- return( true );
- }
-
- return( false );
-}
-
-bool DLG_Get_Number(int &Number)
-{
- return( DLG_Get_Number(Number, LNG("[CAP] Input"), LNG("[DLG] Please enter a numeric value:")) );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool DLG_Directory(wxString &Directory, const wxChar *Caption, const wxChar *def_Dir)
-{
- wxDirDialog dlg(MDI_Get_Top_Window(), Caption, def_Dir);
-
- if( dlg.ShowModal() == wxID_OK )
- {
- Directory = dlg.GetPath();
-
- return( true );
- }
-
- return( false );
-}
-
-bool DLG_Directory(wxString &Directory, const wxChar *Caption)
-{
- return( DLG_Directory(Directory, Caption, SG_File_Get_Path(Directory)) );
-}
-
-//---------------------------------------------------------
-bool DLG_Save(wxString &File_Path, const wxChar *Caption, const wxChar *def_Dir, const wxChar *def_File, const wxChar *Filter)
-{
- wxFileDialog dlg(MDI_Get_Top_Window(), Caption, def_Dir, def_File, Filter, wxSAVE|wxOVERWRITE_PROMPT);
-
- if( dlg.ShowModal() == wxID_OK )
- {
- File_Path = dlg.GetPath();
-
- return( true );
- }
-
- return( false );
-}
-
-bool DLG_Save(wxString &File_Path, int ID_DLG)
-{
- wxString def_Dir;
-
- CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), def_Dir);
-
- if( DLG_Save(File_Path, DLG_Get_FILE_Caption(ID_DLG), def_Dir, wxT(""), DLG_Get_FILE_Filter(ID_DLG)) )
- {
- CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), SG_File_Get_Path(File_Path));
-
- return( true );
- }
-
- return( false );
-}
-
-bool DLG_Save(wxString &File_Path, const wxChar *Caption, const wxChar *Filter)
-{
- return( DLG_Save(File_Path, Caption, SG_File_Get_Path(File_Path), SG_File_Get_Name(File_Path, true), Filter) );
-}
-
-//---------------------------------------------------------
-bool DLG_Open(wxString &File_Path, const wxChar *Caption, const wxChar *def_Dir, const wxChar *def_File, const wxChar *Filter)
-{
- wxFileDialog dlg(MDI_Get_Top_Window(), Caption, def_Dir, def_File, Filter, wxOPEN|wxFILE_MUST_EXIST);
-
- if( dlg.ShowModal() == wxID_OK )
- {
- File_Path = dlg.GetPath();
-
- return( true );
- }
-
- return( false );
-}
-
-bool DLG_Open(wxString &File_Path, int ID_DLG)
-{
- wxString def_Dir;
-
- CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), def_Dir);
-
- if( DLG_Open(File_Path, DLG_Get_FILE_Caption(ID_DLG), def_Dir, wxT(""), DLG_Get_FILE_Filter(ID_DLG)) )
- {
- CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), SG_File_Get_Path(File_Path));
-
- return( true );
- }
-
- return( false );
-}
-
-bool DLG_Open(wxString &File_Path, const wxChar *Caption, const wxChar *Filter)
-{
- return( DLG_Open(File_Path, Caption, SG_File_Get_Path(File_Path), SG_File_Get_Name(File_Path, true), Filter) );
-}
-
-//---------------------------------------------------------
-bool DLG_Open(wxArrayString &File_Paths, const wxChar *Caption, const wxChar *def_Dir, const wxChar *Filter)
-{
- wxFileDialog dlg(MDI_Get_Top_Window(), Caption, def_Dir, wxT(""), Filter, wxOPEN|wxFILE_MUST_EXIST|wxMULTIPLE);
-
- if( dlg.ShowModal() == wxID_OK )
- {
- dlg.GetPaths(File_Paths);
-
- return( File_Paths.GetCount() > 0 );
- }
-
- return( false );
-}
-
-bool DLG_Open(wxArrayString &File_Paths, int ID_DLG)
-{
- wxString def_Dir;
-
- CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), def_Dir);
-
- if( DLG_Open(File_Paths, DLG_Get_FILE_Caption(ID_DLG), def_Dir, DLG_Get_FILE_Filter(ID_DLG)) )
- {
- CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), SG_File_Get_Path(File_Paths[0]));
-
- return( true );
- }
-
- return( false );
-}
-
-bool DLG_Open(wxArrayString &File_Paths, const wxChar *Caption, const wxChar *Filter)
-{
- return( DLG_Open(File_Paths, Caption, wxT(""), Filter) );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool DLG_Image_Save(wxString &File_Path, int &Type, const wxChar *def_Dir, const wxChar *def_File)
-{
- static int Filter_Index = 3;
-
- wxFileDialog dlg(
- MDI_Get_Top_Window(), LNG("[CAP] Save As Image"), def_Dir, def_File, wxString::Format(
- wxT("%s (*.bmp)|*.bmp|")
- wxT("%s (*.jpg)|*.jpg;*.jif;*.jpeg|")
- wxT("%s (*.tif)|*.tif;*.tiff|")
- wxT("%s (*.png)|*.png|")
- wxT("%s (*.gif)|*.gif|")
- wxT("%s (*.pcx)|*.pcx"),
- LNG("Windows or OS/2 Bitmap"),
- LNG("JPEG - JFIF Compliant"),
- LNG("Tagged Image File Format"),
- LNG("Portable Network Graphics"),
- LNG("CompuServe Graphics Interchange"),
- LNG("Zsoft Paintbrush")
- ), wxSAVE|wxOVERWRITE_PROMPT
- );
-
- dlg.SetFilterIndex(Filter_Index);
-
- if( dlg.ShowModal() == wxID_OK )
- {
- File_Path = dlg.GetPath();
- Filter_Index = dlg.GetFilterIndex();
-
- switch( Filter_Index )
- {
- default:
- case 0: Type = wxBITMAP_TYPE_BMP; break;
- case 1: Type = wxBITMAP_TYPE_JPEG; break;
- case 2: Type = wxBITMAP_TYPE_TIF; break;
- case 3: Type = wxBITMAP_TYPE_PNG; break;
- case 4: Type = wxBITMAP_TYPE_GIF; break;
- case 5: Type = wxBITMAP_TYPE_PCX; break;
- case 6: Type = wxBITMAP_TYPE_PNM; break;
- }
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void DLG_Message_Show(const wxChar *Message, const wxChar *Caption)
-{
- wxMessageDialog dlg(MDI_Get_Top_Window(), Message, Caption, wxOK);
-
- dlg.ShowModal();
-}
-
-void DLG_Message_Show(int ID_DLG)
-{
- DLG_Message_Show(DLG_Get_Text(ID_DLG), DLG_Get_Caption(ID_DLG));
-}
-
-void DLG_Message_Show(const wxChar *Message)
-{
- DLG_Message_Show(Message, DLG_Get_Caption(-1));
-}
-
-//---------------------------------------------------------
-int DLG_Message_Show_Error(const wxChar *Message, const wxChar *Caption)
-{
- wxMessageDialog dlg(MDI_Get_Top_Window(), Message, Caption, wxOK|wxCANCEL|wxICON_ERROR);
-
- switch( dlg.ShowModal() )
- {
- case wxID_OK: default:
- return( 1 );
-
- case wxID_CANCEL:
- return( 0 );
- }
-}
-
-int DLG_Message_Show_Error(int ID_DLG)
-{
- return( DLG_Message_Show_Error(DLG_Get_Text(ID_DLG), DLG_Get_Caption(ID_DLG)) );
-}
-
-//---------------------------------------------------------
-bool DLG_Message_Confirm(const wxChar *Message, const wxChar *Caption)
-{
- wxMessageDialog dlg(MDI_Get_Top_Window(), Message, Caption, wxYES_NO|wxICON_QUESTION);
-
- return( dlg.ShowModal() == wxID_YES );
-}
-
-bool DLG_Message_Confirm(int ID_DLG)
-{
- return( DLG_Message_Confirm(DLG_Get_Text(ID_DLG), DLG_Get_Caption(ID_DLG)) );
-}
-
-//---------------------------------------------------------
-int DLG_Message_YesNoCancel(const wxChar *Message, const wxChar *Caption)
-{
- wxMessageDialog dlg(MDI_Get_Top_Window(), Message, Caption, wxYES|wxNO|wxCANCEL|wxICON_QUESTION);
-
- switch( dlg.ShowModal() )
- {
- case wxID_YES: default:
- return( 0 );
-
- case wxID_NO:
- return( 1 );
-
- case wxID_CANCEL:
- return( 2 );
- }
-}
-
-int DLG_Message_YesNoCancel(int ID_DLG)
-{
- return( DLG_Message_YesNoCancel(DLG_Get_Text(ID_DLG), DLG_Get_Caption(ID_DLG)) );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-int DLG_Maps_Add(void)
-{
- bool bOk;
- int i;
- wxString *Maps;
-
- if( g_pMaps )
- {
- if( g_pMaps->Get_Count() <= 0 )
- {
- return( 0 );
- }
- else
- {
- Maps = new wxString[g_pMaps->Get_Count() + 1];
-
- for(i=0; i<g_pMaps->Get_Count(); i++)
- {
- Maps[i] = g_pMaps->Get_Map(i)->Get_Name();
- }
-
- Maps[i] = LNG("[VAL] New");
-
- wxSingleChoiceDialog dlg(
- MDI_Get_Top_Window(),
- LNG("[CAP] Map Selection"),
- LNG("[DLG] Add layer to selected map"),
- g_pMaps->Get_Count() + 1,
- Maps
- );
-
- dlg.SetSelection(g_pMaps->Get_Count());
-
- bOk = dlg.ShowModal() == wxID_OK;
-
- delete[](Maps);
-
- if( bOk )
- {
- return( dlg.GetSelection() );
- }
- }
- }
-
- return( -1 );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// User Interface //
+// //
+// Program: SAGA //
+// //
+//-------------------------------------------------------//
+// //
+// RES_Dialogs.cpp //
+// //
+// Copyright (C) 2005 by Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include <wx/utils.h>
+#include <wx/msgdlg.h>
+#include <wx/dirdlg.h>
+#include <wx/filedlg.h>
+#include <wx/fontdlg.h>
+#include <wx/textdlg.h>
+#include <wx/colordlg.h>
+#include <wx/choicdlg.h>
+
+#include <saga_api/saga_api.h>
+
+#include "res_dialogs.h"
+
+#include "helper.h"
+
+#include "dlg_parameters.h"
+#include "dlg_text.h"
+#include "dlg_table.h"
+#include "dlg_list_grid.h"
+#include "dlg_list_table.h"
+#include "dlg_list_shapes.h"
+#include "dlg_list_tin.h"
+#include "dlg_list_pointcloud.h"
+#include "dlg_colors.h"
+
+#include "wksp_map_manager.h"
+#include "wksp_map.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define CONFIG_GROUP_FILE_DLG wxT("/FileDialogs")
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+const wxChar * DLG_Get_Text(int ID_DLG)
+{
+ switch( ID_DLG )
+ {
+ case ID_DLG_ABOUT: return( LNG("[TXT] SAGA\nSystem for Automated Geoscientific Analyses\nVersion 2.0") );
+ case ID_DLG_CLOSE: return( LNG("[TXT] Do you want to exit SAGA?") );
+ case ID_DLG_DELETE: return( LNG("[TXT] Do you want to delete the selection?") );
+ }
+
+ return( LNG("[TXT] This is not a text!") );
+}
+
+//---------------------------------------------------------
+const wxChar * DLG_Get_Caption(int ID_DLG)
+{
+ switch( ID_DLG )
+ {
+ case ID_DLG_CLOSE: return( LNG("[CAP] Exit") );
+ case ID_DLG_ABOUT: return( LNG("[CAP] About SAGA") );
+ case ID_DLG_DELETE: return( LNG("[CAP] Delete") );
+ }
+
+ return( LNG("[CAP] This Is Not A Caption!") );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+const wxChar * DLG_Get_FILE_Caption(int ID_DLG)
+{
+ switch( ID_DLG )
+ {
+ case ID_DLG_WKSP_OPEN: return( LNG("[CAP] Load") );
+
+ case ID_DLG_MODULES_OPEN: return( LNG("[CAP] Load Module Library") );
+
+ case ID_DLG_PROJECT_OPEN: return( LNG("[CAP] Load Project") );
+ case ID_DLG_PROJECT_SAVE: return( LNG("[CAP] Save Project") );
+
+ case ID_DLG_GRIDS_OPEN: return( LNG("[CAP] Load Grid") );
+ case ID_DLG_GRIDS_SAVE: return( LNG("[CAP] Save Grid") );
+
+ case ID_DLG_SHAPES_OPEN: return( LNG("[CAP] Load Shapes") );
+ case ID_DLG_SHAPES_SAVE: return( LNG("[CAP] Save Shapes") );
+
+ case ID_DLG_TABLES_OPEN: return( LNG("[CAP] Load Table") );
+ case ID_DLG_TABLES_SAVE: return( LNG("[CAP] Save Table") );
+
+ case ID_DLG_TIN_OPEN: return( LNG("[CAP] Load TIN") );
+ case ID_DLG_TIN_SAVE: return( LNG("[CAP] Save TIN") );
+
+ case ID_DLG_POINTCLOUD_OPEN: return( LNG("[CAP] Load Point Cloud") );
+ case ID_DLG_POINTCLOUD_SAVE: return( LNG("[CAP] Save Point Cloud") );
+
+ case ID_DLG_TEXT_OPEN: return( LNG("[CAP] Load Text") );
+ case ID_DLG_TEXT_SAVE: return( LNG("[CAP] Save Text") );
+
+ case ID_DLG_PARAMETERS_OPEN: return( LNG("[CAP] Load Settings") );
+ case ID_DLG_PARAMETERS_SAVE: return( LNG("[CAP] Save Settings") );
+
+ case ID_DLG_COLORS_OPEN: return( LNG("[CAP] Load Colors") );
+ case ID_DLG_COLORS_SAVE: return( LNG("[CAP] Save Colors") );
+ }
+
+ return( LNG("[CAP] Select File") );
+}
+
+//---------------------------------------------------------
+const wxString DLG_Get_FILE_Filter(int ID_DLG)
+{
+ switch( ID_DLG )
+ {
+ case ID_DLG_WKSP_OPEN:
+ return( wxString::Format(
+ wxT("%s|*.sprj;*.mlb;*.dll;*.so;*sgrd;*.dgm;*.grd;*.shp;*.spc;*.txt;*.dbf|")
+ wxT("%s (*.sprj)|*.sprj|")
+ wxT("%s (*.dll, *.so)|*.dll;*.so;*.mlb|")
+ wxT("%s (*.sgrd)|*.sgrd;*.dgm;*.grd|")
+ wxT("%s (*.shp)|*.shp|")
+ wxT("%s (*.txt, *.dbf)|*.txt;*.dbf|")
+ wxT("%s (*.spc)|*.spc|")
+ wxT("%s|*.*"),
+ LNG("All Recognised Files"),
+ LNG("SAGA Project"),
+ LNG("SAGA Module Libraries"),
+ LNG("Grids"),
+ LNG("ESRI Shape Files"),
+ LNG("Tables"),
+ LNG("Point Clouds"),
+ LNG("All Files")
+ ));
+
+ case ID_DLG_MODULES_OPEN:
+ return( wxString::Format(
+ wxT("%s (*.dll, *.so)|*.mlb;*.dll;*.so|")
+ wxT("%s|*.*"),
+ LNG("SAGA Module Libraries"),
+ LNG("All Files")
+ ));
+
+ case ID_DLG_PROJECT_OPEN:
+ case ID_DLG_PROJECT_SAVE:
+ return( wxString::Format(
+ wxT("%s (*.sprj)|*.sprj|")
+ wxT("%s|*.*"),
+ LNG("SAGA Projects"),
+ LNG("All Files")
+ ));
+
+ case ID_DLG_GRIDS_OPEN:
+ return( wxString::Format(
+ wxT("%s (*.sgrd)|*.sgrd;*.dgm;*.grd|")
+ wxT("%s|*.*"),
+ LNG("Grids"),
+ LNG("All Files")
+ ));
+
+ case ID_DLG_GRIDS_SAVE:
+ return( wxString::Format(
+ wxT("%s (*.sgrd)|*.sgrd|")
+ wxT("%s|*.*"),
+ LNG("Grids"),
+ LNG("All Files")
+ ));
+
+ case ID_DLG_SHAPES_OPEN:
+ case ID_DLG_SHAPES_SAVE:
+ return( wxString::Format(
+ wxT("%s (*.shp)|*.shp|")
+ wxT("%s|*.*"),
+ LNG("ESRI Shape Files"),
+ LNG("All Files")
+ ));
+
+ case ID_DLG_TABLES_OPEN:
+ return( wxString::Format(
+ wxT("%s (*.txt, *.dbf)|*.txt;*.dbf|")
+ wxT("%s|*.*"),
+ LNG("Tables"),
+ LNG("All Files")
+ ));
+
+ case ID_DLG_TABLES_SAVE:
+ return( wxString::Format(
+ wxT("%s (*.txt)|*.txt|")
+ wxT("%s (*.dbf)|*.dbf|")
+ wxT("%s|*.*"),
+ LNG("Text"),
+ LNG("DBase"),
+ LNG("All Files")
+ ));
+
+ case ID_DLG_TIN_OPEN:
+ case ID_DLG_TIN_SAVE:
+ return( wxString::Format(
+ wxT("%s (*.shp)|*.shp|")
+ wxT("%s|*.*"),
+ LNG("ESRI Shape Files"),
+ LNG("All Files")
+ ));
+
+ case ID_DLG_POINTCLOUD_OPEN:
+ case ID_DLG_POINTCLOUD_SAVE:
+ return( wxString::Format(
+ wxT("%s (*.spc)|*.spc|")
+ wxT("%s|*.*"),
+ LNG("SAGA Point Clouds"),
+ LNG("All Files")
+ ));
+
+ case ID_DLG_TEXT_OPEN:
+ case ID_DLG_TEXT_SAVE:
+ return( wxString::Format(
+ wxT("%s (*.txt)|*.txt|")
+ wxT("%s|*.*"),
+ LNG("Text Files"),
+ LNG("All Files")
+ ));
+
+ case ID_DLG_PARAMETERS_OPEN:
+ case ID_DLG_PARAMETERS_SAVE:
+ return( wxString::Format(
+ wxT("%s (*.sprm)|*.sprm|")
+ wxT("%s|*.*"),
+ LNG("SAGA Parameter Files"),
+ LNG("All Files")
+ ));
+
+ case ID_DLG_COLORS_OPEN:
+ case ID_DLG_COLORS_SAVE:
+ return( wxString::Format(
+ wxT("%s (*.pal)|*.pal|")
+ wxT("%s|*.*"),
+ LNG("SAGA Colors"),
+ LNG("All Files")
+ ));
+ }
+
+ return( wxString::Format(wxT("%s|*.*"), LNG("All Files")) );
+}
+
+//---------------------------------------------------------
+const wxChar * DLG_Get_FILE_Config(int ID_DLG)
+{
+ switch( ID_DLG )
+ {
+ case ID_DLG_WKSP_OPEN: return( wxT("ALL_LOAD") );
+
+ case ID_DLG_MODULES_OPEN: return( wxT("MLB_LOAD") );
+
+ case ID_DLG_PROJECT_OPEN: return( wxT("PRJ_LOAD") );
+ case ID_DLG_PROJECT_SAVE: return( wxT("PRJ_SAVE") );
+
+ case ID_DLG_GRIDS_OPEN: return( wxT("GRD_LOAD") );
+ case ID_DLG_GRIDS_SAVE: return( wxT("GRD_SAVE") );
+
+ case ID_DLG_SHAPES_OPEN: return( wxT("SHP_LOAD") );
+ case ID_DLG_SHAPES_SAVE: return( wxT("SHP_SAVE") );
+
+ case ID_DLG_TABLES_OPEN: return( wxT("TAB_LOAD") );
+ case ID_DLG_TABLES_SAVE: return( wxT("TAB_SAVE") );
+
+ case ID_DLG_TIN_OPEN: return( wxT("TIN_LOAD") );
+ case ID_DLG_TIN_SAVE: return( wxT("TIN_SAVE") );
+
+ case ID_DLG_POINTCLOUD_OPEN: return( wxT("PTS_LOAD") );
+ case ID_DLG_POINTCLOUD_SAVE: return( wxT("PTS_SAVE") );
+
+ case ID_DLG_TEXT_OPEN: return( wxT("TXT_LOAD") );
+ case ID_DLG_TEXT_SAVE: return( wxT("TXT_SAVE") );
+
+ case ID_DLG_PARAMETERS_OPEN: return( wxT("PRM_LOAD") );
+ case ID_DLG_PARAMETERS_SAVE: return( wxT("PRM_SAVE") );
+
+ case ID_DLG_COLORS_OPEN: return( wxT("COL_LOAD") );
+ case ID_DLG_COLORS_SAVE: return( wxT("COL_SAVE") );
+ }
+
+ return( wxT("FILE") );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+wxRect DLG_Get_Def_Rect(void)
+{
+ wxRect r(wxGetClientDisplayRect());
+
+ r.Deflate((int)(0.15 * r.GetWidth()), (int)(0.15 * r.GetHeight()));
+
+ return( r );
+}
+
+//---------------------------------------------------------
+wxPoint DLG_Get_Def_Position(void)
+{
+ return( DLG_Get_Def_Rect().GetPosition() );
+}
+
+//---------------------------------------------------------
+wxSize DLG_Get_Def_Size(void)
+{
+ return( DLG_Get_Def_Rect().GetSize() );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool DLG_Parameters(CSG_Parameters *pParameters)
+{
+ if( pParameters && pParameters->Get_Count() > 0 )
+ {
+ CDLG_Parameters dlg(pParameters);
+
+ return( dlg.ShowModal() == wxID_OK );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool DLG_Text(const wxChar *Caption, wxString &Text)
+{
+ CDLG_Text dlg(&Text, Caption);
+
+ return( dlg.ShowModal() == wxID_OK );
+}
+
+//---------------------------------------------------------
+bool DLG_Table(const wxChar *Caption, CSG_Table *pTable)
+{
+ CDLG_Table dlg(pTable, Caption);
+
+ return( dlg.ShowModal() == wxID_OK );
+}
+
+//---------------------------------------------------------
+bool DLG_List(const wxChar *Caption, CSG_Parameter_List *pList)
+{
+ CDLG_List_Base *pDialog;
+
+ switch( pList->Get_Type() )
+ {
+ default: pDialog = NULL; break;
+ case PARAMETER_TYPE_Grid_List: pDialog = new CDLG_List_Grid ((CSG_Parameter_Grid_List *)pList, Caption); break;
+ case PARAMETER_TYPE_Table_List: pDialog = new CDLG_List_Table ((CSG_Parameter_Table_List *)pList, Caption); break;
+ case PARAMETER_TYPE_Shapes_List: pDialog = new CDLG_List_Shapes ((CSG_Parameter_Shapes_List *)pList, Caption); break;
+ case PARAMETER_TYPE_TIN_List: pDialog = new CDLG_List_TIN ((CSG_Parameter_TIN_List *)pList, Caption); break;
+ case PARAMETER_TYPE_PointCloud_List: pDialog = new CDLG_List_PointCloud((CSG_Parameter_PointCloud_List *)pList, Caption); break;
+ }
+
+ if( pDialog )
+ {
+ bool bResult = pDialog->ShowModal() == wxID_OK;
+
+ delete(pDialog);
+
+ return( bResult );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool DLG_Colors(CSG_Colors *pColors)
+{
+ CDLG_Colors dlg(pColors);
+
+ return( dlg.ShowModal() == wxID_OK );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool DLG_Colors(int &Palette)
+{
+ wxString Palettes[SG_COLORS_COUNT];
+
+ Palettes[SG_COLORS_DEFAULT] = LNG("default");
+ Palettes[SG_COLORS_DEFAULT_BRIGHT] = LNG("default (same brightness)");
+ Palettes[SG_COLORS_BLACK_WHITE] = LNG("greyscale");
+ Palettes[SG_COLORS_BLACK_RED] = LNG("black > red");
+ Palettes[SG_COLORS_BLACK_GREEN] = LNG("black > green");
+ Palettes[SG_COLORS_BLACK_BLUE] = LNG("black > blue");
+ Palettes[SG_COLORS_WHITE_RED] = LNG("white > red");
+ Palettes[SG_COLORS_WHITE_GREEN] = LNG("white > green");
+ Palettes[SG_COLORS_WHITE_BLUE] = LNG("white > blue");
+ Palettes[SG_COLORS_YELLOW_RED] = LNG("yellow > red");
+ Palettes[SG_COLORS_YELLOW_GREEN] = LNG("yellow > green");
+ Palettes[SG_COLORS_YELLOW_BLUE] = LNG("yellow > blue");
+ Palettes[SG_COLORS_RED_GREEN] = LNG("red > green");
+ Palettes[SG_COLORS_RED_BLUE] = LNG("red > blue");
+ Palettes[SG_COLORS_GREEN_BLUE] = LNG("green > blue");
+ Palettes[SG_COLORS_RED_GREY_BLUE] = LNG("red > grey > blue");
+ Palettes[SG_COLORS_RED_GREY_GREEN] = LNG("red > grey > green");
+ Palettes[SG_COLORS_GREEN_GREY_BLUE] = LNG("green > grey > blue");
+ Palettes[SG_COLORS_RED_GREEN_BLUE] = LNG("red > green > blue");
+ Palettes[SG_COLORS_RED_BLUE_GREEN] = LNG("red > blue > green");
+ Palettes[SG_COLORS_GREEN_RED_BLUE] = LNG("green > red > blue");
+ Palettes[SG_COLORS_RAINBOW] = LNG("Rainbow");
+ Palettes[SG_COLORS_NEON] = LNG("Neon");
+
+ wxSingleChoiceDialog dlg(
+ MDI_Get_Top_Window(),
+ wxT(""),
+ LNG("[CAP] Preset Selection"),
+ SG_COLORS_COUNT, Palettes
+ );
+
+ if( dlg.ShowModal() == wxID_OK )
+ {
+ Palette = dlg.GetSelection();
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool DLG_Color(long &_Colour)
+{
+ static wxColourData Colours;
+
+ Colours.SetChooseFull(true);
+
+ wxColour Colour(SG_GET_R(_Colour), SG_GET_G(_Colour), SG_GET_B(_Colour));
+ wxColourDialog dlg(MDI_Get_Top_Window(), &Colours);
+
+ dlg.GetColourData().SetColour(Colour);
+
+ if( dlg.ShowModal() == wxID_OK )
+ {
+ Colours = dlg.GetColourData();
+ Colour = dlg.GetColourData().GetColour();
+ _Colour = Get_Color_asInt(Colour);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool DLG_Font(wxFont *pFont, long &_Colour)
+{
+ wxColour Colour(SG_GET_R(_Colour), SG_GET_G(_Colour), SG_GET_B(_Colour));
+ wxFontDialog dlg(MDI_Get_Top_Window());
+
+ dlg.GetFontData().SetInitialFont(*pFont);
+ dlg.GetFontData().SetColour(Colour);
+
+ if( dlg.ShowModal() == wxID_OK )
+ {
+ *pFont = dlg.GetFontData().GetChosenFont();
+ Colour = dlg.GetFontData().GetColour();
+ _Colour = Get_Color_asInt(Colour);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool DLG_Get_Number(double &Number, const wxChar *Caption, const wxChar *Text)
+{
+ wxTextEntryDialog dlg(MDI_Get_Top_Window(), Text, Caption, wxString::Format(wxT("%f"), Number));
+
+ return( dlg.ShowModal() == wxID_OK && dlg.GetValue().ToDouble(&Number) );
+}
+
+bool DLG_Get_Number(double &Number)
+{
+ return( DLG_Get_Number(Number, LNG("[CAP] Input"), LNG("[DLG] Please enter a numeric value:")) );
+}
+
+//---------------------------------------------------------
+bool DLG_Get_Number(int &Number, const wxChar *Caption, const wxChar *Text)
+{
+ long lValue;
+ wxTextEntryDialog dlg(MDI_Get_Top_Window(), Text, Caption, wxString::Format(wxT("%d"), Number));
+
+ if( dlg.ShowModal() == wxID_OK && dlg.GetValue().ToLong(&lValue) )
+ {
+ Number = lValue;
+
+ return( true );
+ }
+
+ return( false );
+}
+
+bool DLG_Get_Number(int &Number)
+{
+ return( DLG_Get_Number(Number, LNG("[CAP] Input"), LNG("[DLG] Please enter a numeric value:")) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool DLG_Directory(wxString &Directory, const wxChar *Caption, const wxChar *def_Dir)
+{
+ wxDirDialog dlg(MDI_Get_Top_Window(), Caption, def_Dir);
+
+ if( dlg.ShowModal() == wxID_OK )
+ {
+ Directory = dlg.GetPath();
+
+ return( true );
+ }
+
+ return( false );
+}
+
+bool DLG_Directory(wxString &Directory, const wxChar *Caption)
+{
+ return( DLG_Directory(Directory, Caption, SG_File_Get_Path(Directory)) );
+}
+
+//---------------------------------------------------------
+bool DLG_Save(wxString &File_Path, const wxChar *Caption, const wxChar *def_Dir, const wxChar *def_File, const wxChar *Filter)
+{
+ wxFileDialog dlg(MDI_Get_Top_Window(), Caption, def_Dir, def_File, Filter, wxSAVE|wxOVERWRITE_PROMPT);
+
+ if( dlg.ShowModal() == wxID_OK )
+ {
+ File_Path = dlg.GetPath();
+
+ return( true );
+ }
+
+ return( false );
+}
+
+bool DLG_Save(wxString &File_Path, int ID_DLG)
+{
+ wxString def_Dir, def_Name;
+
+ def_Name = SG_File_Get_Name(File_Path, true).c_str();
+ def_Dir = SG_File_Get_Path(File_Path);
+
+ if( !SG_Dir_Exists(def_Dir) )
+ {
+ CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), def_Dir);
+ }
+
+ if( DLG_Save(File_Path, DLG_Get_FILE_Caption(ID_DLG), def_Dir, def_Name, DLG_Get_FILE_Filter(ID_DLG)) )
+ {
+ CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), SG_File_Get_Path(File_Path));
+
+ return( true );
+ }
+
+ return( false );
+}
+
+bool DLG_Save(wxString &File_Path, const wxChar *Caption, const wxChar *Filter)
+{
+ return( DLG_Save(File_Path, Caption, SG_File_Get_Path(File_Path), SG_File_Get_Name(File_Path, true), Filter) );
+}
+
+//---------------------------------------------------------
+bool DLG_Open(wxString &File_Path, const wxChar *Caption, const wxChar *def_Dir, const wxChar *def_File, const wxChar *Filter)
+{
+ wxFileDialog dlg(MDI_Get_Top_Window(), Caption, def_Dir, def_File, Filter, wxOPEN|wxFILE_MUST_EXIST);
+
+ if( dlg.ShowModal() == wxID_OK )
+ {
+ File_Path = dlg.GetPath();
+
+ return( true );
+ }
+
+ return( false );
+}
+
+bool DLG_Open(wxString &File_Path, int ID_DLG)
+{
+ wxString def_Dir;
+
+ CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), def_Dir);
+
+ if( DLG_Open(File_Path, DLG_Get_FILE_Caption(ID_DLG), def_Dir, wxT(""), DLG_Get_FILE_Filter(ID_DLG)) )
+ {
+ CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), SG_File_Get_Path(File_Path));
+
+ return( true );
+ }
+
+ return( false );
+}
+
+bool DLG_Open(wxString &File_Path, const wxChar *Caption, const wxChar *Filter)
+{
+ return( DLG_Open(File_Path, Caption, SG_File_Get_Path(File_Path), SG_File_Get_Name(File_Path, true), Filter) );
+}
+
+//---------------------------------------------------------
+bool DLG_Open(wxArrayString &File_Paths, const wxChar *Caption, const wxChar *def_Dir, const wxChar *Filter)
+{
+ wxFileDialog dlg(MDI_Get_Top_Window(), Caption, def_Dir, wxT(""), Filter, wxOPEN|wxFILE_MUST_EXIST|wxMULTIPLE);
+
+ if( dlg.ShowModal() == wxID_OK )
+ {
+ dlg.GetPaths(File_Paths);
+
+ return( File_Paths.GetCount() > 0 );
+ }
+
+ return( false );
+}
+
+bool DLG_Open(wxArrayString &File_Paths, int ID_DLG)
+{
+ wxString def_Dir;
+
+ CONFIG_Read(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), def_Dir);
+
+ if( DLG_Open(File_Paths, DLG_Get_FILE_Caption(ID_DLG), def_Dir, DLG_Get_FILE_Filter(ID_DLG)) )
+ {
+ CONFIG_Write(CONFIG_GROUP_FILE_DLG, DLG_Get_FILE_Config(ID_DLG), SG_File_Get_Path(File_Paths[0]));
+
+ return( true );
+ }
+
+ return( false );
+}
+
+bool DLG_Open(wxArrayString &File_Paths, const wxChar *Caption, const wxChar *Filter)
+{
+ return( DLG_Open(File_Paths, Caption, wxT(""), Filter) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool DLG_Image_Save(wxString &File_Path, int &Type, const wxChar *def_Dir, const wxChar *def_File)
+{
+ static int Filter_Index = 3;
+
+ wxFileDialog dlg(
+ MDI_Get_Top_Window(), LNG("[CAP] Save As Image"), def_Dir, def_File, wxString::Format(
+ wxT("%s (*.bmp)|*.bmp|")
+ wxT("%s (*.jpg)|*.jpg;*.jif;*.jpeg|")
+ wxT("%s (*.tif)|*.tif;*.tiff|")
+ wxT("%s (*.png)|*.png|")
+ wxT("%s (*.gif)|*.gif|")
+ wxT("%s (*.pcx)|*.pcx"),
+ LNG("Windows or OS/2 Bitmap"),
+ LNG("JPEG - JFIF Compliant"),
+ LNG("Tagged Image File Format"),
+ LNG("Portable Network Graphics"),
+ LNG("CompuServe Graphics Interchange"),
+ LNG("Zsoft Paintbrush")
+ ), wxSAVE|wxOVERWRITE_PROMPT
+ );
+
+ dlg.SetFilterIndex(Filter_Index);
+
+ if( dlg.ShowModal() == wxID_OK )
+ {
+ File_Path = dlg.GetPath();
+ Filter_Index = dlg.GetFilterIndex();
+
+ switch( Filter_Index )
+ {
+ default:
+ case 0: Type = wxBITMAP_TYPE_BMP; break;
+ case 1: Type = wxBITMAP_TYPE_JPEG; break;
+ case 2: Type = wxBITMAP_TYPE_TIF; break;
+ case 3: Type = wxBITMAP_TYPE_PNG; break;
+ case 4: Type = wxBITMAP_TYPE_GIF; break;
+ case 5: Type = wxBITMAP_TYPE_PCX; break;
+ case 6: Type = wxBITMAP_TYPE_PNM; break;
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void DLG_Message_Show(const wxChar *Message, const wxChar *Caption)
+{
+ wxMessageDialog dlg(MDI_Get_Top_Window(), Message, Caption, wxOK);
+
+ dlg.ShowModal();
+}
+
+void DLG_Message_Show(int ID_DLG)
+{
+ DLG_Message_Show(DLG_Get_Text(ID_DLG), DLG_Get_Caption(ID_DLG));
+}
+
+void DLG_Message_Show(const wxChar *Message)
+{
+ DLG_Message_Show(Message, DLG_Get_Caption(-1));
+}
+
+//---------------------------------------------------------
+int DLG_Message_Show_Error(const wxChar *Message, const wxChar *Caption)
+{
+ wxMessageDialog dlg(MDI_Get_Top_Window(), Message, Caption, wxOK|wxCANCEL|wxICON_ERROR);
+
+ switch( dlg.ShowModal() )
+ {
+ case wxID_OK: default:
+ return( 1 );
+
+ case wxID_CANCEL:
+ return( 0 );
+ }
+}
+
+int DLG_Message_Show_Error(int ID_DLG)
+{
+ return( DLG_Message_Show_Error(DLG_Get_Text(ID_DLG), DLG_Get_Caption(ID_DLG)) );
+}
+
+//---------------------------------------------------------
+bool DLG_Message_Confirm(const wxChar *Message, const wxChar *Caption)
+{
+ wxMessageDialog dlg(MDI_Get_Top_Window(), Message, Caption, wxYES_NO|wxICON_QUESTION);
+
+ return( dlg.ShowModal() == wxID_YES );
+}
+
+bool DLG_Message_Confirm(int ID_DLG)
+{
+ return( DLG_Message_Confirm(DLG_Get_Text(ID_DLG), DLG_Get_Caption(ID_DLG)) );
+}
+
+//---------------------------------------------------------
+int DLG_Message_YesNoCancel(const wxChar *Message, const wxChar *Caption)
+{
+ wxMessageDialog dlg(MDI_Get_Top_Window(), Message, Caption, wxYES|wxNO|wxCANCEL|wxICON_QUESTION);
+
+ switch( dlg.ShowModal() )
+ {
+ case wxID_YES: default:
+ return( 0 );
+
+ case wxID_NO:
+ return( 1 );
+
+ case wxID_CANCEL:
+ return( 2 );
+ }
+}
+
+int DLG_Message_YesNoCancel(int ID_DLG)
+{
+ return( DLG_Message_YesNoCancel(DLG_Get_Text(ID_DLG), DLG_Get_Caption(ID_DLG)) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int DLG_Maps_Add(void)
+{
+ bool bOk;
+ int i;
+ wxString *Maps;
+
+ if( g_pMaps )
+ {
+ if( g_pMaps->Get_Count() <= 0 )
+ {
+ return( 0 );
+ }
+ else
+ {
+ Maps = new wxString[g_pMaps->Get_Count() + 1];
+
+ for(i=0; i<g_pMaps->Get_Count(); i++)
+ {
+ Maps[i] = g_pMaps->Get_Map(i)->Get_Name();
+ }
+
+ Maps[i] = LNG("[VAL] New");
+
+ wxSingleChoiceDialog dlg(
+ MDI_Get_Top_Window(),
+ LNG("[CAP] Map Selection"),
+ LNG("[DLG] Add layer to selected map"),
+ g_pMaps->Get_Count() + 1,
+ Maps
+ );
+
+ dlg.SetSelection(g_pMaps->Get_Count());
+
+ bOk = dlg.ShowModal() == wxID_OK;
+
+ delete[](Maps);
+
+ if( bOk )
+ {
+ return( dlg.GetSelection() );
+ }
+ }
+ }
+
+ return( -1 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_gui/saga.cpp b/src/saga_core/saga_gui/saga.cpp
index 708e170..2782254 100644
--- a/src/saga_core/saga_gui/saga.cpp
+++ b/src/saga_core/saga_gui/saga.cpp
@@ -63,6 +63,7 @@
#include <wx/image.h>
#include <wx/splash.h>
#include <wx/filename.h>
+#include <wx/stdpaths.h>
#include <saga_api/saga_api.h>
@@ -101,8 +102,8 @@ END_EVENT_TABLE()
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-#define SAGA_GUI_VERSION wxT("2.0.4")
-#define SAGA_GUI_BUILD wxT("20090929")
+#define SAGA_GUI_VERSION wxT("2.0.5")
+#define SAGA_GUI_BUILD wxT("20100719")
//---------------------------------------------------------
const wxChar * SAGA_GUI_Get_Version(void)
@@ -142,16 +143,22 @@ CSAGA::~CSAGA(void)
bool CSAGA::OnInit(void)
{
//-----------------------------------------------------
+ g_pSAGA = this;
+
SetVendorName (wxT("SAGA-GIS.org"));
SetAppName (wxT("SAGA"));
- g_pSAGA = this;
+ wxInitAllImageHandlers();
- m_Process_bContinue = true;
+ m_App_Path = wxFileName(argv[0]).GetPath();
_Init_Config();
- wxInitAllImageHandlers();
+ //-----------------------------------------------------
+ long lValue;
+
+ m_Process_bContinue = true;
+ m_Process_Frequency = CONFIG_Read(wxT("/MODULES"), wxT("PROC_FREQ"), lValue) ? lValue : 0;
//-----------------------------------------------------
long iLogo;
@@ -178,6 +185,20 @@ bool CSAGA::OnInit(void)
wxYield();
//-----------------------------------------------------
+#if defined(_SAGA_MSW)
+ wxString Path;
+
+ if( wxGetEnv(wxT("PATH"), &Path) && Path.Length() > 0 )
+ {
+ wxSetEnv(wxT("PATH"), wxString::Format(wxT("%s;%s\\dll"), Path.c_str(), Get_App_Path().c_str()));
+ }
+ else
+ {
+ wxSetEnv(wxT("PATH"), wxString::Format(wxT("%s\\dll"), Get_App_Path().c_str()));
+ }
+#endif // defined(_SAGA_MSW)
+
+ //-----------------------------------------------------
SG_Get_Translator() .Create(SG_File_Make_Path(Get_App_Path(), wxT("saga"), wxT("lng")), false);
SG_Get_Projections().Create(SG_File_Make_Path(Get_App_Path(), wxT("saga"), wxT("srs")));
@@ -232,7 +253,8 @@ void CSAGA::_Init_Config(void)
if( ( fConfig.FileExists() && (!fConfig.IsFileReadable() || !fConfig.IsFileWritable()))
|| (!fConfig.FileExists() && (!fConfig.IsDirReadable () || !fConfig.IsDirWritable ())) )
{
- fConfig.Assign(wxFileName::GetTempDir(), wxT("saga_gui"), wxT("ini"));
+ fConfig.Assign(wxGetHomeDir(), wxT("saga_gui"), wxT("ini"));
+ //fConfig.Assign(wxFileName::GetTempDir(), wxT("saga_gui"), wxT("ini"));
}
pConfig = new wxFileConfig(wxEmptyString, wxEmptyString, fConfig.GetFullPath(), fConfig.GetFullPath(), wxCONFIG_USE_LOCAL_FILE|wxCONFIG_USE_GLOBAL_FILE|wxCONFIG_USE_RELATIVE_PATH);
@@ -270,19 +292,6 @@ void CSAGA::_Init_Config(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-wxString CSAGA::Get_App_Path(void)
-{
- return( SG_File_Get_Path(argv[0]).c_str() );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
void CSAGA::On_Key_Down(wxKeyEvent &event)
{
switch( event.GetKeyCode() )
@@ -298,11 +307,25 @@ void CSAGA::On_Key_Down(wxKeyEvent &event)
}
//---------------------------------------------------------
-bool CSAGA::Process_Wait(void)
+bool CSAGA::Process_Wait(bool bEnforce)
{
- while( Pending() )
+ static bool bYield = false;
+ static wxDateTime tYield = wxDateTime::UNow();
+
+ if( !bYield && (bEnforce || m_Process_Frequency <= 0 || (wxDateTime::Now() - tYield).GetMilliseconds() > m_Process_Frequency) )
{
- Dispatch();
+ bYield = true;
+
+ // Yield();
+ // wxSafeYield(g_pSAGA_Frame);
+
+ while( Pending() )
+ {
+ Dispatch();
+ }
+
+ bYield = false;
+ tYield = wxDateTime::UNow();
}
return( true );
@@ -319,18 +342,7 @@ bool CSAGA::Process_Set_Okay(bool bOkay)
//---------------------------------------------------------
bool CSAGA::Process_Get_Okay(void)
{
- static bool bYield = false;
-
- if( !bYield )
- {
- bYield = true;
-
- // Yield();
- // wxSafeYield(g_pSAGA_Frame);
- Process_Wait();
-
- bYield = false;
- }
+ Process_Wait();
return( m_Process_bContinue );
}
diff --git a/src/saga_core/saga_gui/saga.h b/src/saga_core/saga_gui/saga.h
index 343dd4f..b7a9998 100644
--- a/src/saga_core/saga_gui/saga.h
+++ b/src/saga_core/saga_gui/saga.h
@@ -96,24 +96,32 @@ public:
CSAGA(void);
virtual ~CSAGA(void);
- bool OnInit (void);
- int OnExit (void);
+ bool OnInit (void);
+ int OnExit (void);
- wxString Get_App_Path (void);
+ const wxString & Get_App_Path (void) const { return( m_App_Path ); }
- void On_Key_Down (wxKeyEvent &event);
+ bool Process_Wait (bool bEnforce = false);
- bool Process_Wait (void);
- bool Process_Set_Okay (bool bOkay);
- bool Process_Get_Okay (void);
+ bool Process_Set_Okay (bool bOkay);
+ bool Process_Get_Okay (void);
+
+ int Process_Get_Frequency (void) const { return( m_Process_Frequency ); }
+ void Process_Set_Frequency (int Milliseconds) { m_Process_Frequency = Milliseconds; }
private:
bool m_Process_bContinue;
+ int m_Process_Frequency;
+
+ wxString m_App_Path;
+
+
+ void _Init_Config (void);
- void _Init_Config (void);
+ void On_Key_Down (wxKeyEvent &event);
//---------------------------------------------------------
diff --git a/src/saga_core/saga_gui/saga_frame.cpp b/src/saga_core/saga_gui/saga_frame.cpp
index b764711..3079f2d 100644
--- a/src/saga_core/saga_gui/saga_frame.cpp
+++ b/src/saga_core/saga_gui/saga_frame.cpp
@@ -358,6 +358,8 @@ CSAGA_Frame::CSAGA_Frame(void)
{
Refresh(false);
}
+
+ ProgressBar_Set_Position(0);
}
//---------------------------------------------------------
@@ -683,7 +685,13 @@ void CSAGA_Frame::Show_Tips(bool bShow)
{
bool bTip;
long iTip;
- wxFileName fTip(g_pSAGA->Get_App_Path(), wxT("saga_gui"), wxT("tip"));
+
+#ifdef SHARE_PATH
+ wxFileName fTip(wxT(SHARE_PATH), wxT("saga_tip.txt"));
+#else
+ wxFileName fTip(g_pSAGA->Get_App_Path(), wxT("saga_gui"), wxT("tip"));
+#endif
+
wxTipProvider *pTip;
bTip = CONFIG_Read(wxT("/TIPS"), wxT("ATSTART"), bTip) ? bTip : true;
@@ -745,7 +753,10 @@ bool CSAGA_Frame::ProgressBar_Set_Position(int Position)
Position = 100;
}
- m_pProgressBar->SetValue(Position);
+ if( m_pProgressBar->GetValue() != Position )
+ {
+ m_pProgressBar->SetValue(Position);
+ }
return( Process_Get_Okay(false) );
}
diff --git a/src/saga_core/saga_gui/view_histogram.cpp b/src/saga_core/saga_gui/view_histogram.cpp
index 6aecc2d..02b93f8 100644
--- a/src/saga_core/saga_gui/view_histogram.cpp
+++ b/src/saga_core/saga_gui/view_histogram.cpp
@@ -215,9 +215,14 @@ void CVIEW_Histogram_Control::On_Mouse_Motion(wxMouseEvent &event)
//---------------------------------------------------------
void CVIEW_Histogram_Control::On_Mouse_LDown(wxMouseEvent &event)
{
- if( m_pLayer->Get_Classifier()->Get_Mode() == CLASSIFY_METRIC
- || m_pLayer->Get_Classifier()->Get_Mode() == CLASSIFY_SHADE )
+ switch( m_pLayer->Get_Classifier()->Get_Mode() )
{
+ default:
+ break;
+
+ case CLASSIFY_METRIC:
+ case CLASSIFY_SHADE:
+ case CLASSIFY_OVERLAY:
m_bMouse_Down = true;
m_Mouse_Move = m_Mouse_Down = event.GetPosition();
@@ -250,9 +255,14 @@ void CVIEW_Histogram_Control::On_Mouse_LUp(wxMouseEvent &event)
//---------------------------------------------------------
void CVIEW_Histogram_Control::On_Mouse_RDown(wxMouseEvent &event)
{
- if( m_pLayer->Get_Classifier()->Get_Mode() == CLASSIFY_METRIC
- || m_pLayer->Get_Classifier()->Get_Mode() == CLASSIFY_SHADE )
+ switch( m_pLayer->Get_Classifier()->Get_Mode() )
{
+ default:
+ break;
+
+ case CLASSIFY_METRIC:
+ case CLASSIFY_SHADE:
+ case CLASSIFY_OVERLAY:
switch( m_pLayer->Get_Type() )
{
default:
@@ -566,15 +576,21 @@ void CVIEW_Histogram::On_AsTable(wxCommandEvent &event)
pTable->Add_Field(LNG("COUNT") , SG_DATATYPE_Int);
pTable->Add_Field(LNG("AREA") , SG_DATATYPE_Double);
pTable->Add_Field(LNG("NAME") , SG_DATATYPE_String);
+ pTable->Add_Field(LNG("MIN") , SG_DATATYPE_Double);
+ pTable->Add_Field(LNG("CENTER") , SG_DATATYPE_Double);
+ pTable->Add_Field(LNG("MAX") , SG_DATATYPE_Double);
for(i=0; i<n; i++)
{
pRecord = pTable->Add_Record();
pRecord->Set_Value(0, i + 1);
- pRecord->Set_Value(1, m_pLayer->Get_Classifier()->Histogram_Get_Count(i, false));
- pRecord->Set_Value(2, m_pLayer->Get_Classifier()->Histogram_Get_Count(i, false) * dArea);
- pRecord->Set_Value(3, m_pLayer->Get_Classifier()->Get_Class_Name(i).c_str());
+ pRecord->Set_Value(1, m_pLayer->Get_Classifier()->Histogram_Get_Count (i, false));
+ pRecord->Set_Value(2, m_pLayer->Get_Classifier()->Histogram_Get_Count (i, false) * dArea);
+ pRecord->Set_Value(3, m_pLayer->Get_Classifier()->Get_Class_Name (i).c_str());
+ pRecord->Set_Value(4, m_pLayer->Get_Classifier()->Get_Class_Value_Minimum(i));
+ pRecord->Set_Value(5, m_pLayer->Get_Classifier()->Get_Class_Value_Center (i));
+ pRecord->Set_Value(6, m_pLayer->Get_Classifier()->Get_Class_Value_Maximum(i));
}
g_pData->Add(pTable);
diff --git a/src/saga_core/saga_gui/view_layout_info.cpp b/src/saga_core/saga_gui/view_layout_info.cpp
index 4256816..881b163 100644
--- a/src/saga_core/saga_gui/view_layout_info.cpp
+++ b/src/saga_core/saga_gui/view_layout_info.cpp
@@ -278,24 +278,25 @@ int CVIEW_Layout_Info::Get_Page_Count(void)
//---------------------------------------------------------
void CVIEW_Layout_Info::Fit_Scale(void)
{
- int fMap;
- double zMap, zLegend, Scale, dx, dy;
- wxRect rMap, rLegend;
+ int dc_MapFrame;
+ double dPaperToDC, zLegend, Scale, dDCToMeter, dx, dy;
+ wxRect dc_rMap, dc_rLegend;
CSG_Rect rWorld;
- if( _Get_Layout(Get_PaperSize(), zMap, fMap, rMap, zLegend, rLegend) )
+ if( _Get_Layout(Get_PaperSize(), dPaperToDC, dc_MapFrame, dc_rMap, zLegend, dc_rLegend) )
{
- rWorld = m_pMap->Get_World(rMap);
- Scale = 100.0 * zMap * rWorld.Get_XRange() / (double)rMap.GetWidth();
+ dDCToMeter = 0.001 / dPaperToDC;
+ rWorld = m_pMap->Get_World(dc_rMap);
+ Scale = rWorld.Get_XRange() / (dDCToMeter * dc_rMap.GetWidth());
if( DLG_Get_Number(Scale, LNG("[CAP] Fit Map Scale"), LNG("[DLG] Scale 1 : ")) )
{
- dx = Scale * (double)rMap.GetWidth () / zMap / 100.0 / 2.0;
- dy = Scale * (double)rMap.GetHeight() / zMap / 100.0 / 2.0;
+ dx = Scale * dDCToMeter * dc_rMap.GetWidth ();
+ dy = Scale * dDCToMeter * dc_rMap.GetHeight();
rWorld.Assign(
- rWorld.Get_XCenter() - dx, rWorld.Get_YCenter() - dy,
- rWorld.Get_XCenter() + dx, rWorld.Get_YCenter() + dy
+ rWorld.Get_XCenter() - 0.5 * dx, rWorld.Get_YCenter() - 0.5 * dy,
+ rWorld.Get_XCenter() + 0.5 * dx, rWorld.Get_YCenter() + 0.5 * dy
);
m_pMap->Set_Extent(rWorld);
@@ -311,46 +312,54 @@ void CVIEW_Layout_Info::Fit_Scale(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-bool CVIEW_Layout_Info::_Get_Layout(wxSize sClient, double &zMap, int &fMap, wxRect &rMap, double &zLegend, wxRect &rLegend)
+bool CVIEW_Layout_Info::_Get_Layout(wxSize sDC, double &dPaperToDC, int &dc_MapFrame, wxRect &dc_rMap, double &zLegend, wxRect &dc_rLegend)
{
- int Space;
+ int dc_Space;
wxSize sLegend;
- wxRect rFrame(Get_Margins());
+ wxRect dc_rMargins;
//-----------------------------------------------------
- zMap = sClient.GetWidth() / (double)Get_PaperSize().GetWidth();
- rFrame = wxRect(
- (int)(zMap * rFrame.GetLeft ()),
- (int)(zMap * rFrame.GetTop ()),
- (int)(zMap * rFrame.GetWidth ()),
- (int)(zMap * rFrame.GetHeight())
- );
+ dPaperToDC = sDC.GetWidth() / (double)Get_PaperSize().GetWidth();
+
+ dc_MapFrame = (int)(dPaperToDC * m_pMap->Get_Print_Frame());
+
+ dc_Space = (int)(10.0 * dPaperToDC);
+
+ dc_rMargins = wxRect(
+ (int)(dPaperToDC * Get_Margins().GetLeft ()),
+ (int)(dPaperToDC * Get_Margins().GetTop ()),
+ (int)(dPaperToDC * Get_Margins().GetWidth ()),
+ (int)(dPaperToDC * Get_Margins().GetHeight())
+ );
- Space = (int)(10.0 * zMap);
+ dc_rMap = dc_rMargins;
//-----------------------------------------------------
- if( m_pMap->Get_Print_Legend() && m_pMap->Get_Legend_Size(sLegend, zMap) )
+ if( m_pMap->Get_Print_Legend() && m_pMap->Get_Legend_Size(sLegend, dPaperToDC) )
{
- zLegend = (double)rFrame.GetHeight() / (double)sLegend.y;
+ zLegend = dc_rMargins.GetHeight() / (double)sLegend.y;
- if( zLegend * sLegend.x > 0.2 * (double)rFrame.GetWidth() )
+ if( zLegend * sLegend.x > 0.2 * (double)dc_rMargins.GetWidth() )
{
- zLegend = 0.2 * (double)rFrame.GetWidth() / (double)sLegend.x;
+ zLegend = 0.2 * (double)dc_rMargins.GetWidth() / (double)sLegend.x;
}
- rFrame.SetWidth (rFrame.GetWidth() - (int)(zLegend * sLegend.x + Space));
+ dc_rMap.SetWidth(dc_rMap.GetWidth() - (int)(zLegend * sLegend.x + dc_Space));
- rLegend = wxRect(rFrame.GetRight() + Space, rFrame.GetTop(), (int)(zLegend * sLegend.x), (int)(zLegend * sLegend.y));
+ dc_rLegend = wxRect(
+ dc_rMap.GetRight() + dc_Space,
+ dc_rMap.GetTop(),
+ (int)(zLegend * sLegend.x),
+ (int)(zLegend * sLegend.y)
+ );
}
else
{
- rLegend = wxRect(0, 0, 0, 0);
+ dc_rLegend = wxRect(0, 0, 0, 0);
}
//-----------------------------------------------------
- fMap = (int)(m_pMap->Get_Print_Frame() * zMap);
- rMap = rFrame;
- rMap.Deflate(fMap);
+ dc_rMap.Deflate(dc_MapFrame);
return( true );
}
@@ -365,33 +374,46 @@ bool CVIEW_Layout_Info::_Get_Layout(wxSize sClient, double &zMap, int &fMap, wxR
//---------------------------------------------------------
bool CVIEW_Layout_Info::Draw(wxDC &dc)
{
- int fMap;
- double zMap, zLegend, Scale;
- wxRect rMap, rLegend;
+ int dc_MapFrame;
+ double dPaperToDC, zLegend;
+ wxRect dc_rMap, dc_rLegend;
- if( _Get_Layout(dc.GetSize(), zMap, fMap, rMap, zLegend, rLegend) )
+ if( _Get_Layout(dc.GetSize(), dPaperToDC, dc_MapFrame, dc_rMap, zLegend, dc_rLegend) )
{
//-------------------------------------------------
- if( rLegend.GetWidth() > 0 )
+ if( dc_rLegend.GetWidth() > 0 )
{
- m_pMap->Draw_Legend(dc, zMap, zLegend, wxPoint(rLegend.GetX(), rLegend.GetY()));
+ m_pMap->Draw_Legend(dc, dPaperToDC, zLegend, wxPoint(dc_rLegend.GetX(), dc_rLegend.GetY()));
- Draw_Edge(dc, EDGE_STYLE_SIMPLE, rLegend.GetLeft() - (int)(5 * zMap), rLegend.GetTop(), rLegend.GetRight(), rLegend.GetBottom());
+ Draw_Edge(dc, EDGE_STYLE_SIMPLE,
+ dc_rLegend.GetLeft () - (int)(5 * dPaperToDC),
+ dc_rLegend.GetTop (),
+ dc_rLegend.GetRight (),
+ dc_rLegend.GetBottom()
+ );
}
//-------------------------------------------------
- if( rMap.GetWidth() > 0 )
+ if( dc_rMap.GetWidth() > 0 )
{
- m_pMap->Draw_Map(dc, zMap, rMap, false);
+ m_pMap->Draw_Map(dc, dPaperToDC, dc_rMap, false);
- if( fMap > 0 )
+ if( dc_MapFrame > 0 )
{
- m_pMap->Draw_Frame(dc, rMap, fMap);
+ m_pMap->Draw_Frame(dc, dc_rMap, dc_MapFrame);
}
//---------------------------------------------
- Scale = 100.0 * zMap * m_pMap->Get_World(rMap).Get_XRange() / (double)rMap.GetWidth();
- dc.DrawText(wxString::Format(wxT("%s 1:%s"), LNG("[CAP] Map Scale"), Get_SignificantDecimals_String(Scale).c_str()), rMap.GetLeft(), rMap.GetBottom() + fMap);
+ if( m_pMap->Get_Parameters()->Get_Parameter("PRINT_SCALE_SHOW")->asBool() )
+ {
+ double Scale = m_pMap->Get_World(dc_rMap).Get_XRange() / (dc_rMap.GetWidth() * 0.001 / dPaperToDC);
+
+ dc.DrawText(wxString::Format(wxT("%s 1:%s"), LNG("[CAP] Map Scale"),
+ Get_SignificantDecimals_String(Scale).c_str()),
+ dc_rMap.GetLeft(),
+ dc_rMap.GetBottom() + dc_MapFrame
+ );
+ }
}
}
diff --git a/src/saga_core/saga_gui/view_map_3d.cpp b/src/saga_core/saga_gui/view_map_3d.cpp
index 99438f2..a5f6d33 100644
--- a/src/saga_core/saga_gui/view_map_3d.cpp
+++ b/src/saga_core/saga_gui/view_map_3d.cpp
@@ -256,9 +256,9 @@ wxMenu * CVIEW_Map_3D::_Create_Menu(void)
CMD_Menu_Add_Item(pMenu_Sub, false, ID_CMD_MAP3D_SEQ_POS_DEL_ALL);
CMD_Menu_Add_Item(pMenu_Sub, false, ID_CMD_MAP3D_SEQ_POS_EDIT);
pMenu_Sub->AppendSeparator();
- CMD_Menu_Add_Item(pMenu_Sub, false, ID_CMD_MAP3D_SEQ_PLAY);
- CMD_Menu_Add_Item(pMenu_Sub, false, ID_CMD_MAP3D_SEQ_PLAY_LOOP);
- CMD_Menu_Add_Item(pMenu_Sub, false, ID_CMD_MAP3D_SEQ_SAVE);
+ CMD_Menu_Add_Item(pMenu_Sub, true, ID_CMD_MAP3D_SEQ_PLAY);
+ CMD_Menu_Add_Item(pMenu_Sub, true, ID_CMD_MAP3D_SEQ_PLAY_LOOP);
+ CMD_Menu_Add_Item(pMenu_Sub, true, ID_CMD_MAP3D_SEQ_SAVE);
pMenu->Append(ID_CMD_MAP3D_FIRST, LNG("[MNU] Sequencer"), pMenu_Sub);
return( pMenu );
@@ -411,6 +411,8 @@ void CVIEW_Map_3D::On_Key_Down(wxKeyEvent &event)
//---------------------------------------------------------
void CVIEW_Map_3D::On_Mouse_LDown(wxMouseEvent &event)
{
+ SetFocus();
+
m_Mouse_Down = event.GetPosition();
m_xDown = m_pImage->m_zRotate;
m_yDown = m_pImage->m_xRotate;
@@ -437,6 +439,8 @@ void CVIEW_Map_3D::On_Mouse_LUp(wxMouseEvent &event)
//---------------------------------------------------------
void CVIEW_Map_3D::On_Mouse_RDown(wxMouseEvent &event)
{
+ SetFocus();
+
m_Mouse_Down = event.GetPosition();
m_xDown = m_pImage->m_xShift;
m_yDown = m_pImage->m_yShift;
@@ -463,6 +467,8 @@ void CVIEW_Map_3D::On_Mouse_RUp(wxMouseEvent &event)
//---------------------------------------------------------
void CVIEW_Map_3D::On_Mouse_MDown(wxMouseEvent &event)
{
+ SetFocus();
+
m_Mouse_Down = event.GetPosition();
m_xDown = m_pImage->m_yRotate;
m_yDown = m_pImage->m_zShift;
@@ -555,6 +561,18 @@ void CVIEW_Map_3D::On_Command_UI(wxUpdateUIEvent &event)
case ID_CMD_MAP3D_STEREO:
event.Check(m_pImage->m_bStereo);
break;
+
+ case ID_CMD_MAP3D_SEQ_PLAY:
+ event.Check(m_Play_Mode == PLAY_MODE_RUN_ONCE);
+ break;
+
+ case ID_CMD_MAP3D_SEQ_PLAY_LOOP:
+ event.Check(m_Play_Mode == PLAY_MODE_RUN_LOOP);
+ break;
+
+ case ID_CMD_MAP3D_SEQ_SAVE:
+ event.Check(m_Play_Mode == PLAY_MODE_RUN_SAVE);
+ break;
}
}
@@ -1095,7 +1113,7 @@ bool CVIEW_Map_3D::_Play(void)
if( m_Play_Mode == PLAY_MODE_RUN_SAVE )
{
- m_pImage->Save(wxString::Format(wxT("%s_%03d"), file.c_str(), iFrame++), type);
+ m_pImage->Save(wxString::Format(wxT("%s_%04d.%s"), file.BeforeLast('.').c_str(), iFrame++, file.AfterLast('.').c_str()), type);
}
PROCESS_Wait();
diff --git a/src/saga_core/saga_gui/view_map_control.cpp b/src/saga_core/saga_gui/view_map_control.cpp
index 95f7505..d9e2514 100644
--- a/src/saga_core/saga_gui/view_map_control.cpp
+++ b/src/saga_core/saga_gui/view_map_control.cpp
@@ -113,6 +113,8 @@ BEGIN_EVENT_TABLE(CVIEW_Map_Control, wxPanel)
EVT_RIGHT_DOWN (CVIEW_Map_Control::On_Mouse_RDown)
EVT_RIGHT_UP (CVIEW_Map_Control::On_Mouse_RUp)
EVT_RIGHT_DCLICK (CVIEW_Map_Control::On_Mouse_RDClick)
+ EVT_MIDDLE_DOWN (CVIEW_Map_Control::On_Mouse_MDown)
+ EVT_MIDDLE_UP (CVIEW_Map_Control::On_Mouse_MUp)
END_EVENT_TABLE()
@@ -877,6 +879,92 @@ void CVIEW_Map_Control::On_Mouse_RDClick(wxMouseEvent &event)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+void CVIEW_Map_Control::On_Mouse_MDown(wxMouseEvent &event)
+{
+ bool bCaptureMouse = true;
+
+ m_Mouse_Down = m_Mouse_Move = event.GetPosition();
+
+ switch( m_Mode )
+ {
+ //-----------------------------------------------------
+ case MAP_MODE_SELECT:
+ break;
+
+ //-----------------------------------------------------
+ case MAP_MODE_DISTANCE:
+ break;
+
+ //-----------------------------------------------------
+ case MAP_MODE_ZOOM:
+ m_Drag_Mode = MODULE_INTERACTIVE_DRAG_NONE;
+ Set_Mode(MAP_MODE_PAN_DOWN);
+ break;
+
+ //-----------------------------------------------------
+ case MAP_MODE_PAN:
+ break;
+
+ //-----------------------------------------------------
+ case MAP_MODE_PAN_DOWN:
+ m_Drag_Mode = MODULE_INTERACTIVE_DRAG_NONE;
+ break;
+ }
+
+ //-----------------------------------------------------
+ if( bCaptureMouse )
+ {
+ CaptureMouse();
+ }
+
+ event.Skip();
+}
+
+//---------------------------------------------------------
+void CVIEW_Map_Control::On_Mouse_MUp(wxMouseEvent &event)
+{
+ if( HasCapture() )
+ {
+ ReleaseMouse();
+ }
+
+ _Draw_Inverse(m_Mouse_Down, event.GetPosition());
+ m_Drag_Mode = MODULE_INTERACTIVE_DRAG_NONE;
+
+ switch( m_Mode )
+ {
+ //-----------------------------------------------------
+ case MAP_MODE_SELECT:
+ break;
+
+ //-----------------------------------------------------
+ case MAP_MODE_DISTANCE:
+ break;
+
+ //-----------------------------------------------------
+ case MAP_MODE_ZOOM:
+ break;
+
+ //-----------------------------------------------------
+ case MAP_MODE_PAN:
+ break;
+
+ //-----------------------------------------------------
+ case MAP_MODE_PAN_DOWN:
+ Set_Mode(MAP_MODE_ZOOM);
+ _Move(m_Mouse_Down, event.GetPosition());
+ break;
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
void CVIEW_Map_Control::On_Mouse_Motion(wxMouseEvent &event)
{
if( m_Mode != MAP_MODE_PAN_DOWN )
diff --git a/src/saga_core/saga_gui/view_map_control.h b/src/saga_core/saga_gui/view_map_control.h
index 4256e1c..c670e80 100644
--- a/src/saga_core/saga_gui/view_map_control.h
+++ b/src/saga_core/saga_gui/view_map_control.h
@@ -118,6 +118,8 @@ public:
void On_Mouse_RDown (wxMouseEvent &event);
void On_Mouse_RUp (wxMouseEvent &event);
void On_Mouse_RDClick (wxMouseEvent &event);
+ void On_Mouse_MDown (wxMouseEvent &event);
+ void On_Mouse_MUp (wxMouseEvent &event);
bool Set_Mode (int Mode);
int Get_Mode (void) { return( m_Mode ); }
diff --git a/src/saga_core/saga_gui/view_scatterplot.cpp b/src/saga_core/saga_gui/view_scatterplot.cpp
index c7b2ba7..f4a3f99 100644
--- a/src/saga_core/saga_gui/view_scatterplot.cpp
+++ b/src/saga_core/saga_gui/view_scatterplot.cpp
@@ -88,19 +88,23 @@
//---------------------------------------------------------
void Add_ScatterPlot(CSG_Grid *pGrid)
{
- CSG_Parameter *pNode;
- CSG_Grid *pGrid_Y;
- CSG_Shapes *pShapes;
-
//-----------------------------------------------------
CSG_Parameters Parameters(NULL, wxString::Format(wxT("%s: %s"), LNG("[CAP] Scatterplot"), pGrid->Get_Name()), LNG(""), NULL, true);
+ Parameters.Add_Choice(
+ NULL , "TYPE" , LNG("Compare with..."), LNG(""),
+ CSG_String::Format(SG_T("%s|%s|"),
+ LNG("another grid"),
+ LNG("shapes")
+ )
+ );
+
Parameters.Add_Grid(
NULL , "GRID" , LNG("[CAP] Grid") , LNG(""),
PARAMETER_INPUT_OPTIONAL
);
- pNode = Parameters.Add_Shapes(
+ CSG_Parameter *pNode = Parameters.Add_Shapes(
NULL , "SHAPES" , LNG("[CAP] Shapes") , LNG(""),
PARAMETER_INPUT_OPTIONAL
);
@@ -110,15 +114,40 @@ void Add_ScatterPlot(CSG_Grid *pGrid)
);
//-----------------------------------------------------
- if( DLG_Parameters(&Parameters) )
+ for( ;; )
{
- if( (pGrid_Y = Parameters("GRID")->asGrid()) != NULL )
+ if( DLG_Parameters(&Parameters) == false )
{
- new CVIEW_ScatterPlot(pGrid, pGrid_Y);
+ return;
}
- else if( (pShapes = Parameters("SHAPES")->asShapes()) != NULL )
+
+ switch( Parameters("TYPE")->asInt() )
{
- new CVIEW_ScatterPlot(pGrid, pShapes, Parameters("FIELD")->asInt());
+ case 0:
+ if( Parameters("GRID")->asGrid() )
+ {
+ new CVIEW_ScatterPlot(pGrid, Parameters("GRID")->asGrid());
+
+ return;
+ }
+ else
+ {
+ DLG_Message_Show(LNG("You have to choose a grid for comparison"), LNG("Scatterplot"));
+ }
+ break;
+
+ case 1:
+ if( Parameters("SHAPES")->asShapes() )
+ {
+ new CVIEW_ScatterPlot(pGrid, Parameters("SHAPES")->asShapes(), Parameters("FIELD")->asInt());
+
+ return;
+ }
+ else
+ {
+ DLG_Message_Show(LNG("You have to choose a shapes layer for comparison"), LNG("Scatterplot"));
+ }
+ break;
}
}
}
@@ -431,6 +460,10 @@ void CVIEW_ScatterPlot::On_Size(wxSizeEvent &event)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+#define GET_DC_X(x) (r.GetLeft() + (int)(dx * ((x) - m_Regression.Get_xMin())))
+#define GET_DC_Y(y) (r.GetBottom() - (int)(dy * ((y) - m_Regression.Get_yMin())))
+
+//---------------------------------------------------------
void CVIEW_ScatterPlot::On_Paint(wxPaintEvent &event)
{
wxPaintDC dc(this);
@@ -509,44 +542,34 @@ void CVIEW_ScatterPlot::_Draw_Regression(wxDC &dc, wxRect r, double dx, double d
b = m_Regression.Get_Coefficient();
//-----------------------------------------------------
- if( m_Regression.Get_Type() == REGRESSION_Linear )
- {
- dc.DrawCircle( // Mittelwert...
- r.GetLeft() + (int)(dx * (m_Regression.Get_xMean() - m_Regression.Get_xMin())),
- r.GetBottom() - (int)(dy * (m_Regression.Get_yMean() - m_Regression.Get_yMin())),
- 2
- );
+ dc.DrawCircle(
+ GET_DC_X(m_Regression.Get_xMean()),
+ GET_DC_Y(m_Regression.Get_yMean()), 2
+ );
- dc.DrawLine( // Regressions- u. Std.Abw.-Geraden...
- r.GetLeft() , r.GetBottom() - (int)(dy * ((a + b * m_Regression.Get_xMin()) - m_Regression.Get_yMin())),
- r.GetRight(), r.GetBottom() - (int)(dy * ((a + b * m_Regression.Get_xMax()) - m_Regression.Get_yMin()))
- );
- }
- else
- {
- ex = (m_Regression.Get_xMax() - m_Regression.Get_xMin()) / (double)r.GetWidth();
- x = m_Regression.Get_xMin();
- by = 0;
+ ex = (m_Regression.Get_xMax() - m_Regression.Get_xMin()) / (double)r.GetWidth();
+ x = m_Regression.Get_xMin();
+ by = 0;
- for(ix=0; ix<r.GetWidth(); ix++, x+=ex)
+ for(ix=0; ix<r.GetWidth(); ix++, x+=ex)
+ {
+ switch( m_Regression.Get_Type() )
{
- switch( m_Regression.Get_Type() )
- {
- default: y = 0.0; break;
- case REGRESSION_Rez_X: y = a + b / x; break;
- case REGRESSION_Rez_Y: y = a / (b - x); break;
- case REGRESSION_Pow: y = a * pow(x, b); break;
- case REGRESSION_Exp: y = a * exp(b * x); break;
- case REGRESSION_Log: y = a + b * log(x); break;
- }
+ default: y = 0.0; break;
+ case REGRESSION_Linear: y = a + b * x; break;
+ case REGRESSION_Rez_X: y = a + b / x; break;
+ case REGRESSION_Rez_Y: y = a / (b - x); break;
+ case REGRESSION_Pow: y = a * pow(x, b); break;
+ case REGRESSION_Exp: y = a * exp(b * x); break;
+ case REGRESSION_Log: y = a + b * log(x); break;
+ }
- ay = by;
- by = r.GetBottom() - (int)(dy * (y - m_Regression.Get_yMin()));
+ ay = by;
+ by = r.GetBottom() - (int)(dy * (y - m_Regression.Get_yMin()));
- if( ix > 0 )
- {
- dc.DrawLine(r.GetLeft() + ix - 1, ay, r.GetLeft() + ix, by);
- }
+ if( ix > 0 && r.GetTop() < ay && ay < r.GetBottom() && r.GetTop() < by && by < r.GetBottom() )
+ {
+ dc.DrawLine(r.GetLeft() + ix - 1, ay, r.GetLeft() + ix, by);
}
}
@@ -650,9 +673,8 @@ void CVIEW_ScatterPlot::_Draw_Points(wxDC &dc, wxRect r, double dx, double dy)
for(int i=0; i<m_Regression.Get_Count(); i++)
{
dc.DrawCircle(
- r.GetLeft() + (int)(dx * (m_Regression.Get_xValue(i) - m_Regression.Get_xMin())),
- r.GetBottom() - (int)(dy * (m_Regression.Get_yValue(i) - m_Regression.Get_yMin())),
- 2
+ GET_DC_X(m_Regression.Get_xValue(i)),
+ GET_DC_Y(m_Regression.Get_yValue(i)), 2
);
}
}
diff --git a/src/saga_core/saga_gui/view_table.cpp b/src/saga_core/saga_gui/view_table.cpp
index 3ebc16e..cfd375f 100644
--- a/src/saga_core/saga_gui/view_table.cpp
+++ b/src/saga_core/saga_gui/view_table.cpp
@@ -100,6 +100,8 @@ BEGIN_EVENT_TABLE(CVIEW_Table, CVIEW_Base)
EVT_UPDATE_UI (ID_CMD_TABLE_RECORD_DEL , CVIEW_Table::On_Record_Del_UI)
EVT_MENU (ID_CMD_TABLE_RECORD_DEL_ALL , CVIEW_Table::On_Record_Clr)
EVT_UPDATE_UI (ID_CMD_TABLE_RECORD_DEL_ALL , CVIEW_Table::On_Record_Clr_UI)
+ EVT_MENU (ID_CMD_TABLE_SELECTION_TO_TOP , CVIEW_Table::On_Sel_To_Top)
+ EVT_UPDATE_UI (ID_CMD_TABLE_SELECTION_TO_TOP , CVIEW_Table::On_Sel_To_Top_UI)
END_EVENT_TABLE()
@@ -260,6 +262,17 @@ void CVIEW_Table::On_Record_Clr_UI(wxUpdateUIEvent &event)
m_pControl->On_Record_Clr_UI(event);
}
+//---------------------------------------------------------
+void CVIEW_Table::On_Sel_To_Top(wxCommandEvent &event)
+{
+ m_pControl->On_Sel_To_Top(event);
+}
+
+void CVIEW_Table::On_Sel_To_Top_UI(wxUpdateUIEvent &event)
+{
+ m_pControl->On_Sel_To_Top_UI(event);
+}
+
///////////////////////////////////////////////////////////
// //
diff --git a/src/saga_core/saga_gui/view_table.h b/src/saga_core/saga_gui/view_table.h
index b858ecf..431253d 100644
--- a/src/saga_core/saga_gui/view_table.h
+++ b/src/saga_core/saga_gui/view_table.h
@@ -107,6 +107,8 @@ public:
void On_Record_Del_UI (wxUpdateUIEvent &event);
void On_Record_Clr (wxCommandEvent &event);
void On_Record_Clr_UI (wxUpdateUIEvent &event);
+ void On_Sel_To_Top (wxCommandEvent &event);
+ void On_Sel_To_Top_UI (wxUpdateUIEvent &event);
void Update_Table (void);
void Update_Selection (void);
diff --git a/src/saga_core/saga_gui/view_table_control.cpp b/src/saga_core/saga_gui/view_table_control.cpp
index c1efca4..2d31904 100644
--- a/src/saga_core/saga_gui/view_table_control.cpp
+++ b/src/saga_core/saga_gui/view_table_control.cpp
@@ -129,6 +129,9 @@ BEGIN_EVENT_TABLE(CVIEW_Table_Control, wxGrid)
EVT_MENU (ID_CMD_TABLE_RECORD_DEL_ALL , CVIEW_Table_Control::On_Record_Clr)
EVT_UPDATE_UI (ID_CMD_TABLE_RECORD_DEL_ALL , CVIEW_Table_Control::On_Record_Clr_UI)
+ EVT_MENU (ID_CMD_TABLE_SELECTION_TO_TOP , CVIEW_Table_Control::On_Sel_To_Top)
+ EVT_UPDATE_UI (ID_CMD_TABLE_SELECTION_TO_TOP , CVIEW_Table_Control::On_Sel_To_Top_UI)
+
EVT_MENU (ID_CMD_TABLE_AUTOSIZE_COLS , CVIEW_Table_Control::On_Autosize_Cols)
EVT_MENU (ID_CMD_TABLE_AUTOSIZE_ROWS , CVIEW_Table_Control::On_Autosize_Rows)
END_EVENT_TABLE()
@@ -145,7 +148,9 @@ CVIEW_Table_Control::CVIEW_Table_Control(wxWindow *pParent, CSG_Table *pTable, i
: wxGrid(pParent, -1, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS|wxSUNKEN_BORDER)
{
m_pTable = pTable;
+ m_pRecords = NULL;
m_Constraint = Constraint;
+ m_bUpdating = false;
Set_Labeling(false);
@@ -156,7 +161,12 @@ CVIEW_Table_Control::CVIEW_Table_Control(wxWindow *pParent, CSG_Table *pTable, i
//---------------------------------------------------------
CVIEW_Table_Control::~CVIEW_Table_Control(void)
-{}
+{
+ if( m_pRecords )
+ {
+ SG_Free(m_pRecords);
+ }
+}
///////////////////////////////////////////////////////////
@@ -214,6 +224,8 @@ bool CVIEW_Table_Control::_Set_Table(void)
BeginBatch();
//-----------------------------------------------------
+ m_pRecords = (CSG_Table_Record **)SG_Realloc(m_pRecords, m_pTable->Get_Count() * sizeof(CSG_Table_Record *));
+
Difference = m_pTable->Get_Record_Count() - GetNumberRows();
if( Difference > 0 )
@@ -287,21 +299,42 @@ bool CVIEW_Table_Control::_Set_Table(void)
}
//---------------------------------------------------------
-bool CVIEW_Table_Control::_Set_Records(void)
+bool CVIEW_Table_Control::_Set_Records(bool bSelection_To_Top)
{
BeginBatch();
- for(int iRecord=0; iRecord<m_pTable->Get_Record_Count() && PROGRESSBAR_Set_Position(iRecord, m_pTable->Get_Record_Count()); iRecord++)
+ if( bSelection_To_Top && m_pTable->Get_Selection_Count() > 0 )
{
- _Set_Record(iRecord, m_pTable->Get_Record_byIndex(iRecord));
+ for(int iRecord=0, iSel=0, iNoSel=m_pTable->Get_Selection_Count(); iRecord<m_pTable->Get_Count() && PROGRESSBAR_Set_Position(iRecord, m_pTable->Get_Count()); iRecord++)
+ {
+ CSG_Table_Record *pRecord = m_pTable->Get_Record_byIndex(iRecord);
+
+ if( pRecord->is_Selected() )
+ {
+ _Set_Record(iSel ++, pRecord);
+ }
+ else
+ {
+ _Set_Record(iNoSel++, pRecord);
+ }
+ }
}
+ else
+ {
+ for(int iRecord=0; iRecord<m_pTable->Get_Count() && PROGRESSBAR_Set_Position(iRecord, m_pTable->Get_Count()); iRecord++)
+ {
+ CSG_Table_Record *pRecord = m_pTable->Get_Record_byIndex(iRecord);
- PROCESS_Set_Okay();
+ _Set_Record(iRecord, pRecord);
+ }
+ }
- Update_Selection();
+ PROCESS_Set_Okay();
EndBatch();
+ Update_Selection();
+
return( true );
}
@@ -310,6 +343,8 @@ bool CVIEW_Table_Control::_Set_Record(int iRecord, CSG_Table_Record *pRecord)
{
if( pRecord && iRecord >= 0 && iRecord < GetNumberRows() )
{
+ m_pRecords[iRecord] = pRecord;
+
if( m_Field_Offset )
{
SetRowLabelValue(iRecord, pRecord->asString(0));
@@ -320,11 +355,11 @@ bool CVIEW_Table_Control::_Set_Record(int iRecord, CSG_Table_Record *pRecord)
switch( m_pTable->Get_Field_Type(iField) )
{
default:
- SET_CELL_VALUE(iRecord, iCol, pRecord->asString (iField));
+ SET_CELL_VALUE(iRecord, iCol, pRecord->is_NoData(iField) ? SG_T("") : pRecord->asString(iField));
break;
case SG_DATATYPE_Color:
- SET_CELL_COLOR(iRecord, iCol, pRecord->asInt (iField));
+ SET_CELL_COLOR(iRecord, iCol, pRecord->asInt(iField));
break;
}
}
@@ -345,11 +380,13 @@ bool CVIEW_Table_Control::_Set_Record(int iRecord, CSG_Table_Record *pRecord)
//---------------------------------------------------------
bool CVIEW_Table_Control::Add_Record(void)
{
- if( !FIXED_ROWS && !m_pTable->is_Private() )
+ if( !FIXED_ROWS && !m_pTable->is_Private() && m_pTable->Get_ObjectType() == DATAOBJECT_TYPE_Table )
{
AppendRows();
- _Set_Record(m_pTable->Get_Record_Count(), m_pTable->Add_Record());
+ m_pRecords = (CSG_Table_Record **)SG_Realloc(m_pRecords, GetNumberRows() * sizeof(CSG_Table_Record *));
+
+ _Set_Record(GetNumberRows() - 1, m_pTable->Add_Record());
return( true );
}
@@ -360,7 +397,7 @@ bool CVIEW_Table_Control::Add_Record(void)
//---------------------------------------------------------
bool CVIEW_Table_Control::Ins_Record(void)
{
- if( !FIXED_ROWS && !m_pTable->is_Private() )
+ if( !FIXED_ROWS && !m_pTable->is_Private() && m_pTable->Get_ObjectType() == DATAOBJECT_TYPE_Table )
{
int iRecord = GetGridCursorRow();
@@ -368,6 +405,13 @@ bool CVIEW_Table_Control::Ins_Record(void)
{
InsertRows(iRecord);
+ m_pRecords = (CSG_Table_Record **)SG_Realloc(m_pRecords, GetNumberRows() * sizeof(CSG_Table_Record *));
+
+ for(int i=GetNumberRows()-1; i>iRecord; i--)
+ {
+ m_pRecords[i] = m_pRecords[i - 1];
+ }
+
_Set_Record(iRecord, m_pTable->Ins_Record(iRecord));
return( true );
@@ -380,28 +424,15 @@ bool CVIEW_Table_Control::Ins_Record(void)
//---------------------------------------------------------
bool CVIEW_Table_Control::Del_Record(void)
{
- if( !FIXED_ROWS && (!m_pTable->is_Private() || (m_pTable->Get_Owner() && m_pTable->Get_Owner()->Get_ObjectType() == DATAOBJECT_TYPE_Shapes)) )
+ if( !FIXED_ROWS && !m_pTable->is_Private() )
{
- wxArrayInt Records = GetSelectedRows();
+ m_pTable->Del_Selection();
- if( Records.GetCount() > 0 )
- {
- do
- {
- DeleteRows(Records[0]);
- Records = GetSelectedRows();
- }
- while( Records.GetCount() > 0 );
+ g_pData->Update_Views(m_pTable);
- if( !m_pTable->is_Private() )
- {
- m_pTable->Del_Selection();
-
- g_pData->Update_Views(m_pTable);
- }
+ Update_Table();
- return( true );
- }
+ return( true );
}
return( false );
@@ -430,23 +461,20 @@ bool CVIEW_Table_Control::Del_Records(void)
//---------------------------------------------------------
bool CVIEW_Table_Control::Load(const wxChar *File_Name)
{
- bool bResult = false;
CSG_Table Table;
- if( Table.Create(File_Name)
- && Table.Get_Record_Count() > 0
- && Table.Get_Field_Count() == m_pTable->Get_Field_Count() )
+ if( Table.Create(File_Name) && Table.Get_Count() > 0 && Table.Get_Field_Count() == m_pTable->Get_Field_Count() )
{
m_pTable->Assign_Values(&Table);
_Set_Table();
- bResult = true;
+ return( true );
}
PROCESS_Set_Okay();
- return( bResult );
+ return( false );
}
//---------------------------------------------------------
@@ -482,18 +510,14 @@ void CVIEW_Table_Control::On_Size(wxSizeEvent &event)//&WXUNUSED(event))
//---------------------------------------------------------
void CVIEW_Table_Control::On_Change(wxGridEvent &event)
{
- CSG_Table_Record *pRecord;
+ int iField = m_Field_Offset + event.GetCol();
+ CSG_Table_Record *pRecord = m_pRecords[event.GetRow()];
- if( (pRecord = m_pTable->Get_Record_byIndex(event.GetRow())) != NULL )
+ if( pRecord && iField >= m_Field_Offset && iField < m_pTable->Get_Field_Count() )
{
- int iField = m_Field_Offset + event.GetCol();
-
- if( iField >= m_Field_Offset && iField < m_pTable->Get_Field_Count() )
- {
- pRecord->Set_Value(iField, GetCellValue(event.GetRow(), event.GetCol()).c_str());
+ pRecord->Set_Value(iField, GetCellValue(event.GetRow(), event.GetCol()).c_str());
- SET_CELL_VALUE(event.GetRow(), event.GetCol(), pRecord->asString(iField));
- }
+ SET_CELL_VALUE(event.GetRow(), event.GetCol(), pRecord->asString(iField));
}
}
@@ -725,7 +749,7 @@ void CVIEW_Table_Control::On_Record_Add(wxCommandEvent &event)
void CVIEW_Table_Control::On_Record_Add_UI(wxUpdateUIEvent &event)
{
- event.Enable(!FIXED_ROWS && !m_pTable->is_Private());
+ event.Enable(!FIXED_ROWS && !m_pTable->is_Private() && m_pTable->Get_ObjectType() == DATAOBJECT_TYPE_Table);
}
//---------------------------------------------------------
@@ -736,7 +760,7 @@ void CVIEW_Table_Control::On_Record_Ins(wxCommandEvent &event)
void CVIEW_Table_Control::On_Record_Ins_UI(wxUpdateUIEvent &event)
{
- event.Enable(!FIXED_ROWS && !m_pTable->is_Private());
+ event.Enable(!FIXED_ROWS && !m_pTable->is_Private() && m_pTable->Get_ObjectType() == DATAOBJECT_TYPE_Table);
}
//---------------------------------------------------------
@@ -747,7 +771,7 @@ void CVIEW_Table_Control::On_Record_Del(wxCommandEvent &event)
void CVIEW_Table_Control::On_Record_Del_UI(wxUpdateUIEvent &event)
{
- event.Enable(!FIXED_ROWS);
+ event.Enable(!FIXED_ROWS && !m_pTable->is_Private() && m_pTable->Get_Selection_Count() > 0);
}
//---------------------------------------------------------
@@ -758,7 +782,28 @@ void CVIEW_Table_Control::On_Record_Clr(wxCommandEvent &event)
void CVIEW_Table_Control::On_Record_Clr_UI(wxUpdateUIEvent &event)
{
- event.Enable(!FIXED_ROWS && !m_pTable->is_Private());
+ event.Enable(!FIXED_ROWS && !m_pTable->is_Private() && !m_pTable->is_Private());
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CVIEW_Table_Control::On_Sel_To_Top(wxCommandEvent &event)
+{
+ if( !FIXED_ROWS && m_pTable->Get_Selection_Count() > 0 )
+ {
+ _Set_Records(true);
+ }
+}
+
+void CVIEW_Table_Control::On_Sel_To_Top_UI(wxUpdateUIEvent &event)
+{
+ event.Enable(!FIXED_ROWS && m_pTable->Get_Selection_Count() > 0);
}
@@ -792,7 +837,9 @@ void CVIEW_Table_Control::On_LClick(wxGridEvent &event)
{
if( event.ControlDown() )
{
- SelectRow (event.GetRow(), true);
+ m_pTable->Select(m_pRecords[event.GetRow()], true);
+
+ Update_Selection();
}
else if( event.ShiftDown() )
{
@@ -804,7 +851,7 @@ void CVIEW_Table_Control::On_LClick(wxGridEvent &event)
CSG_Table_Record *pRecord;
- if( (pRecord = m_pTable->Get_Record_byIndex(event.GetRow())) != NULL )
+ if( (pRecord = m_pRecords[event.GetRow()]) != NULL )
{
int iField = m_Field_Offset + event.GetCol();
@@ -899,6 +946,8 @@ void CVIEW_Table_Control::On_RClick_Label(wxGridEvent &event)
CMD_Menu_Add_Item(pMenu, false, ID_CMD_TABLE_RECORD_DEL);
CMD_Menu_Add_Item(pMenu, false, ID_CMD_TABLE_RECORD_DEL_ALL);
pMenu->AppendSeparator();
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_TABLE_SELECTION_TO_TOP);
+ pMenu->AppendSeparator();
CMD_Menu_Add_Item(pMenu, false, ID_CMD_TABLE_AUTOSIZE_ROWS);
PopupMenu(pMenu, event.GetPosition().x - GetRowLabelSize(), event.GetPosition().y);
@@ -928,68 +977,54 @@ void CVIEW_Table_Control::On_LDClick_Label(wxGridEvent &event)
//---------------------------------------------------------
void CVIEW_Table_Control::On_Select(wxGridRangeSelectEvent &event)
{
- BeginBatch();
-
- for(int iRow=event.GetTopRow(); iRow<=event.GetBottomRow(); iRow++)
+ if( !m_bUpdating )
{
- _Select(iRow, event.Selecting());
- }
-
- EndBatch();
-
- _Update_Views();
-
- event.Skip();
-}
+ BeginBatch();
-//---------------------------------------------------------
-inline void CVIEW_Table_Control::_Select(int iRow, bool bSelect)
-{
- CSG_Table_Record *pRecord;
+ for(int iRow=event.GetTopRow(); iRow<=event.GetBottomRow(); iRow++)
+ {
+ if( m_pRecords[iRow]->is_Selected() != event.Selecting() )
+ {
+ m_pTable->Select(m_pRecords[iRow], true);
+ }
+ }
- if( (pRecord = m_pTable->Get_Record_byIndex(iRow)) != NULL && bSelect != pRecord->is_Selected() )
- {
- m_pTable->Select(pRecord, true);
+ EndBatch();
_Update_Views();
}
+
+ event.Skip();
}
//---------------------------------------------------------
void CVIEW_Table_Control::Update_Selection(void)
{
- BeginBatch();
-
- if( m_pTable->Get_Selection_Count() > 0 )
+ if( !m_bUpdating )
{
- int iRecord;
- bool *Select = (bool *)SG_Malloc(m_pTable->Get_Record_Count() * sizeof(bool));
+ m_bUpdating = true;
- for(iRecord=0; iRecord<m_pTable->Get_Record_Count(); iRecord++)
- {
- Select[iRecord] = m_pTable->Get_Record_byIndex(iRecord)->is_Selected();
- }
+ BeginBatch();
ClearSelection();
- for(iRecord=0; iRecord<m_pTable->Get_Record_Count(); iRecord++)
+ if( m_pTable->Get_Selection_Count() > 0 )
{
- if( Select[iRecord] )
+ for(int iRecord=0; iRecord<m_pTable->Get_Count(); iRecord++)
{
- SelectRow(iRecord, true);
+ if( m_pRecords[iRecord]->is_Selected() )
+ {
+ SelectRow(iRecord, true);
+ }
}
}
- SG_Free(Select);
- }
- else
- {
- ClearSelection();
- }
+ EndBatch();
- EndBatch();
+ m_bUpdating = false;
- _Update_Views();
+ _Update_Views();
+ }
}
diff --git a/src/saga_core/saga_gui/view_table_control.h b/src/saga_core/saga_gui/view_table_control.h
index ad4b49d..a0ceec0 100644
--- a/src/saga_core/saga_gui/view_table_control.h
+++ b/src/saga_core/saga_gui/view_table_control.h
@@ -118,6 +118,9 @@ public:
void On_Record_Clr (wxCommandEvent &event);
void On_Record_Clr_UI (wxUpdateUIEvent &event);
+ void On_Sel_To_Top (wxCommandEvent &event);
+ void On_Sel_To_Top_UI (wxUpdateUIEvent &event);
+
void On_Autosize_Cols (wxCommandEvent &event);
void On_Autosize_Rows (wxCommandEvent &event);
@@ -145,17 +148,20 @@ public:
private:
+ bool m_bUpdating;
+
int m_Constraint, m_Field_Offset;
+ class CSG_Table_Record **m_pRecords;
+
class CSG_Table *m_pTable;
bool _Set_Table (void);
- bool _Set_Records (void);
+ bool _Set_Records (bool bSelection_To_Top = false);
bool _Set_Record (int iRecord, class CSG_Table_Record *pRecord);
- void _Select (int iRow, bool bSelect);
void _Update_Views (void);
diff --git a/src/saga_core/saga_gui/wksp.cpp b/src/saga_core/saga_gui/wksp.cpp
index 37e5c07..d191f69 100644
--- a/src/saga_core/saga_gui/wksp.cpp
+++ b/src/saga_core/saga_gui/wksp.cpp
@@ -258,14 +258,29 @@ void CWKSP::On_Page_Changed(wxNotebookEvent &event)
//---------------------------------------------------------
void CWKSP::On_Command(wxCommandEvent &event)
{
- switch( event.GetId() )
+ if( (event.GetId() >= ID_CMD_TABLES_RECENT_FIRST && event.GetId() <= ID_CMD_TABLES_RECENT_LAST)
+ || (event.GetId() >= ID_CMD_SHAPES_RECENT_FIRST && event.GetId() <= ID_CMD_SHAPES_RECENT_LAST)
+ || (event.GetId() >= ID_CMD_POINTCLOUD_RECENT_FIRST && event.GetId() <= ID_CMD_POINTCLOUD_RECENT_LAST)
+ || (event.GetId() >= ID_CMD_TIN_RECENT_FIRST && event.GetId() <= ID_CMD_TIN_RECENT_LAST)
+ || (event.GetId() >= ID_CMD_GRIDS_RECENT_FIRST && event.GetId() <= ID_CMD_GRIDS_RECENT_LAST)
+ || (event.GetId() >= ID_CMD_DATA_PROJECT_RECENT_FIRST && event.GetId() <= ID_CMD_DATA_PROJECT_RECENT_LAST) )
+ {
+ m_pData ->On_Command(event);
+ }
+ else switch( event.GetId() )
{
default:
- if( !g_pACTIVE->Get_Item() || !g_pACTIVE->Get_Item()->On_Command(event.GetId()) )
+ if( !g_pACTIVE->Get_Item() || !g_pACTIVE->Get_Item()->On_Command(event.GetId()) )
{
- m_pModules->On_Command(event);
- m_pData ->On_Command(event);
- m_pMaps ->On_Command(event);
+ if( GetCurrentPage() )
+ {
+ switch( GetCurrentPage()->GetId() )
+ {
+ case ID_WND_WKSP_MODULES: m_pModules->On_Command(event); break;
+ case ID_WND_WKSP_DATA: m_pData ->On_Command(event); break;
+ case ID_WND_WKSP_MAPS: m_pMaps ->On_Command(event); break;
+ }
+ }
}
break;
@@ -281,6 +296,22 @@ void CWKSP::On_Command(wxCommandEvent &event)
}
break;
+ case ID_CMD_MODULES_OPEN:
+ m_pModules->On_Command(event);
+ break;
+
+ case ID_CMD_DATA_PROJECT_NEW:
+ case ID_CMD_DATA_PROJECT_OPEN:
+ case ID_CMD_DATA_PROJECT_OPEN_ADD:
+ case ID_CMD_DATA_PROJECT_SAVE:
+ case ID_CMD_DATA_PROJECT_SAVE_AS:
+ case ID_CMD_TABLES_OPEN:
+ case ID_CMD_SHAPES_OPEN:
+ case ID_CMD_POINTCLOUD_OPEN:
+ case ID_CMD_GRIDS_OPEN:
+ m_pData ->On_Command(event);
+ break;
+
case ID_CMD_WKSP_OPEN:
Open();
break;
diff --git a/src/saga_core/saga_gui/wksp_base_control.cpp b/src/saga_core/saga_gui/wksp_base_control.cpp
index 399c0f3..9ad886f 100644
--- a/src/saga_core/saga_gui/wksp_base_control.cpp
+++ b/src/saga_core/saga_gui/wksp_base_control.cpp
@@ -224,6 +224,14 @@ void CWKSP_Base_Control::On_Command(wxCommandEvent &event)
}
//-----------------------------------------------------
+ if( event.GetId() == ID_CMD_WKSP_ITEM_SEARCH )
+ {
+ _Search_Item();
+
+ return;
+ }
+
+ //-----------------------------------------------------
if( m_pManager->On_Command(event.GetId()) )
{
return;
@@ -559,7 +567,28 @@ bool CWKSP_Base_Control::_Del_Active(bool bSilent)
if( DLG_Message_Confirm(ID_DLG_DELETE)
&& (m_pManager->Get_Type() != WKSP_ITEM_Data_Manager || g_pData->Save_Modified_Sel()) )
{
- for(size_t i=0; i<IDs.GetCount(); i++)
+ size_t i;
+
+ for(i=0; i<IDs.GetCount(); i++)
+ {
+ if( IDs[i].IsOk() )
+ {
+ switch( ((CWKSP_Base_Item *)GetItemData(IDs[i]))->Get_Type() )
+ {
+ case WKSP_ITEM_Shapes:
+ case WKSP_ITEM_TIN:
+ case WKSP_ITEM_PointCloud:
+ case WKSP_ITEM_Grid:
+ g_pMaps->Del((CWKSP_Layer *)GetItemData(IDs[i]));
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+
+ for(i=0; i<IDs.GetCount(); i++)
{
if( IDs[i].IsOk() )
{
@@ -736,6 +765,7 @@ CSG_Parameters * DLG_Copy_Settings(void)
DLG_Copy_Settings(List, (CWKSP_Base_Item *)g_pData->Get_Grids());
DLG_Copy_Settings(List, (CWKSP_Base_Item *)g_pData->Get_Shapes());
DLG_Copy_Settings(List, (CWKSP_Base_Item *)g_pData->Get_TINs());
+ DLG_Copy_Settings(List, (CWKSP_Base_Item *)g_pData->Get_PointClouds());
if( List.Get_Count() > 0 )
{
@@ -830,6 +860,115 @@ bool CWKSP_Base_Control::_Copy_Settings(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+bool CWKSP_Base_Control::_Search_Compare(wxString A, wxString B, bool bCase)
+{
+ return( bCase ? B.Find(A) != wxNOT_FOUND : B.MakeUpper().Find(A.MakeUpper().c_str()) != wxNOT_FOUND );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Base_Control::_Search_Get_List(CSG_Table *pList, CWKSP_Base_Item *pItem, const wxChar *String, bool bName, bool bDesc, bool bCase)
+{
+ if( pItem == NULL )
+ {
+ return( false );
+ }
+
+ if( (bName && _Search_Compare(String, pItem->Get_Name (), bCase))
+ || (bDesc && _Search_Compare(String, pItem->Get_Description(), bCase)) )
+ {
+ CSG_Table_Record *pRecord = pList->Add_Record();
+
+ pRecord->Set_Value(0, pItem->Get_Name().c_str());
+ pRecord->Set_Value(1, pItem->Get_Type_Name(pItem->Get_Type()).c_str());
+ pRecord->Set_Value(2, (long)pItem);
+ }
+
+ if( pItem->is_Manager() )
+ {
+ for(int i=0; i<((CWKSP_Base_Manager *)pItem)->Get_Count(); i++)
+ {
+ _Search_Get_List(pList, ((CWKSP_Base_Manager *)pItem)->Get_Item(i), String, bName, bDesc, bCase);
+ }
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Base_Control::_Search_Item(void)
+{
+ static CSG_Parameters Search(NULL, LNG("Search for..."), LNG(""));
+
+ if( Search.Get_Count() == 0 )
+ {
+ Search.Add_String (NULL, "STRING" , LNG("Search for...") , LNG(""), SG_T(""));
+ Search.Add_Value (NULL, "NAME" , LNG("Name") , LNG(""), PARAMETER_TYPE_Bool, true);
+ Search.Add_Value (NULL, "DESC" , LNG("Description") , LNG(""), PARAMETER_TYPE_Bool, false);
+ Search.Add_Value (NULL, "CASE" , LNG("Case Sensitive") , LNG(""), PARAMETER_TYPE_Bool, false);
+ }
+
+ if( !DLG_Parameters(&Search) )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ CSG_Table List;
+
+ List.Add_Field(LNG("NAME") , SG_DATATYPE_String);
+ List.Add_Field(LNG("TYPE") , SG_DATATYPE_String);
+ List.Add_Field(LNG("ADDR") , SG_DATATYPE_Long);
+
+ _Search_Get_List(&List, m_pManager, Search("STRING")->asString(), Search("NAME")->asBool(), Search("DESC")->asBool(), Search("CASE")->asBool());
+
+ if( List.Get_Count() <= 0 )
+ {
+ wxMessageBox(LNG("Search text not found"), LNG("Search for..."), wxOK|wxICON_EXCLAMATION);
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ wxString *pItems = new wxString[List.Get_Count()];
+
+ for(int i=0; i<List.Get_Count(); i++)
+ {
+ pItems[i].Printf(wxT("[%s] %s"), List[i].asString(1), List[i].asString(0));
+ }
+
+ wxSingleChoiceDialog dlg(MDI_Get_Top_Window(),
+ LNG("Locate..."),
+ wxString::Format(wxT("%s: %s"), LNG("Search Text"), Search("STRING")->asString()),
+ List.Get_Count(), pItems
+ );
+
+ if( dlg.ShowModal() != wxID_OK )
+ {
+ delete[](pItems);
+
+ return( false );
+ }
+
+ delete[](pItems);
+
+ //-----------------------------------------------------
+ CWKSP_Base_Item *pItem = (CWKSP_Base_Item *)List.Get_Record(dlg.GetSelection())->asInt(2);
+
+ EnsureVisible (pItem->GetId());
+ SelectItem (pItem->GetId());
+ ScrollTo (pItem->GetId());
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
void CWKSP_Base_Control::On_Item_LClick(wxMouseEvent &event)
{
_Set_Active();
diff --git a/src/saga_core/saga_gui/wksp_base_control.h b/src/saga_core/saga_gui/wksp_base_control.h
index db94963..cb5ad7d 100644
--- a/src/saga_core/saga_gui/wksp_base_control.h
+++ b/src/saga_core/saga_gui/wksp_base_control.h
@@ -126,6 +126,10 @@ protected:
bool _Copy_Settings (void);
bool _Copy_Settings (class CSG_Parameters *pParameters, class CWKSP_Base_Item *pItem);
+ bool _Search_Compare (wxString A, wxString B, bool bCase);
+ bool _Search_Item (void);
+ bool _Search_Get_List (class CSG_Table *pList, class CWKSP_Base_Item *pItem, const wxChar *String, bool bName, bool bDesc, bool bCase);
+
//---------------------------------------------------------
DECLARE_EVENT_TABLE()
diff --git a/src/saga_core/saga_gui/wksp_base_item.cpp b/src/saga_core/saga_gui/wksp_base_item.cpp
index 7441d3f..6844963 100644
--- a/src/saga_core/saga_gui/wksp_base_item.cpp
+++ b/src/saga_core/saga_gui/wksp_base_item.cpp
@@ -90,6 +90,49 @@ CWKSP_Base_Item * Get_Active_Item(void)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+wxString CWKSP_Base_Item::Get_Type_Name(TWKSP_Item Type)
+{
+ switch( Type )
+ {
+ case WKSP_ITEM_Module_Manager: return( LNG("Module Manager") );
+ case WKSP_ITEM_Module_Library: return( LNG("Module Library") );
+ case WKSP_ITEM_Module: return( LNG("Module") );
+
+ case WKSP_ITEM_Data_Manager: return( LNG("Data Manager") );
+
+ case WKSP_ITEM_Table_Manager: return( LNG("Table Manager") );
+ case WKSP_ITEM_Table: return( LNG("Table") );
+
+ case WKSP_ITEM_Shapes_Manager: return( LNG("Shapes Manager") );
+ case WKSP_ITEM_Shapes_Type: return( LNG("Shape Type Manager") );
+ case WKSP_ITEM_Shapes: return( LNG("Shapes") );
+
+ case WKSP_ITEM_TIN_Manager: return( LNG("TIN Manager") );
+ case WKSP_ITEM_TIN: return( LNG("TIN") );
+
+ case WKSP_ITEM_PointCloud_Manager: return( LNG("Point Cloud Manager") );
+ case WKSP_ITEM_PointCloud: return( LNG("Point Cloud") );
+
+ case WKSP_ITEM_Grid_Manager: return( LNG("Grid Manager") );
+ case WKSP_ITEM_Grid_System: return( LNG("Grid System") );
+ case WKSP_ITEM_Grid: return( LNG("Grid") );
+
+ case WKSP_ITEM_Map_Manager: return( LNG("Map Manager") );
+ case WKSP_ITEM_Map: return( LNG("Map") );
+ case WKSP_ITEM_Map_Layer: return( LNG("Map Layer") );
+
+ default: return( LNG("unkown") );
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
CWKSP_Base_Item::CWKSP_Base_Item(void)
{
m_bManager = false;
diff --git a/src/saga_core/saga_gui/wksp_base_item.h b/src/saga_core/saga_gui/wksp_base_item.h
index 1844a2e..9d4748f 100644
--- a/src/saga_core/saga_gui/wksp_base_item.h
+++ b/src/saga_core/saga_gui/wksp_base_item.h
@@ -152,6 +152,8 @@ public:
bool is_Manager (void) { return( m_bManager ); }
bool is_Selected (void);
+ static wxString Get_Type_Name (TWKSP_Item Type);
+
protected:
diff --git a/src/saga_core/saga_gui/wksp_data_manager.cpp b/src/saga_core/saga_gui/wksp_data_manager.cpp
index 73722b6..1551e40 100644
--- a/src/saga_core/saga_gui/wksp_data_manager.cpp
+++ b/src/saga_core/saga_gui/wksp_data_manager.cpp
@@ -1,1317 +1,1356 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// User Interface //
-// //
-// Program: SAGA //
-// //
-//-------------------------------------------------------//
-// //
-// WKSP_Data_Manager.cpp //
-// //
-// Copyright (C) 2005 by Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#ifdef _SAGA_LINUX
-#include <stdlib.h>
-#endif
-
-#include <wx/filename.h>
-
-#include <saga_api/saga_api.h>
-
-#include "saga.h"
-
-#include "res_commands.h"
-#include "res_dialogs.h"
-
-#include "helper.h"
-#include "project.h"
-
-#include "wksp_data_control.h"
-#include "wksp_data_manager.h"
-#include "wksp_data_menu_files.h"
-
-#include "wksp_table_manager.h"
-#include "wksp_shapes_manager.h"
-#include "wksp_tin_manager.h"
-#include "wksp_pointcloud_manager.h"
-#include "wksp_grid_manager.h"
-
-#include "wksp_map_manager.h"
-
-#include "wksp_module.h"
-
-#include "active.h"
-#include "active_parameters.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CWKSP_Data_Manager *g_pData = NULL;
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CWKSP_Data_Manager::CWKSP_Data_Manager(void)
-{
- m_pTables = NULL;
- m_pShapes = NULL;
- m_pTINs = NULL;
- m_pPointClouds = NULL;
- m_pGrids = NULL;
-
- m_pProject = new CWKSP_Project;
- m_pMenu_Files = new CWKSP_Data_Menu_Files;
-
- g_pData = this;
-
- //-----------------------------------------------------
- bool bValue;
- long lValue;
- wxString sValue;
-
- if( CONFIG_Read(wxT("/DATA/GRIDS"), wxT("CACHE_TMP_DIR") , sValue) )
- {
- SG_Grid_Cache_Set_Directory(sValue);
- }
-
- if( CONFIG_Read(wxT("/DATA/GRIDS"), wxT("CACHE_AUTO") , bValue) )
- {
- SG_Grid_Cache_Set_Automatic(bValue);
- }
-
- if( CONFIG_Read(wxT("/DATA/GRIDS"), wxT("CACHE_THRESHOLD") , lValue) )
- {
- SG_Grid_Cache_Set_Threshold(lValue);
- }
-
- if( CONFIG_Read(wxT("/DATA/GRIDS"), wxT("CACHE_CONFIRM") , lValue) )
- {
- SG_Grid_Cache_Set_Confirm (lValue);
- }
-
- //-----------------------------------------------------
- CSG_Parameter *pNode;
-
- m_Parameters.Create(this, LNG(""), LNG(""));
-
- pNode = m_Parameters.Add_Node(NULL, "NODE_GRID_MEM", LNG("Grid File Caching"), LNG(""));
-
- m_Parameters.Add_FilePath(
- pNode , "GRID_MEM_CACHE_TMPDIR" , LNG("Temporary files"),
- LNG("Directory, where temporary cache files shall be saved."),
- NULL, SG_Grid_Cache_Get_Directory(), true, true
- );
-
- m_Parameters.Add_Value(
- pNode , "GRID_MEM_CACHE_AUTO" , LNG("Automatic mode"),
- LNG("Activate file caching automatically, if memory size exceeds the threshold value."),
- PARAMETER_TYPE_Bool, SG_Grid_Cache_Get_Automatic()
- );
-
- m_Parameters.Add_Value(
- pNode , "GRID_MEM_CACHE_THRSHLD" , LNG("Threshold for automatic mode [MB]"),
- LNG(""),
- PARAMETER_TYPE_Double, SG_Grid_Cache_Get_Threshold_MB(), 0.0, true
- );
-
- m_Parameters.Add_Choice(
- pNode , "GRID_MEM_CACHE_CONFIRM" , LNG("Confirm file caching"),
- LNG(""),
- wxString::Format(wxT("%s|%s|%s|"),
- LNG("do not confirm"),
- LNG("confirm"),
- LNG("confirm with options")
- ),
- SG_Grid_Cache_Get_Confirm()
- );
-
- //-----------------------------------------------------
- pNode = m_Parameters.Add_Node(NULL, "NODE_GENERAL", LNG("General"), LNG(""));
-
- if( CONFIG_Read(wxT("/DATA"), wxT("PROJECT_START") , lValue) == false )
- {
- lValue = 2;
- }
-
- m_Parameters.Add_Choice(
- pNode , "PROJECT_START" , LNG("Start Project"),
- LNG(""),
- wxString::Format(wxT("%s|%s|%s|"),
- LNG("empty"),
- LNG("last opened"),
- LNG("automatically save and load")
- ), lValue
- );
-}
-
-//---------------------------------------------------------
-CWKSP_Data_Manager::~CWKSP_Data_Manager(void)
-{
- g_pData = NULL;
-
- delete(m_pProject);
- delete(m_pMenu_Files);
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Initialise(void)
-{
- wxString FileName;
-
- if( m_pProject->Has_File_Name() )
- {
- return( m_pProject->Load(false) );
- }
- else
- {
- return( CONFIG_Read(wxT("/DATA"), wxT("PROJECT_FILE"), FileName) && wxFileExists(FileName) && m_pProject->Load(FileName, false, false) );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Finalise(void)
-{
- //-----------------------------------------------------
- CONFIG_Write(wxT("/DATA/GRIDS") , wxT("CACHE_TMP_DIR") , SG_Grid_Cache_Get_Directory());
- CONFIG_Write(wxT("/DATA/GRIDS") , wxT("CACHE_AUTO") , SG_Grid_Cache_Get_Automatic());
- CONFIG_Write(wxT("/DATA/GRIDS") , wxT("CACHE_THRESHOLD"), (long)SG_Grid_Cache_Get_Threshold());
- CONFIG_Write(wxT("/DATA/GRIDS") , wxT("CACHE_CONFIRM") , (long)SG_Grid_Cache_Get_Confirm ());
-
- //-----------------------------------------------------
-#ifdef _SAGA_LINUX
-// wxFileName fProject(wxString(getenv( "HOME"), wxConvFile ), wxT("saga_gui"), wxT("cfg"));
- CSG_String sHome(getenv("HOME"));
- wxFileName fProject(sHome.c_str(), wxT("saga_gui"), wxT("cfg"));
-#else
- wxFileName fProject(g_pSAGA->Get_App_Path(), wxT("saga_gui"), wxT("cfg"));
-#endif
-
- CONFIG_Write(wxT("/DATA") , wxT("PROJECT_START") , (long)m_Parameters("PROJECT_START") ->asInt());
-
- if( Get_Count() == 0 )
- {
- wxRemoveFile(fProject.GetFullPath());
- CONFIG_Write(wxT("/DATA"), wxT("PROJECT_FILE"), LNG(""));
- }
- else switch( m_Parameters("PROJECT_START")->asInt() )
- {
- case 0: // empty
- wxRemoveFile(fProject.GetFullPath());
- CONFIG_Write(wxT("/DATA"), wxT("PROJECT_FILE"), LNG(""));
- break;
-
- case 1: // last opened
- wxRemoveFile(fProject.GetFullPath());
- CONFIG_Write(wxT("/DATA"), wxT("PROJECT_FILE"), m_pProject->Get_File_Name());
- break;
-
- case 2: // automatically save and load
- m_pProject->Save(fProject.GetFullPath(), false);
- CONFIG_Write(wxT("/DATA"), wxT("PROJECT_FILE"), fProject.GetFullPath());
- break;
- }
-
- m_pProject->Clr_File_Name();
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-wxString CWKSP_Data_Manager::Get_Name(void)
-{
- return( LNG("[CAP] Data") );
-}
-
-//---------------------------------------------------------
-wxString CWKSP_Data_Manager::Get_Description(void)
-{
- wxString s;
-
- s.Printf(wxT("<b>%s</b><br>"), LNG("[CAP] Data"));
-
- if( Get_Count() <= 0 )
- {
- s.Append(LNG("[TXT] No data loaded."));
- }
- else
- {
- if( m_pProject->Has_File_Name() )
- {
- s.Append(wxString::Format(wxT("%s: %s<br>"), LNG("[CAP] Project File"), m_pProject->Get_File_Name()));
- }
-
- if( Get_Tables() )
- {
- s.Append(wxString::Format(wxT("%s: %d<br>"), LNG("[CAP] Tables"), Get_Tables()->Get_Count()));
- }
-
- if( Get_Shapes() )
- {
- s.Append(wxString::Format(wxT("%s: %d<br>"), LNG("[CAP] Shapes"), Get_Shapes()->Get_Items_Count()));
- }
-
- if( Get_TINs() )
- {
- s.Append(wxString::Format(wxT("%s: %d<br>"), LNG("[CAP] TIN"), Get_TINs()->Get_Count()));
- }
-
- if( Get_PointClouds() )
- {
- s.Append(wxString::Format(wxT("%s: %d<br>"), LNG("[CAP] Point Clouds"), Get_PointClouds()->Get_Count()));
- }
-
- if( Get_Grids() )
- {
- s.Append(wxString::Format(wxT("%s: %d<br>"), LNG("[CAP] Grid Systems"), Get_Grids()->Get_Count()));
- s.Append(wxString::Format(wxT("%s: %d<br>"), LNG("[CAP] Grids"), Get_Grids()->Get_Items_Count()));
- }
- }
-
- return( s );
-}
-
-//---------------------------------------------------------
-wxMenu * CWKSP_Data_Manager::Get_Menu(void)
-{
- wxMenu *pMenu;
-
- pMenu = new wxMenu(LNG("[CAP] Data"));
-
-// CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_CLOSE);
-
-// pMenu->AppendSeparator();
-
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_DATA_PROJECT_NEW);
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_DATA_PROJECT_OPEN);
-// CMD_Menu_Add_Item(pMenu, false, ID_CMD_DATA_PROJECT_OPEN_ADD);
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_DATA_PROJECT_SAVE);
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_DATA_PROJECT_SAVE_AS);
-
- return( pMenu );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::On_Command(int Cmd_ID)
-{
- //-----------------------------------------------------
- if( Open_CMD(Cmd_ID) )
- {
- return( true );
- }
-
- if( m_pTables && Cmd_ID >= ID_CMD_TABLES_FIRST && Cmd_ID <= ID_CMD_TABLES_LAST && m_pTables->On_Command(Cmd_ID) )
- {
- return( true );
- }
-
- if( m_pShapes && Cmd_ID >= ID_CMD_SHAPES_FIRST && Cmd_ID <= ID_CMD_SHAPES_LAST && m_pShapes->On_Command(Cmd_ID) )
- {
- return( true );
- }
-
- if( m_pTINs && Cmd_ID >= ID_CMD_TIN_FIRST && Cmd_ID <= ID_CMD_TIN_LAST && m_pTINs ->On_Command(Cmd_ID) )
- {
- return( true );
- }
-
- if( m_pPointClouds && Cmd_ID >= ID_CMD_POINTCLOUD_FIRST && Cmd_ID <= ID_CMD_POINTCLOUD_LAST && m_pPointClouds->On_Command(Cmd_ID) )
- {
- return( true );
- }
-
- if( m_pGrids && Cmd_ID >= ID_CMD_GRIDS_FIRST && Cmd_ID <= ID_CMD_GRIDS_LAST && m_pGrids ->On_Command(Cmd_ID) )
- {
- return( true );
- }
-
- //-----------------------------------------------------
- switch( Cmd_ID )
- {
- default:
- return( CWKSP_Base_Manager::On_Command(Cmd_ID) );
-
- //-----------------------------------------------------
- case ID_CMD_DATA_PROJECT_NEW: Close(false); break;
- case ID_CMD_DATA_PROJECT_OPEN: m_pProject->Load(false); break;
- case ID_CMD_DATA_PROJECT_OPEN_ADD: m_pProject->Load(true); break;
- case ID_CMD_DATA_PROJECT_SAVE: m_pProject->Save(true); break;
- case ID_CMD_DATA_PROJECT_SAVE_AS: m_pProject->Save(); break;
-
- //-----------------------------------------------------
- case ID_CMD_TABLES_OPEN: Open(DATAOBJECT_TYPE_Table); break;
- case ID_CMD_SHAPES_OPEN: Open(DATAOBJECT_TYPE_Shapes); break;
- case ID_CMD_TIN_OPEN: Open(DATAOBJECT_TYPE_TIN); break;
- case ID_CMD_POINTCLOUD_OPEN: Open(DATAOBJECT_TYPE_PointCloud); break;
- case ID_CMD_GRIDS_OPEN: Open(DATAOBJECT_TYPE_Grid); break;
-
- //-----------------------------------------------------
- case ID_CMD_WKSP_ITEM_RETURN:
- break;
-
- case ID_CMD_WKSP_ITEM_CLOSE:
- Close(false);
- break;
- }
-
- //-----------------------------------------------------
- return( true );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::On_Command_UI(wxUpdateUIEvent &event)
-{
- switch( event.GetId() )
- {
- default:
- return( CWKSP_Base_Manager::On_Command_UI(event) );
-
- case ID_CMD_DATA_PROJECT_NEW:
- event.Enable(Get_Count() > 0 && g_pModule == NULL);
- break;
-
- case ID_CMD_WKSP_ITEM_CLOSE:
- event.Enable(Get_Count() > 0 && g_pModule == NULL);
- break;
-
- case ID_CMD_DATA_PROJECT_SAVE:
- event.Enable(Get_Count() > 0 && m_pProject->Has_File_Name() );
- break;
-
- case ID_CMD_DATA_PROJECT_SAVE_AS:
- event.Enable(Get_Count() > 0);
- break;
- }
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CWKSP_Data_Manager::Parameters_Changed(void)
-{
- SG_Grid_Cache_Set_Automatic (m_Parameters("GRID_MEM_CACHE_AUTO") ->asBool());
- SG_Grid_Cache_Set_Threshold_MB (m_Parameters("GRID_MEM_CACHE_THRSHLD") ->asDouble());
- SG_Grid_Cache_Set_Confirm (m_Parameters("GRID_MEM_CACHE_CONFIRM") ->asInt());
- SG_Grid_Cache_Set_Directory (m_Parameters("GRID_MEM_CACHE_TMPDIR") ->asString());
-
- CWKSP_Base_Manager::Parameters_Changed();
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Check_Parameters(CSG_Parameters *pParameters)
-{
- if( pParameters )
- {
- for(int i=0; i<pParameters->Get_Count(); i++)
- {
- Check_Parameter(pParameters->Get_Parameter(i));
- }
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Check_Parameter(CSG_Parameter *pParameter)
-{
- bool bResult = true;
- int i, DataObject_Type;
-
- if( pParameter )
- {
- switch( pParameter->Get_Type() )
- {
- default: DataObject_Type = -1; break;
- case PARAMETER_TYPE_Grid:
- case PARAMETER_TYPE_Grid_List: DataObject_Type = DATAOBJECT_TYPE_Grid; break;
- case PARAMETER_TYPE_Table:
- case PARAMETER_TYPE_Table_List: DataObject_Type = DATAOBJECT_TYPE_Table; break;
- case PARAMETER_TYPE_Shapes:
- case PARAMETER_TYPE_Shapes_List: DataObject_Type = DATAOBJECT_TYPE_Shapes; break;
- case PARAMETER_TYPE_TIN:
- case PARAMETER_TYPE_TIN_List: DataObject_Type = DATAOBJECT_TYPE_TIN; break;
- case PARAMETER_TYPE_PointCloud:
- case PARAMETER_TYPE_PointCloud_List: DataObject_Type = DATAOBJECT_TYPE_PointCloud; break;
- }
-
- //-------------------------------------------------
- switch( pParameter->Get_Type() )
- {
- default:
- break;
-
- case PARAMETER_TYPE_Grid_System:
- if( !Exists(pParameter->asGrid_System()) )
- {
- bResult = false;
- pParameter->Set_Value((void *)NULL);
- }
- break;
-
- case PARAMETER_TYPE_Grid:
- case PARAMETER_TYPE_Table:
- case PARAMETER_TYPE_Shapes:
- case PARAMETER_TYPE_TIN:
- case PARAMETER_TYPE_PointCloud:
- if( pParameter->asDataObject() != DATAOBJECT_NOTSET
- && pParameter->asDataObject() != DATAOBJECT_CREATE
- && !Exists(pParameter->asDataObject(), DataObject_Type) )
- {
- bResult = false;
- pParameter->Set_Value(DATAOBJECT_NOTSET);
- }
- break;
-
- case PARAMETER_TYPE_Grid_List:
- case PARAMETER_TYPE_Table_List:
- case PARAMETER_TYPE_Shapes_List:
- case PARAMETER_TYPE_TIN_List:
- case PARAMETER_TYPE_PointCloud_List:
- for(i=pParameter->asList()->Get_Count()-1; i>=0; i--)
- {
- if( !Exists(pParameter->asList()->asDataObject(i), DataObject_Type) )
- {
- bResult = false;
- pParameter->asList()->Del_Item(i);
- }
- }
- break;
- }
- }
-
- return( bResult );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Open_CMD(int Cmd_ID)
-{
- return( m_pMenu_Files->Recent_Open(Cmd_ID) );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Open(const wxChar *File_Name)
-{
- if( SG_File_Cmp_Extension(File_Name, wxT("txt"))
- || SG_File_Cmp_Extension(File_Name, wxT("dbf")) )
- {
- return( Open(DATAOBJECT_TYPE_Table , File_Name) != NULL );
- }
-
- if( SG_File_Cmp_Extension(File_Name, wxT("shp")) )
- {
- return( Open(DATAOBJECT_TYPE_Shapes, File_Name) != NULL );
- }
-
- if( SG_File_Cmp_Extension(File_Name, wxT("sgrd"))
- || SG_File_Cmp_Extension(File_Name, wxT("dgm"))
- || SG_File_Cmp_Extension(File_Name, wxT("grd")) )
- {
- return( Open(DATAOBJECT_TYPE_Grid , File_Name) != NULL );
- }
-
- if( SG_File_Cmp_Extension(File_Name, wxT("sprj")) )
- {
- return( m_pProject->Load(File_Name, false, true) );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Open(int DataType)
-{
- int ID;
- wxArrayString File_Paths;
-
- switch( DataType )
- {
- default: return( false );
- case DATAOBJECT_TYPE_Table: ID = ID_DLG_TABLES_OPEN; break;
- case DATAOBJECT_TYPE_Shapes: ID = ID_DLG_SHAPES_OPEN; break;
- case DATAOBJECT_TYPE_TIN: ID = ID_DLG_TIN_OPEN; break;
- case DATAOBJECT_TYPE_PointCloud: ID = ID_DLG_POINTCLOUD_OPEN; break;
- case DATAOBJECT_TYPE_Grid: ID = ID_DLG_GRIDS_OPEN; break;
- }
-
- if( DLG_Open(File_Paths, ID) )
- {
- MSG_General_Add_Line();
-
- for(size_t i=0; i<File_Paths.GetCount(); i++)
- {
- Open(DataType, File_Paths[i]);
- }
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-CWKSP_Base_Item * CWKSP_Data_Manager::Open(int DataType, const wxChar *FileName)
-{
- CSG_Data_Object *pObject;
- CWKSP_Base_Item *pItem;
-
- switch( DataType )
- {
- default:
- pObject = NULL;
- break;
-
- case DATAOBJECT_TYPE_Table:
- pObject = new CSG_Table (FileName);
- break;
-
- case DATAOBJECT_TYPE_Shapes:
- pObject = new CSG_Shapes (FileName);
- break;
-
- case DATAOBJECT_TYPE_TIN:
- pObject = new CSG_TIN (FileName);
- break;
-
- case DATAOBJECT_TYPE_PointCloud:
- pObject = new CSG_PointCloud(FileName);
- break;
-
- case DATAOBJECT_TYPE_Grid:
- pObject = new CSG_Grid (FileName);
- break;
- }
-
- PROCESS_Set_Okay();
-
- if( pObject )
- {
- if( pObject->is_Valid() && (pItem = Add(pObject)) != NULL )
- {
- m_pMenu_Files->Recent_Add(DataType, FileName);
-
- return( pItem );
- }
-
- delete(pObject);
- }
-
- m_pMenu_Files->Recent_Del(DataType, FileName);
-
- return( NULL );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Exists(CSG_Grid_System *pSystem)
-{
- return( m_pGrids && m_pGrids->Exists(pSystem) );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Exists(CSG_Data_Object *pObject, int Type)
-{
- switch( Type )
- {
- case DATAOBJECT_TYPE_Grid:
- return( m_pGrids && m_pGrids ->Exists((CSG_Grid *)pObject) );
-
- case DATAOBJECT_TYPE_Table:
- return(
- ( m_pTables && m_pTables->Exists((CSG_Table *)pObject) )
- || ( m_pShapes && m_pShapes->Exists((CSG_Shapes *)pObject) )
- );
-
- case DATAOBJECT_TYPE_Shapes:
- return( m_pShapes && m_pShapes->Exists((CSG_Shapes *)pObject) );
-
- case DATAOBJECT_TYPE_TIN:
- return( m_pTINs && m_pTINs ->Exists((CSG_TIN *)pObject) );
-
- case DATAOBJECT_TYPE_PointCloud:
- return( m_pPointClouds && m_pPointClouds->Exists((CSG_PointCloud *)pObject) );
- }
-
- return( Exists(pObject, DATAOBJECT_TYPE_Table)
- || Exists(pObject, DATAOBJECT_TYPE_Shapes)
- || Exists(pObject, DATAOBJECT_TYPE_TIN)
- || Exists(pObject, DATAOBJECT_TYPE_PointCloud)
- || Exists(pObject, DATAOBJECT_TYPE_Grid)
- );
-}
-
-//---------------------------------------------------------
-CSG_Data_Object * CWKSP_Data_Manager::Get_byFileName(const wxChar *File_Name, int Type)
-{
- switch( Type )
- {
- case DATAOBJECT_TYPE_Grid:
- return( !m_pGrids ? NULL : m_pGrids ->Get_byFileName(File_Name) );
-
- case DATAOBJECT_TYPE_Table:
- return( !m_pTables ? NULL : m_pTables->Get_byFileName(File_Name) );
-
- case DATAOBJECT_TYPE_Shapes:
- return( !m_pShapes ? NULL : m_pShapes->Get_byFileName(File_Name) );
-
- case DATAOBJECT_TYPE_TIN:
- return( !m_pTINs ? NULL : m_pTINs ->Get_byFileName(File_Name) );
-
- case DATAOBJECT_TYPE_PointCloud:
- return( !m_pPointClouds ? NULL : m_pPointClouds->Get_byFileName(File_Name) );
- }
-
- CSG_Data_Object *pObject;
-
- if( (pObject = Get_byFileName(File_Name, DATAOBJECT_TYPE_Table)) != NULL ) return( pObject );
- if( (pObject = Get_byFileName(File_Name, DATAOBJECT_TYPE_Shapes)) != NULL ) return( pObject );
- if( (pObject = Get_byFileName(File_Name, DATAOBJECT_TYPE_TIN)) != NULL ) return( pObject );
- if( (pObject = Get_byFileName(File_Name, DATAOBJECT_TYPE_Grid)) != NULL ) return( pObject );
-
- return( NULL );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Save_Modified(CWKSP_Base_Item *pItem)
-{
- return( m_pProject->Save_Modified(pItem) );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Save_Modified_Sel(void)
-{
- return( m_pProject->Save_Modified(this, true) );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Close(bool bSilent)
-{
- if( Get_Count() == 0 )
- {
- Finalise();
-
- return( true );
- }
- else if( (bSilent || DLG_Message_Confirm(LNG("[TXT] Close all data sets"), LNG("[CAP] Close"))) && Save_Modified(this) )
- {
- Finalise();
-
- g_pACTIVE->Get_Parameters()->Restore_Parameters();
- g_pMaps->Close(true);
-
- return( g_pData_Ctrl->Close(true) );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CWKSP_Base_Item * CWKSP_Data_Manager::Add(CSG_Data_Object *pObject)
-{
- if( pObject && _Get_Manager(pObject->Get_ObjectType()) )
- {
- switch( pObject->Get_ObjectType() )
- {
- case DATAOBJECT_TYPE_Grid:
- return( (CWKSP_Base_Item *)m_pGrids ->Add((CSG_Grid *)pObject) );
-
- case DATAOBJECT_TYPE_Table:
- return( (CWKSP_Base_Item *)m_pTables->Add((CSG_Table *)pObject) );
-
- case DATAOBJECT_TYPE_Shapes:
- return( (CWKSP_Base_Item *)m_pShapes->Add((CSG_Shapes *)pObject) );
-
- case DATAOBJECT_TYPE_TIN:
- return( (CWKSP_Base_Item *)m_pTINs ->Add((CSG_TIN *)pObject) );
-
- case DATAOBJECT_TYPE_PointCloud:
- return( (CWKSP_Base_Item *)m_pPointClouds->Add((CSG_PointCloud *)pObject) );
-
- default:
- return( NULL );
- }
- }
-
- return( NULL );
-}
-
-//---------------------------------------------------------
-void CWKSP_Data_Manager::Del_Manager(CWKSP_Base_Item *pItem)
-{
- if( pItem == m_pGrids )
- {
- m_pGrids = NULL;
- }
- else if( pItem == m_pTables )
- {
- m_pTables = NULL;
- }
- else if( pItem == m_pShapes )
- {
- m_pShapes = NULL;
- }
- else if( pItem == m_pTINs )
- {
- m_pTINs = NULL;
- }
- else if( pItem == m_pPointClouds )
- {
- m_pPointClouds = NULL;
- }
-
- if( Get_Count() == 0 )
- {
- m_pProject->Clr_File_Name();
- }
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::_Get_Manager(int DataType)
-{
- switch( DataType )
- {
- default:
- return( false );
-
- case DATAOBJECT_TYPE_Grid:
- if( !m_pGrids )
- {
- Add_Item(m_pGrids = new CWKSP_Grid_Manager);
- }
-
- return( m_pGrids != NULL );
-
- case DATAOBJECT_TYPE_Table:
- if( !m_pTables )
- {
- Add_Item(m_pTables = new CWKSP_Table_Manager);
- }
-
- return( m_pTables != NULL );
-
- case DATAOBJECT_TYPE_Shapes:
- if( !m_pShapes )
- {
- Add_Item(m_pShapes = new CWKSP_Shapes_Manager);
- }
-
- return( m_pShapes != NULL );
-
- case DATAOBJECT_TYPE_TIN:
- if( !m_pTINs )
- {
- Add_Item(m_pTINs = new CWKSP_TIN_Manager);
- }
-
- return( m_pTINs != NULL );
-
- case DATAOBJECT_TYPE_PointCloud:
- if( !m_pPointClouds )
- {
- Add_Item(m_pPointClouds = new CWKSP_PointCloud_Manager);
- }
-
- return( m_pPointClouds != NULL );
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Update(CSG_Data_Object *pObject, CSG_Parameters *pParameters)
-{
- if( pObject )
- {
- switch( pObject->Get_ObjectType() )
- {
- case DATAOBJECT_TYPE_Grid:
- return( m_pGrids && m_pGrids ->Update((CSG_Grid *)pObject, pParameters) );
-
- case DATAOBJECT_TYPE_Table:
- return( m_pTables && m_pTables->Update((CSG_Table *)pObject, pParameters) );
-
- case DATAOBJECT_TYPE_Shapes:
- return( m_pShapes && m_pShapes->Update((CSG_Shapes *)pObject, pParameters) );
-
- case DATAOBJECT_TYPE_TIN:
- return( m_pTINs && m_pTINs ->Update((CSG_TIN *)pObject, pParameters) );
-
- case DATAOBJECT_TYPE_PointCloud:
- return( m_pPointClouds && m_pPointClouds->Update((CSG_PointCloud *)pObject, pParameters) );
-
- default:
- break;
- }
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Update_Views(CSG_Data_Object *pObject)
-{
- if( pObject )
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// User Interface //
+// //
+// Program: SAGA //
+// //
+//-------------------------------------------------------//
+// //
+// WKSP_Data_Manager.cpp //
+// //
+// Copyright (C) 2005 by Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifdef _SAGA_LINUX
+#include <stdlib.h>
+#endif
+
+#include <wx/filename.h>
+
+#include <saga_api/saga_api.h>
+
+#include "saga.h"
+
+#include "res_commands.h"
+#include "res_dialogs.h"
+
+#include "helper.h"
+#include "project.h"
+
+#include "wksp_data_control.h"
+#include "wksp_data_manager.h"
+#include "wksp_data_menu_files.h"
+
+#include "wksp_table_manager.h"
+#include "wksp_shapes_manager.h"
+#include "wksp_tin_manager.h"
+#include "wksp_pointcloud_manager.h"
+#include "wksp_grid_manager.h"
+
+#include "wksp_map_manager.h"
+
+#include "wksp_module.h"
+
+#include "active.h"
+#include "active_parameters.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CWKSP_Data_Manager *g_pData = NULL;
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CWKSP_Data_Manager::CWKSP_Data_Manager(void)
+{
+ m_pTables = NULL;
+ m_pShapes = NULL;
+ m_pTINs = NULL;
+ m_pPointClouds = NULL;
+ m_pGrids = NULL;
+
+ m_pProject = new CWKSP_Project;
+ m_pMenu_Files = new CWKSP_Data_Menu_Files;
+
+ g_pData = this;
+
+ //-----------------------------------------------------
+ bool bValue;
+ long lValue;
+ wxString sValue;
+
+ if( CONFIG_Read(wxT("/DATA/GRIDS"), wxT("CACHE_TMP_DIR") , sValue) )
+ {
+ SG_Grid_Cache_Set_Directory(sValue);
+ }
+
+ if( CONFIG_Read(wxT("/DATA/GRIDS"), wxT("CACHE_AUTO") , bValue) )
+ {
+ SG_Grid_Cache_Set_Automatic(bValue);
+ }
+
+ if( CONFIG_Read(wxT("/DATA/GRIDS"), wxT("CACHE_THRESHOLD") , lValue) )
+ {
+ SG_Grid_Cache_Set_Threshold(lValue);
+ }
+
+ if( CONFIG_Read(wxT("/DATA/GRIDS"), wxT("CACHE_CONFIRM") , lValue) )
+ {
+ SG_Grid_Cache_Set_Confirm (lValue);
+ }
+
+ //-----------------------------------------------------
+ CSG_Parameter *pNode;
+
+ m_Parameters.Create(this, LNG(""), LNG(""));
+
+ pNode = m_Parameters.Add_Node(NULL, "NODE_GRID_MEM", LNG("Grid File Caching"), LNG(""));
+
+ m_Parameters.Add_FilePath(
+ pNode , "GRID_MEM_CACHE_TMPDIR" , LNG("Temporary files"),
+ LNG("Directory, where temporary cache files shall be saved."),
+ NULL, SG_Grid_Cache_Get_Directory(), true, true
+ );
+
+ m_Parameters.Add_Value(
+ pNode , "GRID_MEM_CACHE_AUTO" , LNG("Automatic mode"),
+ LNG("Activate file caching automatically, if memory size exceeds the threshold value."),
+ PARAMETER_TYPE_Bool, SG_Grid_Cache_Get_Automatic()
+ );
+
+ m_Parameters.Add_Value(
+ pNode , "GRID_MEM_CACHE_THRSHLD" , LNG("Threshold for automatic mode [MB]"),
+ LNG(""),
+ PARAMETER_TYPE_Double, SG_Grid_Cache_Get_Threshold_MB(), 0.0, true
+ );
+
+ m_Parameters.Add_Choice(
+ pNode , "GRID_MEM_CACHE_CONFIRM" , LNG("Confirm file caching"),
+ LNG(""),
+ wxString::Format(wxT("%s|%s|%s|"),
+ LNG("do not confirm"),
+ LNG("confirm"),
+ LNG("confirm with options")
+ ),
+ SG_Grid_Cache_Get_Confirm()
+ );
+
+ //-----------------------------------------------------
+ pNode = m_Parameters.Add_Node(NULL, "NODE_GRID_DISPLAY", LNG("Grid Display Defaults"), LNG(""));
+
+ if( CONFIG_Read(wxT("/DATA/GRIDS"), wxT("DISPLAY_RANGEFIT") , lValue) == false )
+ {
+ lValue = 2;
+ }
+
+ m_Parameters.Add_Choice(
+ pNode , "GRID_DISPLAY_RANGEFIT" , LNG("Display Range"),
+ LNG(""),
+ wxString::Format(wxT("%s|%s|%s|"),
+ LNG("Minimum/Maximum"),
+ LNG("1.5 * Standard Deviation"),
+ LNG("2.0 * Standard Deviation")
+ ), lValue
+ );
+
+ //-----------------------------------------------------
+ pNode = m_Parameters.Add_Node(NULL, "NODE_GENERAL", LNG("General"), LNG(""));
+
+ if( CONFIG_Read(wxT("/DATA"), wxT("PROJECT_START") , lValue) == false )
+ {
+ lValue = 2;
+ }
+
+ m_Parameters.Add_Choice(
+ pNode , "PROJECT_START" , LNG("Start Project"),
+ LNG(""),
+ wxString::Format(wxT("%s|%s|%s|"),
+ LNG("empty"),
+ LNG("last opened"),
+ LNG("automatically save and load")
+ ), lValue
+ );
+}
+
+//---------------------------------------------------------
+CWKSP_Data_Manager::~CWKSP_Data_Manager(void)
+{
+ g_pData = NULL;
+
+ delete(m_pProject);
+ delete(m_pMenu_Files);
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Initialise(void)
+{
+ wxString FileName;
+
+ if( m_pProject->Has_File_Name() )
+ {
+ return( m_pProject->Load(false) );
+ }
+ else
+ {
+ return( CONFIG_Read(wxT("/DATA"), wxT("PROJECT_FILE"), FileName) && wxFileExists(FileName) && m_pProject->Load(FileName, false, false) );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Finalise(void)
+{
+ //-----------------------------------------------------
+#ifdef _SAGA_LINUX
+// wxFileName fProject(wxString(getenv( "HOME"), wxConvFile ), wxT("saga_gui"), wxT("cfg"));
+ CSG_String sHome(getenv("HOME"));
+ wxFileName fProject(sHome.c_str(), wxT("saga_gui"), wxT("cfg"));
+#else
+ wxFileName fProject(g_pSAGA->Get_App_Path(), wxT("saga_gui"), wxT("cfg"));
+
+ if( ( fProject.FileExists() && (!fProject.IsFileReadable() || !fProject.IsFileWritable()))
+ || (!fProject.FileExists() && (!fProject.IsDirReadable () || !fProject.IsDirWritable ())) )
+ {
+ fProject.Assign(wxGetHomeDir(), wxT("saga_gui"), wxT("cfg"));
+ }
+#endif
+
+ //-----------------------------------------------------
+ CONFIG_Write(wxT("/DATA/GRIDS") , wxT("CACHE_TMP_DIR") , SG_Grid_Cache_Get_Directory());
+ CONFIG_Write(wxT("/DATA/GRIDS") , wxT("CACHE_AUTO") , SG_Grid_Cache_Get_Automatic());
+ CONFIG_Write(wxT("/DATA/GRIDS") , wxT("CACHE_THRESHOLD") , (long)SG_Grid_Cache_Get_Threshold());
+ CONFIG_Write(wxT("/DATA/GRIDS") , wxT("CACHE_CONFIRM") , (long)SG_Grid_Cache_Get_Confirm ());
+
+ CONFIG_Write(wxT("/DATA/GRIDS") , wxT("DISPLAY_RANGEFIT") , (long)m_Parameters("GRID_DISPLAY_RANGEFIT")->asInt());
+
+ CONFIG_Write(wxT("/DATA") , wxT("PROJECT_START") , (long)m_Parameters("PROJECT_START")->asInt());
+
+ if( Get_Count() == 0 )
+ {
+ wxRemoveFile(fProject.GetFullPath());
+ CONFIG_Write(wxT("/DATA"), wxT("PROJECT_FILE"), LNG(""));
+ }
+ else switch( m_Parameters("PROJECT_START")->asInt() )
+ {
+ case 0: // empty
+ wxRemoveFile(fProject.GetFullPath());
+ CONFIG_Write(wxT("/DATA"), wxT("PROJECT_FILE"), LNG(""));
+ break;
+
+ case 1: // last opened
+ wxRemoveFile(fProject.GetFullPath());
+ CONFIG_Write(wxT("/DATA"), wxT("PROJECT_FILE"), m_pProject->Get_File_Name());
+ break;
+
+ case 2: // automatically save and load
+ m_pProject->Save(fProject.GetFullPath(), false);
+ CONFIG_Write(wxT("/DATA"), wxT("PROJECT_FILE"), fProject.GetFullPath());
+ break;
+ }
+
+ m_pProject->Clr_File_Name();
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+wxString CWKSP_Data_Manager::Get_Name(void)
+{
+ return( LNG("[CAP] Data") );
+}
+
+//---------------------------------------------------------
+wxString CWKSP_Data_Manager::Get_Description(void)
+{
+ wxString s;
+
+ s.Printf(wxT("<b>%s</b><br>"), LNG("[CAP] Data"));
+
+ if( Get_Count() <= 0 )
+ {
+ s.Append(LNG("[TXT] No data loaded."));
+ }
+ else
+ {
+ if( m_pProject->Has_File_Name() )
+ {
+ s.Append(wxString::Format(wxT("%s: %s<br>"), LNG("[CAP] Project File"), m_pProject->Get_File_Name()));
+ }
+
+ if( Get_Tables() )
+ {
+ s.Append(wxString::Format(wxT("%s: %d<br>"), LNG("[CAP] Tables"), Get_Tables()->Get_Count()));
+ }
+
+ if( Get_Shapes() )
+ {
+ s.Append(wxString::Format(wxT("%s: %d<br>"), LNG("[CAP] Shapes"), Get_Shapes()->Get_Items_Count()));
+ }
+
+ if( Get_TINs() )
+ {
+ s.Append(wxString::Format(wxT("%s: %d<br>"), LNG("[CAP] TIN"), Get_TINs()->Get_Count()));
+ }
+
+ if( Get_PointClouds() )
+ {
+ s.Append(wxString::Format(wxT("%s: %d<br>"), LNG("[CAP] Point Clouds"), Get_PointClouds()->Get_Count()));
+ }
+
+ if( Get_Grids() )
+ {
+ s.Append(wxString::Format(wxT("%s: %d<br>"), LNG("[CAP] Grid Systems"), Get_Grids()->Get_Count()));
+ s.Append(wxString::Format(wxT("%s: %d<br>"), LNG("[CAP] Grids"), Get_Grids()->Get_Items_Count()));
+ }
+ }
+
+ return( s );
+}
+
+//---------------------------------------------------------
+wxMenu * CWKSP_Data_Manager::Get_Menu(void)
+{
+ wxMenu *pMenu;
+
+ pMenu = new wxMenu(LNG("[CAP] Data"));
+
+// CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_CLOSE);
+
+// pMenu->AppendSeparator();
+
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_DATA_PROJECT_NEW);
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_DATA_PROJECT_OPEN);
+// CMD_Menu_Add_Item(pMenu, false, ID_CMD_DATA_PROJECT_OPEN_ADD);
+
+ if( Get_Count() > 0 )
{
- switch( pObject->Get_ObjectType() )
- {
- case DATAOBJECT_TYPE_Grid:
- return( m_pGrids && m_pGrids ->Update_Views((CSG_Grid *)pObject) );
-
- case DATAOBJECT_TYPE_Table:
- return( m_pTables && m_pTables->Update_Views((CSG_Table *)pObject) );
-
- case DATAOBJECT_TYPE_Shapes:
- return( m_pShapes && m_pShapes->Update_Views((CSG_Shapes *)pObject) );
-
- case DATAOBJECT_TYPE_TIN:
- return( m_pTINs && m_pTINs ->Update_Views((CSG_TIN *)pObject) );
-
- case DATAOBJECT_TYPE_PointCloud:
- return( m_pPointClouds && m_pPointClouds->Update_Views((CSG_PointCloud *)pObject) );
-
- default:
- break;
- }
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Show(CSG_Data_Object *pObject, int Map_Mode)
-{
- if( pObject )
- {
- switch( pObject->Get_ObjectType() )
- {
- case DATAOBJECT_TYPE_Grid:
- return( m_pGrids && m_pGrids ->Show((CSG_Grid *)pObject, Map_Mode) );
-
- case DATAOBJECT_TYPE_Table:
- return( m_pTables && m_pTables->Show((CSG_Table *)pObject) );
-
- case DATAOBJECT_TYPE_Shapes:
- return( m_pShapes && m_pShapes->Show((CSG_Shapes *)pObject, Map_Mode) );
-
- case DATAOBJECT_TYPE_TIN:
- return( m_pTINs && m_pTINs ->Show((CSG_TIN *)pObject, Map_Mode) );
-
- case DATAOBJECT_TYPE_PointCloud:
- return( m_pPointClouds && m_pPointClouds->Show((CSG_PointCloud *)pObject, Map_Mode) );
-
- default:
- break;
- }
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_DATA_PROJECT_SAVE);
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_DATA_PROJECT_SAVE_AS);
+ pMenu->AppendSeparator();
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_SEARCH);
}
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::asImage(CSG_Data_Object *pObject, CSG_Grid *pImage)
-{
- if( pObject )
- {
- switch( pObject->Get_ObjectType() )
- {
- case DATAOBJECT_TYPE_Grid:
- return( m_pGrids && m_pGrids ->asImage((CSG_Grid *)pObject, pImage) );
-
- case DATAOBJECT_TYPE_Shapes:
- return( m_pShapes && m_pShapes->asImage((CSG_Shapes *)pObject, pImage) );
-
- case DATAOBJECT_TYPE_TIN:
- return( m_pTINs && m_pTINs ->asImage((CSG_TIN *)pObject, pImage) );
-
- case DATAOBJECT_TYPE_PointCloud:
- return( m_pPointClouds && m_pPointClouds->asImage((CSG_PointCloud *)pObject, pImage) );
-
- default:
- break;
- }
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Get_Colors(CSG_Data_Object *pObject, CSG_Colors *pColors)
-{
- if( pObject && pColors )
- {
- switch( pObject->Get_ObjectType() )
- {
- case DATAOBJECT_TYPE_Grid:
- return( m_pGrids ->Get_Colors((CSG_Grid *)pObject, pColors) );
-
- case DATAOBJECT_TYPE_Shapes:
- return( m_pShapes->Get_Colors((CSG_Shapes *)pObject, pColors) );
-
- case DATAOBJECT_TYPE_TIN:
- return( m_pTINs ->Get_Colors((CSG_TIN *)pObject, pColors) );
-
- case DATAOBJECT_TYPE_PointCloud:
- return( m_pPointClouds->Get_Colors((CSG_PointCloud *)pObject, pColors) );
-
- default:
- break;
- }
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Set_Colors(CSG_Data_Object *pObject, CSG_Colors *pColors)
-{
- if( pObject && pColors )
- {
- switch( pObject->Get_ObjectType() )
- {
- case DATAOBJECT_TYPE_Grid:
- return( m_pGrids ->Set_Colors((CSG_Grid *)pObject, pColors) );
-
- case DATAOBJECT_TYPE_Shapes:
- return( m_pShapes->Set_Colors((CSG_Shapes *)pObject, pColors) );
-
- case DATAOBJECT_TYPE_TIN:
- return( m_pTINs ->Set_Colors((CSG_TIN *)pObject, pColors) );
-
- case DATAOBJECT_TYPE_PointCloud:
- return( m_pPointClouds->Set_Colors((CSG_PointCloud *)pObject, pColors) );
-
- default:
- break;
- }
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Get_Parameters(CSG_Data_Object *pObject, CSG_Parameters *pParameters)
-{
- if( pObject && pParameters )
- {
- CWKSP_Base_Item *pItem;
-
- switch( pObject->Get_ObjectType() )
- {
- case DATAOBJECT_TYPE_Grid:
- pItem = (CWKSP_Base_Item *)m_pGrids ->Get_Grid ((CSG_Grid *)pObject);
- break;
-
- case DATAOBJECT_TYPE_Shapes:
- pItem = (CWKSP_Base_Item *)m_pShapes->Get_Shapes((CSG_Shapes *)pObject);
- break;
-
- case DATAOBJECT_TYPE_TIN:
- pItem = (CWKSP_Base_Item *)m_pTINs ->Get_TIN ((CSG_TIN *)pObject);
- break;
-
- case DATAOBJECT_TYPE_PointCloud:
- pItem = (CWKSP_Base_Item *)m_pPointClouds->Get_PointCloud((CSG_PointCloud *)pObject);
- break;
-
- case DATAOBJECT_TYPE_Table:
- pItem = (CWKSP_Base_Item *)m_pTables->Get_Table ((CSG_Table *)pObject);
- break;
-
- default:
- pItem = NULL;
- break;
- }
-
- if( pItem && pItem->Get_Parameters() )
- {
- return( pParameters->Assign(pItem->Get_Parameters()) != 0 );
- }
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Set_Parameters(CSG_Data_Object *pObject, CSG_Parameters *pParameters)
-{
- if( pObject && pParameters )
- {
- CWKSP_Base_Item *pItem;
-
- switch( pObject->Get_ObjectType() )
- {
- case DATAOBJECT_TYPE_Grid:
- pItem = (CWKSP_Base_Item *)m_pGrids ->Get_Grid ((CSG_Grid *)pObject);
- break;
-
- case DATAOBJECT_TYPE_Shapes:
- pItem = (CWKSP_Base_Item *)m_pShapes->Get_Shapes((CSG_Shapes *)pObject);
- break;
-
- case DATAOBJECT_TYPE_TIN:
- pItem = (CWKSP_Base_Item *)m_pTINs ->Get_TIN ((CSG_TIN *)pObject);
- break;
-
- case DATAOBJECT_TYPE_PointCloud:
- pItem = (CWKSP_Base_Item *)m_pPointClouds->Get_PointCloud((CSG_PointCloud *)pObject);
- break;
-
- case DATAOBJECT_TYPE_Table:
- pItem = (CWKSP_Base_Item *)m_pTables->Get_Table ((CSG_Table *)pObject);
- break;
-
- default:
- pItem = NULL;
- break;
- }
-
- if( pItem && pItem->Get_Parameters() )
- {
- if( pItem->Get_Parameters()->Assign_Values(pParameters) != 0 )
- {
- pItem->Parameters_Changed();
- }
- }
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "wksp_grid_system.h"
-#include "wksp_grid.h"
-#include "wksp_shapes_type.h"
-#include "wksp_shapes.h"
-#include "wksp_tin.h"
-#include "wksp_pointcloud.h"
-#include "wksp_table.h"
-
-//---------------------------------------------------------
-bool CWKSP_Data_Manager::Get_DataObject_List(CSG_Parameters *pParameters)
-{
- if( pParameters )
- {
- int i, j;
- CSG_String s;
- CWKSP_Shapes_Type *pShapes;
-
- pParameters->Destroy();
-
- for(i=0; i<Get_Grids()->Get_Count(); i++)
- {
- for(j=0; j<Get_Grids()->Get_System(i)->Get_Count(); j++)
- {
- s.Printf(wxT("GRID_%03d_%03d"), i, j);
- pParameters->Add_Grid(NULL, s, s, LNG(""), PARAMETER_INPUT)
- ->Set_Value(Get_Grids()->Get_System(i)->Get_Grid(j)->Get_Grid());
- }
- }
-
- for(i=0; i<Get_PointClouds()->Get_Count(); i++)
- {
- s.Printf(wxT("POINTCLOUD_%03d"), i);
- pParameters->Add_PointCloud(NULL, s, s, LNG(""), PARAMETER_INPUT)
- ->Set_Value(Get_PointClouds()->Get_PointCloud(i)->Get_PointCloud());
- }
-
- if( (pShapes = Get_Shapes()->Get_Shapes_Type(SHAPE_TYPE_Point)) != NULL )
- {
- for(i=0; i<pShapes->Get_Count(); i++)
- {
- s.Printf(wxT("POINT_%03d"), i);
- pParameters->Add_Shapes(NULL, s, s, LNG(""), PARAMETER_INPUT)
- ->Set_Value(pShapes->Get_Shapes(i)->Get_Shapes());
- }
- }
-
- if( (pShapes = Get_Shapes()->Get_Shapes_Type(SHAPE_TYPE_Points)) != NULL )
- {
- for(i=0; i<pShapes->Get_Count(); i++)
- {
- s.Printf(wxT("POINTS_%03d"), i);
- pParameters->Add_Shapes(NULL, s, s, LNG(""), PARAMETER_INPUT)
- ->Set_Value(pShapes->Get_Shapes(i)->Get_Shapes());
- }
- }
-
- if( (pShapes = Get_Shapes()->Get_Shapes_Type(SHAPE_TYPE_Line)) != NULL )
- {
- for(i=0; i<pShapes->Get_Count(); i++)
- {
- s.Printf(wxT("LINE_%03d"), i);
- pParameters->Add_Shapes(NULL, s, s, LNG(""), PARAMETER_INPUT)
- ->Set_Value(pShapes->Get_Shapes(i)->Get_Shapes());
- }
- }
-
- if( (pShapes = Get_Shapes()->Get_Shapes_Type(SHAPE_TYPE_Polygon)) != NULL )
- {
- for(i=0; i<pShapes->Get_Count(); i++)
- {
- s.Printf(wxT("POLYGON_%03d"), i);
- pParameters->Add_Shapes(NULL, s, s, LNG(""), PARAMETER_INPUT)
- ->Set_Value(pShapes->Get_Shapes(i)->Get_Shapes());
- }
- }
-
- for(i=0; i<Get_Tables()->Get_Count(); i++)
- {
- s.Printf(wxT("TABLE_%03d"), i);
- pParameters->Add_Table(NULL, s, s, LNG(""), PARAMETER_INPUT)
- ->Set_Value(Get_Tables()->Get_Table(i)->Get_Table());
- }
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+ return( pMenu );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::On_Command(int Cmd_ID)
+{
+ //-----------------------------------------------------
+ if( Open_CMD(Cmd_ID) )
+ {
+ return( true );
+ }
+
+ if( m_pTables && Cmd_ID >= ID_CMD_TABLES_FIRST && Cmd_ID <= ID_CMD_TABLES_LAST && m_pTables->On_Command(Cmd_ID) )
+ {
+ return( true );
+ }
+
+ if( m_pShapes && Cmd_ID >= ID_CMD_SHAPES_FIRST && Cmd_ID <= ID_CMD_SHAPES_LAST && m_pShapes->On_Command(Cmd_ID) )
+ {
+ return( true );
+ }
+
+ if( m_pTINs && Cmd_ID >= ID_CMD_TIN_FIRST && Cmd_ID <= ID_CMD_TIN_LAST && m_pTINs ->On_Command(Cmd_ID) )
+ {
+ return( true );
+ }
+
+ if( m_pPointClouds && Cmd_ID >= ID_CMD_POINTCLOUD_FIRST && Cmd_ID <= ID_CMD_POINTCLOUD_LAST && m_pPointClouds->On_Command(Cmd_ID) )
+ {
+ return( true );
+ }
+
+ if( m_pGrids && Cmd_ID >= ID_CMD_GRIDS_FIRST && Cmd_ID <= ID_CMD_GRIDS_LAST && m_pGrids ->On_Command(Cmd_ID) )
+ {
+ return( true );
+ }
+
+ //-----------------------------------------------------
+ switch( Cmd_ID )
+ {
+ default:
+ return( CWKSP_Base_Manager::On_Command(Cmd_ID) );
+
+ //-----------------------------------------------------
+ case ID_CMD_DATA_PROJECT_NEW: Close(false); break;
+ case ID_CMD_DATA_PROJECT_OPEN: m_pProject->Load(false); break;
+ case ID_CMD_DATA_PROJECT_OPEN_ADD: m_pProject->Load(true); break;
+ case ID_CMD_DATA_PROJECT_SAVE: m_pProject->Save(true); break;
+ case ID_CMD_DATA_PROJECT_SAVE_AS: m_pProject->Save(); break;
+
+ //-----------------------------------------------------
+ case ID_CMD_TABLES_OPEN: Open(DATAOBJECT_TYPE_Table); break;
+ case ID_CMD_SHAPES_OPEN: Open(DATAOBJECT_TYPE_Shapes); break;
+ case ID_CMD_TIN_OPEN: Open(DATAOBJECT_TYPE_TIN); break;
+ case ID_CMD_POINTCLOUD_OPEN: Open(DATAOBJECT_TYPE_PointCloud); break;
+ case ID_CMD_GRIDS_OPEN: Open(DATAOBJECT_TYPE_Grid); break;
+
+ //-----------------------------------------------------
+ case ID_CMD_WKSP_ITEM_RETURN:
+ break;
+
+ case ID_CMD_WKSP_ITEM_CLOSE:
+ Close(false);
+ break;
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::On_Command_UI(wxUpdateUIEvent &event)
+{
+ switch( event.GetId() )
+ {
+ default:
+ return( CWKSP_Base_Manager::On_Command_UI(event) );
+
+ case ID_CMD_DATA_PROJECT_NEW:
+ event.Enable(Get_Count() > 0 && g_pModule == NULL);
+ break;
+
+ case ID_CMD_WKSP_ITEM_CLOSE:
+ event.Enable(Get_Count() > 0 && g_pModule == NULL);
+ break;
+
+ case ID_CMD_DATA_PROJECT_SAVE:
+ event.Enable(Get_Count() > 0 && m_pProject->Has_File_Name() );
+ break;
+
+ case ID_CMD_DATA_PROJECT_SAVE_AS:
+ event.Enable(Get_Count() > 0);
+ break;
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CWKSP_Data_Manager::Parameters_Changed(void)
+{
+ SG_Grid_Cache_Set_Automatic (m_Parameters("GRID_MEM_CACHE_AUTO") ->asBool());
+ SG_Grid_Cache_Set_Threshold_MB (m_Parameters("GRID_MEM_CACHE_THRSHLD") ->asDouble());
+ SG_Grid_Cache_Set_Confirm (m_Parameters("GRID_MEM_CACHE_CONFIRM") ->asInt());
+ SG_Grid_Cache_Set_Directory (m_Parameters("GRID_MEM_CACHE_TMPDIR") ->asString());
+
+ CWKSP_Base_Manager::Parameters_Changed();
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Check_Parameters(CSG_Parameters *pParameters)
+{
+ if( pParameters )
+ {
+ for(int i=0; i<pParameters->Get_Count(); i++)
+ {
+ Check_Parameter(pParameters->Get_Parameter(i));
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Check_Parameter(CSG_Parameter *pParameter)
+{
+ bool bResult = true;
+ int i, DataObject_Type;
+
+ if( pParameter )
+ {
+ switch( pParameter->Get_Type() )
+ {
+ default: DataObject_Type = -1; break;
+ case PARAMETER_TYPE_Grid:
+ case PARAMETER_TYPE_Grid_List: DataObject_Type = DATAOBJECT_TYPE_Grid; break;
+ case PARAMETER_TYPE_Table:
+ case PARAMETER_TYPE_Table_List: DataObject_Type = DATAOBJECT_TYPE_Table; break;
+ case PARAMETER_TYPE_Shapes:
+ case PARAMETER_TYPE_Shapes_List: DataObject_Type = DATAOBJECT_TYPE_Shapes; break;
+ case PARAMETER_TYPE_TIN:
+ case PARAMETER_TYPE_TIN_List: DataObject_Type = DATAOBJECT_TYPE_TIN; break;
+ case PARAMETER_TYPE_PointCloud:
+ case PARAMETER_TYPE_PointCloud_List: DataObject_Type = DATAOBJECT_TYPE_PointCloud; break;
+ }
+
+ //-------------------------------------------------
+ switch( pParameter->Get_Type() )
+ {
+ default:
+ break;
+
+ case PARAMETER_TYPE_Grid_System:
+ if( !Exists(pParameter->asGrid_System()) )
+ {
+ bResult = false;
+ pParameter->Set_Value((void *)NULL);
+ }
+ break;
+
+ case PARAMETER_TYPE_Grid:
+ case PARAMETER_TYPE_Table:
+ case PARAMETER_TYPE_Shapes:
+ case PARAMETER_TYPE_TIN:
+ case PARAMETER_TYPE_PointCloud:
+ if( pParameter->asDataObject() != DATAOBJECT_NOTSET
+ && pParameter->asDataObject() != DATAOBJECT_CREATE
+ && !Exists(pParameter->asDataObject(), DataObject_Type) )
+ {
+ bResult = false;
+ pParameter->Set_Value(DATAOBJECT_NOTSET);
+ }
+ break;
+
+ case PARAMETER_TYPE_Grid_List:
+ case PARAMETER_TYPE_Table_List:
+ case PARAMETER_TYPE_Shapes_List:
+ case PARAMETER_TYPE_TIN_List:
+ case PARAMETER_TYPE_PointCloud_List:
+ for(i=pParameter->asList()->Get_Count()-1; i>=0; i--)
+ {
+ if( !Exists(pParameter->asList()->asDataObject(i), DataObject_Type) )
+ {
+ bResult = false;
+ pParameter->asList()->Del_Item(i);
+ }
+ }
+ break;
+ }
+ }
+
+ return( bResult );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Open_CMD(int Cmd_ID)
+{
+ return( m_pMenu_Files->Recent_Open(Cmd_ID) );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Open(const wxChar *File_Name)
+{
+ if( SG_File_Cmp_Extension(File_Name, wxT("txt"))
+ || SG_File_Cmp_Extension(File_Name, wxT("dbf")) )
+ {
+ return( Open(DATAOBJECT_TYPE_Table , File_Name) != NULL );
+ }
+
+ if( SG_File_Cmp_Extension(File_Name, wxT("shp")) )
+ {
+ return( Open(DATAOBJECT_TYPE_Shapes, File_Name) != NULL );
+ }
+
+ if( SG_File_Cmp_Extension(File_Name, wxT("spc")) )
+ {
+ return( Open(DATAOBJECT_TYPE_PointCloud, File_Name) != NULL );
+ }
+
+ if( SG_File_Cmp_Extension(File_Name, wxT("sgrd"))
+ || SG_File_Cmp_Extension(File_Name, wxT("dgm"))
+ || SG_File_Cmp_Extension(File_Name, wxT("grd")) )
+ {
+ return( Open(DATAOBJECT_TYPE_Grid , File_Name) != NULL );
+ }
+
+ if( SG_File_Cmp_Extension(File_Name, wxT("sprj")) )
+ {
+ return( m_pProject->Load(File_Name, false, true) );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Open(int DataType)
+{
+ int ID;
+ wxArrayString File_Paths;
+
+ switch( DataType )
+ {
+ default: return( false );
+ case DATAOBJECT_TYPE_Table: ID = ID_DLG_TABLES_OPEN; break;
+ case DATAOBJECT_TYPE_Shapes: ID = ID_DLG_SHAPES_OPEN; break;
+ case DATAOBJECT_TYPE_TIN: ID = ID_DLG_TIN_OPEN; break;
+ case DATAOBJECT_TYPE_PointCloud: ID = ID_DLG_POINTCLOUD_OPEN; break;
+ case DATAOBJECT_TYPE_Grid: ID = ID_DLG_GRIDS_OPEN; break;
+ }
+
+ if( DLG_Open(File_Paths, ID) )
+ {
+ MSG_General_Add_Line();
+
+ for(size_t i=0; i<File_Paths.GetCount(); i++)
+ {
+ Open(DataType, File_Paths[i]);
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+CWKSP_Base_Item * CWKSP_Data_Manager::Open(int DataType, const wxChar *FileName)
+{
+ CSG_Data_Object *pObject;
+ CWKSP_Base_Item *pItem;
+
+ switch( DataType )
+ {
+ default:
+ pObject = NULL;
+ break;
+
+ case DATAOBJECT_TYPE_Table:
+ pObject = new CSG_Table (FileName);
+ break;
+
+ case DATAOBJECT_TYPE_Shapes:
+ pObject = new CSG_Shapes (FileName);
+ break;
+
+ case DATAOBJECT_TYPE_TIN:
+ pObject = new CSG_TIN (FileName);
+ break;
+
+ case DATAOBJECT_TYPE_PointCloud:
+ pObject = new CSG_PointCloud(FileName);
+ break;
+
+ case DATAOBJECT_TYPE_Grid:
+ pObject = new CSG_Grid (FileName);
+ break;
+ }
+
+ PROCESS_Set_Okay();
+
+ if( pObject )
+ {
+ if( pObject->is_Valid() && (pItem = Add(pObject)) != NULL )
+ {
+ m_pMenu_Files->Recent_Add(DataType, FileName);
+
+ return( pItem );
+ }
+
+ delete(pObject);
+ }
+
+ m_pMenu_Files->Recent_Del(DataType, FileName);
+
+ return( NULL );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Exists(CSG_Grid_System *pSystem)
+{
+ return( m_pGrids && m_pGrids->Exists(pSystem) );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Exists(CSG_Data_Object *pObject, int Type)
+{
+ switch( Type )
+ {
+ case DATAOBJECT_TYPE_Grid:
+ return( m_pGrids && m_pGrids ->Exists((CSG_Grid *)pObject) );
+
+ case DATAOBJECT_TYPE_Table:
+ return(
+ ( m_pTables && m_pTables ->Exists((CSG_Table *)pObject) )
+ || ( m_pShapes && m_pShapes ->Exists((CSG_Shapes *)pObject) )
+ );
+
+ case DATAOBJECT_TYPE_Shapes:
+ return(
+ ( m_pShapes && m_pShapes ->Exists((CSG_Shapes *)pObject) )
+ || ( m_pPointClouds && m_pPointClouds->Exists((CSG_PointCloud *)pObject) )
+ );
+
+ case DATAOBJECT_TYPE_TIN:
+ return( m_pTINs && m_pTINs ->Exists((CSG_TIN *)pObject) );
+
+ case DATAOBJECT_TYPE_PointCloud:
+ return( m_pPointClouds && m_pPointClouds->Exists((CSG_PointCloud *)pObject) );
+ }
+
+ return( Exists(pObject, DATAOBJECT_TYPE_Table)
+ || Exists(pObject, DATAOBJECT_TYPE_Shapes)
+ || Exists(pObject, DATAOBJECT_TYPE_TIN)
+ || Exists(pObject, DATAOBJECT_TYPE_PointCloud)
+ || Exists(pObject, DATAOBJECT_TYPE_Grid)
+ );
+}
+
+//---------------------------------------------------------
+CSG_Data_Object * CWKSP_Data_Manager::Get_byFileName(const wxChar *File_Name, int Type)
+{
+ switch( Type )
+ {
+ case DATAOBJECT_TYPE_Grid:
+ return( !m_pGrids ? NULL : m_pGrids ->Get_byFileName(File_Name) );
+
+ case DATAOBJECT_TYPE_Table:
+ return( !m_pTables ? NULL : m_pTables->Get_byFileName(File_Name) );
+
+ case DATAOBJECT_TYPE_Shapes:
+ return( !m_pShapes ? NULL : m_pShapes->Get_byFileName(File_Name) );
+
+ case DATAOBJECT_TYPE_TIN:
+ return( !m_pTINs ? NULL : m_pTINs ->Get_byFileName(File_Name) );
+
+ case DATAOBJECT_TYPE_PointCloud:
+ return( !m_pPointClouds ? NULL : m_pPointClouds->Get_byFileName(File_Name) );
+ }
+
+ CSG_Data_Object *pObject;
+
+ if( (pObject = Get_byFileName(File_Name, DATAOBJECT_TYPE_Table)) != NULL ) return( pObject );
+ if( (pObject = Get_byFileName(File_Name, DATAOBJECT_TYPE_Shapes)) != NULL ) return( pObject );
+ if( (pObject = Get_byFileName(File_Name, DATAOBJECT_TYPE_TIN)) != NULL ) return( pObject );
+ if( (pObject = Get_byFileName(File_Name, DATAOBJECT_TYPE_Grid)) != NULL ) return( pObject );
+
+ return( NULL );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Save_Modified(CWKSP_Base_Item *pItem)
+{
+ return( m_pProject->Save_Modified(pItem) );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Save_Modified_Sel(void)
+{
+ return( m_pProject->Save_Modified(this, true) );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Close(bool bSilent)
+{
+ if( Get_Count() == 0 )
+ {
+ Finalise();
+
+ return( true );
+ }
+ else if( (bSilent || DLG_Message_Confirm(LNG("[TXT] Close all data sets"), LNG("[CAP] Close"))) && Save_Modified(this) )
+ {
+ Finalise();
+
+ g_pACTIVE->Get_Parameters()->Restore_Parameters();
+ g_pMaps->Close(true);
+
+ return( g_pData_Ctrl->Close(true) );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CWKSP_Base_Item * CWKSP_Data_Manager::Add(CSG_Data_Object *pObject)
+{
+ if( pObject && _Get_Manager(pObject->Get_ObjectType()) )
+ {
+ switch( pObject->Get_ObjectType() )
+ {
+ case DATAOBJECT_TYPE_Grid:
+ return( (CWKSP_Base_Item *)m_pGrids ->Add((CSG_Grid *)pObject) );
+
+ case DATAOBJECT_TYPE_Table:
+ return( (CWKSP_Base_Item *)m_pTables->Add((CSG_Table *)pObject) );
+
+ case DATAOBJECT_TYPE_Shapes:
+ return( (CWKSP_Base_Item *)m_pShapes->Add((CSG_Shapes *)pObject) );
+
+ case DATAOBJECT_TYPE_TIN:
+ return( (CWKSP_Base_Item *)m_pTINs ->Add((CSG_TIN *)pObject) );
+
+ case DATAOBJECT_TYPE_PointCloud:
+ return( (CWKSP_Base_Item *)m_pPointClouds->Add((CSG_PointCloud *)pObject) );
+
+ default:
+ return( NULL );
+ }
+ }
+
+ return( NULL );
+}
+
+//---------------------------------------------------------
+void CWKSP_Data_Manager::Del_Manager(CWKSP_Base_Item *pItem)
+{
+ if( pItem == m_pGrids )
+ {
+ m_pGrids = NULL;
+ }
+ else if( pItem == m_pTables )
+ {
+ m_pTables = NULL;
+ }
+ else if( pItem == m_pShapes )
+ {
+ m_pShapes = NULL;
+ }
+ else if( pItem == m_pTINs )
+ {
+ m_pTINs = NULL;
+ }
+ else if( pItem == m_pPointClouds )
+ {
+ m_pPointClouds = NULL;
+ }
+
+ if( Get_Count() == 0 )
+ {
+ m_pProject->Clr_File_Name();
+ }
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::_Get_Manager(int DataType)
+{
+ switch( DataType )
+ {
+ default:
+ return( false );
+
+ case DATAOBJECT_TYPE_Grid:
+ if( !m_pGrids )
+ {
+ Add_Item(m_pGrids = new CWKSP_Grid_Manager);
+ }
+
+ return( m_pGrids != NULL );
+
+ case DATAOBJECT_TYPE_Table:
+ if( !m_pTables )
+ {
+ Add_Item(m_pTables = new CWKSP_Table_Manager);
+ }
+
+ return( m_pTables != NULL );
+
+ case DATAOBJECT_TYPE_Shapes:
+ if( !m_pShapes )
+ {
+ Add_Item(m_pShapes = new CWKSP_Shapes_Manager);
+ }
+
+ return( m_pShapes != NULL );
+
+ case DATAOBJECT_TYPE_TIN:
+ if( !m_pTINs )
+ {
+ Add_Item(m_pTINs = new CWKSP_TIN_Manager);
+ }
+
+ return( m_pTINs != NULL );
+
+ case DATAOBJECT_TYPE_PointCloud:
+ if( !m_pPointClouds )
+ {
+ Add_Item(m_pPointClouds = new CWKSP_PointCloud_Manager);
+ }
+
+ return( m_pPointClouds != NULL );
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Update(CSG_Data_Object *pObject, CSG_Parameters *pParameters)
+{
+ if( pObject )
+ {
+ switch( pObject->Get_ObjectType() )
+ {
+ case DATAOBJECT_TYPE_Grid:
+ return( m_pGrids && m_pGrids ->Update((CSG_Grid *)pObject, pParameters) );
+
+ case DATAOBJECT_TYPE_Table:
+ return( m_pTables && m_pTables->Update((CSG_Table *)pObject, pParameters) );
+
+ case DATAOBJECT_TYPE_Shapes:
+ return( m_pShapes && m_pShapes->Update((CSG_Shapes *)pObject, pParameters) );
+
+ case DATAOBJECT_TYPE_TIN:
+ return( m_pTINs && m_pTINs ->Update((CSG_TIN *)pObject, pParameters) );
+
+ case DATAOBJECT_TYPE_PointCloud:
+ return( m_pPointClouds && m_pPointClouds->Update((CSG_PointCloud *)pObject, pParameters) );
+
+ default:
+ break;
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Update_Views(CSG_Data_Object *pObject)
+{
+ if( pObject )
+ {
+ switch( pObject->Get_ObjectType() )
+ {
+ case DATAOBJECT_TYPE_Grid:
+ return( m_pGrids && m_pGrids ->Update_Views((CSG_Grid *)pObject) );
+
+ case DATAOBJECT_TYPE_Table:
+ return( m_pTables && m_pTables->Update_Views((CSG_Table *)pObject) );
+
+ case DATAOBJECT_TYPE_Shapes:
+ return( m_pShapes && m_pShapes->Update_Views((CSG_Shapes *)pObject) );
+
+ case DATAOBJECT_TYPE_TIN:
+ return( m_pTINs && m_pTINs ->Update_Views((CSG_TIN *)pObject) );
+
+ case DATAOBJECT_TYPE_PointCloud:
+ return( m_pPointClouds && m_pPointClouds->Update_Views((CSG_PointCloud *)pObject) );
+
+ default:
+ break;
+ }
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Show(CSG_Data_Object *pObject, int Map_Mode)
+{
+ if( pObject )
+ {
+ switch( pObject->Get_ObjectType() )
+ {
+ case DATAOBJECT_TYPE_Grid:
+ return( m_pGrids && m_pGrids ->Show((CSG_Grid *)pObject, Map_Mode) );
+
+ case DATAOBJECT_TYPE_Table:
+ return( m_pTables && m_pTables->Show((CSG_Table *)pObject) );
+
+ case DATAOBJECT_TYPE_Shapes:
+ return( m_pShapes && m_pShapes->Show((CSG_Shapes *)pObject, Map_Mode) );
+
+ case DATAOBJECT_TYPE_TIN:
+ return( m_pTINs && m_pTINs ->Show((CSG_TIN *)pObject, Map_Mode) );
+
+ case DATAOBJECT_TYPE_PointCloud:
+ return( m_pPointClouds && m_pPointClouds->Show((CSG_PointCloud *)pObject, Map_Mode) );
+
+ default:
+ break;
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::asImage(CSG_Data_Object *pObject, CSG_Grid *pImage)
+{
+ if( pObject )
+ {
+ switch( pObject->Get_ObjectType() )
+ {
+ case DATAOBJECT_TYPE_Grid:
+ return( m_pGrids && m_pGrids ->asImage((CSG_Grid *)pObject, pImage) );
+
+ case DATAOBJECT_TYPE_Shapes:
+ return( m_pShapes && m_pShapes->asImage((CSG_Shapes *)pObject, pImage) );
+
+ case DATAOBJECT_TYPE_TIN:
+ return( m_pTINs && m_pTINs ->asImage((CSG_TIN *)pObject, pImage) );
+
+ case DATAOBJECT_TYPE_PointCloud:
+ return( m_pPointClouds && m_pPointClouds->asImage((CSG_PointCloud *)pObject, pImage) );
+
+ default:
+ break;
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Get_Colors(CSG_Data_Object *pObject, CSG_Colors *pColors)
+{
+ if( pObject && pColors )
+ {
+ switch( pObject->Get_ObjectType() )
+ {
+ case DATAOBJECT_TYPE_Grid:
+ return( m_pGrids ->Get_Colors((CSG_Grid *)pObject, pColors) );
+
+ case DATAOBJECT_TYPE_Shapes:
+ return( m_pShapes->Get_Colors((CSG_Shapes *)pObject, pColors) );
+
+ case DATAOBJECT_TYPE_TIN:
+ return( m_pTINs ->Get_Colors((CSG_TIN *)pObject, pColors) );
+
+ case DATAOBJECT_TYPE_PointCloud:
+ return( m_pPointClouds->Get_Colors((CSG_PointCloud *)pObject, pColors) );
+
+ default:
+ break;
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Set_Colors(CSG_Data_Object *pObject, CSG_Colors *pColors)
+{
+ if( pObject && pColors )
+ {
+ switch( pObject->Get_ObjectType() )
+ {
+ case DATAOBJECT_TYPE_Grid:
+ return( m_pGrids ->Set_Colors((CSG_Grid *)pObject, pColors) );
+
+ case DATAOBJECT_TYPE_Shapes:
+ return( m_pShapes->Set_Colors((CSG_Shapes *)pObject, pColors) );
+
+ case DATAOBJECT_TYPE_TIN:
+ return( m_pTINs ->Set_Colors((CSG_TIN *)pObject, pColors) );
+
+ case DATAOBJECT_TYPE_PointCloud:
+ return( m_pPointClouds->Set_Colors((CSG_PointCloud *)pObject, pColors) );
+
+ default:
+ break;
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Get_Parameters(CSG_Data_Object *pObject, CSG_Parameters *pParameters)
+{
+ if( pObject && pParameters )
+ {
+ CWKSP_Base_Item *pItem = NULL;
+
+ switch( pObject->Get_ObjectType() )
+ {
+ case DATAOBJECT_TYPE_Grid:
+ if( m_pGrids ) pItem = (CWKSP_Base_Item *)m_pGrids ->Get_Grid ((CSG_Grid *)pObject);
+ break;
+
+ case DATAOBJECT_TYPE_Shapes:
+ if( m_pShapes ) pItem = (CWKSP_Base_Item *)m_pShapes ->Get_Shapes ((CSG_Shapes *)pObject);
+ break;
+
+ case DATAOBJECT_TYPE_TIN:
+ if( m_pTINs ) pItem = (CWKSP_Base_Item *)m_pTINs ->Get_TIN ((CSG_TIN *)pObject);
+ break;
+
+ case DATAOBJECT_TYPE_PointCloud:
+ if( m_pPointClouds ) pItem = (CWKSP_Base_Item *)m_pPointClouds->Get_PointCloud((CSG_PointCloud *)pObject);
+ break;
+
+ case DATAOBJECT_TYPE_Table:
+ if( m_pTables ) pItem = (CWKSP_Base_Item *)m_pTables ->Get_Table ((CSG_Table *)pObject);
+ break;
+
+ default:
+ break;
+ }
+
+ if( pItem && pItem->Get_Parameters() )
+ {
+ return( pParameters->Assign(pItem->Get_Parameters()) != 0 );
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Set_Parameters(CSG_Data_Object *pObject, CSG_Parameters *pParameters)
+{
+ if( pObject && pParameters )
+ {
+ CWKSP_Base_Item *pItem;
+
+ switch( pObject->Get_ObjectType() )
+ {
+ case DATAOBJECT_TYPE_Grid:
+ pItem = (CWKSP_Base_Item *)m_pGrids ->Get_Grid ((CSG_Grid *)pObject);
+ break;
+
+ case DATAOBJECT_TYPE_Shapes:
+ pItem = (CWKSP_Base_Item *)m_pShapes->Get_Shapes((CSG_Shapes *)pObject);
+ break;
+
+ case DATAOBJECT_TYPE_TIN:
+ pItem = (CWKSP_Base_Item *)m_pTINs ->Get_TIN ((CSG_TIN *)pObject);
+ break;
+
+ case DATAOBJECT_TYPE_PointCloud:
+ pItem = (CWKSP_Base_Item *)m_pPointClouds->Get_PointCloud((CSG_PointCloud *)pObject);
+ break;
+
+ case DATAOBJECT_TYPE_Table:
+ pItem = (CWKSP_Base_Item *)m_pTables->Get_Table ((CSG_Table *)pObject);
+ break;
+
+ default:
+ pItem = NULL;
+ break;
+ }
+
+ if( pItem && pItem->Get_Parameters() )
+ {
+ if( pItem->Get_Parameters()->Assign_Values(pParameters) != 0 )
+ {
+ pItem->Parameters_Changed();
+ }
+ }
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "wksp_grid_system.h"
+#include "wksp_grid.h"
+#include "wksp_shapes_type.h"
+#include "wksp_shapes.h"
+#include "wksp_tin.h"
+#include "wksp_pointcloud.h"
+#include "wksp_table.h"
+
+//---------------------------------------------------------
+bool CWKSP_Data_Manager::Get_DataObject_List(CSG_Parameters *pParameters)
+{
+ if( pParameters )
+ {
+ int i, j;
+ CSG_String s;
+ CWKSP_Shapes_Type *pShapes;
+
+ pParameters->Destroy();
+
+ for(i=0; i<Get_Grids()->Get_Count(); i++)
+ {
+ for(j=0; j<Get_Grids()->Get_System(i)->Get_Count(); j++)
+ {
+ s.Printf(wxT("GRID_%03d_%03d"), i, j);
+ pParameters->Add_Grid(NULL, s, s, LNG(""), PARAMETER_INPUT)
+ ->Set_Value(Get_Grids()->Get_System(i)->Get_Grid(j)->Get_Grid());
+ }
+ }
+
+ for(i=0; i<Get_PointClouds()->Get_Count(); i++)
+ {
+ s.Printf(wxT("POINTCLOUD_%03d"), i);
+ pParameters->Add_PointCloud(NULL, s, s, LNG(""), PARAMETER_INPUT)
+ ->Set_Value(Get_PointClouds()->Get_PointCloud(i)->Get_PointCloud());
+ }
+
+ if( (pShapes = Get_Shapes()->Get_Shapes_Type(SHAPE_TYPE_Point)) != NULL )
+ {
+ for(i=0; i<pShapes->Get_Count(); i++)
+ {
+ s.Printf(wxT("POINT_%03d"), i);
+ pParameters->Add_Shapes(NULL, s, s, LNG(""), PARAMETER_INPUT)
+ ->Set_Value(pShapes->Get_Shapes(i)->Get_Shapes());
+ }
+ }
+
+ if( (pShapes = Get_Shapes()->Get_Shapes_Type(SHAPE_TYPE_Points)) != NULL )
+ {
+ for(i=0; i<pShapes->Get_Count(); i++)
+ {
+ s.Printf(wxT("POINTS_%03d"), i);
+ pParameters->Add_Shapes(NULL, s, s, LNG(""), PARAMETER_INPUT)
+ ->Set_Value(pShapes->Get_Shapes(i)->Get_Shapes());
+ }
+ }
+
+ if( (pShapes = Get_Shapes()->Get_Shapes_Type(SHAPE_TYPE_Line)) != NULL )
+ {
+ for(i=0; i<pShapes->Get_Count(); i++)
+ {
+ s.Printf(wxT("LINE_%03d"), i);
+ pParameters->Add_Shapes(NULL, s, s, LNG(""), PARAMETER_INPUT)
+ ->Set_Value(pShapes->Get_Shapes(i)->Get_Shapes());
+ }
+ }
+
+ if( (pShapes = Get_Shapes()->Get_Shapes_Type(SHAPE_TYPE_Polygon)) != NULL )
+ {
+ for(i=0; i<pShapes->Get_Count(); i++)
+ {
+ s.Printf(wxT("POLYGON_%03d"), i);
+ pParameters->Add_Shapes(NULL, s, s, LNG(""), PARAMETER_INPUT)
+ ->Set_Value(pShapes->Get_Shapes(i)->Get_Shapes());
+ }
+ }
+
+ for(i=0; i<Get_Tables()->Get_Count(); i++)
+ {
+ s.Printf(wxT("TABLE_%03d"), i);
+ pParameters->Add_Table(NULL, s, s, LNG(""), PARAMETER_INPUT)
+ ->Set_Value(Get_Tables()->Get_Table(i)->Get_Table());
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_gui/wksp_grid.cpp b/src/saga_core/saga_gui/wksp_grid.cpp
index 3dc23ee..d867e7a 100644
--- a/src/saga_core/saga_gui/wksp_grid.cpp
+++ b/src/saga_core/saga_gui/wksp_grid.cpp
@@ -76,6 +76,9 @@
#include "wksp_layer_classify.h"
#include "wksp_layer_legend.h"
+
+#include "wksp_data_manager.h"
+#include "wksp_grid_manager.h"
#include "wksp_grid.h"
#include "view_scatterplot.h"
@@ -91,9 +94,12 @@
CWKSP_Grid::CWKSP_Grid(CSG_Grid *pGrid)
: CWKSP_Layer(pGrid)
{
- m_pGrid = pGrid;
+ m_pGrid = pGrid;
+
+ m_pOverlay[0] = NULL;
+ m_pOverlay[1] = NULL;
- m_Sel_xN = -1;
+ m_Sel_xN = -1;
Create_Parameters();
}
@@ -134,6 +140,10 @@ wxString CWKSP_Grid::Get_Description(void)
LNG("[CAP] File") , m_pGrid->Get_File_Name()
));
+ s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%s</td></tr>"),
+ LNG("[CAP] Projection") , m_pGrid->Get_Projection().Get_Name().c_str()
+ ));
+
s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%d (x) * %d (y) = %ld</td></tr>"),
LNG("[CAP] Number of cells") , m_pGrid->Get_NX(), m_pGrid->Get_NY(), m_pGrid->Get_NCells()
));
@@ -327,11 +337,6 @@ void CWKSP_Grid::On_Create_Parameters(void)
PARAMETER_TYPE_Double
);
- m_Parameters.Add_Range(
- m_Parameters("NODE_GENERAL") , "GENERAL_Z_NODATA" , LNG("[CAP] No Data"),
- LNG("")
- );
-
//-----------------------------------------------------
// Memory...
@@ -384,17 +389,70 @@ void CWKSP_Grid::On_Create_Parameters(void)
// Classification...
((CSG_Parameter_Choice *)m_Parameters("COLORS_TYPE")->Get_Data())->Set_Items(
- wxString::Format(wxT("%s|%s|%s|%s|%s|"),
+ wxString::Format(wxT("%s|%s|%s|%s|%s|%s|"),
LNG("[VAL] Unique Symbol"),
LNG("[VAL] Lookup Table"),
LNG("[VAL] Graduated Color"),
LNG("[VAL] RGB"),
- LNG("[VAL] Shade")
+ LNG("[VAL] Shade"),
+ LNG("[VAL] RGB Overlay")
)
);
m_Parameters("COLORS_TYPE")->Set_Value(CLASSIFY_METRIC);
+ //-----------------------------------------------------
+ m_Parameters.Add_Node(
+ m_Parameters("NODE_COLORS") , "NODE_SHADE" , LNG("[CAP] Shade"),
+ LNG("")
+ );
+
+ m_Parameters.Add_Choice(
+ m_Parameters("NODE_SHADE") , "SHADE_MODE" , LNG("[CAP] Coloring"),
+ LNG(""),
+ wxString::Format(wxT("%s|%s|%s|%s|%s|%s|%s|%s|"),
+ LNG("bright - dark"),
+ LNG("dark - bright"),
+ LNG("white - cyan"),
+ LNG("cyan - white"),
+ LNG("white - magenta"),
+ LNG("magenta - white"),
+ LNG("white - yellow"),
+ LNG("yellow - white")
+ ), 0
+ );
+
+ //-----------------------------------------------------
+ m_Parameters.Add_Node(
+ m_Parameters("NODE_COLORS") , "NODE_OVERLAY" , LNG("[CAP] RGB Overlay"),
+ LNG("")
+ );
+
+ m_Parameters.Add_Choice(
+ m_Parameters("NODE_OVERLAY") , "OVERLAY_MODE" , LNG("[CAP] Coloring"),
+ LNG(""),
+ wxString::Format(wxT("%s|%s|%s|%s|%s|%s|"),
+ LNG("red=this, green=1, blue=2"),
+ LNG("red=this, green=2, blue=1"),
+ LNG("red=1, green=this, blue=2"),
+ LNG("red=2, green=this, blue=1"),
+ LNG("red=1, green=2, blue=this"),
+ LNG("red=2, green=1, blue=this")
+ ), 0
+ );
+
+ m_Parameters.Add_Grid(
+ m_Parameters("NODE_OVERLAY") , "OVERLAY_1" , LNG("[CAP] Overlay 1"),
+ LNG(""),
+ PARAMETER_INPUT_OPTIONAL, false
+ );
+
+ m_Parameters.Add_Grid(
+ m_Parameters("NODE_OVERLAY") , "OVERLAY_2" , LNG("[CAP] Overlay 2"),
+ LNG(""),
+ PARAMETER_INPUT_OPTIONAL, false
+ );
+
//-----------------------------------------------------
// Cell Values...
@@ -439,11 +497,6 @@ void CWKSP_Grid::On_DataObject_Changed(void)
m_Parameters("GENERAL_Z_UNIT") ->Set_Value((void *)m_pGrid->Get_Unit());
m_Parameters("GENERAL_Z_FACTOR") ->Set_Value(m_pGrid->Get_ZFactor());
- m_Parameters("GENERAL_Z_NODATA")->asRange()->Set_Range(
- m_pGrid->Get_NoData_Value(),
- m_pGrid->Get_NoData_hiValue()
- );
-
//-----------------------------------------------------
m_Parameters("MEMORY_MODE") ->Set_Value(
m_pGrid->is_Compressed() ? 1 : (m_pGrid->is_Cached() ? 2 : 0)
@@ -461,10 +514,12 @@ void CWKSP_Grid::On_Parameters_Changed(void)
m_pGrid->Set_Unit (m_Parameters("GENERAL_Z_UNIT") ->asString());
m_pGrid->Set_ZFactor (m_Parameters("GENERAL_Z_FACTOR") ->asDouble());
- m_pGrid->Set_NoData_Value_Range(
- m_Parameters("GENERAL_Z_NODATA")->asRange()->Get_LoVal(),
- m_Parameters("GENERAL_Z_NODATA")->asRange()->Get_HiVal()
- );
+ //-----------------------------------------------------
+ m_pOverlay[0] = g_pData->Get_Grids()->Get_Grid(m_Parameters("OVERLAY_1")->asGrid());
+ m_pOverlay[1] = g_pData->Get_Grids()->Get_Grid(m_Parameters("OVERLAY_2")->asGrid());
+ m_bOverlay = m_Parameters("COLORS_TYPE")->asInt() == 5;
+
+ m_pClassify->Set_Shade_Mode(m_Parameters("SHADE_MODE")->asInt());
//-----------------------------------------------------
switch( m_Parameters("MEMORY_MODE")->asInt() )
@@ -674,9 +729,9 @@ bool CWKSP_Grid::On_Edit_On_Key_Down(int KeyCode)
//---------------------------------------------------------
bool CWKSP_Grid::On_Edit_On_Mouse_Up(CSG_Point Point, double ClientToWorld, int Key)
{
- int x, y;
+ int x, y;
CSG_Table_Record *pRecord;
- CSG_Rect rWorld(m_Edit_Mouse_Down, Point);
+ CSG_Rect rWorld(m_Edit_Mouse_Down, Point);
m_Sel_xOff = m_pGrid->Get_System().Get_xWorld_to_Grid(rWorld.Get_XMin());
if( m_Sel_xOff < 0 )
@@ -1049,6 +1104,8 @@ void CWKSP_Grid::On_Draw(CWKSP_Map_DC &dc_Map, bool bEdit)
case CLASSIFY_RGB: Transparency = m_Parameters("DISPLAY_TRANSPARENCY")->asDouble() / 100.0; if( Transparency <= 0.0 ) Transparency = 3.0; break;
}
+ m_pClassify->Set_Shade_Mode(m_Parameters("SHADE_MODE")->asInt());
+
if( dc_Map.IMG_Draw_Begin(Transparency) )
{
Interpolation = m_pClassify->Get_Mode() == CLASSIFY_LUT
@@ -1056,7 +1113,7 @@ void CWKSP_Grid::On_Draw(CWKSP_Map_DC &dc_Map, bool bEdit)
: m_Parameters("DISPLAY_INTERPOLATION")->asInt();
if( dc_Map.m_DC2World >= m_pGrid->Get_Cellsize()
- || Interpolation != GRID_INTERPOLATION_NearestNeighbour )
+ || Interpolation != GRID_INTERPOLATION_NearestNeighbour || m_bOverlay )
{
_Draw_Grid_Points (dc_Map, Interpolation);
}
@@ -1081,10 +1138,24 @@ void CWKSP_Grid::On_Draw(CWKSP_Map_DC &dc_Map, bool bEdit)
void CWKSP_Grid::_Draw_Grid_Points(CWKSP_Map_DC &dc_Map, int Interpolation)
{
bool bByteWise = m_pClassify->Get_Mode() == CLASSIFY_RGB;
- int xDC, yDC, axDC, ayDC, bxDC, byDC, Color;
+ int xDC, yDC, axDC, ayDC, bxDC, byDC, Color, r, g, b;
double x, y, z;
CSG_Rect rGrid(m_pGrid->Get_Extent());
+ switch( m_Parameters("OVERLAY_MODE")->asInt() )
+ {
+ default:
+ case 0: r = 0; g = 1; b = 2; break;
+ case 1: r = 0; g = 2; b = 1; break;
+ case 2: r = 1; g = 0; b = 2; break;
+ case 3: r = 2; g = 0; b = 1; break;
+ case 4: r = 1; g = 2; b = 0; break;
+ case 5: r = 2; g = 1; b = 0; break;
+ }
+
+ m_pOverlay[0] = g_pData->Get_Grids()->Get_Grid(m_Parameters("OVERLAY_1")->asGrid());
+ m_pOverlay[1] = g_pData->Get_Grids()->Get_Grid(m_Parameters("OVERLAY_2")->asGrid());
+
rGrid.Inflate(m_pGrid->Get_Cellsize() / 2.0, false);
rGrid.Intersect(dc_Map.m_rWorld);
@@ -1097,9 +1168,33 @@ void CWKSP_Grid::_Draw_Grid_Points(CWKSP_Map_DC &dc_Map, int Interpolation)
{
for(x=rGrid.Get_XMin(), xDC=axDC; xDC<bxDC; x+=dc_Map.m_DC2World, xDC++)
{
- if( m_pGrid->Get_Value(x, y, z, Interpolation, false, bByteWise, true) && m_pClassify->Get_Class_Color_byValue(z, Color) )
+ if( m_pGrid->Get_Value(x, y, z, Interpolation, false, bByteWise, true) )
{
- dc_Map.IMG_Set_Pixel(xDC, yDC, Color);
+ if( m_bOverlay == false )
+ {
+ if( m_pClassify->Get_Class_Color_byValue(z, Color) )
+ {
+ dc_Map.IMG_Set_Pixel(xDC, yDC, Color);
+ }
+ }
+ else
+ {
+ int c[3];
+
+ c[0] = (int)(255.0 * m_pClassify->Get_MetricToRelative(z));
+
+ c[1] = m_pOverlay[0] && m_pOverlay[0]->Get_Grid()->Get_Value(x, y, z, Interpolation, false, false, true)
+ ? (int)(255.0 * m_pOverlay[0]->m_pClassify->Get_MetricToRelative(z)) : 255;
+
+ c[2] = m_pOverlay[1] && m_pOverlay[1]->Get_Grid()->Get_Value(x, y, z, Interpolation, false, false, true)
+ ? (int)(255.0 * m_pOverlay[1]->m_pClassify->Get_MetricToRelative(z)) : 255;
+
+ dc_Map.IMG_Set_Pixel(xDC, yDC, SG_GET_RGB(
+ c[r] < 0 ? 0 : c[r] > 255 ? 255 : c[r],
+ c[g] < 0 ? 0 : c[g] > 255 ? 255 : c[g],
+ c[b] < 0 ? 0 : c[b] > 255 ? 255 : c[b]
+ ));
+ }
}
}
}
diff --git a/src/saga_core/saga_gui/wksp_grid.h b/src/saga_core/saga_gui/wksp_grid.h
index b4a5750..8432796 100644
--- a/src/saga_core/saga_gui/wksp_grid.h
+++ b/src/saga_core/saga_gui/wksp_grid.h
@@ -107,6 +107,8 @@ public:
bool asImage (CSG_Grid *pImage);
+ virtual bool Update (CWKSP_Layer *pChanged) { return( pChanged == this || pChanged == m_pOverlay[0] || pChanged == m_pOverlay[1] ); }
+
protected:
@@ -127,9 +129,13 @@ protected:
private:
- int m_Interpolation, m_Sel_xOff, m_Sel_xN, m_Sel_yOff, m_Sel_yN;
+ bool m_bOverlay;
+
+ int m_Sel_xOff, m_Sel_xN, m_Sel_yOff, m_Sel_yN;
CSG_Grid *m_pGrid;
+
+ CWKSP_Grid *m_pOverlay[2];
void _LUT_Create (void);
diff --git a/src/saga_core/saga_gui/wksp_layer.cpp b/src/saga_core/saga_gui/wksp_layer.cpp
index 2b8abb8..7d64127 100644
--- a/src/saga_core/saga_gui/wksp_layer.cpp
+++ b/src/saga_core/saga_gui/wksp_layer.cpp
@@ -281,6 +281,12 @@ void CWKSP_Layer::Create_Parameters(void)
PARAMETER_TYPE_Bool, true
);
+ m_Parameters.Add_Range(
+ m_Parameters("NODE_GENERAL") , "GENERAL_NODATA" , LNG("[CAP] No Data"),
+ LNG("")
+ );
+
+
//-----------------------------------------------------
m_Parameters.Add_Node(
NULL , "NODE_DISPLAY" , LNG("[CAP] Display"),
@@ -424,6 +430,8 @@ bool CWKSP_Layer::Save(void)
bool bResult;
wxString File_Path;
+ File_Path = m_pObject->Get_File_Name() ? m_pObject->Get_File_Name() : m_pObject->Get_Name();
+
switch( Get_Type() )
{
default:
@@ -490,16 +498,31 @@ void CWKSP_Layer::DataObject_Changed(CSG_Parameters *pParameters)
}
else
{
- double m, s, min, max;
-
if( m_pObject->Get_ObjectType() == DATAOBJECT_TYPE_Grid )
{
+ double m, s, min, max;
CSG_Grid *pGrid = (CSG_Grid *)m_pObject;
- m = pGrid->Get_ArithMean(true);
- s = pGrid->Get_StdDev (true) * 2.0;
- min = m - s; if( min < pGrid->Get_ZMin(true) ) min = pGrid->Get_ZMin(true);
- max = m + s; if( max > pGrid->Get_ZMax(true) ) max = pGrid->Get_ZMax(true);
+ switch( g_pData->Get_Parameters()->Get_Parameter("GRID_DISPLAY_RANGEFIT")->asInt() )
+ {
+ case 0:
+ min = pGrid->Get_ZMin(true);
+ max = pGrid->Get_ZMax(true);
+ break;
+
+ case 1:
+ m = pGrid->Get_ArithMean(true);
+ s = pGrid->Get_StdDev (true) * 1.5;
+ min = m - s; if( min < pGrid->Get_ZMin(true) ) min = pGrid->Get_ZMin(true);
+ max = m + s; if( max > pGrid->Get_ZMax(true) ) max = pGrid->Get_ZMax(true);
+ break;
+
+ case 2:
+ m = pGrid->Get_ArithMean(true);
+ s = pGrid->Get_StdDev (true) * 2.0;
+ min = m - s; if( min < pGrid->Get_ZMin(true) ) min = pGrid->Get_ZMin(true);
+ max = m + s; if( max > pGrid->Get_ZMax(true) ) max = pGrid->Get_ZMax(true);
+ }
m_Parameters("METRIC_ZRANGE")->asRange()->Set_Range(min, max);
}
@@ -525,6 +548,11 @@ void CWKSP_Layer::DataObject_Changed(void)
m_Parameters("OBJECT_NAME")->Set_Value(m_pObject->Get_Name());
+ m_Parameters("GENERAL_NODATA")->asRange()->Set_Range(
+ m_pObject->Get_NoData_Value(),
+ m_pObject->Get_NoData_hiValue()
+ );
+
//-----------------------------------------------------
On_DataObject_Changed();
@@ -545,6 +573,11 @@ void CWKSP_Layer::Parameters_Changed(void)
m_pObject->Set_Name(m_Parameters("OBJECT_NAME")->asString());
+ m_pObject->Set_NoData_Value_Range(
+ m_Parameters("GENERAL_NODATA")->asRange()->Get_LoVal(),
+ m_Parameters("GENERAL_NODATA")->asRange()->Get_HiVal()
+ );
+
//-----------------------------------------------------
m_pClassify->Set_Mode(m_Parameters("COLORS_TYPE")->asInt());
diff --git a/src/saga_core/saga_gui/wksp_layer.h b/src/saga_core/saga_gui/wksp_layer.h
index 980b5da..c25ea53 100644
--- a/src/saga_core/saga_gui/wksp_layer.h
+++ b/src/saga_core/saga_gui/wksp_layer.h
@@ -121,6 +121,8 @@ public:
bool do_Legend (void);
bool do_Show (CSG_Rect const &rMap);
+ virtual bool Update (CWKSP_Layer *pChanged) { return( pChanged == this ); }
+
void Update_Views (bool bMapsOnly);
void View_Closes (class wxMDIChildFrame *pView);
diff --git a/src/saga_core/saga_gui/wksp_layer_classify.cpp b/src/saga_core/saga_gui/wksp_layer_classify.cpp
index 201441f..c3133c2 100644
--- a/src/saga_core/saga_gui/wksp_layer_classify.cpp
+++ b/src/saga_core/saga_gui/wksp_layer_classify.cpp
@@ -75,13 +75,14 @@
//---------------------------------------------------------
CWKSP_Layer_Classify::CWKSP_Layer_Classify(void)
{
- m_Mode = CLASSIFY_UNIQUE;
+ m_Mode = CLASSIFY_UNIQUE;
+ m_Shade_Mode = SHADE_MODE_DSC_GREY;
- m_pLayer = NULL;
- m_pColors = NULL;
- m_pLUT = NULL;
+ m_pLayer = NULL;
+ m_pColors = NULL;
+ m_pLUT = NULL;
- m_HST_Count = NULL;
+ m_HST_Count = NULL;
}
//---------------------------------------------------------
@@ -156,63 +157,113 @@ bool CWKSP_Layer_Classify::Initialise(CWKSP_Layer *pLayer, CSG_Table *pLUT, CSG_
///////////////////////////////////////////////////////////
//---------------------------------------------------------
-void CWKSP_Layer_Classify::Set_Mode(int Mode)
+double CWKSP_Layer_Classify::Get_Class_Value_Minimum(int iClass)
{
- m_Mode = Mode;
-}
+ switch( m_Mode )
+ {
+ default:
+ break;
+ case CLASSIFY_LUT:
+ if( iClass >= 0 && iClass < m_pLUT->Get_Record_Count() )
+ {
+ return( m_pLUT->Get_Record(iClass)->asDouble(LUT_MIN) );
+ }
+ break;
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
+ case CLASSIFY_METRIC:
+ case CLASSIFY_SHADE:
+ case CLASSIFY_OVERLAY:
+ if( m_zRange > 0.0 )
+ {
+ return( Get_RelativeToMetric(iClass / (double)Get_Class_Count()) );
+ }
+ break;
+ }
-//---------------------------------------------------------
-wxString CWKSP_Layer_Classify::Get_Class_Name(int iClass)
+ return( m_zMin );
+}
+
+double CWKSP_Layer_Classify::Get_Class_Value_Maximum(int iClass)
{
- wxString s;
+ switch( m_Mode )
+ {
+ default:
+ break;
+ case CLASSIFY_LUT:
+ if( iClass >= 0 && iClass < m_pLUT->Get_Record_Count() )
+ {
+ return( m_pLUT->Get_Record(iClass)->asDouble(LUT_MAX) );
+ }
+ break;
+
+ case CLASSIFY_METRIC:
+ case CLASSIFY_SHADE:
+ case CLASSIFY_OVERLAY:
+ if( m_zRange > 0.0 )
+ {
+ return( Get_RelativeToMetric((1.0 + iClass) / (double)Get_Class_Count()) );
+ }
+ break;
+ }
+
+ return( m_zMin + m_zRange );
+}
+
+double CWKSP_Layer_Classify::Get_Class_Value_Center(int iClass)
+{
switch( m_Mode )
{
- case CLASSIFY_UNIQUE: default:
+ default:
break;
case CLASSIFY_LUT:
if( iClass >= 0 && iClass < m_pLUT->Get_Record_Count() )
{
- s.Printf(wxT("%s"), m_pLUT->Get_Record(iClass)->asString(LUT_TITLE));
+ return( 0.5 * (m_pLUT->Get_Record(iClass)->asDouble(LUT_MIN) + m_pLUT->Get_Record(iClass)->asDouble(LUT_MAX)) );
}
break;
case CLASSIFY_METRIC:
case CLASSIFY_SHADE:
+ case CLASSIFY_OVERLAY:
if( m_zRange > 0.0 )
{
- if( iClass == 0 )
- {
- s.Printf(wxT("%f < %f"), Get_RelativeToMetric(1.0 * iClass / Get_Class_Count()), Get_RelativeToMetric(1.0 * (1.0 + iClass) / Get_Class_Count()));
- }
- else if( iClass < Get_Class_Count() )
- {
- s.Printf(wxT("< %f"), Get_RelativeToMetric(1.0 * (1.0 + iClass) / Get_Class_Count()));
- }
+ return( Get_RelativeToMetric((0.5 + iClass) / (double)Get_Class_Count()) );
}
- else
+ break;
+ }
+
+ return( m_zMin + 0.5 * m_zRange );
+}
+
+//---------------------------------------------------------
+wxString CWKSP_Layer_Classify::Get_Class_Name(int iClass)
+{
+ CSG_String s;
+
+ switch( m_Mode )
+ {
+ default:
+ break;
+
+ case CLASSIFY_LUT:
+ if( iClass >= 0 && iClass < m_pLUT->Get_Record_Count() )
{
- if( iClass == 0 )
- {
- s.Printf(wxT("<= %f"), m_zMin);
- }
- else
- {
- s.Printf(wxT("> %f"), m_zMin);
- }
+ s.Printf(SG_T("%s"), m_pLUT->Get_Record(iClass)->asString(LUT_TITLE));
}
break;
+
+ case CLASSIFY_METRIC:
+ case CLASSIFY_SHADE:
+ case CLASSIFY_OVERLAY:
+ s = SG_Get_String(Get_Class_Value_Minimum(iClass), -2) + SG_T(" < ")
+ + SG_Get_String(Get_Class_Value_Maximum(iClass), -2);
+ break;
}
- return( s );
+ return( s.c_str() );
}
//---------------------------------------------------------
diff --git a/src/saga_core/saga_gui/wksp_layer_classify.h b/src/saga_core/saga_gui/wksp_layer_classify.h
index 5fbb2ac..c7d1afc 100644
--- a/src/saga_core/saga_gui/wksp_layer_classify.h
+++ b/src/saga_core/saga_gui/wksp_layer_classify.h
@@ -87,7 +87,8 @@ enum
CLASSIFY_LUT,
CLASSIFY_METRIC,
CLASSIFY_RGB,
- CLASSIFY_SHADE
+ CLASSIFY_SHADE,
+ CLASSIFY_OVERLAY
};
//---------------------------------------------------------
@@ -108,6 +109,19 @@ enum
METRIC_MODE_LOGDOWN
};
+//---------------------------------------------------------
+enum
+{
+ SHADE_MODE_DSC_GREY = 0,
+ SHADE_MODE_ASC_GREY,
+ SHADE_MODE_DSC_CYAN,
+ SHADE_MODE_ASC_CYAN,
+ SHADE_MODE_DSC_MAGENTA,
+ SHADE_MODE_ASC_MAGENTA,
+ SHADE_MODE_DSC_YELLOW,
+ SHADE_MODE_ASC_YELLOW
+};
+
///////////////////////////////////////////////////////////
// //
@@ -124,9 +138,12 @@ public: ///////////////////////////////////////////////////
bool Initialise (class CWKSP_Layer *pLayer, CSG_Table *pLUT, CSG_Colors *pColors);
- void Set_Mode (int Mode);
+ void Set_Mode (int Mode) { m_Mode = Mode; }
int Get_Mode (void) { return( m_Mode ); }
+ void Set_Shade_Mode (int Mode) { m_Shade_Mode = Mode; }
+ int Get_Shade_Mode (void) { return( m_Shade_Mode ); }
+
void Set_Unique_Color (int Color);
int Get_Unique_Color (void) { return( m_UNI_Color ); }
@@ -152,6 +169,7 @@ public: ///////////////////////////////////////////////////
case CLASSIFY_METRIC:
case CLASSIFY_SHADE:
+ case CLASSIFY_OVERLAY:
return( m_pColors->Get_Count() );
}
}
@@ -169,11 +187,15 @@ public: ///////////////////////////////////////////////////
case CLASSIFY_METRIC:
case CLASSIFY_SHADE:
+ case CLASSIFY_OVERLAY:
return( _METRIC_Get_Class(Value) );
}
}
//-----------------------------------------------------
+ double Get_Class_Value_Minimum (int iClass);
+ double Get_Class_Value_Center (int iClass);
+ double Get_Class_Value_Maximum (int iClass);
wxString Get_Class_Name (int iClass);
wxString Get_Class_Name_byValue (double Value);
@@ -201,31 +223,13 @@ public: ///////////////////////////////////////////////////
return( false );
case CLASSIFY_METRIC:
- if( iClass < 0 )
- {
- iClass = 0;
- }
- else if( iClass >= m_pColors->Get_Count() )
- {
- iClass = m_pColors->Get_Count() - 1;
- }
-
- Color = m_pColors->Get_Color(iClass);
+ Color = m_pColors->Get_Color(iClass < 0 ? 0 : iClass >= m_pColors->Get_Count() ? m_pColors->Get_Count() - 1 : iClass);
return( true );
case CLASSIFY_SHADE:
- if( iClass < 0 )
- {
- iClass = 0;
- }
- else if( iClass >= m_pColors->Get_Count() )
- {
- iClass = m_pColors->Get_Count() - 1;
- }
-
- Color = m_pColors->Get_Brightness(iClass);
- Color = SG_GET_RGB(Color, Color, Color);
+ case CLASSIFY_OVERLAY:
+ Get_Class_Color_byValue(Get_RelativeToMetric(iClass / (double)m_pColors->Get_Count()), Color);
return( true );
}
@@ -255,10 +259,36 @@ public: ///////////////////////////////////////////////////
break;
case CLASSIFY_METRIC:
- case CLASSIFY_SHADE:
iClass = _METRIC_Get_Class(Value);
break;
+ case CLASSIFY_SHADE:
+ iClass = (int)(255.0 * Get_MetricToRelative(Value));
+ if( iClass < 0 ) iClass = 0; else if( iClass > 255 ) iClass = 255;
+
+ switch( m_Shade_Mode )
+ {
+ default:
+ case SHADE_MODE_DSC_GREY: Color = SG_GET_RGB(255 - iClass, 255 - iClass, 255 - iClass); break;
+ case SHADE_MODE_DSC_CYAN: Color = SG_GET_RGB(255 - iClass, 255 , 255 ); break;
+ case SHADE_MODE_DSC_MAGENTA: Color = SG_GET_RGB(255 , 255 - iClass, 255 ); break;
+ case SHADE_MODE_DSC_YELLOW: Color = SG_GET_RGB(255 , 255 , 255 - iClass); break;
+ case SHADE_MODE_ASC_GREY: Color = SG_GET_RGB( iClass, iClass, iClass); break;
+ case SHADE_MODE_ASC_CYAN: Color = SG_GET_RGB( iClass, 255 , 255 ); break;
+ case SHADE_MODE_ASC_MAGENTA: Color = SG_GET_RGB(255 , iClass, 255 ); break;
+ case SHADE_MODE_ASC_YELLOW: Color = SG_GET_RGB(255 , 255 , iClass); break;
+ }
+
+ return( true );
+
+ case CLASSIFY_OVERLAY:
+ iClass = (int)(255.0 * Get_MetricToRelative(Value));
+ if( iClass < 0 ) iClass = 0; else if( iClass > 255 ) iClass = 255;
+
+ Color = SG_GET_RGB(iClass, iClass, iClass);
+
+ return( true );
+
case CLASSIFY_RGB:
Color = (int)Value;
return( true );
@@ -351,7 +381,7 @@ public: ///////////////////////////////////////////////////
protected: ////////////////////////////////////////////////
- int m_Mode, m_zMode,
+ int m_Mode, m_zMode, m_Shade_Mode,
m_UNI_Color,
*m_HST_Count, *m_HST_Cumul, m_HST_Maximum, m_HST_Total;
diff --git a/src/saga_core/saga_gui/wksp_layer_legend.cpp b/src/saga_core/saga_gui/wksp_layer_legend.cpp
index ab68ea8..1d8047c 100644
--- a/src/saga_core/saga_gui/wksp_layer_legend.cpp
+++ b/src/saga_core/saga_gui/wksp_layer_legend.cpp
@@ -623,6 +623,7 @@ void CWKSP_Layer_Legend::_Draw_Grid(wxDC &dc, CWKSP_Grid *pLayer)
break;
case CLASSIFY_RGB:
+ case CLASSIFY_OVERLAY:
_Draw_Box_Image(dc, m_Position.y, pLayer->Get_Grid());
break;
}
diff --git a/src/saga_core/saga_gui/wksp_map.cpp b/src/saga_core/saga_gui/wksp_map.cpp
index c4a15d1..5c4596b 100644
--- a/src/saga_core/saga_gui/wksp_map.cpp
+++ b/src/saga_core/saga_gui/wksp_map.cpp
@@ -1,304 +1,304 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// User Interface //
-// //
-// Program: SAGA //
-// //
-//-------------------------------------------------------//
-// //
-// WKSP_Map.cpp //
-// //
-// Copyright (C) 2005 by Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Goettingen //
-// Goldschmidtstr. 5 //
-// 37077 Goettingen //
-// Germany //
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include <wx/window.h>
-#include <wx/dcmemory.h>
-#include <wx/filename.h>
-#include <wx/clipbrd.h>
-#include <wx/dataobj.h>
-
-#include <saga_api/doc_pdf.h>
-#include "svg_interactive_map.h"
-
-#include "res_commands.h"
-#include "res_dialogs.h"
-
-#include "helper.h"
-#include "dc_helper.h"
-
-#include "active.h"
-#include "active_legend.h"
-
-#include "wksp_map_control.h"
-#include "wksp_map_manager.h"
-#include "wksp_map.h"
-#include "wksp_map_layer.h"
-#include "wksp_map_buttons.h"
-
-#include "wksp_layer_legend.h"
-#include "wksp_shapes.h"
-
-#include "view_map.h"
-#include "view_map_control.h"
-#include "view_map_3d.h"
-#include "view_layout.h"
-#include "view_layout_info.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#define LEGEND_SPACE 10
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Rect CWKSP_Map_Extents::m_Dummy = CSG_Rect(0, 0, 1, 1);
-
-//---------------------------------------------------------
-CWKSP_Map_Extents::CWKSP_Map_Extents(void)
-{
- m_iExtent = -1;
- m_nExtents = 0;
-}
-
-//---------------------------------------------------------
-CSG_Rect CWKSP_Map_Extents::Set_Back(void)
-{
- if( m_iExtent < 0 )
- return( m_Dummy );
-
- if( !is_First() )
- {
- m_iExtent--;
- }
-
- return( Get_Rect(m_iExtent) );
-}
-
-//---------------------------------------------------------
-CSG_Rect CWKSP_Map_Extents::Set_Forward(void)
-{
- if( m_iExtent < 0 )
- return( m_Dummy );
-
- if( !is_Last() )
- {
- m_iExtent++;
- }
-
- return( Get_Rect(m_iExtent) );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Map_Extents::Add_Extent(const CSG_Rect &Extent, bool bReset)
-{
- if( Extent.Get_XRange() > 0.0 && Extent.Get_YRange() > 0.0 )
- {
- if( bReset )
- {
- m_iExtent = -1;
- m_nExtents = 0;
- }
-
- if( Extent != Get_Extent() )
- {
- m_iExtent ++;
- m_nExtents = m_iExtent + 1;
-
- if( m_nExtents > Get_Count() )
- {
- Add(Extent);
- }
- else
- {
- Get_Rect(m_iExtent) = Extent;
- }
-
- return( true );
- }
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CWKSP_Map::CWKSP_Map(void)
-{
- static int iMap = 0;
-
- m_Name.Printf(wxT("%02d. %s"), ++iMap, LNG("[CAP] Map"));
-
- _Create_Parameters();
-
- m_pView = NULL;
- m_pView_3D = NULL;
- m_pLayout = NULL;
- m_pLayout_Info = new CVIEW_Layout_Info(this);
-
- m_bSynchronise = false;
- m_Img_bSave = false;
-}
-
-//---------------------------------------------------------
-CWKSP_Map::~CWKSP_Map(void)
-{
- View_Show (false);
- View_3D_Show (false);
- View_Layout_Show (false);
-
- delete(m_pLayout_Info);
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-wxString CWKSP_Map::Get_Name(void)
-{
- return( m_Name );
-}
-
-//---------------------------------------------------------
-wxString CWKSP_Map::Get_Description(void)
-{
- wxString s;
-
- s.Append(wxString::Format(wxT("<b>%s</b><table border=\"0\">"),
- LNG("[CAP] Map")
- ));
-
- s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%s</td></tr>"),
- LNG("[CAP] Name") , m_Name.c_str()
- ));
-
- s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%d</td></tr>"),
- LNG("[CAP] Layers") , Get_Count()
- ));
-
- s.Append(wxT("</table>"));
-
- return( s );
-}
-
-//---------------------------------------------------------
-wxMenu * CWKSP_Map::Get_Menu(void)
-{
- wxMenu *pMenu;
-
- pMenu = new wxMenu(LNG("[CAP] Map"));
-
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_CLOSE);
- CMD_Menu_Add_Item(pMenu, true, ID_CMD_MAPS_SHOW);
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_MAPS_SAVE_IMAGE);
- CMD_Menu_Add_Item(pMenu, true, ID_CMD_MAPS_SAVE_IMAGE_ON_CHANGE);
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// User Interface //
+// //
+// Program: SAGA //
+// //
+//-------------------------------------------------------//
+// //
+// WKSP_Map.cpp //
+// //
+// Copyright (C) 2005 by Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Goettingen //
+// Goldschmidtstr. 5 //
+// 37077 Goettingen //
+// Germany //
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include <wx/window.h>
+#include <wx/dcmemory.h>
+#include <wx/filename.h>
+#include <wx/clipbrd.h>
+#include <wx/dataobj.h>
+
+#include <saga_api/doc_pdf.h>
+#include "svg_interactive_map.h"
+
+#include "res_commands.h"
+#include "res_dialogs.h"
+
+#include "helper.h"
+#include "dc_helper.h"
+
+#include "active.h"
+#include "active_legend.h"
+
+#include "wksp_map_control.h"
+#include "wksp_map_manager.h"
+#include "wksp_map.h"
+#include "wksp_map_layer.h"
+#include "wksp_map_buttons.h"
+
+#include "wksp_layer_legend.h"
+#include "wksp_shapes.h"
+
+#include "view_map.h"
+#include "view_map_control.h"
+#include "view_map_3d.h"
+#include "view_layout.h"
+#include "view_layout_info.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define LEGEND_SPACE 10
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Rect CWKSP_Map_Extents::m_Dummy = CSG_Rect(0, 0, 1, 1);
+
+//---------------------------------------------------------
+CWKSP_Map_Extents::CWKSP_Map_Extents(void)
+{
+ m_iExtent = -1;
+ m_nExtents = 0;
+}
+
+//---------------------------------------------------------
+CSG_Rect CWKSP_Map_Extents::Set_Back(void)
+{
+ if( m_iExtent < 0 )
+ return( m_Dummy );
+
+ if( !is_First() )
+ {
+ m_iExtent--;
+ }
+
+ return( Get_Rect(m_iExtent) );
+}
+
+//---------------------------------------------------------
+CSG_Rect CWKSP_Map_Extents::Set_Forward(void)
+{
+ if( m_iExtent < 0 )
+ return( m_Dummy );
+
+ if( !is_Last() )
+ {
+ m_iExtent++;
+ }
+
+ return( Get_Rect(m_iExtent) );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Map_Extents::Add_Extent(const CSG_Rect &Extent, bool bReset)
+{
+ if( Extent.Get_XRange() > 0.0 && Extent.Get_YRange() > 0.0 )
+ {
+ if( bReset )
+ {
+ m_iExtent = -1;
+ m_nExtents = 0;
+ }
+
+ if( Extent != Get_Extent() )
+ {
+ m_iExtent ++;
+ m_nExtents = m_iExtent + 1;
+
+ if( m_nExtents > Get_Count() )
+ {
+ Add(Extent);
+ }
+ else
+ {
+ Get_Rect(m_iExtent) = Extent;
+ }
+
+ return( true );
+ }
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CWKSP_Map::CWKSP_Map(void)
+{
+ static int iMap = 0;
+
+ m_Name.Printf(wxT("%02d. %s"), ++iMap, LNG("[CAP] Map"));
+
+ _Create_Parameters();
+
+ m_pView = NULL;
+ m_pView_3D = NULL;
+ m_pLayout = NULL;
+ m_pLayout_Info = new CVIEW_Layout_Info(this);
+
+ m_bSynchronise = false;
+ m_Img_bSave = false;
+}
+
+//---------------------------------------------------------
+CWKSP_Map::~CWKSP_Map(void)
+{
+ View_Show (false);
+ View_3D_Show (false);
+ View_Layout_Show (false);
+
+ delete(m_pLayout_Info);
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+wxString CWKSP_Map::Get_Name(void)
+{
+ return( m_Name );
+}
+
+//---------------------------------------------------------
+wxString CWKSP_Map::Get_Description(void)
+{
+ wxString s;
+
+ s.Append(wxString::Format(wxT("<b>%s</b><table border=\"0\">"),
+ LNG("[CAP] Map")
+ ));
+
+ s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%s</td></tr>"),
+ LNG("[CAP] Name") , m_Name.c_str()
+ ));
+
+ s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%d</td></tr>"),
+ LNG("[CAP] Layers") , Get_Count()
+ ));
+
+ s.Append(wxT("</table>"));
+
+ return( s );
+}
+
+//---------------------------------------------------------
+wxMenu * CWKSP_Map::Get_Menu(void)
+{
+ wxMenu *pMenu;
+
+ pMenu = new wxMenu(LNG("[CAP] Map"));
+
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_CLOSE);
+ CMD_Menu_Add_Item(pMenu, true, ID_CMD_MAPS_SHOW);
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_MAPS_SAVE_IMAGE);
+ CMD_Menu_Add_Item(pMenu, true, ID_CMD_MAPS_SAVE_IMAGE_ON_CHANGE);
CMD_Menu_Add_Item(pMenu, false, ID_CMD_MAPS_SAVE_TO_CLIPBOARD);
CMD_Menu_Add_Item(pMenu, false, ID_CMD_MAPS_SAVE_TO_CLIPBOARD_LEGEND);
- if( CSG_Doc_PDF::Get_Version() != NULL )
- {
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_MAPS_SAVE_PDF_INDEXED);
- }
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_MAPS_SAVE_INTERACTIVE_SVG);
- CMD_Menu_Add_Item(pMenu, true, ID_CMD_MAPS_3D_SHOW);
- CMD_Menu_Add_Item(pMenu, true, ID_CMD_MAPS_LAYOUT_SHOW);
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_MAPS_SYNCHRONIZE);
-
- return( pMenu );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CWKSP_Map::On_Command(int Cmd_ID)
-{
- switch( Cmd_ID )
- {
- default:
- return( CWKSP_Base_Manager::On_Command(Cmd_ID) );
-
- case ID_CMD_WKSP_ITEM_RETURN:
- View_Show(true);
- break;
-
- case ID_CMD_MAPS_SAVE_IMAGE:
- SaveAs_Image();
- break;
-
- case ID_CMD_MAPS_SAVE_IMAGE_ON_CHANGE:
- SaveAs_Image_On_Change();
- break;
+ if( CSG_Doc_PDF::Get_Version() != NULL )
+ {
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_MAPS_SAVE_PDF_INDEXED);
+ }
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_MAPS_SAVE_INTERACTIVE_SVG);
+ CMD_Menu_Add_Item(pMenu, true, ID_CMD_MAPS_3D_SHOW);
+ CMD_Menu_Add_Item(pMenu, true, ID_CMD_MAPS_LAYOUT_SHOW);
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_MAPS_SYNCHRONIZE);
+
+ return( pMenu );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CWKSP_Map::On_Command(int Cmd_ID)
+{
+ switch( Cmd_ID )
+ {
+ default:
+ return( CWKSP_Base_Manager::On_Command(Cmd_ID) );
+
+ case ID_CMD_WKSP_ITEM_RETURN:
+ View_Show(true);
+ break;
+
+ case ID_CMD_MAPS_SAVE_IMAGE:
+ SaveAs_Image();
+ break;
+
+ case ID_CMD_MAPS_SAVE_IMAGE_ON_CHANGE:
+ SaveAs_Image_On_Change();
+ break;
case ID_CMD_MAPS_SAVE_TO_CLIPBOARD:
SaveAs_Image_Clipboard(false);
@@ -307,176 +307,182 @@ bool CWKSP_Map::On_Command(int Cmd_ID)
case ID_CMD_MAPS_SAVE_TO_CLIPBOARD_LEGEND:
SaveAs_Image_Clipboard(true);
break;
-
- case ID_CMD_MAPS_SAVE_PDF_INDEXED:
- SaveAs_PDF_Indexed();
- break;
-
- case ID_CMD_MAPS_SAVE_INTERACTIVE_SVG:
- SaveAs_Interactive_SVG();
- break;
-
- case ID_CMD_MAPS_SYNCHRONIZE:
- Set_Synchronising(!m_bSynchronise);
- break;
-
- case ID_CMD_MAPS_SHOW:
- View_Toggle();
- break;
-
- case ID_CMD_MAPS_3D_SHOW:
- View_3D_Toggle();
- break;
-
- case ID_CMD_MAPS_LAYOUT_SHOW:
- View_Layout_Toggle();
- break;
- }
-
- return( true );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Map::On_Command_UI(wxUpdateUIEvent &event)
-{
- switch( event.GetId() )
- {
- default:
- return( CWKSP_Base_Manager::On_Command_UI(event) );
-
- case ID_CMD_MAPS_SHOW:
- event.Check(m_pView != NULL);
- break;
-
- case ID_CMD_MAPS_3D_SHOW:
- event.Check(m_pView_3D != NULL);
- break;
-
- case ID_CMD_MAPS_LAYOUT_SHOW:
- event.Check(m_pLayout != NULL);
- break;
-
- case ID_CMD_MAPS_SAVE_IMAGE_ON_CHANGE:
- event.Check(is_Image_Save_Mode());
- break;
- }
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CWKSP_Map::_Create_Parameters(void)
-{
- CSG_Parameter *pNode_0, *pNode_1;
-
- //-----------------------------------------------------
- m_Parameters.Create(this, LNG(""), LNG(""));
- m_Parameters.Set_Callback_On_Parameter_Changed(&_On_Parameter_Changed);
-
- //-----------------------------------------------------
- pNode_0 = m_Parameters.Add_Node(
- NULL , "NODE_GENERAL" , LNG("[CAP] General"),
- LNG("")
- );
-
- m_Parameters.Add_String(
- pNode_0 , "NAME" , LNG("[CAP] Name"),
- LNG(""),
- m_Name.c_str()
- );
-
- m_Parameters.Add_Value(
- pNode_0 , "GOTO_NEWLAYER" , LNG("[CAP] Zoom to added layer"),
- LNG(""),
- PARAMETER_TYPE_Bool, g_pMaps->Get_Parameters()->Get_Parameter("GOTO_NEWLAYER")->asBool()
- );
-
- //-----------------------------------------------------
- pNode_0 = m_Parameters.Add_Node(
- NULL , "NODE_FRAME" , LNG("[CAP] Frame"),
- LNG("")
- );
-
- m_Parameters.Add_Value(
- pNode_0 , "FRAME_SHOW" , LNG("[CAP] Show"),
- LNG(""),
- PARAMETER_TYPE_Bool, g_pMaps->Get_Parameters()->Get_Parameter("FRAME_SHOW")->asBool()
- );
-
- m_Parameters.Add_Value(
- pNode_0 , "FRAME_WIDTH" , LNG("[CAP] Width"),
- LNG(""),
- PARAMETER_TYPE_Int, g_pMaps->Get_Parameters()->Get_Parameter("FRAME_WIDTH")->asInt(), 5, true
- );
-
- //-----------------------------------------------------
- pNode_0 = m_Parameters.Add_Node(
- NULL , "NODE_PRINT" , LNG("[CAP] Print Layout"),
- LNG("")
- );
-
- m_Parameters.Add_Choice(
- pNode_0 , "PRINT_LEGEND" , LNG("[CAP] Show Legend"),
- LNG(""),
- wxString::Format(wxT("%s|%s|"),
- LNG("no"),
- LNG("yes")
- ), 1
- );
-
- m_Parameters.Add_Value(
- pNode_0 , "PRINT_RESOLUTION" , LNG("[CAP] Display Resolution"),
- LNG(""),
- PARAMETER_TYPE_Int, 2, 1, true
- );
-
- pNode_1 = m_Parameters.Add_Node(
- pNode_0 , "NODE_PRINT_FRAME" , LNG("[CAP] Frame"),
- LNG("")
- );
-
- m_Parameters.Add_Value(
- pNode_1 , "PRINT_FRAME_SHOW" , LNG("[CAP] Show"),
- LNG(""),
- PARAMETER_TYPE_Bool, true
- );
-
- m_Parameters.Add_Value(
- pNode_1 , "PRINT_FRAME_WIDTH" , LNG("[CAP] Width"),
- LNG(""),
- PARAMETER_TYPE_Int, 7, 5, true
- );
-
- //-----------------------------------------------------
- m_Img_Parms.Set_Name(LNG("[CAP] Save Map as Image..."));
-
- pNode_0 = m_Img_Parms.Add_Node(NULL, "NODE_MAP", LNG("Map"), LNG(""));
-
- m_Img_Parms.Add_Value(
- pNode_0 , "NX" , LNG("[PRM] Map Width [Pixels]"),
- LNG(""),
- PARAMETER_TYPE_Int, 800 , 1, true
- );
-
- m_Img_Parms.Add_Value(
- pNode_0 , "NY" , LNG("[PRM] Map Height [Pixels]"),
- LNG(""),
- PARAMETER_TYPE_Int, 600 , 1, true
- );
-
- m_Img_Parms.Add_Value(
- pNode_0 , "FR" , LNG("[PRM] Frame Width [Pixels]"),
- LNG(""),
- PARAMETER_TYPE_Int, 20 , 0, true
- );
-
+
+ case ID_CMD_MAPS_SAVE_PDF_INDEXED:
+ SaveAs_PDF_Indexed();
+ break;
+
+ case ID_CMD_MAPS_SAVE_INTERACTIVE_SVG:
+ SaveAs_Interactive_SVG();
+ break;
+
+ case ID_CMD_MAPS_SYNCHRONIZE:
+ Set_Synchronising(!m_bSynchronise);
+ break;
+
+ case ID_CMD_MAPS_SHOW:
+ View_Toggle();
+ break;
+
+ case ID_CMD_MAPS_3D_SHOW:
+ View_3D_Toggle();
+ break;
+
+ case ID_CMD_MAPS_LAYOUT_SHOW:
+ View_Layout_Toggle();
+ break;
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Map::On_Command_UI(wxUpdateUIEvent &event)
+{
+ switch( event.GetId() )
+ {
+ default:
+ return( CWKSP_Base_Manager::On_Command_UI(event) );
+
+ case ID_CMD_MAPS_SHOW:
+ event.Check(m_pView != NULL);
+ break;
+
+ case ID_CMD_MAPS_3D_SHOW:
+ event.Check(m_pView_3D != NULL);
+ break;
+
+ case ID_CMD_MAPS_LAYOUT_SHOW:
+ event.Check(m_pLayout != NULL);
+ break;
+
+ case ID_CMD_MAPS_SAVE_IMAGE_ON_CHANGE:
+ event.Check(is_Image_Save_Mode());
+ break;
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CWKSP_Map::_Create_Parameters(void)
+{
+ CSG_Parameter *pNode_0, *pNode_1;
+
+ //-----------------------------------------------------
+ m_Parameters.Create(this, LNG(""), LNG(""));
+ m_Parameters.Set_Callback_On_Parameter_Changed(&_On_Parameter_Changed);
+
+ //-----------------------------------------------------
+ pNode_0 = m_Parameters.Add_Node(
+ NULL , "NODE_GENERAL" , LNG("[CAP] General"),
+ LNG("")
+ );
+
+ m_Parameters.Add_String(
+ pNode_0 , "NAME" , LNG("[CAP] Name"),
+ LNG(""),
+ m_Name.c_str()
+ );
+
+ m_Parameters.Add_Value(
+ pNode_0 , "GOTO_NEWLAYER" , LNG("[CAP] Zoom to added layer"),
+ LNG(""),
+ PARAMETER_TYPE_Bool, g_pMaps->Get_Parameters()->Get_Parameter("GOTO_NEWLAYER")->asBool()
+ );
+
+ //-----------------------------------------------------
+ pNode_0 = m_Parameters.Add_Node(
+ NULL , "NODE_FRAME" , LNG("[CAP] Frame"),
+ LNG("")
+ );
+
+ m_Parameters.Add_Value(
+ pNode_0 , "FRAME_SHOW" , LNG("[CAP] Show"),
+ LNG(""),
+ PARAMETER_TYPE_Bool, g_pMaps->Get_Parameters()->Get_Parameter("FRAME_SHOW")->asBool()
+ );
+
+ m_Parameters.Add_Value(
+ pNode_0 , "FRAME_WIDTH" , LNG("[CAP] Width"),
+ LNG(""),
+ PARAMETER_TYPE_Int, g_pMaps->Get_Parameters()->Get_Parameter("FRAME_WIDTH")->asInt(), 5, true
+ );
+
+ //-----------------------------------------------------
+ pNode_0 = m_Parameters.Add_Node(
+ NULL , "NODE_PRINT" , LNG("[CAP] Print Layout"),
+ LNG("")
+ );
+
+ m_Parameters.Add_Choice(
+ pNode_0 , "PRINT_LEGEND" , LNG("[CAP] Show Legend"),
+ LNG(""),
+ wxString::Format(wxT("%s|%s|"),
+ LNG("no"),
+ LNG("yes")
+ ), 1
+ );
+
+ m_Parameters.Add_Value(
+ pNode_0 , "PRINT_RESOLUTION" , LNG("[CAP] Display Resolution"),
+ LNG(""),
+ PARAMETER_TYPE_Int, 2, 1, true
+ );
+
+ pNode_1 = m_Parameters.Add_Node(
+ pNode_0 , "NODE_PRINT_FRAME" , LNG("[CAP] Frame"),
+ LNG("")
+ );
+
+ m_Parameters.Add_Value(
+ pNode_1 , "PRINT_FRAME_SHOW" , LNG("[CAP] Show"),
+ LNG(""),
+ PARAMETER_TYPE_Bool, true
+ );
+
+ m_Parameters.Add_Value(
+ pNode_1 , "PRINT_FRAME_WIDTH" , LNG("[CAP] Width"),
+ LNG(""),
+ PARAMETER_TYPE_Int, 7, 5, true
+ );
+
+ m_Parameters.Add_Value(
+ pNode_0 , "PRINT_SCALE_SHOW" , LNG("[CAP] Show Scale"),
+ LNG(""),
+ PARAMETER_TYPE_Bool, true
+ );
+
+ //-----------------------------------------------------
+ m_Img_Parms.Set_Name(LNG("[CAP] Save Map as Image..."));
+
+ pNode_0 = m_Img_Parms.Add_Node(NULL, "NODE_MAP", LNG("Map"), LNG(""));
+
+ m_Img_Parms.Add_Value(
+ pNode_0 , "NX" , LNG("[PRM] Map Width [Pixels]"),
+ LNG(""),
+ PARAMETER_TYPE_Int, 800 , 1, true
+ );
+
+ m_Img_Parms.Add_Value(
+ pNode_0 , "NY" , LNG("[PRM] Map Height [Pixels]"),
+ LNG(""),
+ PARAMETER_TYPE_Int, 600 , 1, true
+ );
+
+ m_Img_Parms.Add_Value(
+ pNode_0 , "FR" , LNG("[PRM] Frame Width [Pixels]"),
+ LNG(""),
+ PARAMETER_TYPE_Int, 20 , 0, true
+ );
+
m_Img_Parms.Add_Value(
pNode_0 , "REF" , LNG("[PRM] Save Georeference (world file)"),
LNG(""),
@@ -489,546 +495,575 @@ void CWKSP_Map::_Create_Parameters(void)
PARAMETER_TYPE_Bool, 1
);
- pNode_0 = m_Img_Parms.Add_Node(NULL, "NODE_LEGEND", LNG("[PRM] Legend"), LNG(""));
-
- m_Img_Parms.Add_Value(
- pNode_0 , "LG" , LNG("[PRM] Save"),
- LNG(""),
- PARAMETER_TYPE_Bool, 1
- );
-
- m_Img_Parms.Add_Value(
- pNode_0 , "LZ" , LNG("[PRM] Zoom"),
- LNG(""),
- PARAMETER_TYPE_Double, 1.0, 0, true
- );
-}
-
-//---------------------------------------------------------
-int CWKSP_Map::Get_Frame_Width(void)
-{
- return( m_Parameters("FRAME_SHOW")->asBool() ? m_Parameters("FRAME_WIDTH")->asInt() : 0 );
-}
-
-//---------------------------------------------------------
-int CWKSP_Map::Get_Print_Resolution(void)
-{
- return( m_Parameters("PRINT_RESOLUTION")->asInt() );
-}
-
-//---------------------------------------------------------
-int CWKSP_Map::Get_Print_Frame(void)
-{
- return( m_Parameters("PRINT_FRAME_SHOW")->asBool() ? m_Parameters("PRINT_FRAME_WIDTH")->asInt() : 0 );
-}
-
-//---------------------------------------------------------
-int CWKSP_Map::Get_Print_Legend(void)
-{
- return( m_Parameters("PRINT_LEGEND")->asInt() );
-}
-
-//---------------------------------------------------------
-int CWKSP_Map::_On_Parameter_Changed(CSG_Parameter *pParameter)
-{
- if( pParameter && pParameter->Get_Owner() && pParameter->Get_Owner()->Get_Owner() )
- {
- return( ((CWKSP_Map *)pParameter->Get_Owner()->Get_Owner())->
- On_Parameter_Changed(pParameter->Get_Owner(), pParameter)
- );
- }
-
- return( 0 );
-}
-
-//---------------------------------------------------------
-int CWKSP_Map::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
-{
- return( 1 );
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::Parameters_Changed(void)
-{
- m_Name = m_Parameters("NAME")->asString();
-
- if( m_pView )
- {
- m_pView->SetTitle(m_Name);
-
- m_pView->Ruler_Set_Width(Get_Frame_Width());
- }
-
- View_Refresh(false);
-
- CWKSP_Base_Manager::Parameters_Changed();
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CWKSP_Map_Layer * CWKSP_Map::Find_Layer(CWKSP_Layer *pLayer)
-{
- for(int i=0; i<Get_Count(); i++)
- {
- if( pLayer == Get_Layer(i)->Get_Layer() )
- {
- return( Get_Layer(i) );
- }
- }
-
- return( NULL );
-}
-
-//---------------------------------------------------------
-int CWKSP_Map::Get_Layer(CWKSP_Layer *pLayer)
-{
- for(int i=0; i<Get_Count(); i++)
- {
- if( pLayer == Get_Layer(i)->Get_Layer() )
- {
- return( i );
- }
- }
-
- return( -1 );
-}
-
-//---------------------------------------------------------
-CWKSP_Map_Layer * CWKSP_Map::Add_Layer(CWKSP_Layer *pLayer)
-{
- CWKSP_Map_Layer *pItem;
-
- if( Get_Layer(pLayer) < 0 )
- {
- if( Get_Count() == 0 )
- {
- Set_Extent(pLayer->Get_Extent());
- }
-
- if( Get_Count() == 0 || m_Parameters("GOTO_NEWLAYER")->asBool() )
- {
- Set_Extent(pLayer->Get_Extent());
- }
-
- Add_Item(pItem = new CWKSP_Map_Layer(pLayer));
-
- Move_Top(pItem);
-
- return( pItem );
- }
-
- return( NULL );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Map::Update(CWKSP_Layer *pLayer, bool bMapOnly)
-{
- int iLayer;
-
- if( (iLayer = Get_Layer(pLayer)) >= 0 )
- {
- if( !bMapOnly )
- {
- Get_Layer(iLayer)->Parameters_Changed();
- }
-
- if( m_pView )
- {
- View_Refresh(bMapOnly);
- }
-
- _Img_Save_On_Change();
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CWKSP_Map::_Set_Extent(const CSG_Rect &Extent)
-{
- if( Extent.Get_XRange() > 0.0 && Extent.Get_YRange() > 0.0 )
- {
- View_Refresh(true);
-
- if( m_bSynchronise )
- {
- _Synchronise_Extents();
- }
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::Set_Extent(const CSG_Rect &Extent, bool bReset)
-{
- if( m_Extents.Add_Extent(Extent, bReset) )
- {
- _Set_Extent(Extent);
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::Set_Extent(void)
-{
- CSG_Parameters p(NULL, LNG("[CAP] Map Extent"), LNG(""));
-
- p.Add_Range(NULL, "X", LNG("West-East") , LNG(""), Get_Extent().Get_XMin(), Get_Extent().Get_XMax());
- p.Add_Range(NULL, "Y", LNG("South-North") , LNG(""), Get_Extent().Get_YMin(), Get_Extent().Get_YMax());
-
- if( DLG_Parameters(&p) )
- {
- Set_Extent(CSG_Rect(
- p("X")->asRange()->Get_LoVal(),
- p("Y")->asRange()->Get_LoVal(),
- p("X")->asRange()->Get_HiVal(),
- p("Y")->asRange()->Get_HiVal())
- );
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::Set_Extent_Full(void)
-{
- if( Get_Count() > 0 )
- {
- CSG_Rect Extent(Get_Layer(0)->Get_Layer()->Get_Extent());
-
- for(int i=1; i<Get_Count(); i++)
- {
- Extent.Union(Get_Layer(i)->Get_Layer()->Get_Extent());
- }
-
- Set_Extent(Extent);
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::Set_Extent_Active(void)
-{
- if( Get_Active_Layer() )
- {
- Set_Extent(Get_Active_Layer()->Get_Extent());
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::Set_Extent_Selection(void)
-{
- if( Get_Active_Layer() )
- {
- Set_Extent(Get_Active_Layer()->Edit_Get_Extent());
- }
-}
-
-//---------------------------------------------------------
-bool CWKSP_Map::Set_Extent_Back(bool bCheck_Only)
-{
- if( !m_Extents.is_First() )
- {
- if( !bCheck_Only )
- {
- _Set_Extent(m_Extents.Set_Back());
- }
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Map::Set_Extent_Forward(bool bCheck_Only)
-{
- if( !m_Extents.is_Last() )
- {
- if( !bCheck_Only )
- {
- _Set_Extent(m_Extents.Set_Forward());
- }
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::Set_Synchronising(bool bOn)
-{
- m_bSynchronise = bOn;
-
- if( m_bSynchronise )
- {
- _Synchronise_Extents();
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::_Synchronise_Extents(void)
-{
- for(int i=0; i<Get_Manager()->Get_Count(); i++)
- {
- if( Get_Manager()->Get_Item(i) != this )
- {
- ((CWKSP_Map_Manager *)Get_Manager())->Get_Map(i)->Set_Extent(Get_Extent());
- }
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CWKSP_Map::On_Delete(CWKSP_Map_Layer *pLayer)
-{
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CWKSP_Map::View_Closes(wxMDIChildFrame *pView)
-{
- if( wxDynamicCast(pView, CVIEW_Map) != NULL )
- {
- m_pView = NULL;
- }
-
- if( wxDynamicCast(pView, CVIEW_Map_3D) != NULL )
- {
- m_pView_3D = NULL;
- }
-
- if( wxDynamicCast(pView, CVIEW_Layout) != NULL )
- {
- m_pLayout = NULL;
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::View_Refresh(bool bMapOnly)
-{
- if( !bMapOnly && g_pACTIVE && g_pACTIVE->Get_Legend() )
- {
- g_pACTIVE->Get_Legend()->Refresh(true);
- }
-
- if( m_pView )
- {
- m_pView->Refresh_Map();
- }
-
- if( m_pView_3D )
- {
- m_pView_3D->On_Source_Changed();
- }
-
- if( m_pLayout )
- {
- m_pLayout->Refresh_Layout();
- }
-
- _Set_Thumbnail();
-
- if( g_pMap_Buttons )
- {
- g_pMap_Buttons->Refresh();
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::View_Show(bool bShow)
-{
- if( bShow )
- {
- if( !m_pView )
- {
- m_pView = new CVIEW_Map(this, Get_Frame_Width());
- }
- else
- {
- View_Refresh(false);
- m_pView->Activate();
- }
- }
- else if( m_pView )
- {
- m_pView->Destroy();
- delete(m_pView);
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::View_Toggle(void)
-{
- View_Show( m_pView == NULL );
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::View_3D_Show(bool bShow)
-{
- if( bShow && !m_pView_3D )
- {
- m_pView_3D = new CVIEW_Map_3D(this);
- }
- else if( !bShow && m_pView_3D )
- {
- m_pView_3D->Destroy();
- delete(m_pView_3D);
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::View_3D_Toggle(void)
-{
- View_3D_Show( m_pView_3D == NULL );
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::View_Layout_Show(bool bShow)
-{
- if( bShow && !m_pLayout )
- {
- m_pLayout = new CVIEW_Layout(m_pLayout_Info);
- }
- else if( !bShow && m_pLayout )
- {
- m_pLayout->Destroy();
- delete(m_pLayout);
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::View_Layout_Toggle(void)
-{
- View_Layout_Show( m_pLayout == NULL );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CSG_Rect CWKSP_Map::Get_World(wxRect rClient)
-{
- double d, dWorld, dClient;
- TSG_Rect Extent;
-
- Extent = Get_Extent().m_rect;
-
- dClient = (double)rClient.GetHeight() / (double)rClient.GetWidth();
- dWorld = Get_Extent().Get_YRange() / Get_Extent().Get_XRange();
-
- if( dWorld > dClient )
- {
- d = (Get_Extent().Get_XRange() - Get_Extent().Get_YRange() / dClient) / 2.0;
- Extent.xMin += d;
- Extent.xMax -= d;
- }
- else
- {
- d = (Get_Extent().Get_YRange() - Get_Extent().Get_XRange() * dClient) / 2.0;
- Extent.yMin += d;
- Extent.yMax -= d;
- }
-
- return( CSG_Rect(Extent) );
-}
-
-//---------------------------------------------------------
-CSG_Point CWKSP_Map::Get_World(wxRect rClient, wxPoint ptClient)
-{
- double d;
- CSG_Rect rWorld(Get_World(rClient));
-
- ptClient.y = rClient.GetHeight() - ptClient.y;
- d = rWorld.Get_XRange() / (double)rClient.GetWidth();
-
- return( CSG_Point(
- rWorld.Get_XMin() + ptClient.x * d,
- rWorld.Get_YMin() + ptClient.y * d)
- );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#define MASK_R 255
-#define MASK_G 0
-#define MASK_B 255
-
-//---------------------------------------------------------
-bool CWKSP_Map::Get_Image(wxImage &Image, CSG_Rect &rWorld)
-{
- if( Image.GetWidth() > 0 && Image.GetHeight() > 0 )
- {
- wxBitmap BMP(Image);
- wxMemoryDC dc;
-
- dc.SelectObject(BMP);
- Draw_Map(dc, 1.0, wxRect(0, 0, Image.GetWidth(), Image.GetHeight()), false, SG_GET_RGB(MASK_R, MASK_G, MASK_B));
- dc.SelectObject(wxNullBitmap);
-
- rWorld = Get_World(wxRect(0, 0, Image.GetWidth(), Image.GetHeight()));
- Image = BMP.ConvertToImage();
- Image.SetMaskColour(MASK_R, MASK_G, MASK_B);
-
- return( true );
- }
-
- return( false );
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::SaveAs_Image(void)
-{
- //-----------------------------------------------------
- if( View_Get() && View_Get()->Get_Map_Control() )
- {
- wxSize s(View_Get()->Get_Map_Control()->GetClientSize());
-
- m_Img_Parms("NX")->Set_Value(s.x);
- m_Img_Parms("NY")->Set_Value(s.y);
- }
-
- if( DLG_Image_Save(m_Img_File, m_Img_Type) && DLG_Parameters(&m_Img_Parms) )
- {
- _Img_Save(m_Img_File, m_Img_Type);
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::SaveAs_Image_Clipboard(bool bLegend)
+ pNode_0 = m_Img_Parms.Add_Node(NULL, "NODE_LEGEND", LNG("[PRM] Legend"), LNG(""));
+
+ m_Img_Parms.Add_Value(
+ pNode_0 , "LG" , LNG("[PRM] Save"),
+ LNG(""),
+ PARAMETER_TYPE_Bool, 1
+ );
+
+ m_Img_Parms.Add_Value(
+ pNode_0 , "LZ" , LNG("[PRM] Zoom"),
+ LNG(""),
+ PARAMETER_TYPE_Double, 1.0, 0, true
+ );
+}
+
+//---------------------------------------------------------
+int CWKSP_Map::Get_Frame_Width(void)
+{
+ return( m_Parameters("FRAME_SHOW")->asBool() ? m_Parameters("FRAME_WIDTH")->asInt() : 0 );
+}
+
+//---------------------------------------------------------
+int CWKSP_Map::Get_Print_Resolution(void)
+{
+ return( m_Parameters("PRINT_RESOLUTION")->asInt() );
+}
+
+//---------------------------------------------------------
+int CWKSP_Map::Get_Print_Frame(void)
+{
+ return( m_Parameters("PRINT_FRAME_SHOW")->asBool() ? m_Parameters("PRINT_FRAME_WIDTH")->asInt() : 0 );
+}
+
+//---------------------------------------------------------
+int CWKSP_Map::Get_Print_Legend(void)
+{
+ return( m_Parameters("PRINT_LEGEND")->asInt() );
+}
+
+//---------------------------------------------------------
+int CWKSP_Map::_On_Parameter_Changed(CSG_Parameter *pParameter)
+{
+ if( pParameter && pParameter->Get_Owner() && pParameter->Get_Owner()->Get_Owner() )
+ {
+ return( ((CWKSP_Map *)pParameter->Get_Owner()->Get_Owner())->
+ On_Parameter_Changed(pParameter->Get_Owner(), pParameter)
+ );
+ }
+
+ return( 0 );
+}
+
+//---------------------------------------------------------
+int CWKSP_Map::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ return( 1 );
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::Parameters_Changed(void)
+{
+ m_Name = m_Parameters("NAME")->asString();
+
+ if( m_pView )
+ {
+ m_pView->SetTitle(m_Name);
+
+ m_pView->Ruler_Set_Width(Get_Frame_Width());
+ }
+
+ View_Refresh(false);
+
+ CWKSP_Base_Manager::Parameters_Changed();
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CWKSP_Map_Layer * CWKSP_Map::Find_Layer(CWKSP_Layer *pLayer)
+{
+ for(int i=0; i<Get_Count(); i++)
+ {
+ if( pLayer == Get_Layer(i)->Get_Layer() )
+ {
+ return( Get_Layer(i) );
+ }
+ }
+
+ return( NULL );
+}
+
+//---------------------------------------------------------
+int CWKSP_Map::Get_Layer(CWKSP_Layer *pLayer)
+{
+ for(int i=0; i<Get_Count(); i++)
+ {
+ if( pLayer == Get_Layer(i)->Get_Layer() )
+ {
+ return( i );
+ }
+ }
+
+ return( -1 );
+}
+
+//---------------------------------------------------------
+CWKSP_Map_Layer * CWKSP_Map::Add_Layer(CWKSP_Layer *pLayer)
+{
+ CWKSP_Map_Layer *pItem;
+
+ if( Get_Layer(pLayer) < 0 )
+ {
+ if( Get_Count() == 0 )
+ {
+ Set_Extent(pLayer->Get_Extent());
+ }
+
+ if( Get_Count() == 0 || (m_Parameters("GOTO_NEWLAYER")->asBool() && pLayer->Get_Extent().Get_XRange() > 0.0 && pLayer->Get_Extent().Get_YRange() > 0.0) )
+ {
+ Set_Extent(pLayer->Get_Extent());
+ }
+
+ if( Get_Count() == 0 )
+ {
+ m_Parameters("NAME")->Set_Value(pLayer->Get_Name());
+
+ Parameters_Changed();
+ }
+
+ Add_Item(pItem = new CWKSP_Map_Layer(pLayer));
+
+ Move_Top(pItem);
+
+ return( pItem );
+ }
+
+ return( NULL );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Map::Update(CWKSP_Layer *pLayer, bool bMapOnly)
+{
+ bool bRefresh = false;
+
+ for(int i=0; i<Get_Count(); i++)
+ {
+ if( Get_Layer(i)->Get_Layer()->Update(pLayer) )
+ {
+ bRefresh = true;
+
+ if( !bMapOnly )
+ {
+ Get_Layer(i)->Parameters_Changed();
+ }
+ }
+ }
+
+ if( bRefresh )
+ {
+ if( m_pView )
+ {
+ View_Refresh(bMapOnly);
+ }
+
+ _Img_Save_On_Change();
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CWKSP_Map::_Set_Extent(const CSG_Rect &Extent)
+{
+ if( Extent.Get_XRange() > 0.0 && Extent.Get_YRange() > 0.0 )
+ {
+ View_Refresh(true);
+
+ if( m_bSynchronise )
+ {
+ _Synchronise_Extents();
+ }
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::Set_Extent(const CSG_Rect &Extent, bool bReset)
+{
+ CSG_Rect r(Extent);
+
+ if( r.Get_XRange() == 0.0 )
+ {
+ r.m_rect.xMin -= 1.0;
+ r.m_rect.xMax += 1.0;
+ }
+
+ if( r.Get_YRange() == 0.0 )
+ {
+ r.m_rect.yMin -= 1.0;
+ r.m_rect.yMax += 1.0;
+ }
+
+ if( m_Extents.Add_Extent(r, bReset) )
+ {
+ _Set_Extent(r);
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::Set_Extent(void)
+{
+ CSG_Parameters p(NULL, LNG("[CAP] Map Extent"), LNG(""));
+
+ p.Add_Range(NULL, "X", LNG("West-East") , LNG(""), Get_Extent().Get_XMin(), Get_Extent().Get_XMax());
+ p.Add_Range(NULL, "Y", LNG("South-North") , LNG(""), Get_Extent().Get_YMin(), Get_Extent().Get_YMax());
+
+ if( DLG_Parameters(&p) )
+ {
+ Set_Extent(CSG_Rect(
+ p("X")->asRange()->Get_LoVal(),
+ p("Y")->asRange()->Get_LoVal(),
+ p("X")->asRange()->Get_HiVal(),
+ p("Y")->asRange()->Get_HiVal())
+ );
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::Set_Extent_Full(void)
+{
+ if( Get_Count() > 0 )
+ {
+ CSG_Rect Extent(Get_Layer(0)->Get_Layer()->Get_Extent());
+
+ for(int i=1; i<Get_Count(); i++)
+ {
+ Extent.Union(Get_Layer(i)->Get_Layer()->Get_Extent());
+ }
+
+ Set_Extent(Extent);
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::Set_Extent_Active(void)
+{
+ if( Get_Active_Layer() )
+ {
+ Set_Extent(Get_Active_Layer()->Get_Extent());
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::Set_Extent_Selection(void)
+{
+ if( Get_Active_Layer() )
+ {
+ Set_Extent(Get_Active_Layer()->Edit_Get_Extent());
+ }
+}
+
+//---------------------------------------------------------
+bool CWKSP_Map::Set_Extent_Back(bool bCheck_Only)
+{
+ if( !m_Extents.is_First() )
+ {
+ if( !bCheck_Only )
+ {
+ _Set_Extent(m_Extents.Set_Back());
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Map::Set_Extent_Forward(bool bCheck_Only)
+{
+ if( !m_Extents.is_Last() )
+ {
+ if( !bCheck_Only )
+ {
+ _Set_Extent(m_Extents.Set_Forward());
+ }
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::Set_Synchronising(bool bOn)
+{
+ m_bSynchronise = bOn;
+
+ if( m_bSynchronise )
+ {
+ _Synchronise_Extents();
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::_Synchronise_Extents(void)
+{
+ for(int i=0; i<Get_Manager()->Get_Count(); i++)
+ {
+ if( Get_Manager()->Get_Item(i) != this )
+ {
+ ((CWKSP_Map_Manager *)Get_Manager())->Get_Map(i)->Set_Extent(Get_Extent());
+ }
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CWKSP_Map::On_Delete(CWKSP_Map_Layer *pLayer)
+{
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CWKSP_Map::View_Closes(wxMDIChildFrame *pView)
+{
+ if( wxDynamicCast(pView, CVIEW_Map) != NULL )
+ {
+ m_pView = NULL;
+ }
+
+ if( wxDynamicCast(pView, CVIEW_Map_3D) != NULL )
+ {
+ m_pView_3D = NULL;
+ }
+
+ if( wxDynamicCast(pView, CVIEW_Layout) != NULL )
+ {
+ m_pLayout = NULL;
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::View_Refresh(bool bMapOnly)
+{
+ if( !bMapOnly && g_pACTIVE && g_pACTIVE->Get_Legend() )
+ {
+ g_pACTIVE->Get_Legend()->Refresh(true);
+ }
+
+ if( m_pView )
+ {
+ m_pView->Refresh_Map();
+ }
+
+ if( m_pView_3D )
+ {
+ m_pView_3D->On_Source_Changed();
+ }
+
+ if( m_pLayout )
+ {
+ m_pLayout->Refresh_Layout();
+ }
+
+ _Set_Thumbnail();
+
+ if( g_pMap_Buttons )
+ {
+ g_pMap_Buttons->Refresh();
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::View_Show(bool bShow)
+{
+ if( bShow )
+ {
+ if( !m_pView )
+ {
+ m_pView = new CVIEW_Map(this, Get_Frame_Width());
+ }
+ else
+ {
+ View_Refresh(false);
+ m_pView->Activate();
+ }
+ }
+ else if( m_pView )
+ {
+ m_pView->Destroy();
+ delete(m_pView);
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::View_Toggle(void)
+{
+ View_Show( m_pView == NULL );
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::View_3D_Show(bool bShow)
+{
+ if( bShow && !m_pView_3D )
+ {
+ m_pView_3D = new CVIEW_Map_3D(this);
+ }
+ else if( !bShow && m_pView_3D )
+ {
+ m_pView_3D->Destroy();
+ delete(m_pView_3D);
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::View_3D_Toggle(void)
+{
+ View_3D_Show( m_pView_3D == NULL );
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::View_Layout_Show(bool bShow)
+{
+ if( bShow && !m_pLayout )
+ {
+ m_pLayout = new CVIEW_Layout(m_pLayout_Info);
+ }
+ else if( !bShow && m_pLayout )
+ {
+ m_pLayout->Destroy();
+ delete(m_pLayout);
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::View_Layout_Toggle(void)
+{
+ View_Layout_Show( m_pLayout == NULL );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Rect CWKSP_Map::Get_World(wxRect rClient)
+{
+ double d, dWorld, dClient;
+ TSG_Rect Extent;
+
+ Extent = Get_Extent().m_rect;
+
+ dClient = (double)rClient.GetHeight() / (double)rClient.GetWidth();
+ dWorld = Get_Extent().Get_YRange() / Get_Extent().Get_XRange();
+
+ if( dWorld > dClient )
+ {
+ d = (Get_Extent().Get_XRange() - Get_Extent().Get_YRange() / dClient) / 2.0;
+ Extent.xMin += d;
+ Extent.xMax -= d;
+ }
+ else
+ {
+ d = (Get_Extent().Get_YRange() - Get_Extent().Get_XRange() * dClient) / 2.0;
+ Extent.yMin += d;
+ Extent.yMax -= d;
+ }
+
+ return( CSG_Rect(Extent) );
+}
+
+//---------------------------------------------------------
+CSG_Point CWKSP_Map::Get_World(wxRect rClient, wxPoint ptClient)
+{
+ double d;
+ CSG_Rect rWorld(Get_World(rClient));
+
+ ptClient.y = rClient.GetHeight() - ptClient.y;
+ d = rWorld.Get_XRange() / (double)rClient.GetWidth();
+
+ return( CSG_Point(
+ rWorld.Get_XMin() + ptClient.x * d,
+ rWorld.Get_YMin() + ptClient.y * d)
+ );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define MASK_R 255
+#define MASK_G 0
+#define MASK_B 255
+
+//---------------------------------------------------------
+bool CWKSP_Map::Get_Image(wxImage &Image, CSG_Rect &rWorld)
+{
+ if( Image.GetWidth() > 0 && Image.GetHeight() > 0 )
+ {
+ wxBitmap BMP(Image);
+ wxMemoryDC dc;
+
+ dc.SelectObject(BMP);
+ Draw_Map(dc, 1.0, wxRect(0, 0, Image.GetWidth(), Image.GetHeight()), false, SG_GET_RGB(MASK_R, MASK_G, MASK_B));
+ dc.SelectObject(wxNullBitmap);
+
+ rWorld = Get_World(wxRect(0, 0, Image.GetWidth(), Image.GetHeight()));
+ Image = BMP.ConvertToImage();
+ Image.SetMaskColour(MASK_R, MASK_G, MASK_B);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::SaveAs_Image(void)
+{
+ //-----------------------------------------------------
+ if( View_Get() && View_Get()->Get_Map_Control() )
+ {
+ wxSize s(View_Get()->Get_Map_Control()->GetClientSize());
+
+ m_Img_Parms("NX")->Set_Value(s.x);
+ m_Img_Parms("NY")->Set_Value(s.y);
+ }
+
+ if( DLG_Image_Save(m_Img_File, m_Img_Type) && DLG_Parameters(&m_Img_Parms) )
+ {
+ _Img_Save(m_Img_File, m_Img_Type);
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::SaveAs_Image_Clipboard(bool bLegend)
{
if( bLegend == false )
{
@@ -1082,129 +1117,129 @@ void CWKSP_Map::SaveAs_Image_Clipboard(bool bLegend)
}
Set_Buisy_Cursor(false);
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::SaveAs_Image_Clipboard(int nx, int ny, int frame)
-{
- Set_Buisy_Cursor(true);
-
- wxSize s;
- wxRect r;
- wxBitmap BMP;
- wxMemoryDC dc;
-
-// if( frame < 0 ) frame = Get_Frame_Width();
- if( frame < 5 ) frame = 0;
-
- r = wxRect(0, 0, nx + 2 * frame, ny + 2 * frame);
-
- BMP.Create(r.GetWidth(), r.GetHeight());
- r.Deflate(frame);
- dc.SelectObject(BMP);
- dc.SetBackground(*wxWHITE_BRUSH);
- dc.Clear();
-
- Draw_Map(dc, 1.0, r, false);
- Draw_Frame(dc, r, frame);
-
- dc.SelectObject(wxNullBitmap);
-
- if( wxTheClipboard->Open() )
- {
- wxBitmapDataObject *pBMP = new wxBitmapDataObject;
- pBMP->SetBitmap(BMP);
- wxTheClipboard->SetData(pBMP);
- wxTheClipboard->Close();
- }
-
- Set_Buisy_Cursor(false);
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::SaveAs_Image_On_Change(void)
-{
- if( m_Img_bSave )
- {
- m_Img_bSave = false;
- }
- else if( DLG_Image_Save(m_Img_File, m_Img_Type) && DLG_Parameters(&m_Img_Parms) )
- {
- m_Img_bSave = true;
- m_Img_Count = 0;
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::_Img_Save_On_Change(void)
-{
- if( m_Img_bSave )
- {
- wxFileName fn(m_Img_File), file(m_Img_File);
-
- file.SetName(wxString::Format(wxT("%s_%03d"), fn.GetName().c_str(), m_Img_Count++));
-
- _Img_Save(file.GetFullPath(), m_Img_Type);
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::_Img_Save(wxString file, int type)
-{
- int nx, ny, Frame;
- wxSize s;
- wxRect r;
- wxBitmap BMP;
- wxMemoryDC dc;
-
- Set_Buisy_Cursor(true);
-
- nx = m_Img_Parms("NX")->asInt();
- ny = m_Img_Parms("NY")->asInt();
- Frame = m_Img_Parms("FR")->asInt(); if( Frame < 5 ) Frame = 0;
- r = wxRect(0, 0, nx + 2 * Frame, ny + 2 * Frame);
-
- BMP.Create(r.GetWidth(), r.GetHeight());
- r.Deflate(Frame);
- dc.SelectObject(BMP);
- dc.SetBackground(*wxWHITE_BRUSH);
- dc.Clear();
-
- Draw_Map(dc, 1.0, r, false);
- Draw_Frame(dc, r, Frame);
-
- dc.SelectObject(wxNullBitmap);
- BMP.SaveFile(file, (wxBitmapType)type);
-
- if( m_Img_Parms("REF")->asBool() )
- {
- CSG_File Stream;
- wxFileName fn(file);
-
- switch( type )
- {
- default: fn.SetExt(wxT("world")); break;
- case wxBITMAP_TYPE_BMP: fn.SetExt(wxT("bpw")); break;
- case wxBITMAP_TYPE_GIF: fn.SetExt(wxT("gfw")); break;
- case wxBITMAP_TYPE_JPEG: fn.SetExt(wxT("jgw")); break;
- case wxBITMAP_TYPE_PNG: fn.SetExt(wxT("pgw")); break;
- case wxBITMAP_TYPE_PCX: fn.SetExt(wxT("pxw")); break;
- case wxBITMAP_TYPE_TIF: fn.SetExt(wxT("tfw")); break;
- }
-
- if( Stream.Open(fn.GetFullPath().c_str(), SG_FILE_W, false) )
- {
- CSG_Rect rWorld(Get_World(r));
- double d = rWorld.Get_XRange() / r.GetWidth();
-
- Stream.Printf(wxT("%.10f\n%.10f\n%.10f\n%.10f\n%.10f\n%.10f\n"),
- d, 0.0, 0.0,-d,
- rWorld.Get_XMin() - Frame * d,
- rWorld.Get_YMax() + Frame * d
- );
- }
- }
-
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::SaveAs_Image_Clipboard(int nx, int ny, int frame)
+{
+ Set_Buisy_Cursor(true);
+
+ wxSize s;
+ wxRect r;
+ wxBitmap BMP;
+ wxMemoryDC dc;
+
+// if( frame < 0 ) frame = Get_Frame_Width();
+ if( frame < 5 ) frame = 0;
+
+ r = wxRect(0, 0, nx + 2 * frame, ny + 2 * frame);
+
+ BMP.Create(r.GetWidth(), r.GetHeight());
+ r.Deflate(frame);
+ dc.SelectObject(BMP);
+ dc.SetBackground(*wxWHITE_BRUSH);
+ dc.Clear();
+
+ Draw_Map(dc, 1.0, r, false);
+ Draw_Frame(dc, r, frame);
+
+ dc.SelectObject(wxNullBitmap);
+
+ if( wxTheClipboard->Open() )
+ {
+ wxBitmapDataObject *pBMP = new wxBitmapDataObject;
+ pBMP->SetBitmap(BMP);
+ wxTheClipboard->SetData(pBMP);
+ wxTheClipboard->Close();
+ }
+
+ Set_Buisy_Cursor(false);
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::SaveAs_Image_On_Change(void)
+{
+ if( m_Img_bSave )
+ {
+ m_Img_bSave = false;
+ }
+ else if( DLG_Image_Save(m_Img_File, m_Img_Type) && DLG_Parameters(&m_Img_Parms) )
+ {
+ m_Img_bSave = true;
+ m_Img_Count = 0;
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::_Img_Save_On_Change(void)
+{
+ if( m_Img_bSave )
+ {
+ wxFileName fn(m_Img_File), file(m_Img_File);
+
+ file.SetName(wxString::Format(wxT("%s_%03d"), fn.GetName().c_str(), m_Img_Count++));
+
+ _Img_Save(file.GetFullPath(), m_Img_Type);
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::_Img_Save(wxString file, int type)
+{
+ int nx, ny, Frame;
+ wxSize s;
+ wxRect r;
+ wxBitmap BMP;
+ wxMemoryDC dc;
+
+ Set_Buisy_Cursor(true);
+
+ nx = m_Img_Parms("NX")->asInt();
+ ny = m_Img_Parms("NY")->asInt();
+ Frame = m_Img_Parms("FR")->asInt(); if( Frame < 5 ) Frame = 0;
+ r = wxRect(0, 0, nx + 2 * Frame, ny + 2 * Frame);
+
+ BMP.Create(r.GetWidth(), r.GetHeight());
+ r.Deflate(Frame);
+ dc.SelectObject(BMP);
+ dc.SetBackground(*wxWHITE_BRUSH);
+ dc.Clear();
+
+ Draw_Map(dc, 1.0, r, false);
+ Draw_Frame(dc, r, Frame);
+
+ dc.SelectObject(wxNullBitmap);
+ BMP.SaveFile(file, (wxBitmapType)type);
+
+ if( m_Img_Parms("REF")->asBool() )
+ {
+ CSG_File Stream;
+ wxFileName fn(file);
+
+ switch( type )
+ {
+ default: fn.SetExt(wxT("world")); break;
+ case wxBITMAP_TYPE_BMP: fn.SetExt(wxT("bpw")); break;
+ case wxBITMAP_TYPE_GIF: fn.SetExt(wxT("gfw")); break;
+ case wxBITMAP_TYPE_JPEG: fn.SetExt(wxT("jgw")); break;
+ case wxBITMAP_TYPE_PNG: fn.SetExt(wxT("pgw")); break;
+ case wxBITMAP_TYPE_PCX: fn.SetExt(wxT("pxw")); break;
+ case wxBITMAP_TYPE_TIF: fn.SetExt(wxT("tfw")); break;
+ }
+
+ if( Stream.Open(fn.GetFullPath().c_str(), SG_FILE_W, false) )
+ {
+ CSG_Rect rWorld(Get_World(r));
+ double d = rWorld.Get_XRange() / r.GetWidth();
+
+ Stream.Printf(wxT("%.10f\n%.10f\n%.10f\n%.10f\n%.10f\n%.10f\n"),
+ d, 0.0, 0.0,-d,
+ rWorld.Get_XMin() - Frame * d,
+ rWorld.Get_YMax() + Frame * d
+ );
+ }
+ }
+
if( m_Img_Parms("KML")->asBool() )
{
CSG_File Stream;
@@ -1243,512 +1278,512 @@ void CWKSP_Map::_Img_Save(wxString file, int type)
}
}
- if( m_Img_Parms("LG")->asBool() && Get_Legend_Size(s, 1.0, m_Img_Parms("LZ")->asDouble()) )
- {
- wxFileName fn(file);
- file = fn.GetName();
- file.Append(wxT("_legend"));
- fn.SetName(file);
- file = fn.GetFullPath();
-
- BMP.Create(s.GetWidth(), s.GetHeight());
- dc.SelectObject(BMP);
- dc.SetBackground(*wxWHITE_BRUSH);
- dc.Clear();
-
- Draw_Legend(dc, 1.0, m_Img_Parms("LZ")->asDouble(), wxPoint(0, 0));
-
- dc.SelectObject(wxNullBitmap);
- BMP.SaveFile(file, (wxBitmapType)type);
- }
-
- Set_Buisy_Cursor(false);
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::SaveAs_PDF_Indexed(void)
-{
- static CSG_Parameters Parameters(NULL, LNG("[CAP] Save to PDF"), LNG(""), NULL, false);
-
- //-----------------------------------------------------
- if( Parameters.Get_Count() == 0 )
- {
- Parameters.Add_FilePath(
- NULL , "FILENAME" , LNG("[FLD] PDF Document"),
- LNG(""),
- wxString::Format(
- wxT("%s (*.pdf)|*pdf|")
- wxT("%s|*.*"),
- LNG("PDF Files"),
- LNG("All Files")
- ), NULL, true, false
- );
-
- Parameters.Add_Choice(
- NULL , "PAPER_SIZE" , LNG("[FLD] Paper Format"),
- LNG(""),
-
- CSG_String::Format(wxT("%s|%s|%s|%s|"),
- LNG("A4 Portrait"),
- LNG("A4 Landscape"),
- LNG("A3 Portrait"),
- LNG("A3 Landscape")
- )
- );
-
- Parameters.Add_String(
- NULL , "NAME" , LNG("[FLD] Title"),
- LNG(""),
- LNG("")
- );
-
- Parameters.Add_Shapes(
- NULL , "SHAPES" , LNG("[FLD] Shapes"),
- LNG(""),
- PARAMETER_INPUT_OPTIONAL
- );
-
- Parameters.Add_Table_Field(
- Parameters("SHAPES") , "FIELD" , LNG("[FLD] Attribute"),
- LNG("")
- );
-
- // Parameters.Add_Grid(
- // NULL , "GRID" , LNG("[FLD] Grid"),
- // LNG(""),
- // PARAMETER_INPUT_OPTIONAL
- // );
-
- Parameters.Add_FilePath(
- NULL , "FILEICON" , LNG("[FLD] Icon"),
- LNG(""),
-
- CSG_String::Format(wxT("%s|*.png;*.jpg|%s|*.png|%s|*.jpg|%s|*.*"),
- LNG("All Recognised Files"),
- LNG("PNG Files"),
- LNG("JPG Files"),
- LNG("All Files")
- ), NULL, false, false
- );
-
- Parameters.Add_Value(
- NULL , "ROUNDSCALE" , LNG("[FLD] Round Scale"),
- LNG(""),
- PARAMETER_TYPE_Bool, true
- );
- }
-
- //-----------------------------------------------------
- if( DLG_Parameters(&Parameters) )
- {
- bool bResult, bRoundScale;
- int iField;
- CSG_String Name, FileName, FileName_Icon, FilePath_Maps;
- CSG_Rect rOverview, rMap;
- CSG_Shapes *pShapes;
- // CSG_Grid *pGrid;
- CSG_Doc_PDF PDF;
-
- MSG_General_Add(wxString::Format(wxT("%s..."), LNG("[MSG] Save to PDF")), true, true);
-
- bResult = false;
- Name = Parameters("NAME") ->asString(); if( Name.Length() < 1 ) Name = LNG("Maps");
- FileName = Parameters("FILENAME") ->asString();
- FileName_Icon = Parameters("FILEICON") ->asString();
- pShapes = Parameters("SHAPES") ->asShapes();
- // pGrid = Parameters("GRID") ->asGrid();
- iField = Parameters("FIELD") ->asInt();
- bRoundScale = Parameters("ROUNDSCALE") ->asBool();
-
- switch( Parameters("PAPER_SIZE")->asInt() )
- {
- default:
- case 0: PDF.Open(PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_PORTRAIT , Name); break; // A4 Portrait
- case 1: PDF.Open(PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_LANDSCAPE, Name); break; // A4 Landscape
- case 2: PDF.Open(PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_PORTRAIT , Name); break; // A3 Portrait
- case 3: PDF.Open(PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_LANDSCAPE, Name); break; // A3 Landscape
- }
-
- //-------------------------------------------------
- if( PDF.Is_Open() )
- {
- PDF.Layout_Set_Box_Space(5, false);
-
- PDF.Layout_Add_Box( 0.0, 0.0, 100.0, 75.0, "MAP");
- PDF.Layout_Add_Box( 0.0, 75.0, 50.0, 100.0, "DIVISIONS");
- PDF.Layout_Add_Box( 50.0, 75.0, 60.0, 80.0, "ICON");
- PDF.Layout_Add_Box( 60.0, 75.0, 100.0, 80.0, "TITLE");
- PDF.Layout_Add_Box( 50.0, 80.0, 100.0, 100.0, "DESCRIPTION");
-
- FilePath_Maps = SG_File_Make_Path(SG_File_Get_Path(FileName), SG_File_Get_Name(FileName, false));
- rOverview = pShapes ? pShapes->Get_Extent() : Get_Extent();
- // rOverview = pShapes ? pShapes->Get_Extent() : (pGrid ? pGrid->Get_Extent() : Get_Extent());
-
- //---------------------------------------------
- // PDF.Draw_Text (PDF.Layout_Get_Box("TITLE").Get_XMin(), PDF.Layout_Get_Box("TITLE").Get_YCenter(), LNG("This is a Test!!!"), 24);
- // PDF.Draw_Rectangle (PDF.Layout_Get_Box("DIVISIONS"));
- // PDF.Draw_Grid (PDF.Layout_Get_Box("DIVISIONS"), Parameters("GRID")->asGrid(), CSG_Colors(), 0.0, 0.0, 0, &rOverview);
- // PDF.Draw_Shapes (PDF.Layout_Get_Box("DIVISIONS"), pShapes, PDF_STYLE_POLYGON_STROKE, SG_COLOR_GREEN, SG_COLOR_BLACK, 1, &rOverview);
- // PDF.Draw_Graticule (PDF.Layout_Get_Box("DIVISIONS"), rOverview);
-
- //---------------------------------------------
- Draw_PDF(&PDF, FilePath_Maps, -1, FileName_Icon, Name, rOverview, bRoundScale, iField, pShapes);
-
- if( pShapes )
- {
- for(int i=0; i<pShapes->Get_Count() && SG_UI_Process_Set_Progress(i, pShapes->Get_Count()); i++)
- {
- Draw_PDF(&PDF, FilePath_Maps, i, FileName_Icon, Name, pShapes->Get_Shape(i)->Get_Extent(), bRoundScale, iField, pShapes);
- }
- }
-
- //---------------------------------------------
- PROCESS_Set_Okay(true);
- Set_Buisy_Cursor(true);
- bResult = PDF.Save(FileName);
- Set_Buisy_Cursor(false);
- }
-
- MSG_General_Add(bResult ? LNG("[MSG] okay") : LNG("[MSG] failed"), false, false, bResult ? SG_UI_MSG_STYLE_SUCCESS : SG_UI_MSG_STYLE_FAILURE);
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::Draw_PDF(CSG_Doc_PDF *pPDF, const wxChar *FilePath_Maps, int Image_ID, const wxChar *FileName_Icon, const wxChar *Title, CSG_Rect rWorld, bool bRoundScale, int iField, CSG_Shapes *pShapes)
-{
- int FrameSize_1 = 20, FrameSize_2 = 10;
- double d, e, Scale, Ratio;
- CSG_String FileName, Description, s;
- CSG_Rect rBox;
- wxRect rBMP;
- wxBitmap BMP;
- wxMemoryDC dc;
-
- if( pPDF && rWorld.Get_XRange() > 0.0 && rWorld.Get_YRange() > 0.0 && pPDF->Add_Page() )
- {
- rWorld.Inflate(5.0, true);
-
- //-------------------------------------------------
- rBox = pPDF->Layout_Get_Box("MAP");
- rBox.Deflate(FrameSize_1, false);
-
- rBMP = wxRect(0, 0, (int)rBox.Get_XRange(), (int)rBox.Get_YRange());
- BMP.Create(rBMP.GetWidth(), rBMP.GetHeight());
- dc.SelectObject(BMP);
- dc.SetBackground(*wxWHITE_BRUSH);
- dc.Clear();
-
- if( bRoundScale )
- {
- Scale = rWorld.Get_XRange() / (pPDF->Get_Page_To_Meter() * (double)rBMP.GetWidth());
-
- // if( Scale > 1000 )
- // {
- Ratio = ((ceil(Scale / 1000.)) / (Scale / 1000.) - 1);
- rWorld.Inflate(Ratio * 100, true);
- // }
- }
-
- Scale = rWorld.Get_XRange() / (pPDF->Get_Page_To_Meter() * rBMP.GetWidth());
-
- Draw_Map(dc, rWorld, 1.0, rBMP, false);
- dc.SelectObject(wxNullBitmap);
- SG_Dir_Create(FilePath_Maps);
- FileName = SG_File_Make_Path(FilePath_Maps, wxString::Format(wxT("image_%03d"), Image_ID + 1), wxT("png"));
- BMP.SaveFile(FileName.c_str(), wxBITMAP_TYPE_PNG);
-
- pPDF->Draw_Image (rBox, FileName);
- pPDF->Draw_Graticule(rBox, rWorld, FrameSize_1);
-
- //-------------------------------------------------
- rBox = pPDF->Layout_Get_Box("ICON");
-
- if( FileName_Icon )
- {
- pPDF->Draw_Image(rBox, FileName_Icon);
- }
- else
- {
- pPDF->Draw_Rectangle(rBox);
- }
-
- //-------------------------------------------------
- rBox = pPDF->Layout_Get_Box("DIVISIONS");
-
- pPDF->Draw_Rectangle(rBox);
-
- if( pShapes )
- {
- CSG_Rect rShapes(pShapes->Get_Extent());
-
- rShapes.Inflate(5.0, true);
- rBox.Deflate(FrameSize_2, false);
-
- pPDF->Draw_Graticule(rBox, rShapes, FrameSize_2);
- pPDF->Draw_Shapes(rBox, pShapes, PDF_STYLE_POLYGON_FILLSTROKE, SG_COLOR_GREEN, SG_COLOR_BLACK, 0, &rShapes);
-
- if( Image_ID >= 0 && Image_ID < pShapes->Get_Count() )
- {
- pPDF->Draw_Shape(rBox, pShapes->Get_Shape(Image_ID), PDF_STYLE_POLYGON_FILLSTROKE, SG_COLOR_YELLOW, SG_COLOR_RED, 1, &rShapes);
- }
- }
-
- //-------------------------------------------------
- rBox = pPDF->Layout_Get_Box("TITLE");
-
- pPDF->Draw_Text(rBox.Get_XMin(), rBox.Get_YCenter(), Title, 20, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_CENTER|PDF_STYLE_TEXT_UNDERLINE);
-
- //-------------------------------------------------
- rBox = pPDF->Layout_Get_Box("DESCRIPTION");
-
- Description.Append(wxString::Format(wxT("%d. %s\n"), Image_ID + 2, LNG("Map")));
-
- if( pShapes && Image_ID >= 0 && Image_ID < pShapes->Get_Count() )
- {
- switch( pShapes->Get_Type() )
- {
- default:
- break;
-
- case SHAPE_TYPE_Line:
- d = ((CSG_Shape_Line *)pShapes->Get_Shape(Image_ID))->Get_Length();
- e = d > 1000.0 ? 1000.0 : 1.0;
- s = d > 1000.0 ? wxT("km") : wxT("m");
- Description.Append(wxString::Format(wxT("%s: %f%s\n"), LNG("Length") , d / e, s.c_str()));
- break;
-
- case SHAPE_TYPE_Polygon:
- d = ((CSG_Shape_Polygon *)pShapes->Get_Shape(Image_ID))->Get_Area();
- e = d > 1000000.0 ? 1000000.0 : (d > 10000.0 ? 10000.0 : 1.0);
- s = d > 1000000.0 ? wxT("km\xc2\xb2") : (d > 10000.0 ? wxT("ha") : wxT("m\xc2\xb2"));
- Description.Append(wxString::Format(wxT("%s: %f%s\n"), LNG("Area") , d / e, s.c_str()));
-
- d = ((CSG_Shape_Polygon *)pShapes->Get_Shape(Image_ID))->Get_Perimeter();
- e = d > 1000.0 ? 1000.0 : 1.0;
- s = d > 1000.0 ? wxT("km") : wxT("m");
- Description.Append(wxString::Format(wxT("%s: %f%s\n"), LNG("Perimeter") , d / e, s.c_str()));
-
- Description.Append(wxString::Format(wxT("%s: %d\n") , LNG("Parts") , ((CSG_Shape_Polygon *)pShapes->Get_Shape(Image_ID))->Get_Part_Count()));
- break;
- }
-
- if( iField >= 0 && iField < pShapes->Get_Field_Count() )
- {
- Description.Append(wxString::Format(wxT("%s: %s\n"), pShapes->Get_Field_Name(iField), pShapes->Get_Shape(Image_ID)->asString(iField)));
- }
- }
-
- Description.Append(wxString::Format(wxT("%s 1:%s"), LNG("Scale"), SG_Get_String(Scale, 2).c_str()));
-
- pPDF->Draw_Text(rBox.Get_XMin(), rBox.Get_YMax(), Description, 12, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP);
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::SaveAs_Interactive_SVG(void)
-{
- static CSG_Parameters Parameters(NULL, LNG("[CAP] Save As Interactive SVG"), LNG(""), NULL, false);
-
- //-----------------------------------------------------
- if( Parameters.Get_Count() == 0 )
- {
- Parameters.Add_FilePath(
- NULL , "FILENAME" , LNG("[FLD] SVG File"),
- LNG(""),
- wxString::Format(wxT("%s|*.svg|%s|*.*"),
- LNG("SVG - Scalable Vector Graphics Files (*.svg)"),
- LNG("All Files")
- ), NULL, true, false
- );
-
- Parameters.Add_Shapes(
- NULL , "SHAPES" , LNG("[FLD] Index Layer"),
- LNG(""),
- PARAMETER_INPUT_OPTIONAL
- );
- }
-
- //-----------------------------------------------------
- if( DLG_Parameters(&Parameters) )
- {
- CSG_String FileName;
- CSG_Shapes *pIndexLayer;
- CSVG_Interactive_Map SVG;
-
- MSG_General_Add(wxString::Format(wxT("%s..."), LNG("[MSG] Save as Interactive SVG")), true, true);
-
- pIndexLayer = Parameters("SHAPES") ->asShapes();
- FileName = Parameters("FILENAME") ->asString();
-
- SVG.Create_From_Map(this, pIndexLayer, FileName);
-
- MSG_General_Add(LNG("[MSG] okay"), false, false, SG_UI_MSG_STYLE_SUCCESS);
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-const wxBitmap & CWKSP_Map::Get_Thumbnail(int dx, int dy)
-{
- if( dx > 0 && m_Thumbnail.GetWidth() != dx
- && dy > 0 && m_Thumbnail.GetHeight() != dy )
- {
- m_Thumbnail.Create(dx, dy);
-
- _Set_Thumbnail();
- }
-
- return( m_Thumbnail );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Map::_Set_Thumbnail(void)
-{
- if( m_Thumbnail.GetWidth() > 0 && m_Thumbnail.GetHeight() > 0 )
- {
- wxMemoryDC dc;
- wxRect r(0, 0, m_Thumbnail.GetWidth(), m_Thumbnail.GetHeight());
-
- dc.SelectObject(m_Thumbnail);
- dc.SetBackground(*wxWHITE_BRUSH);
- dc.Clear();
-
- Draw_Map(dc, Get_Extent(), 1.0, r, false);
-
- dc.SelectObject(wxNullBitmap);
-
- return( true );
- }
-
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CWKSP_Map::Draw_Map(wxDC &dc, double Zoom, const wxRect &rClient, bool bEdit, int Background)
-{
- Draw_Map(dc, Get_World(rClient), Zoom, rClient, bEdit, Background);
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::Draw_Map(wxDC &dc, const CSG_Rect &rWorld, double Zoom, const wxRect &rClient, bool bEdit, int Background)
-{
- CWKSP_Map_DC dc_Map(rWorld, rClient, Zoom, Background);
-
- for(int i=Get_Count()-1; i>=0; i--)
- {
- if( Get_Layer(i)->do_Show() && Get_Layer(i)->Get_Layer()->do_Show(Get_Extent()) )
- {
- Get_Layer(i)->Get_Layer()->Draw(dc_Map, bEdit && Get_Layer(i)->Get_Layer() == Get_Active_Layer());
- }
- }
-
- dc_Map.Draw(dc);
-}
-
-//---------------------------------------------------------
-void CWKSP_Map::Draw_Frame(wxDC &dc, wxRect rMap, int Width)
-{
- Draw_Frame(dc, Get_World(rMap), rMap, Width);
-}
-
-void CWKSP_Map::Draw_Frame(wxDC &dc, const CSG_Rect &rWorld, wxRect rMap, int Width)
-{
- wxRect r, rFrame(rMap);
-
- Draw_Edge(dc, EDGE_STYLE_SIMPLE, rMap.GetLeft(), rMap.GetTop(), rMap.GetRight(), rMap.GetBottom());
-
- rFrame.Inflate(Width);
-
- r = wxRect(rMap.GetLeft() , rFrame.GetTop() , rMap.GetWidth(), Width);
- Draw_Scale(dc, r, rWorld.Get_XMin(), rWorld.Get_XMax() , true , true , false);
-
- r = wxRect(rMap.GetLeft() , rMap.GetBottom() , rMap.GetWidth(), Width);
- Draw_Scale(dc, r, 0.0 , rWorld.Get_XRange(), true , true , true);
-
- r = wxRect(rFrame.GetLeft() , rMap.GetTop() , Width, rMap.GetHeight());
- Draw_Scale(dc, r, rWorld.Get_YMin(), rWorld.Get_YMax() , false, false, false);
-
- r = wxRect(rMap.GetRight() , rMap.GetTop() , Width, rMap.GetHeight());
- Draw_Scale(dc, r, 0.0 , rWorld.Get_YRange(), false, false, true);
-
- Draw_Edge(dc, EDGE_STYLE_SIMPLE, rFrame.GetLeft(), rFrame.GetTop(), rFrame.GetRight(), rFrame.GetBottom());
-}
-
-//---------------------------------------------------------
-bool CWKSP_Map::Draw_Legend(wxDC &dc, double Zoom_Map, double Zoom, wxPoint Position, wxSize *pSize, int Layout)
-{
- bool bVertical;
- int i, n;
- wxSize s, Size;
-
- Size.x = 0;
- Size.y = 0;
-
- bVertical = (Layout & LEGEND_LAYOUT_VERTICAL) != 0;
-
- for(i=0, n=0; i<Get_Count(); i++)
- {
- if( Get_Layer(i)->Get_Layer()->do_Legend() )
- {
- n++;
-
- Get_Layer(i)->Get_Layer()->Get_Legend()->Draw(dc, Zoom, Zoom_Map, Position, &s, bVertical);
-
- if( bVertical )
- {
- s.y += (int)(Zoom * LEGEND_SPACE);
- Position.y += s.y;
- Size.y += s.y;
-
- if( Size.x < s.x )
- Size.x = s.x;
- }
- else
- {
- s.x += (int)(Zoom * LEGEND_SPACE);
- Position.x += s.x;
- Size.x += s.x;
-
- if( Size.y < s.y )
- Size.y = s.y;
- }
- }
- }
-
- if( pSize )
- {
- *pSize = Size;
- }
-
- return( n > 0 );
-}
-
-//---------------------------------------------------------
-bool CWKSP_Map::Get_Legend_Size(wxSize &Size, double Zoom_Map, double Zoom, int Layout)
-{
- wxMemoryDC dc;
-
- return( Draw_Legend(dc, Zoom_Map, Zoom, wxPoint(0, 0), &Size, Layout) );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+ if( m_Img_Parms("LG")->asBool() && Get_Legend_Size(s, 1.0, m_Img_Parms("LZ")->asDouble()) )
+ {
+ wxFileName fn(file);
+ file = fn.GetName();
+ file.Append(wxT("_legend"));
+ fn.SetName(file);
+ file = fn.GetFullPath();
+
+ BMP.Create(s.GetWidth(), s.GetHeight());
+ dc.SelectObject(BMP);
+ dc.SetBackground(*wxWHITE_BRUSH);
+ dc.Clear();
+
+ Draw_Legend(dc, 1.0, m_Img_Parms("LZ")->asDouble(), wxPoint(0, 0));
+
+ dc.SelectObject(wxNullBitmap);
+ BMP.SaveFile(file, (wxBitmapType)type);
+ }
+
+ Set_Buisy_Cursor(false);
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::SaveAs_PDF_Indexed(void)
+{
+ static CSG_Parameters Parameters(NULL, LNG("[CAP] Save to PDF"), LNG(""), NULL, false);
+
+ //-----------------------------------------------------
+ if( Parameters.Get_Count() == 0 )
+ {
+ Parameters.Add_FilePath(
+ NULL , "FILENAME" , LNG("[FLD] PDF Document"),
+ LNG(""),
+ wxString::Format(
+ wxT("%s (*.pdf)|*pdf|")
+ wxT("%s|*.*"),
+ LNG("PDF Files"),
+ LNG("All Files")
+ ), NULL, true, false
+ );
+
+ Parameters.Add_Choice(
+ NULL , "PAPER_SIZE" , LNG("[FLD] Paper Format"),
+ LNG(""),
+
+ CSG_String::Format(wxT("%s|%s|%s|%s|"),
+ LNG("A4 Portrait"),
+ LNG("A4 Landscape"),
+ LNG("A3 Portrait"),
+ LNG("A3 Landscape")
+ )
+ );
+
+ Parameters.Add_String(
+ NULL , "NAME" , LNG("[FLD] Title"),
+ LNG(""),
+ LNG("")
+ );
+
+ Parameters.Add_Shapes(
+ NULL , "SHAPES" , LNG("[FLD] Shapes"),
+ LNG(""),
+ PARAMETER_INPUT_OPTIONAL
+ );
+
+ Parameters.Add_Table_Field(
+ Parameters("SHAPES") , "FIELD" , LNG("[FLD] Attribute"),
+ LNG("")
+ );
+
+ // Parameters.Add_Grid(
+ // NULL , "GRID" , LNG("[FLD] Grid"),
+ // LNG(""),
+ // PARAMETER_INPUT_OPTIONAL
+ // );
+
+ Parameters.Add_FilePath(
+ NULL , "FILEICON" , LNG("[FLD] Icon"),
+ LNG(""),
+
+ CSG_String::Format(wxT("%s|*.png;*.jpg|%s|*.png|%s|*.jpg|%s|*.*"),
+ LNG("All Recognised Files"),
+ LNG("PNG Files"),
+ LNG("JPG Files"),
+ LNG("All Files")
+ ), NULL, false, false
+ );
+
+ Parameters.Add_Value(
+ NULL , "ROUNDSCALE" , LNG("[FLD] Round Scale"),
+ LNG(""),
+ PARAMETER_TYPE_Bool, true
+ );
+ }
+
+ //-----------------------------------------------------
+ if( DLG_Parameters(&Parameters) )
+ {
+ bool bResult, bRoundScale;
+ int iField;
+ CSG_String Name, FileName, FileName_Icon, FilePath_Maps;
+ CSG_Rect rOverview, rMap;
+ CSG_Shapes *pShapes;
+ // CSG_Grid *pGrid;
+ CSG_Doc_PDF PDF;
+
+ MSG_General_Add(wxString::Format(wxT("%s..."), LNG("[MSG] Save to PDF")), true, true);
+
+ bResult = false;
+ Name = Parameters("NAME") ->asString(); if( Name.Length() < 1 ) Name = LNG("Maps");
+ FileName = Parameters("FILENAME") ->asString();
+ FileName_Icon = Parameters("FILEICON") ->asString();
+ pShapes = Parameters("SHAPES") ->asShapes();
+ // pGrid = Parameters("GRID") ->asGrid();
+ iField = Parameters("FIELD") ->asInt();
+ bRoundScale = Parameters("ROUNDSCALE") ->asBool();
+
+ switch( Parameters("PAPER_SIZE")->asInt() )
+ {
+ default:
+ case 0: PDF.Open(PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_PORTRAIT , Name); break; // A4 Portrait
+ case 1: PDF.Open(PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_LANDSCAPE, Name); break; // A4 Landscape
+ case 2: PDF.Open(PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_PORTRAIT , Name); break; // A3 Portrait
+ case 3: PDF.Open(PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_LANDSCAPE, Name); break; // A3 Landscape
+ }
+
+ //-------------------------------------------------
+ if( PDF.Is_Open() )
+ {
+ PDF.Layout_Set_Box_Space(5, false);
+
+ PDF.Layout_Add_Box( 0.0, 0.0, 100.0, 75.0, "MAP");
+ PDF.Layout_Add_Box( 0.0, 75.0, 50.0, 100.0, "DIVISIONS");
+ PDF.Layout_Add_Box( 50.0, 75.0, 60.0, 80.0, "ICON");
+ PDF.Layout_Add_Box( 60.0, 75.0, 100.0, 80.0, "TITLE");
+ PDF.Layout_Add_Box( 50.0, 80.0, 100.0, 100.0, "DESCRIPTION");
+
+ FilePath_Maps = SG_File_Make_Path(SG_File_Get_Path(FileName), SG_File_Get_Name(FileName, false));
+ rOverview = pShapes ? pShapes->Get_Extent() : Get_Extent();
+ // rOverview = pShapes ? pShapes->Get_Extent() : (pGrid ? pGrid->Get_Extent() : Get_Extent());
+
+ //---------------------------------------------
+ // PDF.Draw_Text (PDF.Layout_Get_Box("TITLE").Get_XMin(), PDF.Layout_Get_Box("TITLE").Get_YCenter(), LNG("This is a Test!!!"), 24);
+ // PDF.Draw_Rectangle (PDF.Layout_Get_Box("DIVISIONS"));
+ // PDF.Draw_Grid (PDF.Layout_Get_Box("DIVISIONS"), Parameters("GRID")->asGrid(), CSG_Colors(), 0.0, 0.0, 0, &rOverview);
+ // PDF.Draw_Shapes (PDF.Layout_Get_Box("DIVISIONS"), pShapes, PDF_STYLE_POLYGON_STROKE, SG_COLOR_GREEN, SG_COLOR_BLACK, 1, &rOverview);
+ // PDF.Draw_Graticule (PDF.Layout_Get_Box("DIVISIONS"), rOverview);
+
+ //---------------------------------------------
+ Draw_PDF(&PDF, FilePath_Maps, -1, FileName_Icon, Name, rOverview, bRoundScale, iField, pShapes);
+
+ if( pShapes )
+ {
+ for(int i=0; i<pShapes->Get_Count() && SG_UI_Process_Set_Progress(i, pShapes->Get_Count()); i++)
+ {
+ Draw_PDF(&PDF, FilePath_Maps, i, FileName_Icon, Name, pShapes->Get_Shape(i)->Get_Extent(), bRoundScale, iField, pShapes);
+ }
+ }
+
+ //---------------------------------------------
+ PROCESS_Set_Okay(true);
+ Set_Buisy_Cursor(true);
+ bResult = PDF.Save(FileName);
+ Set_Buisy_Cursor(false);
+ }
+
+ MSG_General_Add(bResult ? LNG("[MSG] okay") : LNG("[MSG] failed"), false, false, bResult ? SG_UI_MSG_STYLE_SUCCESS : SG_UI_MSG_STYLE_FAILURE);
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::Draw_PDF(CSG_Doc_PDF *pPDF, const wxChar *FilePath_Maps, int Image_ID, const wxChar *FileName_Icon, const wxChar *Title, CSG_Rect rWorld, bool bRoundScale, int iField, CSG_Shapes *pShapes)
+{
+ int FrameSize_1 = 20, FrameSize_2 = 10;
+ double d, e, Scale, Ratio;
+ CSG_String FileName, Description, s;
+ CSG_Rect rBox;
+ wxRect rBMP;
+ wxBitmap BMP;
+ wxMemoryDC dc;
+
+ if( pPDF && rWorld.Get_XRange() > 0.0 && rWorld.Get_YRange() > 0.0 && pPDF->Add_Page() )
+ {
+ rWorld.Inflate(5.0, true);
+
+ //-------------------------------------------------
+ rBox = pPDF->Layout_Get_Box("MAP");
+ rBox.Deflate(FrameSize_1, false);
+
+ rBMP = wxRect(0, 0, (int)rBox.Get_XRange(), (int)rBox.Get_YRange());
+ BMP.Create(rBMP.GetWidth(), rBMP.GetHeight());
+ dc.SelectObject(BMP);
+ dc.SetBackground(*wxWHITE_BRUSH);
+ dc.Clear();
+
+ if( bRoundScale )
+ {
+ Scale = rWorld.Get_XRange() / (pPDF->Get_Page_To_Meter() * (double)rBMP.GetWidth());
+
+ // if( Scale > 1000 )
+ // {
+ Ratio = ((ceil(Scale / 1000.)) / (Scale / 1000.) - 1);
+ rWorld.Inflate(Ratio * 100, true);
+ // }
+ }
+
+ Scale = rWorld.Get_XRange() / (pPDF->Get_Page_To_Meter() * rBMP.GetWidth());
+
+ Draw_Map(dc, rWorld, 1.0, rBMP, false);
+ dc.SelectObject(wxNullBitmap);
+ SG_Dir_Create(FilePath_Maps);
+ FileName = SG_File_Make_Path(FilePath_Maps, wxString::Format(wxT("image_%03d"), Image_ID + 1), wxT("png"));
+ BMP.SaveFile(FileName.c_str(), wxBITMAP_TYPE_PNG);
+
+ pPDF->Draw_Image (rBox, FileName);
+ pPDF->Draw_Graticule(rBox, rWorld, FrameSize_1);
+
+ //-------------------------------------------------
+ rBox = pPDF->Layout_Get_Box("ICON");
+
+ if( FileName_Icon )
+ {
+ pPDF->Draw_Image(rBox, FileName_Icon);
+ }
+ else
+ {
+ pPDF->Draw_Rectangle(rBox);
+ }
+
+ //-------------------------------------------------
+ rBox = pPDF->Layout_Get_Box("DIVISIONS");
+
+ pPDF->Draw_Rectangle(rBox);
+
+ if( pShapes )
+ {
+ CSG_Rect rShapes(pShapes->Get_Extent());
+
+ rShapes.Inflate(5.0, true);
+ rBox.Deflate(FrameSize_2, false);
+
+ pPDF->Draw_Graticule(rBox, rShapes, FrameSize_2);
+ pPDF->Draw_Shapes(rBox, pShapes, PDF_STYLE_POLYGON_FILLSTROKE, SG_COLOR_GREEN, SG_COLOR_BLACK, 0, &rShapes);
+
+ if( Image_ID >= 0 && Image_ID < pShapes->Get_Count() )
+ {
+ pPDF->Draw_Shape(rBox, pShapes->Get_Shape(Image_ID), PDF_STYLE_POLYGON_FILLSTROKE, SG_COLOR_YELLOW, SG_COLOR_RED, 1, &rShapes);
+ }
+ }
+
+ //-------------------------------------------------
+ rBox = pPDF->Layout_Get_Box("TITLE");
+
+ pPDF->Draw_Text(rBox.Get_XMin(), rBox.Get_YCenter(), Title, 20, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_CENTER|PDF_STYLE_TEXT_UNDERLINE);
+
+ //-------------------------------------------------
+ rBox = pPDF->Layout_Get_Box("DESCRIPTION");
+
+ Description.Append(wxString::Format(wxT("%d. %s\n"), Image_ID + 2, LNG("Map")));
+
+ if( pShapes && Image_ID >= 0 && Image_ID < pShapes->Get_Count() )
+ {
+ switch( pShapes->Get_Type() )
+ {
+ default:
+ break;
+
+ case SHAPE_TYPE_Line:
+ d = ((CSG_Shape_Line *)pShapes->Get_Shape(Image_ID))->Get_Length();
+ e = d > 1000.0 ? 1000.0 : 1.0;
+ s = d > 1000.0 ? wxT("km") : wxT("m");
+ Description.Append(wxString::Format(wxT("%s: %f%s\n"), LNG("Length") , d / e, s.c_str()));
+ break;
+
+ case SHAPE_TYPE_Polygon:
+ d = ((CSG_Shape_Polygon *)pShapes->Get_Shape(Image_ID))->Get_Area();
+ e = d > 1000000.0 ? 1000000.0 : (d > 10000.0 ? 10000.0 : 1.0);
+ s = d > 1000000.0 ? wxT("km\xc2\xb2") : (d > 10000.0 ? wxT("ha") : wxT("m\xc2\xb2"));
+ Description.Append(wxString::Format(wxT("%s: %f%s\n"), LNG("Area") , d / e, s.c_str()));
+
+ d = ((CSG_Shape_Polygon *)pShapes->Get_Shape(Image_ID))->Get_Perimeter();
+ e = d > 1000.0 ? 1000.0 : 1.0;
+ s = d > 1000.0 ? wxT("km") : wxT("m");
+ Description.Append(wxString::Format(wxT("%s: %f%s\n"), LNG("Perimeter") , d / e, s.c_str()));
+
+ Description.Append(wxString::Format(wxT("%s: %d\n") , LNG("Parts") , ((CSG_Shape_Polygon *)pShapes->Get_Shape(Image_ID))->Get_Part_Count()));
+ break;
+ }
+
+ if( iField >= 0 && iField < pShapes->Get_Field_Count() )
+ {
+ Description.Append(wxString::Format(wxT("%s: %s\n"), pShapes->Get_Field_Name(iField), pShapes->Get_Shape(Image_ID)->asString(iField)));
+ }
+ }
+
+ Description.Append(wxString::Format(wxT("%s 1:%s"), LNG("Scale"), SG_Get_String(Scale, 2).c_str()));
+
+ pPDF->Draw_Text(rBox.Get_XMin(), rBox.Get_YMax(), Description, 12, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP);
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::SaveAs_Interactive_SVG(void)
+{
+ static CSG_Parameters Parameters(NULL, LNG("[CAP] Save As Interactive SVG"), LNG(""), NULL, false);
+
+ //-----------------------------------------------------
+ if( Parameters.Get_Count() == 0 )
+ {
+ Parameters.Add_FilePath(
+ NULL , "FILENAME" , LNG("[FLD] SVG File"),
+ LNG(""),
+ wxString::Format(wxT("%s|*.svg|%s|*.*"),
+ LNG("SVG - Scalable Vector Graphics Files (*.svg)"),
+ LNG("All Files")
+ ), NULL, true, false
+ );
+
+ Parameters.Add_Shapes(
+ NULL , "SHAPES" , LNG("[FLD] Index Layer"),
+ LNG(""),
+ PARAMETER_INPUT_OPTIONAL
+ );
+ }
+
+ //-----------------------------------------------------
+ if( DLG_Parameters(&Parameters) )
+ {
+ CSG_String FileName;
+ CSG_Shapes *pIndexLayer;
+ CSVG_Interactive_Map SVG;
+
+ MSG_General_Add(wxString::Format(wxT("%s..."), LNG("[MSG] Save as Interactive SVG")), true, true);
+
+ pIndexLayer = Parameters("SHAPES") ->asShapes();
+ FileName = Parameters("FILENAME") ->asString();
+
+ SVG.Create_From_Map(this, pIndexLayer, FileName);
+
+ MSG_General_Add(LNG("[MSG] okay"), false, false, SG_UI_MSG_STYLE_SUCCESS);
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+const wxBitmap & CWKSP_Map::Get_Thumbnail(int dx, int dy)
+{
+ if( dx > 0 && m_Thumbnail.GetWidth() != dx
+ && dy > 0 && m_Thumbnail.GetHeight() != dy )
+ {
+ m_Thumbnail.Create(dx, dy);
+
+ _Set_Thumbnail();
+ }
+
+ return( m_Thumbnail );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Map::_Set_Thumbnail(void)
+{
+ if( m_Thumbnail.GetWidth() > 0 && m_Thumbnail.GetHeight() > 0 )
+ {
+ wxMemoryDC dc;
+ wxRect r(0, 0, m_Thumbnail.GetWidth(), m_Thumbnail.GetHeight());
+
+ dc.SelectObject(m_Thumbnail);
+ dc.SetBackground(*wxWHITE_BRUSH);
+ dc.Clear();
+
+ Draw_Map(dc, Get_Extent(), 1.0, r, false);
+
+ dc.SelectObject(wxNullBitmap);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CWKSP_Map::Draw_Map(wxDC &dc, double Zoom, const wxRect &rClient, bool bEdit, int Background)
+{
+ Draw_Map(dc, Get_World(rClient), Zoom, rClient, bEdit, Background);
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::Draw_Map(wxDC &dc, const CSG_Rect &rWorld, double Zoom, const wxRect &rClient, bool bEdit, int Background)
+{
+ CWKSP_Map_DC dc_Map(rWorld, rClient, Zoom, Background);
+
+ for(int i=Get_Count()-1; i>=0; i--)
+ {
+ if( Get_Layer(i)->do_Show() && Get_Layer(i)->Get_Layer()->do_Show(Get_Extent()) )
+ {
+ Get_Layer(i)->Get_Layer()->Draw(dc_Map, bEdit && Get_Layer(i)->Get_Layer() == Get_Active_Layer());
+ }
+ }
+
+ dc_Map.Draw(dc);
+}
+
+//---------------------------------------------------------
+void CWKSP_Map::Draw_Frame(wxDC &dc, wxRect rMap, int Width)
+{
+ Draw_Frame(dc, Get_World(rMap), rMap, Width);
+}
+
+void CWKSP_Map::Draw_Frame(wxDC &dc, const CSG_Rect &rWorld, wxRect rMap, int Width)
+{
+ wxRect r, rFrame(rMap);
+
+ Draw_Edge(dc, EDGE_STYLE_SIMPLE, rMap.GetLeft(), rMap.GetTop(), rMap.GetRight(), rMap.GetBottom());
+
+ rFrame.Inflate(Width);
+
+ r = wxRect(rMap.GetLeft() , rFrame.GetTop() , rMap.GetWidth(), Width);
+ Draw_Scale(dc, r, rWorld.Get_XMin(), rWorld.Get_XMax() , true , true , false);
+
+ r = wxRect(rMap.GetLeft() , rMap.GetBottom() , rMap.GetWidth(), Width);
+ Draw_Scale(dc, r, 0.0 , rWorld.Get_XRange(), true , true , true);
+
+ r = wxRect(rFrame.GetLeft() , rMap.GetTop() , Width, rMap.GetHeight());
+ Draw_Scale(dc, r, rWorld.Get_YMin(), rWorld.Get_YMax() , false, false, false);
+
+ r = wxRect(rMap.GetRight() , rMap.GetTop() , Width, rMap.GetHeight());
+ Draw_Scale(dc, r, 0.0 , rWorld.Get_YRange(), false, false, true);
+
+ Draw_Edge(dc, EDGE_STYLE_SIMPLE, rFrame.GetLeft(), rFrame.GetTop(), rFrame.GetRight(), rFrame.GetBottom());
+}
+
+//---------------------------------------------------------
+bool CWKSP_Map::Draw_Legend(wxDC &dc, double Zoom_Map, double Zoom, wxPoint Position, wxSize *pSize, int Layout)
+{
+ bool bVertical;
+ int i, n;
+ wxSize s, Size;
+
+ Size.x = 0;
+ Size.y = 0;
+
+ bVertical = (Layout & LEGEND_LAYOUT_VERTICAL) != 0;
+
+ for(i=0, n=0; i<Get_Count(); i++)
+ {
+ if( Get_Layer(i)->Get_Layer()->do_Legend() )
+ {
+ n++;
+
+ Get_Layer(i)->Get_Layer()->Get_Legend()->Draw(dc, Zoom, Zoom_Map, Position, &s, bVertical);
+
+ if( bVertical )
+ {
+ s.y += (int)(Zoom * LEGEND_SPACE);
+ Position.y += s.y;
+ Size.y += s.y;
+
+ if( Size.x < s.x )
+ Size.x = s.x;
+ }
+ else
+ {
+ s.x += (int)(Zoom * LEGEND_SPACE);
+ Position.x += s.x;
+ Size.x += s.x;
+
+ if( Size.y < s.y )
+ Size.y = s.y;
+ }
+ }
+ }
+
+ if( pSize )
+ {
+ *pSize = Size;
+ }
+
+ return( n > 0 );
+}
+
+//---------------------------------------------------------
+bool CWKSP_Map::Get_Legend_Size(wxSize &Size, double Zoom_Map, double Zoom, int Layout)
+{
+ wxMemoryDC dc;
+
+ return( Draw_Legend(dc, Zoom_Map, Zoom, wxPoint(0, 0), &Size, Layout) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_gui/wksp_map_dc.cpp b/src/saga_core/saga_gui/wksp_map_dc.cpp
index cb17325..e322245 100644
--- a/src/saga_core/saga_gui/wksp_map_dc.cpp
+++ b/src/saga_core/saga_gui/wksp_map_dc.cpp
@@ -79,6 +79,19 @@ CWKSP_Map_DC::CWKSP_Map_DC(const CSG_Rect &rWorld, const wxRect &rDC, double Sca
m_Scale = Scale;
//-----------------------------------------------------
+ if( m_rWorld.Get_XRange() == 0.0 )
+ {
+ m_rWorld.m_rect.xMin -= 1.0;
+ m_rWorld.m_rect.xMax += 1.0;
+ }
+
+ if( m_rWorld.Get_YRange() == 0.0 )
+ {
+ m_rWorld.m_rect.yMin -= 1.0;
+ m_rWorld.m_rect.yMax += 1.0;
+ }
+
+ //-----------------------------------------------------
double d = (double)m_rDC.GetWidth() / (double)m_rDC.GetHeight();
if( d > m_rWorld.Get_XRange() / m_rWorld.Get_YRange() )
diff --git a/src/saga_core/saga_gui/wksp_map_dc.h b/src/saga_core/saga_gui/wksp_map_dc.h
index 29c42c5..75a02a3 100644
--- a/src/saga_core/saga_gui/wksp_map_dc.h
+++ b/src/saga_core/saga_gui/wksp_map_dc.h
@@ -151,10 +151,9 @@ public:
break;
case IMG_MODE_SHADING:
- d = (r + g + b) / 3.0 / 256.0;
- m_img_rgb[n + 0] = (Color = (int)(d * m_img_dc_rgb[n + 0])) > 255 ? 255 : Color;
- m_img_rgb[n + 1] = (Color = (int)(d * m_img_dc_rgb[n + 1])) > 255 ? 255 : Color;
- m_img_rgb[n + 2] = (Color = (int)(d * m_img_dc_rgb[n + 2])) > 255 ? 255 : Color;
+ m_img_rgb[n + 0] = (int)(r / 255.0 * m_img_dc_rgb[n + 0]);
+ m_img_rgb[n + 1] = (int)(g / 255.0 * m_img_dc_rgb[n + 1]);
+ m_img_rgb[n + 2] = (int)(b / 255.0 * m_img_dc_rgb[n + 2]);
break;
case IMG_MODE_TRANSPARENT:
diff --git a/src/saga_core/saga_gui/wksp_map_manager.cpp b/src/saga_core/saga_gui/wksp_map_manager.cpp
index 9f931d3..3625086 100644
--- a/src/saga_core/saga_gui/wksp_map_manager.cpp
+++ b/src/saga_core/saga_gui/wksp_map_manager.cpp
@@ -236,6 +236,8 @@ wxMenu * CWKSP_Map_Manager::Get_Menu(void)
if( Get_Count() > 0 )
{
CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_CLOSE);
+ pMenu->AppendSeparator();
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_SEARCH);
}
return( pMenu );
diff --git a/src/saga_core/saga_gui/wksp_module.cpp b/src/saga_core/saga_gui/wksp_module.cpp
index d9e8dd8..a69f807 100644
--- a/src/saga_core/saga_gui/wksp_module.cpp
+++ b/src/saga_core/saga_gui/wksp_module.cpp
@@ -748,6 +748,11 @@ bool CWKSP_Module::Execute(bool bDialog)
g_pData->Check_Parameters(m_pModule->Get_Parameters());
+ for(int i=0; i<m_pModule->Get_Parameters_Count(); i++)
+ {
+ g_pData->Check_Parameters(m_pModule->Get_Parameters(i));
+ }
+
MSG_General_Add_Line();
MSG_Execution_Add_Line();
MSG_ADD(wxString::Format(wxT("%s: %s"), LNG("[MSG] Executing module"), m_pModule->Get_Name()));
diff --git a/src/saga_core/saga_gui/wksp_module_library.cpp b/src/saga_core/saga_gui/wksp_module_library.cpp
index 8e4df7b..044d2d4 100644
--- a/src/saga_core/saga_gui/wksp_module_library.cpp
+++ b/src/saga_core/saga_gui/wksp_module_library.cpp
@@ -161,7 +161,8 @@ CWKSP_Module_Library::CWKSP_Module_Library(const wxChar *FileName)
//---------------------------------------------------------
CWKSP_Module_Library::~CWKSP_Module_Library(void)
{
- CWKSP_Module *pItem;
+ TSG_PFNC_MLB_Finalize MLB_Finalize;
+ CWKSP_Module *pItem;
if( m_Library.IsLoaded() )
{
@@ -169,6 +170,11 @@ CWKSP_Module_Library::~CWKSP_Module_Library(void)
{
MSG_General_Add(wxString::Format(wxT("%s: %s..."), LNG("[MSG] Close Library"), m_File_Name.c_str()), true, true);
+ if( (MLB_Finalize = (TSG_PFNC_MLB_Finalize)m_Library.GetSymbol(SYMBOL_MLB_Finalize)) != NULL )
+ {
+ MLB_Finalize();
+ }
+
while( (pItem = Get_Module(0)) != NULL )
{
Del_Item(pItem);
diff --git a/src/saga_core/saga_gui/wksp_module_manager.cpp b/src/saga_core/saga_gui/wksp_module_manager.cpp
index 29a74e7..43dda47 100644
--- a/src/saga_core/saga_gui/wksp_module_manager.cpp
+++ b/src/saga_core/saga_gui/wksp_module_manager.cpp
@@ -61,6 +61,7 @@
#include <wx/filename.h>
#include <saga_api/saga_api.h>
+#include <saga_odbc/saga_odbc.h>
#include "saga.h"
@@ -74,6 +75,7 @@
#include "wksp_module_menu.h"
#include "wksp_module.h"
+
///////////////////////////////////////////////////////////
// //
// //
@@ -116,6 +118,12 @@ CWKSP_Module_Manager::CWKSP_Module_Manager(void)
LNG("until user closes it")
), 1
);
+
+ m_Parameters.Add_Value(
+ NULL , "PROC_FREQ" , LNG("Process Update Frequency [milliseconds]"),
+ LNG(""),
+ PARAMETER_TYPE_Int , 0, 0, true
+ );
}
//---------------------------------------------------------
@@ -152,6 +160,8 @@ bool CWKSP_Module_Manager::Initialise(void)
//---------------------------------------------------------
bool CWKSP_Module_Manager::Finalise(void)
{
+ SG_ODBC_Get_Connection_Manager().Destroy();
+
_Config_Write();
return( true );
@@ -196,6 +206,8 @@ wxMenu * CWKSP_Module_Manager::Get_Menu(void)
{
CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_CLOSE);
CMD_Menu_Add_Item(pMenu, false, ID_CMD_MODULES_SAVE_HTML);
+ pMenu->AppendSeparator();
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_SEARCH);
}
return( pMenu );
@@ -290,6 +302,14 @@ void CWKSP_Module_Manager::On_Execute_UI(wxUpdateUIEvent &event)
///////////////////////////////////////////////////////////
//---------------------------------------------------------
+void CWKSP_Module_Manager::Parameters_Changed(void)
+{
+ g_pSAGA->Process_Set_Frequency(m_Parameters("PROC_FREQ")->asInt());
+
+ CWKSP_Base_Item::Parameters_Changed();
+}
+
+//---------------------------------------------------------
bool CWKSP_Module_Manager::Do_Beep(void)
{
return( m_Parameters("BEEP")->asBool() );
@@ -323,6 +343,11 @@ void CWKSP_Module_Manager::_Config_Read(void)
m_Parameters("START_LOGO") ->Set_Value((int)lValue);
}
+ if( CONFIG_Read(wxT("/MODULES"), wxT("PROC_FREQ") , lValue) )
+ {
+ m_Parameters("PROC_FREQ") ->Set_Value((int)lValue);
+ }
+
for(int i=0; CONFIG_Read(CFG_LIBS, wxString::Format(CFG_LIBF, i), sValue); i++)
{
Open(sValue);
@@ -336,6 +361,7 @@ void CWKSP_Module_Manager::_Config_Write(void)
{
CONFIG_Write(wxT("/MODULES") , wxT("BEEP") , m_Parameters("BEEP") ->asBool());
CONFIG_Write(wxT("/MODULES") , wxT("START_LOGO") , (long)m_Parameters("START_LOGO") ->asInt());
+ CONFIG_Write(wxT("/MODULES") , wxT("PROC_FREQ") , (long)m_Parameters("PROC_FREQ") ->asInt());
CONFIG_Delete(CFG_LIBS);
@@ -377,7 +403,10 @@ int CWKSP_Module_Manager::_Open_Directory(const wxChar *sDirectory, bool bOnlySu
{
do
{
- nOpened += _Open_Directory(SG_File_Make_Path(Dir.GetName(), FileName, NULL));
+ if( FileName.CmpNoCase(wxT("dll")) )
+ {
+ nOpened += _Open_Directory(SG_File_Make_Path(Dir.GetName(), FileName, NULL));
+ }
}
while( Dir.GetNext(&FileName) );
}
@@ -417,9 +446,9 @@ bool CWKSP_Module_Manager::Open(const wxChar *File_Name)
CWKSP_Module_Library *pLibrary;
//-----------------------------------------------------
- if( SG_File_Cmp_Extension(File_Name, SG_T("mlb"))
+ if( SG_File_Cmp_Extension(File_Name, wxT("mlb"))
|| SG_File_Cmp_Extension(File_Name, wxT("dll"))
- || SG_File_Cmp_Extension(File_Name, wxT("so")) )
+ || SG_File_Cmp_Extension(File_Name, wxT("so" )) )
{
MSG_General_Add(wxString::Format(wxT("%s: %s..."), LNG("[MSG] Load library"), File_Name), true, true);
@@ -554,6 +583,7 @@ void CWKSP_Module_Manager::_Make_HTML_Docs(void)
if( Stream_Libs.is_Open() )
{
s = Get_FilePath_Relative(Directory.c_str(), FileName.GetFullPath().c_str()).c_str(); if( s[0] == '\\' ) s = s.AfterFirst('\\');
+ if(s[0]=='/') s = s.AfterFirst('/');
Stream_Libs.Printf(wxT("<li><a href=\"%s\">%s</a></li>\n"), s.c_str(), Get_Library(i)->Get_Name().c_str());
}
@@ -570,7 +600,11 @@ void CWKSP_Module_Manager::_Make_HTML_Docs(void)
if( bDirectory )
s = wxT("./../index");
else
- s = Get_FilePath_Relative(Main.c_str(), FileName.GetFullPath().c_str()).c_str(); if( s[0] == '\\' ) s = s.AfterFirst('\\');
+ s = Get_FilePath_Relative(Main.c_str(), FileName.GetFullPath().c_str()).c_str();
+ if( s[0] == '\\' )
+ s = s.AfterFirst('\\');
+ if(s[0]=='/')
+ s = s.AfterFirst('/');
FileName.SetName(wxT("modules"));
Stream_List.Open(FileName.GetFullPath().c_str(), SG_FILE_W, false);
diff --git a/src/saga_core/saga_gui/wksp_module_manager.h b/src/saga_core/saga_gui/wksp_module_manager.h
index 2fc0864..b8ea68c 100644
--- a/src/saga_core/saga_gui/wksp_module_manager.h
+++ b/src/saga_core/saga_gui/wksp_module_manager.h
@@ -100,7 +100,8 @@ public:
virtual bool On_Command (int Cmd_ID);
virtual bool On_Command_UI (wxUpdateUIEvent &event);
- virtual class CSG_Parameters * Get_Parameters (void) { return( &m_Parameters ); }
+ virtual class CSG_Parameters * Get_Parameters (void) { return( &m_Parameters ); }
+ virtual void Parameters_Changed (void);
void On_Execute (wxCommandEvent &event);
void On_Execute_UI (wxUpdateUIEvent &event);
@@ -121,7 +122,7 @@ public:
private:
- CSG_Parameters m_Parameters;
+ CSG_Parameters m_Parameters;
class CWKSP_Module_Menu *m_pMenu;
diff --git a/src/saga_core/saga_gui/wksp_pointcloud.cpp b/src/saga_core/saga_gui/wksp_pointcloud.cpp
index 0d4cb7b..cd73b8a 100644
--- a/src/saga_core/saga_gui/wksp_pointcloud.cpp
+++ b/src/saga_core/saga_gui/wksp_pointcloud.cpp
@@ -1,525 +1,601 @@
-
-///////////////////////////////////////////////////////////
-// //
-// SAGA //
-// //
-// System for Automated Geoscientific Analyses //
-// //
-// User Interface //
-// //
-// Program: SAGA //
-// //
-//-------------------------------------------------------//
-// //
-// WKSP_PointCloud.cpp //
-// //
-// Copyright (C) 2009 by Olaf Conrad //
-// //
-//-------------------------------------------------------//
-// //
-// This file is part of 'SAGA - System for Automated //
-// Geoscientific Analyses'. SAGA is free software; you //
-// can redistribute it and/or modify it under the terms //
-// of the GNU General Public License as published by the //
-// Free Software Foundation; version 2 of the License. //
-// //
-// SAGA is distributed in the hope that it will be //
-// useful, but WITHOUT ANY WARRANTY; without even the //
-// implied warranty of MERCHANTABILITY or FITNESS FOR A //
-// PARTICULAR PURPOSE. See the GNU General Public //
-// License for more details. //
-// //
-// You should have received a copy of the GNU General //
-// Public License along with this program; if not, //
-// write to the Free Software Foundation, Inc., //
-// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
-// USA. //
-// //
-//-------------------------------------------------------//
-// //
-// contact: Olaf Conrad //
-// Institute of Geography //
-// University of Hamburg //
-// Germany //
-// //
-// e-mail: oconrad at saga-gis.org //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-#include "res_commands.h"
-
-#include "helper.h"
-
-#include "wksp_map_control.h"
-
-#include "wksp_layer_classify.h"
-
-#include "wksp_pointcloud.h"
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-CWKSP_PointCloud::CWKSP_PointCloud(CSG_PointCloud *pPointCloud)
- : CWKSP_Layer(pPointCloud)
-{
- m_pPointCloud = pPointCloud;
-
- m_Edit_Attributes.Destroy();
- m_Edit_Attributes.Add_Field(LNG("[CAP] Name") , SG_DATATYPE_String);
- m_Edit_Attributes.Add_Field(LNG("[CAP] Value"), SG_DATATYPE_String);
-
- Create_Parameters();
-
- //-----------------------------------------------------
- m_Parameters("COLORS_TYPE") ->Set_Value(CLASSIFY_METRIC);
- m_Parameters("COLORS_ATTRIB") ->Set_Value(2);
-
- On_Parameter_Changed(&m_Parameters, m_Parameters("COLORS_ATTRIB"));
-
- Parameters_Changed();
-}
-
-//---------------------------------------------------------
-CWKSP_PointCloud::~CWKSP_PointCloud(void)
-{}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-wxString CWKSP_PointCloud::Get_Name(void)
-{
- return( wxString::Format(wxT("%02d. %s"), 1 + Get_ID(), m_pPointCloud->Get_Name()) );
-}
-
-//---------------------------------------------------------
-wxString CWKSP_PointCloud::Get_Description(void)
-{
- wxString s;
-
- //-----------------------------------------------------
- s.Append(wxString::Format(wxT("<b>%s</b><table border=\"0\">"),
- LNG("[CAP] Point Cloud")
- ));
-
- s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%s</td></tr>"),
- LNG("[CAP] Name") , m_pPointCloud->Get_Name()
- ));
-
- s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%s</td></tr>"),
- LNG("[CAP] File") , m_pPointCloud->Get_File_Name()
- ));
-
- s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%d</td></tr>"),
- LNG("[CAP] Number of Points") , m_pPointCloud->Get_Count()
- ));
-
- s.Append(wxT("</table>"));
-
- //-----------------------------------------------------
- s.Append(wxString::Format(wxT("<table border=\"1\"><tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th>"),
- LNG("[CAP] Field"),
- LNG("[CAP] Name"),
- LNG("[CAP] Type"),
- LNG("[CAP] Minimum"),
- LNG("[CAP] Maximum"),
- LNG("[CAP] Mean"),
- LNG("[CAP] Standard Deviation")
- ));
-
- for(int i=0; i<m_pPointCloud->Get_Field_Count(); i++)
- {
- s.Append(wxString::Format(wxT("<tr><td>%d</td><td>%s</td><td>%s</td><td>%f</td><td>%f</td><td>%f</td><td>%f</td></tr>"),
- i + 1,
- m_pPointCloud->Get_Field_Name(i),
- SG_Data_Type_Get_Name(m_pPointCloud->Get_Field_Type(i)),
- m_pPointCloud->Get_Minimum(i),
- m_pPointCloud->Get_Maximum(i),
- m_pPointCloud->Get_Mean(i),
- m_pPointCloud->Get_StdDev(i)
- ));
- }
-
- s.Append(wxT("</table>"));
-
- //-----------------------------------------------------
-// s.Append(wxString::Format(wxT("<hr><b>%s</b><font size=\"-1\">"), LNG("[CAP] Data History")));
-// s.Append(m_pPointCloud->Get_History().Get_HTML());
-// s.Append(wxString::Format(wxT("</font")));
-
- //-----------------------------------------------------
- return( s );
-}
-
-//---------------------------------------------------------
-wxMenu * CWKSP_PointCloud::Get_Menu(void)
-{
- wxMenu *pMenu;
-
- pMenu = new wxMenu(m_pPointCloud->Get_Name());
-
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_CLOSE);
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_POINTCLOUD_SHOW);
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_POINTCLOUD_SAVE);
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_POINTCLOUD_SAVEAS);
- CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_SETTINGS_COPY);
-
-// pMenu->AppendSeparator();
-
-// wxMenu *pTable = new wxMenu(LNG("[MNU] Table"));
-// CMD_Menu_Add_Item(pTable, true, ID_CMD_TABLES_SHOW);
-// CMD_Menu_Add_Item(pTable, true, ID_CMD_TABLES_DIAGRAM);
-// CMD_Menu_Add_Item(pTable, false, ID_CMD_TABLES_SCATTERPLOT);
-// pMenu->Append(ID_CMD_WKSP_FIRST, LNG("[MNU] Attributes"), pTable);
-
- return( pMenu );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CWKSP_PointCloud::On_Command(int Cmd_ID)
-{
- switch( Cmd_ID )
- {
- default:
- return( CWKSP_Layer::On_Command(Cmd_ID) );
-
- case ID_CMD_POINTCLOUD_LAST:
- break;
- }
-
- return( true );
-}
-
-//---------------------------------------------------------
-bool CWKSP_PointCloud::On_Command_UI(wxUpdateUIEvent &event)
-{
- switch( event.GetId() )
- {
- default:
- return( CWKSP_Layer::On_Command_UI(event) );
-
- case ID_CMD_POINTCLOUD_LAST:
- break;
- }
-
- return( true );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CWKSP_PointCloud::On_Create_Parameters(void)
-{
- //-----------------------------------------------------
- // General...
-
- m_Parameters.Add_Choice(
- m_Parameters("NODE_COLORS") , "COLORS_ATTRIB" , LNG("[CAP] Attribute"),
- LNG(""),
- LNG("")
- );
-
- m_Parameters.Add_Choice(
- m_Parameters("NODE_COLORS") , "COLORS_AGGREGATE" , LNG("[CAP] Value Aggregation"),
- LNG(""),
- CSG_String::Format(SG_T("%s|%s|%s|%s|"),
- LNG("first value"),
- LNG("last value"),
- LNG("lowest z"),
- LNG("highest z")
- ), 1
- );
-
- //-----------------------------------------------------
- m_Parameters.Add_Value(
- m_Parameters("NODE_DISPLAY") , "DISPLAY_SIZE" , LNG("[CAP] Point Size"),
- LNG(""),
- PARAMETER_TYPE_Int, 0, 0, true
- );
-
- //-----------------------------------------------------
- m_Parameters.Add_Value(
- m_Parameters("NODE_DISPLAY") , "DISPLAY_TRANSPARENCY" , LNG("[CAP] Transparency [%]"),
- LNG(""),
- PARAMETER_TYPE_Double, 0.0, 0.0, true, 100.0, true
- );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CWKSP_PointCloud::On_DataObject_Changed(void)
-{
- int i;
- wxString sChoices;
-
- for(i=0; i<m_pPointCloud->Get_Field_Count(); i++)
- {
- sChoices.Append(wxString::Format(wxT("%s|"), m_pPointCloud->Get_Field_Name(i)));
- }
-
- m_Parameters("COLORS_ATTRIB")->asChoice()->Set_Items(sChoices);
-}
-
-//---------------------------------------------------------
-void CWKSP_PointCloud::On_Parameters_Changed(void)
-{
- if( (m_Color_Field = m_Parameters("COLORS_ATTRIB")->asInt()) >= m_pPointCloud->Get_Field_Count() )
- {
- m_Color_Field = -1;
- }
-
- long DefColor = m_Parameters("UNISYMBOL_COLOR")->asColor();
- m_Color_Pen = wxColour(SG_GET_R(DefColor), SG_GET_G(DefColor), SG_GET_B(DefColor));
-
- m_PointSize = m_Parameters("DISPLAY_SIZE") ->asInt();
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-int CWKSP_PointCloud::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
-{
- if( !SG_STR_CMP(pParameter->Get_Identifier(), wxT("COLORS_ATTRIB")) )
- {
- CSG_Parameters Parameters;
-
- int zField = pParameter->asInt();
-
- double m = m_pPointCloud->Get_Mean (zField);
- double s = m_pPointCloud->Get_StdDev(zField) * 2.0;
- double min = m - s; if( min < m_pPointCloud->Get_Minimum(zField) ) min = m_pPointCloud->Get_Minimum(zField);
- double max = m + s; if( max > m_pPointCloud->Get_Maximum(zField) ) max = m_pPointCloud->Get_Maximum(zField);
-
- pParameters->Get_Parameter("METRIC_ZRANGE")->asRange()->Set_Range(min, max);
- }
-
- return( 1 );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-wxString CWKSP_PointCloud::Get_Value(CSG_Point ptWorld, double Epsilon)
-{
- return( LNG("") );
-}
-
-//---------------------------------------------------------
-double CWKSP_PointCloud::Get_Value_Range(void)
-{
- return( m_Color_Field >= 0 ? m_pPointCloud->Get_Range(m_Color_Field) : 0.0 );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CWKSP_PointCloud::asImage(CSG_Grid *pImage)
-{
- return( false );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-bool CWKSP_PointCloud::On_Edit_On_Mouse_Up(CSG_Point Point, double ClientToWorld, int Key)
-{
- CSG_Rect rWorld(m_Edit_Mouse_Down, Point);
-
- if( rWorld.Get_XRange() == 0.0 && rWorld.Get_YRange() == 0.0 )
- {
- rWorld.Inflate(2.0 * ClientToWorld, false);
- }
-
- return( true );
-}
-
-//---------------------------------------------------------
-bool CWKSP_PointCloud::On_Edit_Set_Attributes(void)
-{
- return( true );
-}
-
-//---------------------------------------------------------
-TSG_Rect CWKSP_PointCloud::On_Edit_Get_Extent(void)
-{
- return( m_pPointCloud->Get_Extent() );
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-void CWKSP_PointCloud::On_Draw(CWKSP_Map_DC &dc_Map, bool bEdit)
-{
- if( Get_Extent().Intersects(dc_Map.m_rWorld) != INTERSECTION_None && dc_Map.IMG_Draw_Begin(m_Parameters("DISPLAY_TRANSPARENCY")->asDouble() / 100.0) )
- {
- _Draw_Points (dc_Map);
-
- dc_Map.IMG_Draw_End();
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
-inline void CWKSP_PointCloud::_Draw_Point(CWKSP_Map_DC &dc_Map, int x, int y, double z, int Color)
-{
- if( m_Aggregation == 1 || m_Z.is_InGrid(x, y) )
- {
- switch( m_Aggregation )
- {
- case 0: // first value
- if( m_N.asInt(x, y) == 0 )
- {
- dc_Map.IMG_Set_Pixel(x, y, Color);
- }
- break;
-
- case 1: // last value
- dc_Map.IMG_Set_Pixel(x, y, Color);
- break;
-
- case 2: // lowest z
- if( m_N.asInt(x, y) == 0 || z < m_Z.asDouble(x, y) )
- {
- dc_Map.IMG_Set_Pixel(x, y, Color);
- m_Z.Set_Value(x, y, z);
- }
- break;
-
- case 3: // highest z
- if( m_N.asInt(x, y) == 0 || z > m_Z.asDouble(x, y) )
- {
- dc_Map.IMG_Set_Pixel(x, y, Color);
- m_Z.Set_Value(x, y, z);
- }
- break;
- }
-
- m_N.Add_Value(x, y, 1);
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_PointCloud::_Draw_Point(CWKSP_Map_DC &dc_Map, int x, int y, double z, int Color, int Radius)
-{
- _Draw_Point(dc_Map, x, y, z, Color);
-
- for(int iy=1; iy<=Radius; iy++)
- {
- for(int ix=0; ix<=Radius; ix++)
- {
- if( ix*ix + iy*iy <= Radius*Radius )
- {
- _Draw_Point(dc_Map, x + ix, y + iy, z, Color);
- _Draw_Point(dc_Map, x + iy, y - ix, z, Color);
- _Draw_Point(dc_Map, x - ix, y - iy, z, Color);
- _Draw_Point(dc_Map, x - iy, y + ix, z, Color);
- }
- }
- }
-}
-
-//---------------------------------------------------------
-void CWKSP_PointCloud::_Draw_Points(CWKSP_Map_DC &dc_Map)
-{
- m_Aggregation = m_Parameters("COLORS_AGGREGATE")->asInt();
-
- if( m_Aggregation != 1 )
- {
- m_Z.Create(SG_DATATYPE_Double, dc_Map.m_rDC.GetWidth(), dc_Map.m_rDC.GetHeight());
- m_N.Create(SG_DATATYPE_Int , dc_Map.m_rDC.GetWidth(), dc_Map.m_rDC.GetHeight());
- }
-
- //-----------------------------------------------------
- for(int i=0; i<m_pPointCloud->Get_Count(); i++)
- {
- TSG_Point_3D Point = m_pPointCloud->Get_Point(i);
-
- if( dc_Map.m_rWorld.Contains(Point.x, Point.y) )
- {
- int Color;
- int x = (int)dc_Map.xWorld2DC(Point.x);
- int y = (int)dc_Map.yWorld2DC(Point.y);
-
- m_pClassify->Get_Class_Color_byValue(m_pPointCloud->Get_Value(i, m_Color_Field), Color);
-
- _Draw_Point(dc_Map, x, y, Point.z, Color, m_PointSize);
- }
- }
-}
-
-
-///////////////////////////////////////////////////////////
-// //
-// //
-// //
-///////////////////////////////////////////////////////////
-
-//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// User Interface //
+// //
+// Program: SAGA //
+// //
+//-------------------------------------------------------//
+// //
+// WKSP_PointCloud.cpp //
+// //
+// Copyright (C) 2009 by Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "res_commands.h"
+
+#include "helper.h"
+
+#include "wksp_map_control.h"
+
+#include "wksp_layer_classify.h"
+
+#include "wksp_pointcloud.h"
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CWKSP_PointCloud::CWKSP_PointCloud(CSG_PointCloud *pPointCloud)
+ : CWKSP_Layer(pPointCloud)
+{
+ m_pPointCloud = pPointCloud;
+
+ m_Edit_Attributes.Destroy();
+ m_Edit_Attributes.Add_Field(LNG("[CAP] Name") , SG_DATATYPE_String);
+ m_Edit_Attributes.Add_Field(LNG("[CAP] Value"), SG_DATATYPE_String);
+
+ Create_Parameters();
+
+ //-----------------------------------------------------
+ m_Parameters("COLORS_TYPE") ->Set_Value(CLASSIFY_METRIC);
+ m_Parameters("COLORS_ATTRIB") ->Set_Value(2);
+
+ On_Parameter_Changed(&m_Parameters, m_Parameters("COLORS_ATTRIB"));
+
+ Parameters_Changed();
+}
+
+//---------------------------------------------------------
+CWKSP_PointCloud::~CWKSP_PointCloud(void)
+{}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+wxString CWKSP_PointCloud::Get_Name(void)
+{
+ return( wxString::Format(wxT("%02d. %s"), 1 + Get_ID(), m_pPointCloud->Get_Name()) );
+}
+
+//---------------------------------------------------------
+wxString CWKSP_PointCloud::Get_Description(void)
+{
+ wxString s;
+
+ //-----------------------------------------------------
+ s.Append(wxString::Format(wxT("<b>%s</b><table border=\"0\">"),
+ LNG("[CAP] Point Cloud")
+ ));
+
+ s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%s</td></tr>"),
+ LNG("[CAP] Name") , m_pPointCloud->Get_Name()
+ ));
+
+ s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%s</td></tr>"),
+ LNG("[CAP] File") , m_pPointCloud->Get_File_Name()
+ ));
+
+ s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%s</td></tr>"),
+ LNG("[CAP] Projection") , m_pPointCloud->Get_Projection().Get_Name().c_str()
+ ));
+
+ s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%d</td></tr>"),
+ LNG("[CAP] Number of Points") , m_pPointCloud->Get_Count()
+ ));
+
+ s.Append(wxT("</table>"));
+
+ //-----------------------------------------------------
+ s.Append(wxString::Format(wxT("<table border=\"1\"><tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th>"),
+ LNG("[CAP] Field"),
+ LNG("[CAP] Name"),
+ LNG("[CAP] Type"),
+ LNG("[CAP] Minimum"),
+ LNG("[CAP] Maximum"),
+ LNG("[CAP] Mean"),
+ LNG("[CAP] Standard Deviation")
+ ));
+
+ for(int i=0; i<m_pPointCloud->Get_Field_Count(); i++)
+ {
+ s.Append(wxString::Format(wxT("<tr><td>%d</td><td>%s</td><td>%s</td><td>%f</td><td>%f</td><td>%f</td><td>%f</td></tr>"),
+ i + 1,
+ m_pPointCloud->Get_Field_Name(i),
+ SG_Data_Type_Get_Name(m_pPointCloud->Get_Field_Type(i)),
+ m_pPointCloud->Get_Minimum(i),
+ m_pPointCloud->Get_Maximum(i),
+ m_pPointCloud->Get_Mean(i),
+ m_pPointCloud->Get_StdDev(i)
+ ));
+ }
+
+ s.Append(wxT("</table>"));
+
+ //-----------------------------------------------------
+// s.Append(wxString::Format(wxT("<hr><b>%s</b><font size=\"-1\">"), LNG("[CAP] Data History")));
+// s.Append(m_pPointCloud->Get_History().Get_HTML());
+// s.Append(wxString::Format(wxT("</font")));
+
+ //-----------------------------------------------------
+ return( s );
+}
+
+//---------------------------------------------------------
+wxMenu * CWKSP_PointCloud::Get_Menu(void)
+{
+ wxMenu *pMenu, *pSubMenu;
+
+ pMenu = new wxMenu(m_pPointCloud->Get_Name());
+
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_CLOSE);
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_POINTCLOUD_SHOW);
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_POINTCLOUD_SAVE);
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_POINTCLOUD_SAVEAS);
+ CMD_Menu_Add_Item(pMenu, false, ID_CMD_WKSP_ITEM_SETTINGS_COPY);
+
+ pMenu->AppendSeparator();
+
+ pSubMenu = new wxMenu(LNG("[MNU] Classificaton"));
+ CMD_Menu_Add_Item(pSubMenu , false, ID_CMD_POINTCLOUD_RANGE_MINMAX);
+ CMD_Menu_Add_Item(pSubMenu , false, ID_CMD_POINTCLOUD_RANGE_STDDEV150);
+ CMD_Menu_Add_Item(pSubMenu , false, ID_CMD_POINTCLOUD_RANGE_STDDEV200);
+
+ pMenu->Append(ID_CMD_WKSP_FIRST, LNG("[MNU] Classification"), pSubMenu);
+
+
+// wxMenu *pTable = new wxMenu(LNG("[MNU] Table"));
+// CMD_Menu_Add_Item(pTable, true, ID_CMD_TABLES_SHOW);
+// CMD_Menu_Add_Item(pTable, true, ID_CMD_TABLES_DIAGRAM);
+// CMD_Menu_Add_Item(pTable, false, ID_CMD_TABLES_SCATTERPLOT);
+// pMenu->Append(ID_CMD_WKSP_FIRST, LNG("[MNU] Attributes"), pTable);
+
+ return( pMenu );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CWKSP_PointCloud::On_Command(int Cmd_ID)
+{
+ switch( Cmd_ID )
+ {
+ default:
+ return( CWKSP_Layer::On_Command(Cmd_ID) );
+
+ case ID_CMD_POINTCLOUD_LAST:
+ break;
+
+ case ID_CMD_POINTCLOUD_RANGE_MINMAX:
+ Set_Color_Range(
+ m_pPointCloud->Get_Minimum(m_Color_Field),
+ m_pPointCloud->Get_Maximum(m_Color_Field)
+ );
+ break;
+
+ case ID_CMD_POINTCLOUD_RANGE_STDDEV150:
+ Set_Color_Range(
+ m_pPointCloud->Get_Mean(m_Color_Field) - 1.5 * m_pPointCloud->Get_StdDev(m_Color_Field),
+ m_pPointCloud->Get_Mean(m_Color_Field) + 1.5 * m_pPointCloud->Get_StdDev(m_Color_Field)
+ );
+ break;
+
+ case ID_CMD_POINTCLOUD_RANGE_STDDEV200:
+ Set_Color_Range(
+ m_pPointCloud->Get_Mean(m_Color_Field) - 2.0 * m_pPointCloud->Get_StdDev(m_Color_Field),
+ m_pPointCloud->Get_Mean(m_Color_Field) + 2.0 * m_pPointCloud->Get_StdDev(m_Color_Field)
+ );
+ break;
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CWKSP_PointCloud::On_Command_UI(wxUpdateUIEvent &event)
+{
+ switch( event.GetId() )
+ {
+ default:
+ return( CWKSP_Layer::On_Command_UI(event) );
+
+ case ID_CMD_POINTCLOUD_LAST:
+ break;
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CWKSP_PointCloud::On_Create_Parameters(void)
+{
+ //-----------------------------------------------------
+ // General...
+
+ m_Parameters.Add_Choice(
+ m_Parameters("NODE_COLORS") , "COLORS_ATTRIB" , LNG("[CAP] Attribute"),
+ LNG(""),
+ LNG("")
+ );
+
+ m_Parameters.Add_Choice(
+ m_Parameters("NODE_COLORS") , "COLORS_AGGREGATE" , LNG("[CAP] Value Aggregation"),
+ LNG(""),
+ CSG_String::Format(SG_T("%s|%s|%s|%s|"),
+ LNG("first value"),
+ LNG("last value"),
+ LNG("lowest z"),
+ LNG("highest z")
+ ), 1
+ );
+
+ //-----------------------------------------------------
+ m_Parameters.Add_Value(
+ m_Parameters("NODE_DISPLAY") , "DISPLAY_SIZE" , LNG("[CAP] Point Size"),
+ LNG(""),
+ PARAMETER_TYPE_Int, 0, 0, true
+ );
+
+ //-----------------------------------------------------
+ m_Parameters.Add_Value(
+ m_Parameters("NODE_DISPLAY") , "DISPLAY_TRANSPARENCY" , LNG("[CAP] Transparency [%]"),
+ LNG(""),
+ PARAMETER_TYPE_Double, 0.0, 0.0, true, 100.0, true
+ );
+
+ //-----------------------------------------------------
+ // Classification...
+
+ ((CSG_Parameter_Choice *)m_Parameters("COLORS_TYPE")->Get_Data())->Set_Items(
+ wxString::Format(wxT("%s|%s|%s|%s|"),
+ LNG("[VAL] Unique Symbol"),
+ LNG("[VAL] Lookup Table"),
+ LNG("[VAL] Graduated Color"),
+ LNG("[VAL] RGB")
+ )
+ );
+
+ m_Parameters("COLORS_TYPE")->Set_Value(CLASSIFY_METRIC);
+
+
+ //-----------------------------------------------------
+ DataObject_Changed((CSG_Parameters *)NULL);
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CWKSP_PointCloud::On_DataObject_Changed(void)
+{
+ int i;
+ wxString sChoices;
+
+ for(i=0; i<m_pPointCloud->Get_Field_Count(); i++)
+ {
+ sChoices.Append(wxString::Format(wxT("%s|"), m_pPointCloud->Get_Field_Name(i)));
+ }
+
+ m_Parameters("COLORS_ATTRIB")->asChoice()->Set_Items(sChoices);
+}
+
+//---------------------------------------------------------
+void CWKSP_PointCloud::On_Parameters_Changed(void)
+{
+ if( (m_Color_Field = m_Parameters("COLORS_ATTRIB")->asInt()) >= m_pPointCloud->Get_Field_Count() )
+ {
+ m_Color_Field = -1;
+ }
+
+ long DefColor = m_Parameters("UNISYMBOL_COLOR")->asColor();
+ m_Color_Pen = wxColour(SG_GET_R(DefColor), SG_GET_G(DefColor), SG_GET_B(DefColor));
+
+ m_PointSize = m_Parameters("DISPLAY_SIZE") ->asInt();
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int CWKSP_PointCloud::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter)
+{
+ if( !SG_STR_CMP(pParameter->Get_Identifier(), wxT("COLORS_ATTRIB")) )
+ {
+ CSG_Parameters Parameters;
+
+ int zField = pParameter->asInt();
+
+ double m = m_pPointCloud->Get_Mean (zField);
+ double s = m_pPointCloud->Get_StdDev(zField) * 2.0;
+ double min = m - s; if( min < m_pPointCloud->Get_Minimum(zField) ) min = m_pPointCloud->Get_Minimum(zField);
+ double max = m + s; if( max > m_pPointCloud->Get_Maximum(zField) ) max = m_pPointCloud->Get_Maximum(zField);
+
+ pParameters->Get_Parameter("METRIC_ZRANGE")->asRange()->Set_Range(min, max);
+ }
+
+ return( 1 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+wxString CWKSP_PointCloud::Get_Value(CSG_Point ptWorld, double Epsilon)
+{
+ CSG_Shape *pShape;
+
+ if( (pShape = m_pPointCloud->Get_Shape(ptWorld, Epsilon)) != NULL )
+ {
+ if( m_Color_Field >= 0 )
+ {
+ switch( m_pClassify->Get_Mode() )
+ {
+ case CLASSIFY_LUT:
+ return( m_pClassify->Get_Class_Name_byValue(pShape->asDouble(m_Color_Field)) );
+
+ case CLASSIFY_METRIC: default:
+ return( pShape->asString(m_Color_Field) );
+
+ case CLASSIFY_RGB:
+ double Value = pShape->asDouble(m_Color_Field);
+ return( wxString::Format(wxT("R%03d G%03d B%03d"), SG_GET_R((int)Value), SG_GET_G((int)Value), SG_GET_B((int)Value)) );
+ }
+ }
+ else
+ {
+ return( wxString::Format(wxT("%s: %d"), LNG("[CAP] Index"), pShape->Get_Index() + 1) );
+ }
+ }
+
+ return( LNG("") );
+}
+
+//---------------------------------------------------------
+double CWKSP_PointCloud::Get_Value_Range(void)
+{
+ return( m_Color_Field >= 0 ? m_pPointCloud->Get_Range(m_Color_Field) : 0.0 );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CWKSP_PointCloud::asImage(CSG_Grid *pImage)
+{
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CWKSP_PointCloud::On_Edit_On_Mouse_Up(CSG_Point Point, double ClientToWorld, int Key)
+{
+ CSG_Rect rWorld(m_Edit_Mouse_Down, Point);
+
+ if( rWorld.Get_XRange() == 0.0 && rWorld.Get_YRange() == 0.0 )
+ {
+ rWorld.Inflate(2.0 * ClientToWorld, false);
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CWKSP_PointCloud::On_Edit_Set_Attributes(void)
+{
+ return( true );
+}
+
+//---------------------------------------------------------
+TSG_Rect CWKSP_PointCloud::On_Edit_Get_Extent(void)
+{
+ return( m_pPointCloud->Get_Extent() );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+void CWKSP_PointCloud::On_Draw(CWKSP_Map_DC &dc_Map, bool bEdit)
+{
+ if( Get_Extent().Intersects(dc_Map.m_rWorld) != INTERSECTION_None && dc_Map.IMG_Draw_Begin(m_Parameters("DISPLAY_TRANSPARENCY")->asDouble() / 100.0) )
+ {
+ _Draw_Points (dc_Map);
+
+ dc_Map.IMG_Draw_End();
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+inline void CWKSP_PointCloud::_Draw_Point(CWKSP_Map_DC &dc_Map, int x, int y, double z, int Color)
+{
+ if( m_Aggregation == 1 ) // last value
+ {
+ dc_Map.IMG_Set_Pixel(x, y, Color);
+ }
+ else if( m_Z.is_InGrid(x, y) )
+ {
+ switch( m_Aggregation )
+ {
+ case 0: // first value
+ if( m_N.asInt(x, y) == 0 )
+ {
+ dc_Map.IMG_Set_Pixel(x, y, Color);
+ }
+ break;
+
+ case 2: // lowest z
+ if( m_N.asInt(x, y) == 0 || z < m_Z.asDouble(x, y) )
+ {
+ dc_Map.IMG_Set_Pixel(x, y, Color);
+ m_Z.Set_Value(x, y, z);
+ }
+ break;
+
+ case 3: // highest z
+ if( m_N.asInt(x, y) == 0 || z > m_Z.asDouble(x, y) )
+ {
+ dc_Map.IMG_Set_Pixel(x, y, Color);
+ m_Z.Set_Value(x, y, z);
+ }
+ break;
+ }
+
+ m_N.Add_Value(x, y, 1);
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_PointCloud::_Draw_Point(CWKSP_Map_DC &dc_Map, int x, int y, double z, int Color, int Radius)
+{
+ _Draw_Point(dc_Map, x, y, z, Color);
+
+ for(int iy=1; iy<=Radius; iy++)
+ {
+ for(int ix=0; ix<=Radius; ix++)
+ {
+ if( ix*ix + iy*iy <= Radius*Radius )
+ {
+ _Draw_Point(dc_Map, x + ix, y + iy, z, Color);
+ _Draw_Point(dc_Map, x + iy, y - ix, z, Color);
+ _Draw_Point(dc_Map, x - ix, y - iy, z, Color);
+ _Draw_Point(dc_Map, x - iy, y + ix, z, Color);
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
+void CWKSP_PointCloud::_Draw_Points(CWKSP_Map_DC &dc_Map)
+{
+ m_Aggregation = m_Parameters("COLORS_AGGREGATE")->asInt();
+
+ if( m_Aggregation != 1 )
+ {
+ m_Z.Create(SG_DATATYPE_Double, dc_Map.m_rDC.GetWidth(), dc_Map.m_rDC.GetHeight());
+ m_N.Create(SG_DATATYPE_Int , dc_Map.m_rDC.GetWidth(), dc_Map.m_rDC.GetHeight());
+ }
+
+ //-----------------------------------------------------
+ for(int i=0; i<m_pPointCloud->Get_Count(); i++)
+ {
+ TSG_Point_Z Point = m_pPointCloud->Get_Point(i);
+
+ if( dc_Map.m_rWorld.Contains(Point.x, Point.y) )
+ {
+ int Color;
+ int x = (int)dc_Map.xWorld2DC(Point.x);
+ int y = (int)dc_Map.yWorld2DC(Point.y);
+
+ m_pClassify->Get_Class_Color_byValue(m_pPointCloud->Get_Value(i, m_Color_Field), Color);
+
+ _Draw_Point(dc_Map, x, y, Point.z, Color, m_PointSize);
+ }
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_gui/wksp_shapes.cpp b/src/saga_core/saga_gui/wksp_shapes.cpp
index b4279cd..75e15dd 100644
--- a/src/saga_core/saga_gui/wksp_shapes.cpp
+++ b/src/saga_core/saga_gui/wksp_shapes.cpp
@@ -130,6 +130,10 @@ wxString CWKSP_Shapes::Get_Description(void)
));
s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%s</td></tr>"),
+ LNG("[CAP] Projection") , m_pShapes->Get_Projection().Get_Name().c_str()
+ ));
+
+ s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%s</td></tr>"),
LNG("[CAP] Modified") , m_pShapes->is_Modified() ? LNG("[VAL] yes") : LNG("[VAL] no")
));
@@ -519,6 +523,12 @@ int CWKSP_Shapes::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Paramete
return( 1 );
}
+//---------------------------------------------------------
+void CWKSP_Shapes::On_Update_Views(void)
+{
+ m_pTable->Update_Views();
+}
+
///////////////////////////////////////////////////////////
// //
@@ -984,10 +994,10 @@ bool CWKSP_Shapes::_Chart_Set_Options(void)
if( 1 )
{
- int i, n;
+ int i, n;
CSG_Colors Colors;
- CSG_String sFields;
- CSG_Parameter *pFields, *pColors;
+ CSG_String sFields;
+ CSG_Parameter *pFields, *pField;
for(i=0, n=0; i<m_pShapes->Get_Field_Count(); i++)
{
@@ -1037,8 +1047,7 @@ bool CWKSP_Shapes::_Chart_Set_Options(void)
5, 25, 0, true
);
- pFields = pChart->Add_Node(NULL, "NODE_FIELDS" , LNG("Fields") , LNG(""));
- pColors = pChart->Add_Node(NULL, "NODE_COLORS" , LNG("Field Colors") , LNG(""));
+ pFields = pChart->Add_Node(NULL, "NODE_FIELDS", LNG("Fields"), LNG(""));
Colors.Set_Count(n);
@@ -1048,14 +1057,14 @@ bool CWKSP_Shapes::_Chart_Set_Options(void)
{
sFields.Append(CSG_String::Format(wxT("%s|"), m_pShapes->Get_Field_Name(i)));
- pChart->Add_Value(
+ pField = pChart->Add_Value(
pFields , wxString::Format(wxT("FIELD_%d"), i), m_pShapes->Get_Field_Name(i),
LNG(""),
PARAMETER_TYPE_Bool , false
);
pChart->Add_Value(
- pColors , wxString::Format(wxT("COLOR_%d"), i), m_pShapes->Get_Field_Name(i),
+ pField , wxString::Format(wxT("COLOR_%d"), i), SG_T(""),
LNG(""),
PARAMETER_TYPE_Color, Colors.Get_Color(n++)
);
@@ -1188,6 +1197,8 @@ void CWKSP_Shapes::_Draw_Chart_Bar(CWKSP_Map_DC &dc_Map, CSG_Table_Record *pReco
int i;
double d, dx, dy, max, ix;
+ y += sy / 2;
+
for(i=1, max=fabs(pRecord->asDouble(m_Chart[0].x)); i<m_Chart.Get_Count(); i++)
{
if( (d = fabs(pRecord->asDouble(m_Chart[i].x))) > max )
diff --git a/src/saga_core/saga_gui/wksp_shapes.h b/src/saga_core/saga_gui/wksp_shapes.h
index 0774d40..5581beb 100644
--- a/src/saga_core/saga_gui/wksp_shapes.h
+++ b/src/saga_core/saga_gui/wksp_shapes.h
@@ -134,6 +134,8 @@ protected:
virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter);
+ virtual void On_Update_Views (void);
+
virtual void On_Draw (CWKSP_Map_DC &dc_Map, bool bEdit);
CSG_Parameter * _AttributeList_Add (CSG_Parameter *pNode, const char *Identifier, const wxChar *Name, const wxChar *Description);
diff --git a/src/saga_core/saga_gui/wksp_shapes_line.cpp b/src/saga_core/saga_gui/wksp_shapes_line.cpp
index 5f548ab..818cb2b 100644
--- a/src/saga_core/saga_gui/wksp_shapes_line.cpp
+++ b/src/saga_core/saga_gui/wksp_shapes_line.cpp
@@ -300,6 +300,9 @@ void CWKSP_Shapes_Line::_Draw_Initialize(CWKSP_Map_DC &dc_Map)
//---------------------------------------------------------
void CWKSP_Shapes_Line::_Draw_Shape(CWKSP_Map_DC &dc_Map, CSG_Shape *pShape, bool bSelection)
{
+ if( (m_iSize >= 0 && pShape->is_NoData(m_iSize)) || (m_iColor >= 0 && pShape->is_NoData(m_iColor)) )
+ return;
+
//-----------------------------------------------------
if( bSelection )
{
diff --git a/src/saga_core/saga_gui/wksp_shapes_point.cpp b/src/saga_core/saga_gui/wksp_shapes_point.cpp
index 913789c..651f09e 100644
--- a/src/saga_core/saga_gui/wksp_shapes_point.cpp
+++ b/src/saga_core/saga_gui/wksp_shapes_point.cpp
@@ -186,6 +186,21 @@ void CWKSP_Shapes_Point::On_Create_Parameters(void)
);
m_Parameters.Add_Choice(
+ m_Parameters("SIZE_ATTRIB") , "SIZE_SCALE" , LNG("[CAP] Attribute Values"),
+ LNG(""),
+ wxString::Format(wxT("%s|%s|"),
+ LNG("[VAL] no scaling"),
+ LNG("[VAL] scale to size range")
+ ), 1
+ );
+
+ m_Parameters.Add_Range(
+ m_Parameters("SIZE_ATTRIB") , "SIZE_RANGE" , LNG("[CAP] Size Range"),
+ LNG(""),
+ 2, 10, 0, true
+ );
+
+ m_Parameters.Add_Choice(
m_Parameters("NODE_SIZE") , "SIZE_TYPE" , LNG("[CAP] Size relates to..."),
LNG(""),
wxString::Format(wxT("%s|%s|"),
@@ -200,12 +215,6 @@ void CWKSP_Shapes_Point::On_Create_Parameters(void)
PARAMETER_TYPE_Double, 5, 0, true
);
- m_Parameters.Add_Range(
- m_Parameters("NODE_SIZE") , "SIZE_RANGE" , LNG("[CAP] Size Range"),
- LNG(""),
- 2, 10, 0, true
- );
-
//-----------------------------------------------------
// Label...
@@ -282,7 +291,8 @@ void CWKSP_Shapes_Point::On_Parameters_Changed(void)
}
//-----------------------------------------------------
- m_Size_Type = m_Parameters("SIZE_TYPE")->asInt();
+ m_Size_Type = m_Parameters("SIZE_TYPE") ->asInt();
+ m_Size_Scale = m_Parameters("SIZE_SCALE")->asInt();
if( (m_iSize = m_Parameters("SIZE_ATTRIB")->asInt()) >= m_pShapes->Get_Field_Count()
|| (m_dSize = m_pShapes->Get_Maximum(m_iSize) - (m_Size_Min = m_pShapes->Get_Minimum(m_iSize))) <= 0.0 )
@@ -418,7 +428,23 @@ inline void CWKSP_Shapes_Point::_Draw_Initialize(CWKSP_Map_DC &dc_Map)
inline bool CWKSP_Shapes_Point::_Draw_Initialize(CWKSP_Map_DC &dc_Map, int &Size, CSG_Shape *pShape, bool bSelection)
{
//-----------------------------------------------------
- double dSize = m_iSize < 0 ? m_Size : m_Size + (pShape->asDouble(m_iSize) - m_Size_Min) * m_dSize;
+ double dSize;
+
+ if( m_iSize < 0 ) // default size
+ {
+ dSize = m_Size;
+ }
+ else // size by attribute
+ {
+ if( m_Size_Scale == 0 ) // take value as is
+ {
+ dSize = pShape->asDouble(m_iSize);
+ }
+ else // scale to size range
+ {
+ dSize = (pShape->asDouble(m_iSize) - m_Size_Min) * m_dSize + m_Size;
+ }
+ }
switch( m_Size_Type )
{
@@ -462,9 +488,12 @@ inline bool CWKSP_Shapes_Point::_Draw_Initialize(CWKSP_Map_DC &dc_Map, int &Size
//---------------------------------------------------------
void CWKSP_Shapes_Point::_Draw_Shape(CWKSP_Map_DC &dc_Map, CSG_Shape *pShape, bool bSelection)
{
- int Size;
+ if( (m_iSize >= 0 && pShape->is_NoData(m_iSize)) || (m_iColor >= 0 && pShape->is_NoData(m_iColor)) )
+ return;
//-----------------------------------------------------
+ int Size;
+
if( _Draw_Initialize(dc_Map, Size, pShape, bSelection) )
{
TSG_Point_Int p(dc_Map.World2DC(pShape->Get_Point(0)));
diff --git a/src/saga_core/saga_gui/wksp_shapes_point.h b/src/saga_core/saga_gui/wksp_shapes_point.h
index bc1612e..a3b1fdb 100644
--- a/src/saga_core/saga_gui/wksp_shapes_point.h
+++ b/src/saga_core/saga_gui/wksp_shapes_point.h
@@ -95,7 +95,7 @@ protected:
bool m_bOutline;
- int m_iSize, m_Size_Type, m_Symbol_Type, m_iLabel_Angle, m_Label_Align;
+ int m_iSize, m_Size_Type, m_Size_Scale, m_Symbol_Type, m_iLabel_Angle, m_Label_Align;
double m_Size, m_dSize, m_Size_Min, m_Label_Angle;
diff --git a/src/saga_core/saga_gui/wksp_shapes_points.cpp b/src/saga_core/saga_gui/wksp_shapes_points.cpp
index 4cdeeaf..12c60b0 100644
--- a/src/saga_core/saga_gui/wksp_shapes_points.cpp
+++ b/src/saga_core/saga_gui/wksp_shapes_points.cpp
@@ -146,9 +146,12 @@ int CWKSP_Shapes_Points::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_P
//---------------------------------------------------------
void CWKSP_Shapes_Points::_Draw_Shape(CWKSP_Map_DC &dc_Map, CSG_Shape *pShape, bool bSelection)
{
- int Size;
+ if( (m_iSize >= 0 && pShape->is_NoData(m_iSize)) || (m_iColor >= 0 && pShape->is_NoData(m_iColor)) )
+ return;
//-----------------------------------------------------
+ int Size;
+
if( CWKSP_Shapes_Point::_Draw_Initialize(dc_Map, Size, pShape, bSelection) )
{
for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++)
diff --git a/src/saga_core/saga_gui/wksp_shapes_polygon.cpp b/src/saga_core/saga_gui/wksp_shapes_polygon.cpp
index 90daf29..7b0a6dc 100644
--- a/src/saga_core/saga_gui/wksp_shapes_polygon.cpp
+++ b/src/saga_core/saga_gui/wksp_shapes_polygon.cpp
@@ -241,20 +241,23 @@ void CWKSP_Shapes_Polygon::_Draw_Shape(CWKSP_Map_DC &dc_Map, CSG_Shape *pShape,
dc_Map.dc.SetBrush(m_Brush);
dc_Map.dc.SetPen(m_Pen);
}
- else if( m_iColor >= 0 )
+ else if( m_iColor >= 0 && (m_pClassify->Get_Mode() != CLASSIFY_METRIC || !pShape->is_NoData(m_iColor)) )
{
- int Color = m_pClassify->Get_Class_Color_byValue(pShape->asDouble(m_iColor));
+ int Color;
- m_Brush.SetColour(SG_GET_R(Color), SG_GET_G(Color), SG_GET_B(Color));
- dc_Map.dc.SetBrush(m_Brush);
-
- if( !m_bOutline )
+ if( m_pClassify->Get_Class_Color_byValue(pShape->asDouble(m_iColor), Color) )
{
- m_Pen.SetColour(SG_GET_R(Color), SG_GET_G(Color), SG_GET_B(Color));
- dc_Map.dc.SetPen(m_Pen);
- }
+ m_Brush.SetColour(SG_GET_R(Color), SG_GET_G(Color), SG_GET_B(Color));
+ dc_Map.dc.SetBrush(m_Brush);
- dc_Map.Draw_Polygon((CSG_Shape_Polygon *)pShape);
+ if( !m_bOutline )
+ {
+ m_Pen.SetColour(SG_GET_R(Color), SG_GET_G(Color), SG_GET_B(Color));
+ dc_Map.dc.SetPen(m_Pen);
+ }
+
+ dc_Map.Draw_Polygon((CSG_Shape_Polygon *)pShape);
+ }
}
if( m_bCentroid )
diff --git a/src/saga_core/saga_gui/wksp_table.cpp b/src/saga_core/saga_gui/wksp_table.cpp
index 2386580..c4c6262 100644
--- a/src/saga_core/saga_gui/wksp_table.cpp
+++ b/src/saga_core/saga_gui/wksp_table.cpp
@@ -95,6 +95,11 @@ CWKSP_Table::CWKSP_Table(CSG_Table *pTable, CWKSP_Base_Item *pOwner)
LNG(""),
m_pTable->Get_Name()
);
+
+ m_Parameters.Add_Range(
+ m_Parameters("NODE_GENERAL") , "GENERAL_NODATA" , LNG("[CAP] No Data"),
+ LNG("")
+ );
}
//---------------------------------------------------------
@@ -123,7 +128,7 @@ CWKSP_Table::~CWKSP_Table(void)
//---------------------------------------------------------
wxString CWKSP_Table::Get_Name(void)
{
- return( m_pTable->Get_Name() );
+ return( wxString::Format(wxT("%02d. %s"), 1 + Get_ID(), m_pTable->Get_Name()) );
}
//---------------------------------------------------------
@@ -274,6 +279,11 @@ void CWKSP_Table::Parameters_Changed(void)
{
m_pTable->Set_Name(m_Parameters("NAME")->asString());
+ m_pTable->Set_NoData_Value_Range(
+ m_Parameters("GENERAL_NODATA")->asRange()->Get_LoVal(),
+ m_Parameters("GENERAL_NODATA")->asRange()->Get_HiVal()
+ );
+
Update_Views();
CWKSP_Base_Item::Parameters_Changed();
@@ -352,6 +362,11 @@ bool CWKSP_Table::DataObject_Changed(CSG_Parameters *pParameters)
m_Parameters("NAME")->Set_Value(m_pTable->Get_Name());
+ m_Parameters("GENERAL_NODATA")->asRange()->Set_Range(
+ m_pTable->Get_NoData_Value(),
+ m_pTable->Get_NoData_hiValue()
+ );
+
//-----------------------------------------------------
// g_pACTIVE->Update(this, false);
diff --git a/src/saga_core/saga_gui/wksp_tin.cpp b/src/saga_core/saga_gui/wksp_tin.cpp
index 2fb8ade..3362b13 100644
--- a/src/saga_core/saga_gui/wksp_tin.cpp
+++ b/src/saga_core/saga_gui/wksp_tin.cpp
@@ -129,6 +129,10 @@ wxString CWKSP_TIN::Get_Description(void)
LNG("[CAP] File") , m_pTIN->Get_File_Name()
));
+ s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%s</td></tr>"),
+ LNG("[CAP] Projection") , m_pTIN->Get_Projection().Get_Name().c_str()
+ ));
+
s.Append(wxString::Format(wxT("<tr><td>%s</td><td>%d</td></tr>"),
LNG("[CAP] Points") , m_pTIN->Get_Node_Count()
));
diff --git a/src/saga_core/saga_odbc/Makefile.am b/src/saga_core/saga_odbc/Makefile.am
new file mode 100644
index 0000000..251dbb8
--- /dev/null
+++ b/src/saga_core/saga_odbc/Makefile.am
@@ -0,0 +1,18 @@
+if DEBUG
+DBGFLAGS = -g -DDEBUG
+endif
+if SAGA_UNICODE
+DEP_DEFS = -D_SAGA_UNICODE
+endif
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = $(DEP_LFLG) -lodbc
+lib_LTLIBRARIES = libsaga_odbc.la
+libsaga_odbc_la_LDFLAGS =$(AM_LDFLAGS) -release $(VERSION)
+libsaga_odbc_la_SOURCES =\
+saga_odbc.cpp\
+saga_odbc.h\
+otlv4.h
+
+libsaga_odbc_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
diff --git a/src/saga_core/saga_odbc/Makefile.in b/src/saga_core/saga_odbc/Makefile.in
new file mode 100644
index 0000000..3dd7015
--- /dev/null
+++ b/src/saga_core/saga_odbc/Makefile.in
@@ -0,0 +1,542 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+ at SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = src/saga_core/saga_odbc
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(libdir)"
+LTLIBRARIES = $(lib_LTLIBRARIES)
+libsaga_odbc_la_DEPENDENCIES = \
+ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+am_libsaga_odbc_la_OBJECTS = saga_odbc.lo
+libsaga_odbc_la_OBJECTS = $(am_libsaga_odbc_la_OBJECTS)
+libsaga_odbc_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(libsaga_odbc_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I. at am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(libsaga_odbc_la_SOURCES)
+DIST_SOURCES = $(libsaga_odbc_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISABLELIBHARU = @DISABLELIBHARU@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+HARU_LIB = @HARU_LIB@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+POW_LIB = @POW_LIB@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+ at DEBUG_TRUE@DBGFLAGS = -g -DDEBUG
+ at SAGA_UNICODE_TRUE@DEP_DEFS = -D_SAGA_UNICODE
+DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD
+CXX_INCS = -I$(top_srcdir)/src/saga_core
+AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS)
+AM_LDFLAGS = $(DEP_LFLG) -lodbc
+lib_LTLIBRARIES = libsaga_odbc.la
+libsaga_odbc_la_LDFLAGS = $(AM_LDFLAGS) -release $(VERSION)
+libsaga_odbc_la_SOURCES = \
+saga_odbc.cpp\
+saga_odbc.h\
+otlv4.h
+
+libsaga_odbc_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/saga_core/saga_odbc/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/saga_core/saga_odbc/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+ }
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libsaga_odbc.la: $(libsaga_odbc_la_OBJECTS) $(libsaga_odbc_la_DEPENDENCIES)
+ $(libsaga_odbc_la_LINK) -rpath $(libdir) $(libsaga_odbc_la_OBJECTS) $(libsaga_odbc_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/saga_odbc.Plo at am__quote@
+
+.cpp.o:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+ at am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+ at am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-libLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libLTLIBRARIES clean-libtool ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am \
+ install-libLTLIBRARIES install-man install-pdf 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 uninstall uninstall-am uninstall-libLTLIBRARIES
+
+
+# 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:
diff --git a/src/saga_core/saga_odbc/otlv4.h b/src/saga_core/saga_odbc/otlv4.h
new file mode 100644
index 0000000..a994a13
--- /dev/null
+++ b/src/saga_core/saga_odbc/otlv4.h
@@ -0,0 +1,33879 @@
+// =================================================================================
+// ORACLE, ODBC and DB2/CLI Template Library, Version 4.0.210,
+// Copyright (C) 1996-2010, Sergei Kuchin (skuchin at gmail.com)
+//
+// This library is free software. Permission to use, copy, modify,
+// and/or distribute this software for any purpose with or without fee
+// is hereby granted, provided that the above copyright notice and
+// this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+//
+// a.k.a. as Open BSD license
+// (http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/share/misc/license.template
+// =================================================================================
+
+#ifndef __OTL_H__
+#define __OTL_H__
+
+#if defined(OTL_INCLUDE_0)
+#include "otl_include_0.h"
+#endif
+
+#define OTL_VERSION_NUMBER (0x0400D2L)
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1400)
+#pragma warning (disable:4351)
+#pragma warning (disable:4290)
+#define OTL_STRCAT_S(dest,dest_sz,src) strcat_s(dest,dest_sz,src)
+#define OTL_STRCPY_S(dest,dest_sz,src) strcpy_s(dest,dest_sz,src)
+#define OTL_STRNCPY_S(dest,dest_sz,src,count) strncpy_s(dest,dest_sz,src,count)
+#else
+#define OTL_STRCAT_S(dest,dest_sz,src) strcat(dest,src)
+#define OTL_STRCPY_S(dest,dest_sz,src) strcpy(dest,src)
+#define OTL_STRNCPY_S(dest,dest_sz,src,count) strncpy(dest,src,count)
+#endif
+
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+//======================= CONFIGURATION #DEFINEs ===========================
+
+// Uncomment the following line in order to include the OTL for ODBC:
+//#define OTL_ODBC
+
+// Uncomment the following line in order to include the OTL for
+// MySQL/MyODBC for MyODBC 2.5 (pretty old). Otherwise, use OTL_ODBC
+//#define OTL_ODBC_MYSQL
+
+// Uncomment the following line in order to include the OTL for DB2 CLI:
+//#define OTL_DB2_CLI
+
+// Uncomment the following line in order to include the OTL for
+// Oracle 7:
+//#define OTL_ORA7
+
+// Uncomment the following line in order to include the OTL for
+// Oracle 8:
+//#define OTL_ORA8
+
+// Uncomment the following line in order to include the OTL for
+// Oracle 8i:
+//#define OTL_ORA8I
+
+// Uncomment the following line in order to include the OTL for
+// Oracle 9i:
+//#define OTL_ORA9I
+
+// Uncomment the following line in order to include the OTL for
+// Oracle 10g Release 1:
+//#define OTL_ORA10G
+
+// Uncomment the following line in order to include the OTL for
+// Oracle 10g Release 2:
+//#define OTL_ORA10G_R2
+
+// Uncomment the following line in order to include the OTL for
+// Oracle 11g Release 1
+//#define OTL_ORA11G
+
+
+// The macro definitions may be also turned on via C++ compiler command line
+// option, e.g.: -DOTL_ODBC, -DOTL_ORA7, -DOTL_ORA8, -DOTL_ORA8I, -DOTL_ODBC_UNIX
+// -DOTL_ODBC_MYSQL, -DOTL_DB2_CLI
+
+// this becomes the default from version 4.0.162 and on.
+// the #define is not enabled for vc++ 6.0 in version 4.0.167 and higher.
+#if !defined(OTL_UNCAUGHT_EXCEPTION_ON) && !(defined(_MSC_VER)&&(_MSC_VER==1200))
+#define OTL_UNCAUGHT_EXCEPTION_ON
+#endif
+
+#if !defined(OTL_TRACE_LEVEL)
+
+#define OTL_TRACE_FORMAT_TZ_DATETIME(s)
+#define OTL_TRACE_FORMAT_DATETIME(s)
+
+#else
+
+#if !defined(OTL_TRACE_FORMAT_DATETIME)
+
+#define OTL_TRACE_FORMAT_TZ_DATETIME(s) \
+s.month<<"/"<<s.day<<"/"<<s.year \
+<<" "<<s.hour<<":"<<s.minute<<":"<<s.second<<"."<<s.fraction \
+<<" "<<s.tz_hour<<":"<<s.tz_minute
+
+#define OTL_TRACE_FORMAT_DATETIME(s) \
+s.month<<"/"<<s.day<<"/"<<s.year \
+<<" "<<s.hour<<":"<<s.minute<<":"<<s.second<<"."<<s.fraction
+
+#endif
+#endif
+
+#if defined(OTL_ORA11G)
+#define OTL_ORA10G_R2
+#endif
+
+#if defined(OTL_ORA11G_R2)
+#define OTL_ORA10G_R2
+#endif
+
+#if defined(OTL_STREAM_LEGACY_BUFFER_SIZE_TYPE)
+typedef short int otl_stream_buffer_size_type;
+#else
+typedef int otl_stream_buffer_size_type;
+#endif
+
+
+#if defined(OTL_ODBC_MULTI_MODE)
+#define OTL_ODBC
+#define OTL_ODBC_SQL_EXTENDED_FETCH_ON
+#endif
+
+#if defined(OTL_ODBC_MSSQL_2005)
+#define OTL_ODBC
+#endif
+
+#if defined(OTL_ODBC_MSSQL_2008)
+#define OTL_ODBC
+#define OTL_ODBC_MSSQL_2005
+#endif
+
+#if defined(OTL_IODBC_BSD)
+#define OTL_ODBC
+#define OTL_ODBC_UNIX
+#endif
+
+#if defined(OTL_ODBC_TIMESTEN_WIN)
+#define OTL_ODBC_TIMESTEN
+#define OTL_ODBC
+#define OTL_ODBC_SQL_EXTENDED_FETCH_ON
+#define ODBCVER 0x0250
+#include <timesten.h>
+#endif
+
+#if defined(OTL_ODBC_TIMESTEN_UNIX)
+#define OTL_ODBC_TIMESTEN
+#define OTL_ODBC
+#define OTL_ODBC_UNIX
+#define OTL_ODBC_SQL_EXTENDED_FETCH_ON
+#include <timesten.h>
+#endif
+
+#if defined(OTL_ODBC_ENTERPRISEDB)
+#define OTL_ODBC_POSTGRESQL
+#endif
+
+#if defined(OTL_ODBC_POSTGRESQL)
+#define OTL_ODBC
+#endif
+
+// Comment out this #define when using pre-ANSI C++ compiler
+#if !defined(OTL_ODBC_zOS) && !defined (OTL_ANSI_CPP)
+#define OTL_ANSI_CPP
+#endif
+
+#if defined(OTL_ODBC_zOS)
+#define OTL_ODBC_UNIX
+#define OTL_ODBC_SQL_EXTENDED_FETCH_ON
+#endif
+
+#if defined(OTL_ORA8I)
+#define OTL_ORA8
+#define OTL_ORA8_8I_REFCUR
+#define OTL_ORA8_8I_DESC_COLUMN_SCALE
+#endif
+
+#if defined(OTL_ORA10G)||defined(OTL_ORA10G_R2)
+#define OTL_ORA9I
+#define OTL_ORA_NATIVE_TYPES
+#endif
+
+#if defined(OTL_ORA9I)
+#define OTL_ORA8
+#define OTL_ORA8_8I_REFCUR
+#define OTL_ORA8_8I_DESC_COLUMN_SCALE
+#endif
+
+#if defined(OTL_ODBC_MYSQL)
+#define OTL_ODBC
+#endif
+
+#if defined(OTL_ODBC_XTG_IBASE6)
+#define OTL_ODBC
+#endif
+
+#define OTL_VALUE_TEMPLATE
+//#define OTL_ODBC_SQL_EXTENDED_FETCH_ON
+
+#if defined(OTL_ODBC_UNIX) && !defined(OTL_ODBC)
+#define OTL_ODBC
+#endif
+
+#if defined(OTL_BIND_VAR_STRICT_TYPE_CHECKING_ON)
+#define OTL_CHECK_BIND_VARS \
+ if(strcmp(type_arr,"INT")==0|| \
+ strcmp(type_arr,"UNSIGNED")==0|| \
+ strcmp(type_arr,"SHORT")==0|| \
+ strcmp(type_arr,"LONG")==0|| \
+ strcmp(type_arr,"FLOAT")==0|| \
+ strcmp(type_arr,"DOUBLE")==0|| \
+ strcmp(type_arr,"TIMESTAMP")==0|| \
+ strcmp(type_arr,"TZ_TIMESTAMP")==0|| \
+ strcmp(type_arr,"LTZ_TIMESTAMP")==0|| \
+ strcmp(type_arr,"BIGINT")==0|| \
+ strcmp(type_arr,"CHAR")==0|| \
+ strcmp(type_arr,"CHARZ")==0|| \
+ strcmp(type_arr,"DB2DATE")==0|| \
+ strcmp(type_arr,"DB2TIME")==0|| \
+ strcmp(type_arr,"VARCHAR_LONG")==0|| \
+ strcmp(type_arr,"RAW_LONG")==0|| \
+ strcmp(type_arr,"RAW")==0|| \
+ strcmp(type_arr,"CLOB")==0|| \
+ strcmp(type_arr,"BLOB")==0|| \
+ strcmp(type_arr,"NCHAR")==0|| \
+ strcmp(type_arr,"NCLOB")==0|| \
+ strcmp(type_arr,"REFCUR")==0) \
+ ; \
+ else \
+ return 0;
+#else
+#define OTL_CHECK_BIND_VARS
+#endif
+
+// ------------------- Namespace generation ------------------------
+#if defined(OTL_EXPLICIT_NAMESPACES)
+
+#if defined(OTL_DB2_CLI)
+#define OTL_ODBC_NAMESPACE_BEGIN namespace db2 {
+#define OTL_ODBC_NAMESPACE_PREFIX db2::
+#define OTL_ODBC_NAMESPACE_END }
+#else
+#define OTL_ODBC_NAMESPACE_BEGIN namespace odbc {
+#define OTL_ODBC_NAMESPACE_PREFIX odbc::
+#define OTL_ODBC_NAMESPACE_END }
+#endif
+
+#define OTL_ORA7_NAMESPACE_BEGIN namespace oracle {
+#define OTL_ORA7_NAMESPACE_PREFIX oracle::
+#define OTL_ORA7_NAMESPACE_END }
+
+#define OTL_ORA8_NAMESPACE_BEGIN namespace oracle {
+#define OTL_ORA8_NAMESPACE_PREFIX oracle::
+#define OTL_ORA8_NAMESPACE_END }
+
+#else
+
+// Only one OTL is being intantiated
+#if defined(OTL_ODBC)&&!defined(OTL_ORA8)&& \
+ !defined(OTL_ORA7)&&!defined(OTL_DB2_CLI) \
+ || !defined(OTL_ODBC)&&defined(OTL_ORA8)&& \
+ !defined(OTL_ORA7)&&!defined(OTL_DB2_CLI) \
+ || !defined(OTL_ODBC)&&!defined(OTL_ORA8)&& \
+ defined(OTL_ORA7)&&!defined(OTL_DB2_CLI) \
+ || !defined(OTL_ODBC)&&!defined(OTL_ORA8)&& \
+ !defined(OTL_ORA7)&&defined(OTL_DB2_CLI)
+
+#define OTL_ODBC_NAMESPACE_BEGIN
+#define OTL_ODBC_NAMESPACE_PREFIX
+#define OTL_ODBC_NAMESPACE_END
+
+#define OTL_ORA7_NAMESPACE_BEGIN
+#define OTL_ORA7_NAMESPACE_PREFIX
+#define OTL_ORA7_NAMESPACE_END
+
+#define OTL_ORA8_NAMESPACE_BEGIN
+#define OTL_ORA8_NAMESPACE_PREFIX
+#define OTL_ORA8_NAMESPACE_END
+
+#endif
+
+// ================ Combinations of two OTLs =========================
+#if defined(OTL_ODBC) && defined(OTL_ORA7) && \
+ !defined(OTL_ORA8) && !defined(OTL_DB2_CLI)
+
+#define OTL_ODBC_NAMESPACE_BEGIN namespace odbc{
+#define OTL_ODBC_NAMESPACE_PREFIX odbc::
+#define OTL_ODBC_NAMESPACE_END }
+
+#define OTL_ORA7_NAMESPACE_BEGIN namespace oracle {
+#define OTL_ORA7_NAMESPACE_PREFIX oracle::
+#define OTL_ORA7_NAMESPACE_END }
+
+#define OTL_ORA8_NAMESPACE_BEGIN
+#define OTL_ORA8_NAMESPACE_PREFIX
+#define OTL_ORA8_NAMESPACE_END
+
+#endif
+
+#if defined(OTL_ODBC) && !defined(OTL_ORA7) && \
+ defined(OTL_ORA8) && !defined(OTL_DB2_CLI)
+
+#define OTL_ODBC_NAMESPACE_BEGIN namespace odbc{
+#define OTL_ODBC_NAMESPACE_PREFIX odbc::
+#define OTL_ODBC_NAMESPACE_END }
+
+#define OTL_ORA8_NAMESPACE_BEGIN namespace oracle {
+#define OTL_ORA8_NAMESPACE_PREFIX oracle::
+#define OTL_ORA8_NAMESPACE_END }
+
+#define OTL_ORA7_NAMESPACE_BEGIN
+#define OTL_ORA7_NAMESPACE_PREFIX
+#define OTL_ORA7_NAMESPACE_END
+
+
+#endif
+
+#if !defined(OTL_ODBC) && defined(OTL_ORA7) && \
+ !defined(OTL_ORA8) && defined(OTL_DB2_CLI)
+
+#define OTL_ORA7_NAMESPACE_BEGIN namespace oracle {
+#define OTL_ORA7_NAMESPACE_PREFIX oracle::
+#define OTL_ORA7_NAMESPACE_END }
+
+#define OTL_ORA8_NAMESPACE_BEGIN
+#define OTL_ORA8_NAMESPACE_PREFIX
+#define OTL_ORA8_NAMESPACE_END
+
+#define OTL_ODBC_NAMESPACE_BEGIN namespace db2 {
+#define OTL_ODBC_NAMESPACE_PREFIX db2::
+#define OTL_ODBC_NAMESPACE_END }
+
+
+#endif
+
+#if !defined(OTL_ODBC) && !defined(OTL_ORA7) && \
+ defined(OTL_ORA8) && defined(OTL_DB2_CLI)
+
+#define OTL_ORA8_NAMESPACE_BEGIN namespace oracle {
+#define OTL_ORA8_NAMESPACE_PREFIX oracle::
+#define OTL_ORA8_NAMESPACE_END }
+
+#define OTL_ORA7_NAMESPACE_BEGIN
+#define OTL_ORA7_NAMESPACE_PREFIX
+#define OTL_ORA7_NAMESPACE_END
+
+#define OTL_ODBC_NAMESPACE_BEGIN namespace db2 {
+#define OTL_ODBC_NAMESPACE_PREFIX db2::
+#define OTL_ODBC_NAMESPACE_END }
+
+
+#endif
+
+#endif
+
+// -------------------- End of namespace generation -------------------
+
+// --------------------- Invalid combinations --------------------------
+
+#if (defined(OTL_ORA7_TIMESTAMP_TO_STRING)||defined(OTL_ORA7_STRING_TO_TIMESTAMP)) \
+ && defined(OTL_ORA_TIMESTAMP)
+#error Invalid combination: OTL_ORA_TIMESTAMP and \
+OTL_ORA7_TIMESTAMP_TO_STRING/OTL_ORA7_STRING_TO_TIMESTAMP
+#endif
+
+#if defined(OTL_ORA_MAP_BIGINT_TO_LONG) && \
+ defined(OTL_BIGINT_TO_STR) && \
+ defined(OTL_STR_TO_BIGINT)
+#error OTL_ORA_MAP_BIGINT_TO_LONG cannot be used when \
+OTL_BIGINT_TO_STR and OTL_STR_TO_BIGINT are defined
+#endif
+
+#if defined(OTL_STL) && defined(OTL_UNICODE_STRING_TYPE)
+#error Invalid combination: OTL_STL and OTL_UNICODE_STRING_TYPE
+#endif
+
+#if defined(OTL_ORA_UTF8) && !defined(OTL_ORA10G) && \
+ !defined(OTL_ORA_10G_R2) && !defined(OTL_ORA9I)
+#error Invalid combination: OTL_ORA_UTF8 can only be used with OTL_ORA9I or higher
+#endif
+
+#if defined(OTL_ORA_UTF8) && defined(OTL_UNICODE)
+#error Invalid combination: OTL_ORA_UTF8 and OTL_UNICODE are mutually exclusive
+#endif
+
+#if defined(OTL_ODBC) && defined(OTL_DB2_CLI)
+#error Invalid combination: OTL_ODBC && OTL_DB2_CLI together
+#endif
+
+#if defined(OTL_ORA7) && defined(OTL_ORA8)
+#error Invalid combination: OTL_ORA7 && OTL_ORA8(I) together
+#endif
+
+#if (defined(OTL_ORA7) || defined(OTL_ORA8) || \
+ defined(OTL_ORA8I) || defined(OTL_ORA9I) ) && \
+ defined(OTL_BIGINT) && \
+ (defined(OTL_ODBC) || defined(OTL_DB2_CLI))
+#error OTL_BIGINT is not supported when OTL_ORAXX and OTL_ODBC \
+(or OTL_DB2_CLI) are defined together
+#endif
+
+#if defined (OTL_ORA7) && defined(OTL_ORA8)
+#error Invalid combination: OTL_ORA7 && OTL_ORA8(I) together
+#endif
+
+#if defined(OTL_ORA_OCI_ENV_CREATE) && \
+ (!defined(OTL_ORA8I) && !defined(OTL_ORA9I) && \
+ !defined(OTL_ORA10G) && !defined(OTL_ORA10G_R2))
+#error OTL_ORA_OCI_ENV_CREATE can be only defined when OTL_ORA8I, OTL_ORA9I, OTL_ORA10G, OTL_ORA10G_R2, or OTL_ORA11G is defined
+#endif
+// --------------------------------------------------------------------
+
+#if defined(OTL_TRACE_LEVEL)
+
+#if !defined(OTL_TRACE_LINE_PREFIX)
+#define OTL_TRACE_LINE_PREFIX "OTL TRACE ==> "
+#endif
+
+#if defined(OTL_UNICODE_CHAR_TYPE) && !defined(OTL_UNICODE)
+#error OTL_UNICODE needs to be defined if OTL_UNICODE_CHAR_TYPE is defined
+#endif
+
+#if defined(OTL_UNICODE_STRING_TYPE) && !defined(OTL_UNICODE_CHAR_TYPE)
+#error OTL_UNICODE_CHAR_TYPE needs to be defined if OTL_UNICODE_STRING_TYPE is defined
+#endif
+
+#if defined(OTL_UNICODE_STRING_TYPE) && !defined(OTL_UNICODE_CHAR_TYPE)
+#error OTL_UNICODE_CHAR_TYPE needs to be defined if OTL_UNICODE_STRING_TYPE is defined
+#endif
+
+#if defined(OTL_UNICODE_STRING_TYPE) && !defined(OTL_UNICODE)
+#error OTL_UNICODE needs to be defined if OTL_UNICODE_STRING_TYPE is defined
+#endif
+
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON) && !defined(OTL_UNICODE_CHAR_TYPE)
+#error OTL_UNICODE_CHAR_TYPE needs to be defined if OTL_UNICODE_EXCEPTION_AND_RLOGON is defined
+#endif
+
+
+#if !defined(OTL_TRACE_LINE_SUFFIX)
+#if defined(OTL_UNICODE)
+#define OTL_TRACE_LINE_SUFFIX L"\n"
+#else
+#define OTL_TRACE_LINE_SUFFIX "\n"
+#endif
+#endif
+
+#if !defined(OTL_TRACE_STREAM_OPEN)
+#define OTL_TRACE_STREAM_OPEN \
+ if(OTL_TRACE_LEVEL & 0x4){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,this); \
+ OTL_TRACE_STREAM<<")::open(buffer_size="; \
+ OTL_TRACE_STREAM<<arr_size; \
+ OTL_TRACE_STREAM<<", sqlstm="; \
+ OTL_TRACE_STREAM<<sqlstm; \
+ OTL_TRACE_STREAM<<", connect="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,&db); \
+ OTL_TRACE_STREAM<<", implicit_select="; \
+ OTL_TRACE_STREAM<<implicit_select; \
+ if(sqlstm_label){ \
+ OTL_TRACE_STREAM<<", label="; \
+ OTL_TRACE_STREAM<<sqlstm_label; \
+ } \
+ OTL_TRACE_STREAM<<");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+
+#if !defined(OTL_TRACE_STREAM_OPEN2)
+#define OTL_TRACE_STREAM_OPEN2 \
+ if(OTL_TRACE_LEVEL & 0x4){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,this); \
+ OTL_TRACE_STREAM<<")::open(buffer_size="; \
+ OTL_TRACE_STREAM<<arr_size; \
+ OTL_TRACE_STREAM<<", sqlstm="; \
+ OTL_TRACE_STREAM<<sqlstm; \
+ OTL_TRACE_STREAM<<", connect="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,&db); \
+ if(ref_cur_placeholder){ \
+ OTL_TRACE_STREAM<<", ref_cur_placeholder="; \
+ OTL_TRACE_STREAM<<ref_cur_placeholder; \
+ } \
+ if(sqlstm_label){ \
+ OTL_TRACE_STREAM<<", label="; \
+ OTL_TRACE_STREAM<<sqlstm_label; \
+ } \
+ OTL_TRACE_STREAM<<");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+
+#if !defined(OTL_TRACE_DIRECT_EXEC)
+#define OTL_TRACE_DIRECT_EXEC \
+ if(OTL_TRACE_LEVEL & 0x2){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_cursor::direct_exec(connect="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,&connect); \
+ OTL_TRACE_STREAM<<",sqlstm=\""; \
+ OTL_TRACE_STREAM<<sqlstm; \
+ OTL_TRACE_STREAM<<"\",exception_enabled="; \
+ OTL_TRACE_STREAM<<exception_enabled; \
+ OTL_TRACE_STREAM<<");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+
+#if !defined(OTL_TRACE_SYNTAX_CHECK)
+#define OTL_TRACE_SYNTAX_CHECK \
+ if(OTL_TRACE_LEVEL & 0x2){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_cursor::syntax_check(connect="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,&connect); \
+ OTL_TRACE_STREAM<<",sqlstm=\""; \
+ OTL_TRACE_STREAM<<sqlstm; \
+ OTL_TRACE_STREAM<<"\""; \
+ OTL_TRACE_STREAM<<");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+
+#if !defined(OTL_TRACE_FUNC)
+#define OTL_TRACE_FUNC(level,class_name,func_name,args) \
+ if(OTL_TRACE_LEVEL & level){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<class_name; \
+ OTL_TRACE_STREAM<<"(this="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,this); \
+ OTL_TRACE_STREAM<<")::" func_name "("; \
+ OTL_TRACE_STREAM<<args; \
+ OTL_TRACE_STREAM<<");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+
+#if !defined(OTL_TRACE_EXCEPTION)
+#define OTL_TRACE_EXCEPTION(code,msg,stm_text,var_info) \
+ if(OTL_TRACE_LEVEL & 0x20){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_exception, code="; \
+ OTL_TRACE_STREAM<<code; \
+ OTL_TRACE_STREAM<<", msg="; \
+ char* c=OTL_RCAST(char*,msg); \
+ while(*c && *c!='\n'){ \
+ OTL_TRACE_STREAM<<*c; \
+ ++c; \
+ } \
+ OTL_TRACE_STREAM<<", stm_text="; \
+ OTL_TRACE_STREAM<<stm_text; \
+ OTL_TRACE_STREAM<<", var_info="; \
+ OTL_TRACE_STREAM<<var_info; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+
+#if !defined(OTL_TRACE_RLOGON_ORA7) && defined(OTL_ORA7)
+#define OTL_TRACE_RLOGON_ORA7(level,class_name,func_name, \
+ connect_str,auto_commit) \
+ if(OTL_TRACE_LEVEL & level){ \
+ char temp_connect_str[2048]; \
+ const char* c1=OTL_RCAST(const char*,connect_str); \
+ char* c2=temp_connect_str; \
+ while(*c1 && *c1!='/'){ \
+ *c2=*c1; \
+ ++c1; ++c2; \
+ } \
+ if(*c1=='/'){ \
+ *c2=*c1; \
+ ++c1; ++c2; \
+ while(*c1 && *c1!='@'){ \
+ *c2='*'; \
+ ++c1; ++c2; \
+ } \
+ if(*c1=='@'){ \
+ while(*c1){ \
+ *c2=*c1; \
+ ++c1; ++c2; \
+ } \
+ } \
+ } \
+ *c2=0; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<class_name; \
+ OTL_TRACE_STREAM<<"(this="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,this); \
+ OTL_TRACE_STREAM<<")::" func_name "("; \
+ OTL_TRACE_STREAM<<"connect_str=\""; \
+ OTL_TRACE_STREAM<<temp_connect_str; \
+ OTL_TRACE_STREAM<<"\", auto_commit="; \
+ OTL_TRACE_STREAM<<auto_commit; \
+ OTL_TRACE_STREAM<<");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+
+#if !defined(OTL_TRACE_RLOGON_ORA8) && defined(OTL_ORA8)
+#define OTL_TRACE_RLOGON_ORA8(level,class_name,func_name, \
+ tnsname,userid,passwd, \
+ auto_commit) \
+ if(OTL_TRACE_LEVEL & level){ \
+ char temp_connect_str[2048]; \
+ OTL_STRCPY_S(temp_connect_str,sizeof(temp_connect_str),userid); \
+ OTL_STRCAT_S(temp_connect_str,sizeof(temp_connect_str),"/"); \
+ size_t sz=strlen(passwd); \
+ for(size_t i=0;i<sz;++i) \
+ OTL_STRCAT_S(temp_connect_str,sizeof(temp_connect_str),"*"); \
+ size_t tns_sz=strlen(tnsname); \
+ if(tns_sz>0){ \
+ OTL_STRCAT_S(temp_connect_str,sizeof(temp_connect_str),"@"); \
+ OTL_STRCAT_S(temp_connect_str,sizeof(temp_connect_str),tnsname); \
+ } \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<class_name<<"(this="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,this); \
+ OTL_TRACE_STREAM<<")::" func_name "("; \
+ OTL_TRACE_STREAM<<"connect_str=\""; \
+ OTL_TRACE_STREAM<<temp_connect_str; \
+ OTL_TRACE_STREAM<<"\", auto_commit="; \
+ OTL_TRACE_STREAM<<auto_commit <<");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+
+#if !defined(OTL_TRACE_RLOGON_ODBC)&&(defined(OTL_ODBC)||defined(OTL_DB2_CLI))
+#define OTL_TRACE_RLOGON_ODBC(level,class_name,func_name, \
+ tnsname,userid,passwd, \
+ auto_commit) \
+ if(OTL_TRACE_LEVEL & level){ \
+ char temp_connect_str2[2048]; \
+ OTL_STRCPY_S(temp_connect_str2,sizeof(temp_connect_str2),userid); \
+ OTL_STRCAT_S(temp_connect_str2,sizeof(temp_connect_str2),"/"); \
+ size_t sz=strlen(passwd); \
+ for(size_t i=0;i<sz;++i) \
+ OTL_STRCAT_S(temp_connect_str2,sizeof(temp_connect_str2),"*"); \
+ size_t tns_sz=strlen(tnsname); \
+ if(tns_sz>0){ \
+ OTL_STRCAT_S(temp_connect_str2,sizeof(temp_connect_str2),"@"); \
+ OTL_STRCAT_S(temp_connect_str2,sizeof(temp_connect_str2),tnsname); \
+ } \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<class_name; \
+ OTL_TRACE_STREAM<<"(this="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,this); \
+ OTL_TRACE_STREAM<<")::" func_name "("; \
+ OTL_TRACE_STREAM<<"connect_str=\""; \
+ OTL_TRACE_STREAM<<temp_connect_str2; \
+ OTL_TRACE_STREAM<<"\", auto_commit="; \
+ OTL_TRACE_STREAM<<auto_commit; \
+ OTL_TRACE_STREAM<<");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+
+#if !defined(OTL_TRACE_RLOGON_ODBC_W)&& \
+ (defined(OTL_ODBC)||defined(OTL_DB2_CLI))
+#define OTL_TRACE_RLOGON_ODBC_W(level,class_name,func_name, \
+ tnsname,userid,passwd, \
+ auto_commit) \
+ if(OTL_TRACE_LEVEL & level){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<class_name; \
+ OTL_TRACE_STREAM<<L"(this="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,this); \
+ OTL_TRACE_STREAM<<L")::" func_name L"("; \
+ OTL_TRACE_STREAM<<L"connect_str=\""; \
+ OTL_TRACE_STREAM<<userid<<L"/***@"<<tnsname; \
+ OTL_TRACE_STREAM<<L"\", auto_commit="; \
+ OTL_TRACE_STREAM<<auto_commit; \
+ OTL_TRACE_STREAM<<L");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+
+#if !defined(OTL_TRACE_FIRST_FETCH)
+#if defined(OTL_TRACE_ENABLE_STREAM_LABELS)
+#define OTL_TRACE_FIRST_FETCH \
+ if(OTL_TRACE_LEVEL & 0x8){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<this->master_stream_ptr_; \
+ OTL_TRACE_STREAM<<"), "; \
+ OTL_TRACE_STREAM<<"fetched the first batch of rows, SQL Stm="; \
+ if(this->stm_label) \
+ OTL_TRACE_STREAM<<this->stm_label; \
+ else \
+ OTL_TRACE_STREAM<<this->stm_text; \
+ OTL_TRACE_STREAM<<", RPC="; \
+ OTL_TRACE_STREAM<<row_count; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#else
+#define OTL_TRACE_FIRST_FETCH \
+ if(OTL_TRACE_LEVEL & 0x8){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<this->master_stream_ptr_; \
+ OTL_TRACE_STREAM<<"), "; \
+ OTL_TRACE_STREAM<<"fetched the first batch of rows, SQL Stm="; \
+ OTL_TRACE_STREAM<<this->stm_text; \
+ OTL_TRACE_STREAM<<", RPC="; \
+ OTL_TRACE_STREAM<<row_count; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+#endif
+
+#if !defined(OTL_TRACE_NEXT_FETCH)
+#if defined(OTL_TRACE_ENABLE_STREAM_LABELS)
+#define OTL_TRACE_NEXT_FETCH \
+ if(OTL_TRACE_LEVEL & 0x8 && cur_row==0){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<this->master_stream_ptr_; \
+ OTL_TRACE_STREAM<<"), "; \
+ OTL_TRACE_STREAM<<"fetched the next batch of rows, SQL Stm=" ; \
+ if(this->stm_label) \
+ OTL_TRACE_STREAM<<this->stm_label; \
+ else \
+ OTL_TRACE_STREAM<<this->stm_text; \
+ OTL_TRACE_STREAM<<", RPC="; \
+ OTL_TRACE_STREAM<<row_count; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#define OTL_TRACE_NEXT_FETCH2 \
+ if(OTL_TRACE_LEVEL & 0x8 && cur_row==1){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<this->master_stream_ptr_; \
+ OTL_TRACE_STREAM<<"), "; \
+ OTL_TRACE_STREAM<<"fetched the next batch of rows, SQL Stm=" ; \
+ if(this->stm_label) \
+ OTL_TRACE_STREAM<<this->stm_label; \
+ else \
+ OTL_TRACE_STREAM<<this->stm_text; \
+ OTL_TRACE_STREAM<<", RPC="; \
+ OTL_TRACE_STREAM<<row_count; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#else
+#define OTL_TRACE_NEXT_FETCH \
+ if(OTL_TRACE_LEVEL & 0x8 && cur_row==0){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<this->master_stream_ptr_; \
+ OTL_TRACE_STREAM<<"), "; \
+ OTL_TRACE_STREAM<<"fetched the next batch of rows, SQL Stm=" ; \
+ OTL_TRACE_STREAM<<this->stm_text; \
+ OTL_TRACE_STREAM<<", RPC="; \
+ OTL_TRACE_STREAM<<row_count; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#define OTL_TRACE_NEXT_FETCH2 \
+ if(OTL_TRACE_LEVEL & 0x8 && cur_row==1){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<this->master_stream_ptr_; \
+ OTL_TRACE_STREAM<<"), "; \
+ OTL_TRACE_STREAM<<"fetched the next batch of rows, SQL Stm=" ; \
+ OTL_TRACE_STREAM<<this->stm_text; \
+ OTL_TRACE_STREAM<<", RPC="; \
+ OTL_TRACE_STREAM<<row_count; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+#endif
+
+#if !defined(OTL_TRACE_STREAM_EXECUTION)
+#if defined(OTL_TRACE_ENABLE_STREAM_LABELS)
+#define OTL_TRACE_STREAM_EXECUTION \
+ if(OTL_TRACE_LEVEL & 0x8){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<override->get_master_stream_ptr(); \
+ OTL_TRACE_STREAM<<"), executing SQL Stm="; \
+ if(this->stm_label) \
+ OTL_TRACE_STREAM<<this->stm_label; \
+ else \
+ OTL_TRACE_STREAM<<this->stm_text; \
+ OTL_TRACE_STREAM<<", buffer size="; \
+ OTL_TRACE_STREAM<<this->array_size; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#else
+#define OTL_TRACE_STREAM_EXECUTION \
+ if(OTL_TRACE_LEVEL & 0x8){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<override->get_master_stream_ptr(); \
+ OTL_TRACE_STREAM<<"), executing SQL Stm="; \
+ OTL_TRACE_STREAM<<this->stm_text; \
+ OTL_TRACE_STREAM<<", buffer size="; \
+ OTL_TRACE_STREAM<<this->array_size; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+#endif
+
+#if !defined(OTL_TRACE_STREAM_EXECUTION2)
+#if defined(OTL_TRACE_ENABLE_STREAM_LABELS)
+#define OTL_TRACE_STREAM_EXECUTION2 \
+ if(OTL_TRACE_LEVEL & 0x8){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<this->master_stream_ptr_; \
+ OTL_TRACE_STREAM<<"), executing SQL Stm="; \
+ if(this->stm_label) \
+ OTL_TRACE_STREAM<<this->stm_label; \
+ else \
+ OTL_TRACE_STREAM<<this->stm_text; \
+ OTL_TRACE_STREAM<<", current batch size="; \
+ OTL_TRACE_STREAM<<(cur_y+1); \
+ OTL_TRACE_STREAM<<", row offset="; \
+ OTL_TRACE_STREAM<<rowoff; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#else
+#define OTL_TRACE_STREAM_EXECUTION2 \
+ if(OTL_TRACE_LEVEL & 0x8){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<this->master_stream_ptr_; \
+ OTL_TRACE_STREAM<<"), executing SQL Stm="; \
+ OTL_TRACE_STREAM<<this->stm_text; \
+ OTL_TRACE_STREAM<<", current batch size="; \
+ OTL_TRACE_STREAM<<(cur_y+1); \
+ OTL_TRACE_STREAM<<", row offset="; \
+ OTL_TRACE_STREAM<<rowoff; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }
+#endif
+#endif
+
+#if !defined(OTL_TRACE_READ)
+
+#define OTL_TRACE_READ(val,function,type) \
+ if(OTL_TRACE_LEVEL & 0x10){ \
+ otl_var_desc* temp_vdesc=describe_next_in_var(); \
+ if(temp_vdesc){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,this); \
+ OTL_TRACE_STREAM<<")::" function "(" type ": "; \
+ OTL_TRACE_STREAM<<"ftype="; \
+ OTL_TRACE_STREAM<<temp_vdesc->ftype; \
+ OTL_TRACE_STREAM<<", placeholder="; \
+ OTL_TRACE_STREAM<<temp_vdesc->name; \
+ OTL_TRACE_STREAM<<", value="; \
+ OTL_TRACE_STREAM<<val; \
+ OTL_TRACE_STREAM <<");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }else{ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"loading superfluous input variable"; \
+ OTL_TRACE_STREAM<<"::" function "(" type ": "; \
+ OTL_TRACE_STREAM<<", value="; \
+ OTL_TRACE_STREAM<<val; \
+ OTL_TRACE_STREAM<<");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ } \
+ }
+#endif
+
+#if !defined(OTL_TRACE_WRITE)
+#define OTL_TRACE_WRITE(val,function,type) \
+ if(OTL_TRACE_LEVEL & 0x10){ \
+ otl_var_desc* temp_vdesc=describe_next_out_var(); \
+ if (temp_vdesc){ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"otl_stream(this="; \
+ OTL_TRACE_STREAM<<OTL_RCAST(void*,this); \
+ OTL_TRACE_STREAM<<")::" function "(" type " : "; \
+ OTL_TRACE_STREAM<<"ftype="; \
+ OTL_TRACE_STREAM<<temp_vdesc->ftype; \
+ OTL_TRACE_STREAM<<", placeholder="; \
+ OTL_TRACE_STREAM<<temp_vdesc->name; \
+ OTL_TRACE_STREAM<<", value="; \
+ if(this->is_null()) \
+ OTL_TRACE_STREAM<<"NULL"; \
+ else \
+ OTL_TRACE_STREAM<<val; \
+ OTL_TRACE_STREAM<<");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ }else{ \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_PREFIX; \
+ OTL_TRACE_STREAM<<"writing superfluous output variable"; \
+ OTL_TRACE_STREAM<<"::" function "(" type " : "; \
+ OTL_TRACE_STREAM<<", value="; \
+ if(this->is_null()) \
+ OTL_TRACE_STREAM<<"NULL"; \
+ else \
+ OTL_TRACE_STREAM<<val; \
+ OTL_TRACE_STREAM<<");"; \
+ OTL_TRACE_STREAM<<OTL_TRACE_LINE_SUFFIX; \
+ } \
+ }
+#endif
+
+#else
+
+#define OTL_TRACE_LINE_PREFIX
+#define OTL_TRACE_LINE_SUFFIX
+#define OTL_TRACE_DIRECT_EXEC
+#define OTL_TRACE_SYNTAX_CHECK
+#define OTL_TRACE_FUNC(level,class_name,func_name,args)
+#define OTL_TRACE_EXCEPTION(code,msg,stm_text,var_info)
+#define OTL_TRACE_RLOGON_ORA7(level,class_name,func_name, \
+ connect_str,auto_commit)
+#define OTL_TRACE_RLOGON_ORA8(level,class_name,func_name, \
+ tnsname,userid,passwd, \
+ auto_commit)
+#define OTL_TRACE_RLOGON_ODBC(level,class_name,func_name, \
+ tnsname,userid,passwd, \
+ auto_commit)
+#define OTL_TRACE_STREAM_OPEN
+#define OTL_TRACE_STREAM_OPEN2
+#define OTL_TRACE_FIRST_FETCH
+#define OTL_TRACE_NEXT_FETCH
+#define OTL_TRACE_NEXT_FETCH2
+#define OTL_TRACE_STREAM_EXECUTION
+#define OTL_TRACE_STREAM_EXECUTION2
+#define OTL_TRACE_WRITE(val,function,type)
+#define OTL_TRACE_READ(val,function,type)
+#define OTL_TRACE_RLOGON_ODBC_W(level,class_name,func_name, \
+ tnsname,userid,passwd, \
+ auto_commit)
+#endif
+
+#if defined(OTL_DB2_CLI)
+#define OTL_ODBC
+#endif
+
+#if defined(OTL_UNICODE)
+
+#if !defined(OTL_UNICODE_CHAR_TYPE)
+#define OTL_UNICODE_CHAR_TYPE wchar_t
+#endif
+
+#if !defined(OTL_UNICODE_CHAR_TYPE_TRACE_NAME)
+#define OTL_UNICODE_CHAR_TYPE_TRACE_NAME "wchar_t"
+#endif
+
+#endif
+
+#if defined(OTL_UNICODE)&& \
+ (defined(OTL_ORA8I)|| \
+ defined(OTL_ORA9I)|| \
+ defined(OTL_ORA10G)||defined(OTL_ORA10G_R2))
+#define OTL_ORA_UNICODE
+#endif
+
+#if defined(OTL_UNICODE)
+
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I)||defined(OTL_ORA10G)||defined(OTL_ORA10G_R2)) && defined(OTL_ODBC)
+#error OTL_UNICODE is not supported when both OTL_ORAxx and OTL_ODBC/OTL_DB2_CLI are defined
+#endif
+
+#if defined(OTL_ORA8I)||defined(OTL_ORA9I)||defined(OTL_ORA10G)||defined(OTL_ORA10G_R2)
+
+#define OTL_CHAR unsigned short
+#define OTL_UNICODE_CHAR OTL_CHAR
+#define OTL_WCHAR unsigned long
+
+#if defined(OTL_ORA8I)
+#define OTL_UNICODE_ID OCI_UCS2ID
+#endif
+
+#if defined(OTL_ORA9I)
+#define OTL_UNICODE_ID OCI_UTF16ID
+#endif
+
+#elif defined(OTL_ODBC)
+
+#define OTL_CHAR unsigned short
+#define OTL_UNICODE_CHAR OTL_CHAR
+#define OTL_WCHAR OTL_CHAR
+
+#endif
+
+#else
+
+#define OTL_CHAR unsigned char
+
+#endif
+
+
+#if defined(OTL_ORA7) || defined(OTL_ORA8)
+#define OTL_PL_TAB
+#endif
+
+const int otl_odbc_adapter=1;
+const int otl_ora7_adapter=2;
+const int otl_ora8_adapter=3;
+
+const int otl_inout_binding=1;
+const int otl_select_binding=2;
+
+const int otl_unsupported_type=-10000;
+
+#if defined(OTL_ANSI_CPP)
+
+#define OTL_SCAST(_t,_e) static_cast<_t >(_e)
+#define OTL_RCAST(_t,_e) reinterpret_cast<_t >(_e)
+#define OTL_DCAST(_t,_e) dynamic_cast<_t >(_e)
+#define OTL_CCAST(_t,_e) const_cast<_t >(_e)
+
+#define OTL_CONST_EXCEPTION const
+
+#if defined(OTL_FUNC_THROW_SPEC_ON)
+#define OTL_THROWS_OTL_EXCEPTION throw(otl_exception)
+#define OTL_NO_THROW throw()
+#else
+#define OTL_THROWS_OTL_EXCEPTION
+#define OTL_NO_THROW
+#endif
+
+#define OTL_TYPE_NAME typename
+
+#include <new>
+
+#else
+
+#define OTL_SCAST(_t,_e) ((_t)(_e))
+#define OTL_RCAST(_t,_e) ((_t)(_e))
+#define OTL_DCAST(_t,_e) ((_t)(_e))
+#define OTL_CCAST(_t,_e) ((_t)(_e))
+#define OTL_CONST_EXCEPTION
+#define OTL_THROWS_OTL_EXCEPTION
+#define OTL_NO_THROW
+#define OTL_TYPE_NAME class
+
+#endif
+
+#define OTL_PCONV(_to,_from,_val) \
+OTL_SCAST(_to,*OTL_RCAST(_from*,OTL_CCAST(void*,_val)))
+
+#if defined(OTL_ACE)
+
+#include <ace/SString.h>
+#include <ace/Array.h>
+#include <ace/Null_Mutex.h>
+#include <ace/Functor.h>
+#include <ace/RB_Tree.h>
+
+#define OTL_USER_DEFINED_STRING_CLASS_ON
+#define USER_DEFINED_STRING_CLASS ACE_TString
+#define OTL_VALUE_TEMPLATE_ON
+
+const int otl_tmpl_vector_default_size=16;
+
+template<OTL_TYPE_NAME T>
+class otl_tmpl_vector: public ACE_Array<T>{
+public:
+
+ otl_tmpl_vector(const int init_size=otl_tmpl_vector_default_size)
+ : ACE_Array<T>(init_size==0?otl_tmpl_vector_default_size:init_size)
+ {
+ length_=0;
+ }
+
+ ~otl_tmpl_vector(){}
+
+ int capacity(void) const
+ {
+ return this->max_size();
+ }
+
+ int size(void) const
+ {
+ return length_;
+ }
+
+ void clear(void)
+ {
+ length_=0;
+ }
+
+ void resize(const int new_size, const T& t=T())
+ {
+ ACE_Array<T>::size(new_size);
+ if(new_size>length_){
+ for(int i=length_;i<new_size;++i)
+ (*this)[i]=t;
+ }
+ length_=new_size;
+ }
+
+ void push_back(const T& elem)
+ {
+ int curr_max_size=OTL_SCAST(int,this->max_size());
+ if(length_==curr_max_size)
+ ACE_Array<T>::size(curr_max_size*2);
+ ++length_;
+ (*this)[length_-1]=elem;
+ }
+
+ void pop_back(void)
+ {
+ if(length_>0)
+ --length_;
+ }
+
+private:
+
+ int length_;
+
+};
+
+#endif
+
+#if defined(OTL_UNCAUGHT_EXCEPTION_ON)
+#include <exception>
+#if !defined(OTL_STLPORT)
+inline bool otl_uncaught_exception()
+{
+ return std::uncaught_exception();
+}
+#else
+inline bool otl_uncaught_exception()
+{
+ return __std_alias::uncaught_exception();
+}
+#endif
+#else
+inline bool otl_uncaught_exception()
+{
+ return false;
+}
+#endif
+
+#if defined(OTL_STLPORT)
+#if defined(__STLPORT_STD)
+#define OTL_STLPORT_NAMESPACE __STLPORT_STD
+#else
+#if defined(_STLP_USE_OWN_NAMESPACE)
+#define OTL_STLPORT_NAMESPACE _STL
+#else
+#define OTL_STLPORT_NAMESPACE std
+#endif
+#endif
+
+#define OTL_STL
+
+#endif
+
+
+#if defined(OTL_VALUE_TEMPLATE_ON) && !defined(OTL_STL) && !defined(OTL_ACE)
+#define STD_NAMESPACE_PREFIX
+#if (defined(_MSC_VER)&&(_MSC_VER>=1300))||defined(OTL_ANSI_CPP)
+#include <iostream>
+using namespace std;
+#else
+#include <iostream.h>
+#endif
+#endif
+
+#if defined(OTL_USER_DEFINED_STRING_CLASS_ON)
+
+#if defined(OTL_STL)
+#error OTL_STL cannot be used in combination with OTL_USER_DEFINED_STRING_CLASS_ON
+#endif
+
+#if defined(USER_DEFINED_STRING_CLASS)
+#define OTL_STRING_CONTAINER USER_DEFINED_STRING_CLASS
+#define STD_NAMESPACE_PREFIX
+#else
+#error USER_DEFINED_STRING_CLASS macro needs to be defined before including otlv4.h
+#endif
+
+#endif
+
+
+#if defined(OTL_STL)
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1200)
+#pragma warning (disable:4786)
+#pragma warning (disable:4290)
+#pragma warning (disable:4996)
+#endif
+#endif
+
+#if defined(OTL_STL_NOSTD_NAMESPACE)
+#ifndef OTL_STRING_CONTAINER
+#define OTL_STRING_CONTAINER string
+#endif
+#define STD_NAMESPACE_PREFIX
+#else
+#ifndef OTL_STRING_CONTAINER
+
+#if defined(OTL_STLPORT)
+#define OTL_STRING_CONTAINER OTL_STLPORT_NAMESPACE ::string
+#else
+#define OTL_STRING_CONTAINER std::string
+#endif
+
+#endif
+
+#if defined(OTL_STLPORT)
+#define STD_NAMESPACE_PREFIX OTL_STLPORT_NAMESPACE ::
+#else
+#define STD_NAMESPACE_PREFIX std::
+#endif
+
+
+#endif
+
+#include <string>
+#include <iterator>
+#include <vector>
+
+#ifndef OTL_STL_NOSTD_NAMESPACE
+#include <iostream>
+#else
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+#include <iostream>
+using namespace std;
+#else
+#include <iostream.h>
+#endif
+#endif
+
+#endif
+
+//======================= END OF CONFIGURATION ==============================
+
+
+// ====== COMMON NON-TEMPLATE OBJECTS: CONSTANTS, CLASSES, ETC. ===========
+
+#if defined(OTL_ORA8)
+const int otl_var_list_size=1024;
+#else
+const int otl_var_list_size=512;
+#endif
+
+const int otl_error_code_0=32000;
+#define otl_error_msg_0 "Incompatible data types in stream operation"
+
+const int otl_error_code_1=32004;
+#define otl_error_msg_1 "No input variables have been defined in SQL statement"
+
+const int otl_error_code_2=32003;
+#define otl_error_msg_2 "Not all input variables have been initialized"
+
+const int otl_error_code_3=32001;
+#define otl_error_msg_3 "Row must be full for flushing output stream"
+
+const int otl_error_code_4=32005;
+#define otl_error_msg_4 "Input string value is too large to fit into the buffer"
+
+const int otl_error_code_5=32006;
+#define otl_error_msg_5 "Input otl_long_string is too large to fit into the buffer"
+
+const int otl_error_code_6=32007;
+#define otl_error_msg_6 "PL/SQL table size is too large (>32767)"
+
+const int otl_error_code_7=32008;
+#define otl_error_msg_7 "Writing CLOB/BLOB in stream mode: actual size is greater than specified"
+
+const int otl_error_code_8=32009;
+#define otl_error_msg_8 "Closing CLOB/BLOB in stream mode: actual size is not equal to specified size"
+
+const int otl_error_code_9=32010;
+#define otl_error_msg_9 "CLOB/BLOB stream is not open for writing"
+
+const int otl_error_code_10=32011;
+#define otl_error_msg_10 "CLOB/BLOB stream is not open for reading"
+
+const int otl_error_code_11=32012;
+#define otl_error_msg_11 "First session must be started with session_begin()"
+
+const int otl_error_code_12=32013;
+#define otl_error_msg_12 "Invalid bind variable declaration"
+
+const int otl_error_code_13=32014;
+#define otl_error_msg_13 "No stored procedure was found"
+
+const int otl_error_code_14=32015;
+#define otl_error_msg_14 "Unsupported data type: "
+
+const int otl_error_code_15=32016;
+#define otl_error_msg_15 "Unsupported procedure type"
+
+const int otl_error_code_16=32017;
+#define otl_error_msg_16 "Stream buffer size can't be > 1 in this case"
+
+const int otl_error_code_17=32018;
+#define otl_error_msg_17 \
+"ODBC / DB2 CLI function name is not recognized. " \
+"It should be one of the following: SQLTables, SQLColumns, " \
+"SQLProcedures, SQLColumnPrivileges, SQLTablePrivileges, " \
+"SQLPrimaryKeys, SQLProcedureColumns, SQLForeignKeys"
+
+const int otl_error_code_18=32019;
+#define otl_error_msg_18 \
+"otl_stream::operator>>() should have been called " \
+"before otl_stream::operator int()"
+
+const int otl_error_code_19=32020;
+#define otl_error_msg_19 \
+"otl_stream_read_iterator: otl_stream is not open"
+
+const int otl_error_code_20=32021;
+#define otl_error_msg_20 \
+"otl_stream_read_iterator: PL/SQL table and 'refcur' " \
+"parameters are not supported"
+
+const int otl_error_code_21=32022;
+#define otl_error_msg_21 \
+"otl_stream_read_iterator: otl_stream cannot be described"
+
+const int otl_error_code_22=32023;
+#define otl_error_msg_22 \
+"otl_stream_read_iterator: position is out of range"
+
+const int otl_error_code_23=32024;
+#define otl_error_msg_23 \
+"otl_stream_read_iterator: incompatible types in get()"
+
+const int otl_error_code_24=32025;
+#define otl_error_msg_24 \
+"otl_stream::operator int() is not supported in the LOB stream mode"
+
+const int otl_error_code_25=32026;
+#define otl_error_msg_25 \
+"otl_stream_read_iterator: get(otl_lob_stream*&) function " \
+"can only be used if otl_stream::set_lob_stream_mode(true) had been called " \
+"before the iterator was attached to the stream"
+
+const int otl_error_code_26=32027;
+#define otl_error_msg_26 \
+"otl_stream_read_iterator: variable name is not recognized "
+
+const int otl_error_code_27=32028;
+#define otl_error_msg_27 "Unsupported column data type"
+
+const int otl_error_code_28=32029;
+#define otl_error_msg_28 \
+"RAW value cannot be read with otl_lob_stream, use otl_long_string instead"
+
+const int otl_error_code_29=32030;
+#define otl_error_msg_29 \
+"otl_stream is already open"
+
+const int otl_error_code_30=32031;
+#define otl_error_msg_30 \
+"otl_connect is already connected"
+
+const int otl_error_code_31=32032;
+#define otl_error_msg_31 \
+"SELECT otl_stream buffer size for TimesTen should be in [0..128] range"
+
+const int otl_error_code_32=32033;
+#define otl_error_msg_32 \
+"otl_connect object needs to be connected to DB before using otl_subscriber"
+
+const int otl_error_code_33=32034;
+#define otl_error_msg_33 \
+"otl_stream buffer size should be 1 when refcur or plsql table is used"
+
+const int otl_error_code_34=32035;
+#define otl_error_msg_34 "END-OF-ROW check failed"
+
+const int otl_oracle_date_size=7;
+
+const int otl_explicit_select=0;
+const int otl_implicit_select=1;
+
+const int otl_input_param=0;
+const int otl_output_param=1;
+const int otl_inout_param=2;
+
+const unsigned int otl_all_num2str=1;
+const unsigned int otl_all_date2str=2;
+
+const int otl_num_str_size=60;
+const int otl_date_str_size=60;
+
+class otl_select_struct_override{
+public:
+
+ otl_select_struct_override():
+ col_ndx(new short int[otl_var_list_size]),
+ col_type(new short int[otl_var_list_size]),
+ col_size(new int[otl_var_list_size]),
+ len(0),
+ all_mask(0),
+ lob_stream_mode(false),
+ container_size_(otl_var_list_size),
+ master_stream_ptr_(0)
+ {
+ }
+
+ ~otl_select_struct_override()
+ {
+ delete[] col_ndx;
+ delete[] col_type;
+ delete[] col_size;
+ }
+
+ void set_master_stream_ptr(void* stream_ptr)
+ {
+ master_stream_ptr_=stream_ptr;
+ }
+
+ void* get_master_stream_ptr(){return master_stream_ptr_;}
+
+ void reset(void)
+ {
+ len=0;
+ all_mask=0;
+ lob_stream_mode=false;
+ }
+
+ void add_override(const int andx, const int atype, const int asize=0)
+ {
+ if(len==otl_var_list_size){
+ int temp_container_size=container_size_;
+ container_size_*=2;
+ short int* temp_col_ndx=new short int[container_size_];
+ short int* temp_col_type=new short int[container_size_];
+ int* temp_col_size=new int[container_size_];
+ memcpy(temp_col_ndx,col_ndx,sizeof(short int)*temp_container_size);
+ memcpy(temp_col_type,col_type,sizeof(short int)*temp_container_size);
+ memcpy(temp_col_size,col_size,sizeof(int)*temp_container_size);
+ delete[] col_ndx;
+ delete[] col_type;
+ delete[] col_size;
+ col_ndx=temp_col_ndx;
+ col_type=temp_col_type;
+ col_size=temp_col_size;
+ }
+ ++len;
+ col_ndx[len-1]=OTL_SCAST(short,andx);
+ col_type[len-1]=OTL_SCAST(short,atype);
+ col_size[len-1]=asize;
+ }
+
+ int find(const int ndx) const
+ {
+ int i;
+ for(i=0;i<len;++i)
+ if(ndx==col_ndx[i])
+ return i;
+ return -1;
+ }
+
+ void set_all_column_types(const unsigned int amask=0)
+ {
+ all_mask=amask;
+ }
+
+ int getLen(void) const
+ {
+ return len;
+ }
+
+ unsigned int get_all_mask() const
+ {
+ return all_mask;
+ }
+
+ short int get_col_type(int ndx) const
+ {
+ return col_type[ndx];
+ }
+
+ int get_col_size(int ndx) const
+ {
+ return col_size[ndx];
+ }
+
+ void setLen(const int alen)
+ {
+ len=alen;
+ }
+
+ bool get_lob_stream_mode() const
+ {
+ return lob_stream_mode;
+ }
+
+ void set_lob_stream_mode(const bool alobs_tream_mode)
+ {
+ lob_stream_mode=alobs_tream_mode;
+ }
+
+private:
+
+ short int* col_ndx;
+ short int* col_type;
+ int* col_size;
+ int len;
+
+ unsigned int all_mask;
+ bool lob_stream_mode;
+
+ int container_size_;
+ void* master_stream_ptr_;
+
+// this class is not meant to be copied: copy constructor and
+// operator= are declared private
+
+ otl_select_struct_override(const otl_select_struct_override&):
+ col_ndx(0),
+ col_type(0),
+ col_size(0),
+ len(0),
+ all_mask(0),
+ lob_stream_mode(false),
+ container_size_(0),
+ master_stream_ptr_(0)
+ {
+ }
+
+ otl_select_struct_override& operator=(const otl_select_struct_override&)
+ {
+ return *this;
+ }
+
+};
+
+inline int otl_decimal_degree(unsigned int num)
+{
+ int n=0;
+ while(num!=0){
+ ++n;
+ num/=10;
+ }
+ return n;
+}
+
+inline bool otl_isspace(char c)
+{
+ return c==' '||c=='\t'||c=='\n'||
+ c=='\r'||c=='\f'||c=='\v';
+}
+
+inline char otl_to_upper(char c)
+{
+ return OTL_SCAST(char,toupper(c));
+}
+
+inline bool otl_str_case_insensitive_equal(const char* s1, const char* s2)
+{
+ while(*s1 && *s2){
+ if(otl_to_upper(*s1)!=otl_to_upper(*s2))
+ return false;
+ ++s1;
+ ++s2;
+ }
+ if(*s1==0 && *s2==0)
+ return true;
+ else
+ return false;
+}
+
+inline unsigned int otl_to_fraction
+(unsigned int fraction,int frac_prec)
+{
+ if(fraction==0||frac_prec==0)return fraction;
+ int fraction_degree=otl_decimal_degree(fraction);
+ if(fraction_degree>frac_prec){
+ // in case if the actual fraction value is beyond the "fraction
+ // precision" range, truncate the value
+ int excess_decimal_digits=fraction_degree-frac_prec;
+ for(int iter=1;iter<=excess_decimal_digits;++iter)
+ fraction/=10;
+ }
+ int degree_diff=9-frac_prec;
+ for(int i=0;i<degree_diff;++i)
+ fraction*=10;
+ return fraction;
+}
+
+inline unsigned int otl_from_fraction
+(unsigned int fraction,int frac_prec)
+{
+ if(fraction==0||frac_prec==0)return fraction;
+ int degree_diff=9-frac_prec;
+ for(int i=0;i<degree_diff;++i)
+ fraction/=10;
+ return fraction;
+}
+
+#define OTL_NO_STM_TEXT "#No Stm Text available#"
+
+class otl_datetime{
+public:
+
+ int year;
+ int month;
+ int day;
+ int hour;
+ int minute;
+ int second;
+ unsigned long fraction;
+ int frac_precision;
+
+#if defined(OTL_ORA_TIMESTAMP) || defined(OTL_ODBC_TIME_ZONE)
+ short int tz_hour;
+ short int tz_minute;
+#endif
+
+ otl_datetime():
+ year(1900),
+ month(1),
+ day(1),
+ hour(0),
+ minute(0),
+ second(0),
+ fraction(0),
+ frac_precision(0)
+#if defined(OTL_ORA_TIMESTAMP) || defined(OTL_ODBC_TIME_ZONE)
+ ,tz_hour(0),
+ tz_minute(0)
+#endif
+ {
+ }
+
+ otl_datetime
+ (const int ayear,
+ const int amonth,
+ const int aday,
+ const int ahour,
+ const int aminute,
+ const int asecond,
+ const unsigned long afraction=0,
+ const int afrac_precision=0
+#if defined(OTL_ORA_TIMESTAMP)||defined(OTL_ODBC_TIME_ZONE)
+ ,
+ const short int atz_hour=0,
+ const short int atz_minute=0
+#endif
+ ):
+ year(ayear),
+ month(amonth),
+ day(aday),
+ hour(ahour),
+ minute(aminute),
+ second(asecond),
+ fraction(afraction),
+ frac_precision(afrac_precision)
+#if defined(OTL_ORA_TIMESTAMP)||defined(OTL_ODBC_TIME_ZONE)
+ ,tz_hour(atz_hour),
+ tz_minute(atz_minute)
+#endif
+ {
+ }
+
+ otl_datetime(const otl_datetime& dt):
+ year(dt.year),
+ month(dt.month),
+ day(dt.day),
+ hour(dt.hour),
+ minute(dt.minute),
+ second(dt.second),
+ fraction(dt.fraction),
+ frac_precision(dt.frac_precision)
+#if defined(OTL_ORA_TIMESTAMP)||defined(OTL_ODBC_TIME_ZONE)
+ ,tz_hour(dt.tz_hour),
+ tz_minute(dt.tz_minute)
+#endif
+ {
+ }
+
+ ~otl_datetime(){}
+
+ otl_datetime& operator=(const otl_datetime& dt)
+ {
+ copy(dt);
+ return *this;
+ }
+
+private:
+
+ void copy(const otl_datetime& dt)
+ {
+ year=dt.year;
+ month=dt.month;
+ day=dt.day;
+ hour=dt.hour;
+ minute=dt.minute;
+ second=dt.second;
+ fraction=dt.fraction;
+ frac_precision=dt.frac_precision;
+#if defined(OTL_ORA_TIMESTAMP)||defined(OTL_ODBC_TIME_ZONE)
+ tz_hour=dt.tz_hour;
+ tz_minute=dt.tz_minute;
+#endif
+ }
+
+};
+
+struct otl_oracle_date{
+
+ unsigned char century;
+ unsigned char year;
+ unsigned char month;
+ unsigned char day;
+ unsigned char hour;
+ unsigned char minute;
+ unsigned char second;
+
+ otl_oracle_date():
+ century(0),
+ year(0),
+ month(0),
+ day(0),
+ hour(0),
+ minute(0),
+ second(0)
+ {
+ }
+
+ ~otl_oracle_date(){}
+
+};
+
+inline void convert_date(otl_datetime& t,const otl_oracle_date& s)
+{
+ t.year=(OTL_SCAST(int, s.century-100)*100+(OTL_SCAST(int, s.year-100)));
+ t.month=s.month;
+ t.day=s.day;
+ t.hour=s.hour-1;
+ t.minute=s.minute-1;
+ t.second=s.second-1;
+}
+
+inline void convert_date(otl_oracle_date& t,const otl_datetime& s)
+{
+ t.year=OTL_SCAST(unsigned char, ((s.year%100)+100));
+ t.century=OTL_SCAST(unsigned char, ((s.year/100)+100));
+ t.month=OTL_SCAST(unsigned char, s.month);
+ t.day=OTL_SCAST(unsigned char, s.day);
+ t.hour=OTL_SCAST(unsigned char, (s.hour+1));
+ t.minute=OTL_SCAST(unsigned char, (s.minute+1));
+ t.second=OTL_SCAST(unsigned char, (s.second+1));
+}
+
+class otl_null{
+public:
+
+ otl_null(){}
+ ~otl_null(){}
+
+private:
+
+#if (defined(_MSC_VER)&&(_MSC_VER==1200))
+ int dummy; // this is to fix a compiler bug in VC++ 6.0
+#endif
+
+};
+
+class otl_column_desc{
+public:
+
+ char* name;
+ int dbtype;
+ int otl_var_dbtype;
+#if defined(_WIN64)
+ __int64 dbsize;
+#else
+ int dbsize;
+#endif
+ int scale;
+#if defined(_WIN64)
+ __int64 prec;
+#else
+ int prec;
+#endif
+ int nullok;
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ int charset_form;
+ int char_size;
+#endif
+
+ otl_column_desc():
+ name(0),
+ dbtype(0),
+ otl_var_dbtype(0),
+ dbsize(0),
+ scale(0),
+ prec(0),
+ nullok(0),
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ charset_form(0),
+ char_size(0),
+#endif
+ name_len_(0)
+ {
+ }
+
+ ~otl_column_desc()
+ {
+ delete[] name;
+ }
+
+ otl_column_desc& operator=(const otl_column_desc& desc)
+ {
+ if(name_len_>=desc.name_len_)
+ OTL_STRCPY_S(name,name_len_,desc.name);
+ else if(name==0 && desc.name!=0){
+ name=new char[desc.name_len_];
+ name_len_=desc.name_len_;
+ OTL_STRCPY_S(name,name_len_,desc.name);
+ }else if(name_len_<desc.name_len_ && desc.name!=0){
+ delete[] name;
+ name=new char[desc.name_len_];
+ name_len_=desc.name_len_;
+ OTL_STRCPY_S(name,name_len_,desc.name);
+ }
+ dbtype=desc.dbtype;
+ otl_var_dbtype=desc.otl_var_dbtype;
+ dbsize=desc.dbsize;
+ scale=desc.scale;
+ prec=desc.prec;
+ nullok=desc.nullok;
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ charset_form=desc.charset_form;
+ char_size=desc.char_size;
+#endif
+
+ return *this;
+ }
+
+ void set_name(const char* aname,const int aname_len=0)
+ {
+ int len;
+ if(aname_len==0)
+ len=OTL_SCAST(int,strlen(aname))+1;
+ else
+ len=aname_len+1;
+ if(name_len_<len){
+ if(name)delete[] name;
+ name=new char[len];
+ name_len_=len;
+ for(int i=0;i<len-1;++i)
+ name[i]=aname[i];
+ name[len-1]=0;
+ }
+ }
+
+private:
+
+ int name_len_;
+
+ otl_column_desc(const otl_column_desc&):
+ name(0),
+ dbtype(0),
+ otl_var_dbtype(0),
+ dbsize(0),
+ scale(0),
+ prec(0),
+ nullok(0),
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ charset_form(0),
+ char_size(0),
+#endif
+ name_len_(0)
+ {
+ }
+
+};
+
+class otl_var_desc{
+public:
+
+ int param_type;
+ int ftype;
+ int elem_size;
+ int array_size;
+ int pos;
+ int name_pos;
+ char name[128];
+ int pl_tab_flag;
+
+ otl_var_desc():
+ param_type(0),
+ ftype(0),
+ elem_size(0),
+ array_size(0),
+ pos(0),
+ name_pos(0),
+ name(),
+ pl_tab_flag(0)
+ {
+ name[0]=0;
+ }
+
+ ~otl_var_desc(){}
+
+ void copy_name(const char* nm)
+ {
+ if(!nm)
+ name[0]=0;
+ else{
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ OTL_STRNCPY_S(name,sizeof(name),nm,sizeof(name)-1);
+ name[sizeof(name)-1]=0;
+#else
+ strncpy(name,nm,sizeof(name));
+ name[sizeof(name)-1]=0;
+#endif
+#else
+ strncpy(name,nm,sizeof(name));
+ name[sizeof(name)-1]=0;
+#endif
+ }
+ }
+
+};
+
+const int otl_var_none=0;
+const int otl_var_char=1;
+const int otl_var_double=2;
+const int otl_var_float=3;
+const int otl_var_int=4;
+const int otl_var_unsigned_int=5;
+const int otl_var_short=6;
+const int otl_var_long_int=7;
+const int otl_var_timestamp=8;
+const int otl_var_varchar_long=9;
+const int otl_var_raw_long=10;
+const int otl_var_clob=11;
+const int otl_var_blob=12;
+const int otl_var_refcur=13;
+const int otl_var_long_string=15;
+const int otl_var_db2time=16;
+const int otl_var_db2date=17;
+const int otl_var_tz_timestamp=18;
+const int otl_var_ltz_timestamp=19;
+const int otl_var_bigint=20;
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+const int otl_var_nchar=21;
+const int otl_var_nclob=22;
+#else
+#endif
+const int otl_var_raw=23;
+const int otl_var_lob_stream=100;
+
+const int otl_bigint_str_size=40;
+
+const int otl_sql_exec_from_cursor_class=0;
+const int otl_sql_exec_from_select_cursor_class=1;
+
+class otl_long_string{
+public:
+
+ unsigned char* v;
+
+ otl_long_string(const int buffer_size=32760,const int input_length=0):
+ v(0),
+ length(0),
+ extern_buffer_flag(0),
+ buf_size(0),
+ this_is_last_piece_(false)
+ {
+ this_is_last_piece_=false;
+ if(buffer_size==0){
+ v=0;
+ length=0;
+ extern_buffer_flag=0;
+ }else{
+ extern_buffer_flag=0;
+ length=input_length;
+ buf_size=buffer_size;
+ v=new unsigned char[buffer_size+1];
+ memset(v,0,buffer_size);
+ }
+ }
+
+ otl_long_string
+ (const void* external_buffer,
+ const int buffer_size,
+ const int input_length=0):
+ v(OTL_RCAST(unsigned char*, OTL_CCAST(void*, external_buffer))),
+ length(input_length),
+ extern_buffer_flag(1),
+ buf_size(buffer_size),
+ this_is_last_piece_(false)
+ {
+ }
+
+ otl_long_string& operator=(const otl_long_string& s)
+ {
+ this_is_last_piece_=s.this_is_last_piece_;
+ if(s.extern_buffer_flag){
+ if(!extern_buffer_flag)
+ delete[] v;
+ v=s.v;
+ length=s.length;
+ extern_buffer_flag=s.extern_buffer_flag;
+ buf_size=s.buf_size;
+ }else{
+ if(extern_buffer_flag){
+ v=new unsigned char[s.buf_size+1];
+ buf_size=s.buf_size;
+ }else if(buf_size<s.buf_size){
+ delete[] v;
+ v=new unsigned char[s.buf_size+1];
+ buf_size=s.buf_size;
+ }
+ length=s.length;
+ extern_buffer_flag=s.extern_buffer_flag;
+ memcpy(v,s.v,length);
+ if(length<buf_size&&s.v[length]==0)
+ v[length]=0;
+ }
+ return *this;
+ }
+
+ otl_long_string(const otl_long_string& s):
+ v(0),
+ length(s.length),
+ extern_buffer_flag(s.extern_buffer_flag),
+ buf_size(s.buf_size),
+ this_is_last_piece_(s.this_is_last_piece_)
+ {
+ if(s.extern_buffer_flag)
+ v=s.v;
+ else{
+ v=new unsigned char[buf_size+1];
+ memcpy(v,s.v,length);
+ if(length<buf_size&&s.v[length]==0)
+ v[length]=0;
+ }
+ }
+
+ virtual ~otl_long_string()
+ {
+ if(!extern_buffer_flag)delete[] v;
+ }
+
+ void set_len(const int alen=0){length=alen;}
+ int len(void)const {return length;}
+
+ void set_last_piece(const bool this_is_last_piece=false)
+ {
+ this_is_last_piece_=this_is_last_piece;
+ }
+
+ bool is_last_piece() const
+ {
+ return this_is_last_piece_;
+ }
+
+ unsigned char& operator[](int ndx)
+ {
+ return v[ndx];
+ }
+
+ virtual void null_terminate_string(const int alen)
+ {
+ (*this)[alen]=0;
+ }
+
+ int get_buf_size() const
+ {
+ return buf_size;
+ }
+
+ int get_extern_buffer_flag() const
+ {
+ return extern_buffer_flag;
+ }
+
+protected:
+
+ int length;
+ int extern_buffer_flag;
+ int buf_size;
+ bool this_is_last_piece_;
+
+};
+
+#if defined(OTL_UNICODE)
+class otl_long_unicode_string: public otl_long_string{
+public:
+
+ otl_long_unicode_string(const int buffer_size=32760,const int input_length=0)
+ : otl_long_string(0,0)
+ {
+ extern_buffer_flag=0;
+ length=input_length;
+ buf_size=buffer_size;
+ v=new unsigned char[(buffer_size+1)*sizeof(OTL_WCHAR)];
+ memset(v,0,buffer_size*sizeof(OTL_WCHAR));
+ }
+
+ otl_long_unicode_string
+ (const void* external_buffer,
+ const int buffer_size,
+ const int input_length=0)
+ : otl_long_string(external_buffer,buffer_size,input_length)
+ {
+ extern_buffer_flag=1;
+ length=input_length;
+ buf_size=buffer_size;
+ v=OTL_RCAST(unsigned char*, OTL_CCAST(void*, external_buffer));
+ }
+
+ otl_long_unicode_string(const otl_long_unicode_string& s) : otl_long_string(0,0)
+ {
+ this->buf_size=s.buf_size;
+ this->this_is_last_piece_=s.this_is_last_piece_;
+ this->extern_buffer_flag=s.extern_buffer_flag;
+ this->v=0;
+ this->length=s.length;
+ if(s.extern_buffer_flag)
+ v=s.v;
+ else{
+ v=new unsigned char[(buf_size+1)*sizeof(OTL_WCHAR)];
+ memcpy(v,s.v,length*sizeof(OTL_WCHAR));
+ if(length<buf_size&&s.v[length]==0)
+ (*this)[length]=0;
+ }
+ }
+
+ otl_long_unicode_string& operator=(const otl_long_unicode_string& s)
+ {
+ this_is_last_piece_=s.this_is_last_piece_;
+ if(s.extern_buffer_flag){
+ if(!extern_buffer_flag)
+ delete[] v;
+ v=s.v;
+ length=s.length;
+ extern_buffer_flag=s.extern_buffer_flag;
+ buf_size=s.buf_size;
+ }else{
+ if(extern_buffer_flag){
+ v=new unsigned char[(s.buf_size+1)*sizeof(OTL_WCHAR)];
+ buf_size=s.buf_size;
+ }else if(buf_size<s.buf_size){
+ delete[] v;
+ v=new unsigned char[(s.buf_size+1)*sizeof(OTL_WCHAR)];
+ buf_size=s.buf_size;
+ }
+ length=s.length;
+ extern_buffer_flag=s.extern_buffer_flag;
+ memcpy(v,s.v,length*sizeof(OTL_WCHAR));
+ if(length<buf_size&&s.v[length]==0)
+ (*this)[length]=0;
+ }
+ return *this;
+ }
+
+ virtual ~otl_long_unicode_string(){}
+
+ OTL_CHAR& operator[](int ndx)
+ {
+ return OTL_RCAST(OTL_CHAR*,v)[ndx];
+ }
+
+ virtual void null_terminate_string(const int alen)
+ {
+ (*this)[alen]=0;
+ }
+
+};
+
+#endif
+
+inline const char* otl_var_type_name(const int ftype)
+{
+ const char* const_CHAR="CHAR";
+ const char* const_DOUBLE="DOUBLE";
+ const char* const_FLOAT="FLOAT";
+ const char* const_INT="INT";
+ const char* const_UNSIGNED_INT="UNSIGNED INT";
+ const char* const_SHORT_INT="SHORT INT";
+ const char* const_LONG_INT="LONG INT";
+ const char* const_TIMESTAMP="TIMESTAMP";
+ const char* const_DB2DATE="DB2DATE";
+ const char* const_DB2TIME="DB2TIME";
+ const char* const_TZ_TIMESTAMP="TIMESTAMP WITH TIME ZONE";
+ const char* const_LTZ_TIMESTAMP="TIMESTAMP WITH LOCAL TIME ZONE";
+ const char* const_BIGINT="BIGINT";
+ const char* const_VARCHAR_LONG="VARCHAR LONG";
+ const char* const_RAW_LONG="RAW LONG";
+ const char* const_CLOB="CLOB";
+ const char* const_BLOB="BLOB";
+ const char* const_RAW="RAW";
+ const char* const_UNKNOWN="UNKNOWN";
+ const char* const_LONG_STRING="otl_long_string()";
+ const char* const_LOB_STREAM="otl_lob_stream*&";
+ const char* const_USER_DEFINED="User-defined type (object type, VARRAY, Nested Table)";
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ const char* const_NCHAR="NCHAR";
+ const char* const_NCLOB="NCLOB";
+#endif
+
+ switch(ftype){
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ case otl_var_nchar:
+ return const_NCHAR;
+ case otl_var_nclob:
+ return const_NCLOB;
+#endif
+ case otl_var_char:
+ return const_CHAR;
+ case otl_var_double:
+ return const_DOUBLE;
+ case otl_var_float:
+ return const_FLOAT;
+ case otl_var_int:
+ return const_INT;
+ case otl_var_unsigned_int:
+ return const_UNSIGNED_INT;
+ case otl_var_short:
+ return const_SHORT_INT;
+ case otl_var_long_int:
+ return const_LONG_INT;
+ case otl_var_timestamp:
+ return const_TIMESTAMP;
+ case otl_var_db2date:
+ return const_DB2DATE;
+ case otl_var_db2time:
+ return const_DB2TIME;
+ case otl_var_tz_timestamp:
+ return const_TZ_TIMESTAMP;
+ case otl_var_ltz_timestamp:
+ return const_LTZ_TIMESTAMP;
+ case otl_var_bigint:
+ return const_BIGINT;
+ case otl_var_varchar_long:
+ return const_VARCHAR_LONG;
+ case otl_var_raw_long:
+ return const_RAW_LONG;
+ case otl_var_clob:
+ return const_CLOB;
+ case otl_var_blob:
+ return const_BLOB;
+ case otl_var_raw:
+ return const_RAW;
+ case otl_var_long_string:
+ return const_LONG_STRING;
+ case otl_var_lob_stream:
+ return const_LOB_STREAM;
+ case 108:
+ return const_USER_DEFINED;
+ default:
+ return const_UNKNOWN;
+ }
+}
+
+inline void otl_var_info_var
+(const char* name,
+ const int ftype,
+ const int type_code,
+ char* var_info,
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400) // VC++ 8.0 or higher
+ const size_t var_info_sz
+#else
+ const size_t /*var_info_sz*/
+#endif
+#else
+ const size_t /*var_info_sz*/
+#endif
+)
+{char buf1[128];
+ char buf2[128];
+ OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype));
+ OTL_STRCPY_S(buf2,sizeof(buf2),otl_var_type_name(type_code));
+ OTL_STRCPY_S(var_info,var_info_sz,"Variable: ");
+ OTL_STRCAT_S(var_info,var_info_sz,name);
+ OTL_STRCAT_S(var_info,var_info_sz,"<");
+ OTL_STRCAT_S(var_info,var_info_sz,buf1);
+ OTL_STRCAT_S(var_info,var_info_sz,">, datatype in operator <</>>: ");
+ OTL_STRCAT_S(var_info,var_info_sz,buf2);
+}
+
+inline void otl_var_info_var2
+(const char* name,
+ const int ftype,
+ char* var_info,
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400) // VC++ 8.0 or higher
+ const size_t var_info_sz
+#else
+ const size_t /*var_info_sz*/
+#endif
+#else
+ const size_t /*var_info_sz*/
+#endif
+)
+{char buf1[128];
+ OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype));
+ OTL_STRCPY_S(var_info,var_info_sz,"Variable: ");
+ OTL_STRCPY_S(var_info,var_info_sz,name);
+ OTL_STRCAT_S(var_info,var_info_sz,"<");
+ OTL_STRCAT_S(var_info,var_info_sz,buf1);
+ OTL_STRCAT_S(var_info,var_info_sz,">");
+}
+
+inline void otl_var_info_var3
+(const char* name,
+ const int ftype,
+ const int type_code,
+ char* var_info,
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400) // VC++ 8.0 or higher
+ const size_t var_info_sz
+#else
+ const size_t /*var_info_sz*/
+#endif
+#else
+ const size_t /*var_info_sz*/
+#endif
+)
+{char buf1[128];
+ char buf2[128];
+ OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype));
+ OTL_STRCPY_S(buf2,sizeof(buf2),otl_var_type_name(type_code));
+ OTL_STRCPY_S(var_info,var_info_sz,"Variable: ");
+ OTL_STRCAT_S(var_info,var_info_sz,name);
+ OTL_STRCAT_S(var_info,var_info_sz,"<");
+ OTL_STRCAT_S(var_info,var_info_sz,buf1);
+ OTL_STRCAT_S(var_info,
+ var_info_sz,
+ ">, datatype in otl_stream_read_iterator::get(): ");
+ OTL_STRCAT_S(var_info,var_info_sz,buf2);
+}
+
+inline void otl_var_info_var4
+(const char* name,
+ const int ftype,
+ const int type_code,
+ char* var_info,
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400) // VC++ 8.0 or higher
+ const size_t var_info_sz
+#else
+ const size_t /*var_info_sz*/
+#endif
+#else
+ const size_t /*var_info_sz*/
+#endif
+)
+{char buf1[128];
+ char buf2[128];
+ OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype));
+ OTL_STRCPY_S(buf2,sizeof(buf2),otl_var_type_name(type_code));
+ OTL_STRCPY_S(var_info,var_info_sz,"Variable: ");
+ OTL_STRCAT_S(var_info,var_info_sz,name);
+ OTL_STRCAT_S(var_info,var_info_sz,"<");
+ OTL_STRCAT_S(var_info,var_info_sz,buf1);
+ OTL_STRCAT_S(var_info,
+ var_info_sz,
+ ">, datatype in otl_stream_read_iterator::get(): ");
+ OTL_STRCAT_S(var_info,var_info_sz,buf2);
+}
+
+inline void otl_strcpy(
+ unsigned char* trg,
+ unsigned char* src,
+ int& overflow,
+ const int inp_size=0,
+ const int actual_inp_size=-1
+)
+{
+ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg);
+ const OTL_CHAR* c2=OTL_RCAST(const OTL_CHAR*,src);
+ int out_size=0;
+ overflow=0;
+ if(actual_inp_size!=-1){
+ while(out_size<inp_size-1 && out_size<actual_inp_size){
+ *c1++=*c2++;
+ ++out_size;
+ }
+ *c1=0;
+ if(out_size==inp_size-1 && out_size<actual_inp_size)
+ overflow=1;
+ }else{
+ while(*c2 && out_size<inp_size-1){
+ *c1++=*c2++;
+ ++out_size;
+ }
+ *c1=0;
+ if(*c2 && out_size==inp_size-1)
+ overflow=1;
+ }
+}
+
+#if defined(OTL_UNICODE) || (defined(_MSC_VER) && (_MSC_VER >= 1400))
+inline void otl_strcpy
+ (unsigned char* trg,
+ const unsigned char* src)
+{
+ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg);
+ const OTL_CHAR* c2=OTL_RCAST(const OTL_CHAR*,src);
+ while(*c2){
+ *c1++=*c2++;
+ }
+ *c1=0;
+}
+#else
+inline void otl_strcpy(unsigned char* trg,const unsigned char* src)
+{
+ strcpy(OTL_RCAST(char*,trg),OTL_RCAST(const char*,src));
+}
+#endif
+
+inline void otl_strcat(char* trg,const char* src)
+{
+ while(*trg)++trg;
+ while(*src){
+ *trg=*src;
+ ++trg;
+ ++src;
+ }
+ *trg=0;
+}
+
+#if defined(OTL_UNICODE) && !defined(OTL_ODBC)
+inline void otl_strcpy2(
+ unsigned char* trg,
+ const unsigned char* src,
+ const int max_src_len
+)
+{
+ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg);
+ const OTL_CHAR* c2=OTL_RCAST(const OTL_CHAR*,src);
+ int src_len=OTL_SCAST(int,*OTL_SCAST(const unsigned short*,c2));
+ int len=0;
+ ++c2;
+ while(*c2&&len<max_src_len&&len<src_len){
+ *c1++=*c2++;
+ ++len;
+ }
+ *c1=0;
+#else
+inline void otl_strcpy2(
+ unsigned char* trg,
+ const unsigned char* src,
+ const int /* max_src_len */
+)
+{
+ otl_strcpy(trg,src);
+#endif
+}
+
+#if defined(OTL_UNICODE)
+inline void otl_memcpy(
+ unsigned char* trg,
+ unsigned char* src,
+ const int src_len,
+ const int ftype
+)
+{
+ if(ftype==otl_var_raw_long||ftype==otl_var_raw){
+ memcpy(trg,src,src_len);
+ return;
+ }
+
+ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg);
+ OTL_CHAR* c2=OTL_RCAST(OTL_CHAR*,src);
+ int len=0;
+ while(len<src_len){
+ *c1++=*c2++;
+ ++len;
+ }
+
+#else
+inline void otl_memcpy(
+ unsigned char* trg,
+ unsigned char* src,
+ const int src_len,
+ const int /* ftype */
+)
+{
+ memcpy(trg,src,src_len);
+#endif
+}
+
+#if defined(OTL_UNICODE) && !defined(OTL_ODBC)
+inline void otl_strcpy3(
+ unsigned char* trg,
+ unsigned char* src,
+ const int max_src_len,
+ int& overflow,
+ const int inp_size=0
+)
+{
+ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg);
+ OTL_CHAR* c2=OTL_RCAST(OTL_CHAR*,src);
+ int len=0;
+ int src_len=OTL_SCAST(int,*OTL_RCAST(unsigned short*,c2));
+ ++c2;
+ int out_size=0;
+ overflow=0;
+ while(len<src_len&&len<max_src_len&&out_size<inp_size-1){
+ *c1++=*c2++;
+ ++out_size;
+ ++len;
+ }
+ *c1=0;
+ if(len<src_len&&out_size==inp_size-1)
+ overflow=1;
+#else
+inline void otl_strcpy3(
+ unsigned char* trg,
+ unsigned char* src,
+ const int /* max_src_len */,
+ int& overflow,
+ const int inp_size=0
+)
+{
+ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg);
+ OTL_CHAR* c2=OTL_RCAST(OTL_CHAR*,src);
+ int out_size=0;
+ overflow=0;
+ while(*c2&&out_size<inp_size-1){
+ *c1++=*c2++;
+ ++out_size;
+ }
+ *c1=0;
+ if(*c2&&out_size==inp_size-1)
+ overflow=1;
+#endif
+}
+
+inline void otl_strcpy4(
+ unsigned char* trg,
+ unsigned char* src,
+ int& overflow,
+ const int inp_size=0,
+ const int actual_inp_size=-1
+)
+{
+#if defined(OTL_UNICODE) && !defined(OTL_ODBC)
+ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg);
+ OTL_CHAR* bc1=c1;
+ ++c1;
+ OTL_CHAR* c2=OTL_RCAST(OTL_CHAR*,src);
+ int out_size=0;
+ overflow=0;
+ if(actual_inp_size!=-1){
+ while(out_size<inp_size-1 && out_size<actual_inp_size){
+ *c1++=*c2++;
+ ++out_size;
+ }
+ *OTL_RCAST(unsigned short*,bc1)=OTL_SCAST(unsigned short,out_size);
+ if(out_size==inp_size-1 && out_size<actual_inp_size)
+ overflow=1;
+ }else{
+ while(*c2&&out_size<inp_size-1){
+ *c1++=*c2++;
+ ++out_size;
+ }
+ *OTL_RCAST(unsigned short*,bc1)=OTL_SCAST(unsigned short,out_size);
+ if(*c2&&out_size==inp_size-1)
+ overflow=1;
+ }
+#else
+ OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg);
+ OTL_CHAR* c2=OTL_RCAST(OTL_CHAR*,src);
+ int out_size=0;
+ overflow=0;
+ if(actual_inp_size!=-1){
+ while(out_size<inp_size-1 && out_size<actual_inp_size){
+ *c1++=*c2++;
+ ++out_size;
+ }
+ *c1=0;
+ if(out_size==inp_size-1 && out_size<actual_inp_size)
+ overflow=1;
+ }else{
+ while(*c2&&out_size<inp_size-1){
+ *c1++=*c2++;
+ ++out_size;
+ }
+ *c1=0;
+ if(*c2&&out_size==inp_size-1)
+ overflow=1;
+ }
+#endif
+}
+
+inline char* otl_itoa(int i,char* a)
+{
+ const char* digits="0123456789";
+ int n=i;
+ int k;
+ char buf[64];
+ char* c=buf;
+ char *c1=a;
+ int klen=0;
+ char digit=' ';
+ bool negative=false;
+ if(n<0){
+ n=-n;
+ negative=true;
+ }
+ do{
+ if(n>=10)
+ k=n%10;
+ else
+ k=n;
+ digit=digits[k];
+ *c=digit;
+ ++c;
+ ++klen;
+ n=n/10;
+ }while(n!=0);
+ *c=0;
+ if(negative){
+ *c1='-';
+ ++c1;
+ }
+ for(int j=klen-1;j>=0;--j){
+ *c1=buf[j];
+ ++c1;
+ }
+ *c1=0;
+ return c1;
+}
+
+inline void otl_var_info_col
+(const int pos,
+ const int ftype,
+ const int type_code,
+ char* var_info,
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400) // VC++ 8.0 or higher
+ const size_t var_info_sz
+#else
+ const size_t /*var_info_sz*/
+#endif
+#else
+ const size_t /*var_info_sz*/
+#endif
+)
+{
+ char buf1[128];
+ char buf2[128];
+ char name[128];
+
+ otl_itoa(pos,name);
+ OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype));
+ OTL_STRCPY_S(buf2,sizeof(buf2),otl_var_type_name(type_code));
+ OTL_STRCPY_S(var_info,var_info_sz,"Column: ");
+ OTL_STRCAT_S(var_info,var_info_sz,name);
+ OTL_STRCAT_S(var_info,var_info_sz,"<");
+ OTL_STRCAT_S(var_info,var_info_sz,buf1);
+ OTL_STRCAT_S(var_info,
+ var_info_sz,
+ ">, datatype in operator <</>>: ");
+ OTL_STRCAT_S(var_info,var_info_sz,buf2);
+}
+
+inline void otl_var_info_col2
+(const int pos,
+ const int ftype,
+ char* var_info,
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400) // VC++ 8.0 or higher
+ const size_t var_info_sz
+#else
+ const size_t /*var_info_sz*/
+#endif
+#else
+ const size_t /*var_info_sz*/
+#endif
+)
+{
+ char buf1[128];
+ char name[128];
+
+ otl_itoa(pos,name);
+ OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype));
+ OTL_STRCPY_S(var_info,var_info_sz,"Column: ");
+ OTL_STRCAT_S(var_info,var_info_sz,name);
+ OTL_STRCAT_S(var_info,var_info_sz,"<");
+ OTL_STRCAT_S(var_info,var_info_sz,buf1);
+ OTL_STRCAT_S(var_info,var_info_sz,">");
+}
+
+inline void otl_var_info_col3
+(const int pos,
+ const int ftype,
+ const char* col_name,
+ char* var_info,
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400) // VC++ 8.0 or higher
+ const size_t var_info_sz
+#else
+ const size_t /*var_info_sz*/
+#endif
+#else
+ const size_t /*var_info_sz*/
+#endif
+)
+{
+ char buf1[128];
+ char name[128];
+
+ otl_itoa(pos,name);
+ OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype));
+ OTL_STRCPY_S(var_info,var_info_sz,"Column: ");
+ OTL_STRCAT_S(var_info,var_info_sz,name);
+ OTL_STRCAT_S(var_info,var_info_sz," / ");
+ OTL_STRCAT_S(var_info,var_info_sz,col_name);
+ OTL_STRCAT_S(var_info,var_info_sz," <");
+ OTL_STRCAT_S(var_info,var_info_sz,buf1);
+ OTL_STRCAT_S(var_info,var_info_sz,">");
+}
+
+class otl_pl_tab_generic{
+public:
+
+ otl_pl_tab_generic():
+ p_v(0),
+ p_null(0),
+ elem_size(0),
+ tab_size(0),
+ tab_len(0),
+ vtype(0)
+ {
+ }
+
+ virtual ~otl_pl_tab_generic(){}
+
+ unsigned char* val(int ndx=0)
+ {
+ return p_v+(ndx*elem_size);
+ }
+
+ int is_null(int ndx=0)
+ {
+ return p_null[ndx]!=0;
+ }
+
+ void set_null(int ndx=0)
+ {
+ p_null[ndx]=1;
+ }
+
+ void set_non_null(int ndx=0)
+ {
+ p_null[ndx]=0;
+ }
+
+ void init_generic(void)
+ {int i;
+ memset(p_v,0,elem_size*tab_len);
+ for(i=0;i<tab_len;++i)
+ p_null[i]=0;
+ }
+
+ int len()
+ {
+ return tab_len;
+ }
+
+ void set_len(int new_len=0)
+ {
+ tab_len=new_len;
+ }
+
+ int get_vtype() const
+ {
+ return vtype;
+ }
+
+ int get_elem_size() const
+ {
+ return elem_size;
+ }
+
+ int get_tab_size() const
+ {
+ return tab_size;
+ }
+
+ unsigned char* get_p_v()
+ {
+ return p_v;
+ }
+
+protected:
+
+ unsigned char* p_v;
+ short* p_null;
+ int elem_size;
+ int tab_size;
+ int tab_len;
+ int vtype;
+
+private:
+
+ otl_pl_tab_generic(const otl_pl_tab_generic&):
+ p_v(0),
+ p_null(0),
+ elem_size(0),
+ tab_size(0),
+ tab_len(0),
+ vtype(0)
+ {
+ }
+
+ otl_pl_tab_generic& operator=(const otl_pl_tab_generic&)
+ {
+ return *this;
+ }
+
+};
+
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+template<OTL_TYPE_NAME T,const int T_type>
+inline int otl_numeric_convert_T
+(const int ftype,const void* val,T& n)
+{
+ if(ftype==T_type){
+ n=*OTL_RCAST(T*,OTL_CCAST(void*,val));
+ return 1;
+ }else
+ return 0;
+}
+
+template<OTL_TYPE_NAME T>
+inline int otl_numeric_convert_T2(const int ftype,const void* val,T& n)
+{
+ int rc=1;
+ switch(ftype){
+ case otl_var_double:
+ n=OTL_PCONV(T,double,val);
+ break;
+ case otl_var_short:
+ n=OTL_PCONV(T,short,val);
+ break;
+ case otl_var_int:
+ n=OTL_PCONV(T,int,val);
+ break;
+ case otl_var_unsigned_int:
+ n=OTL_PCONV(T,unsigned int,val);
+ break;
+ case otl_var_long_int:
+ n=OTL_PCONV(T,long int,val);
+ break;
+ case otl_var_float:
+ n=OTL_PCONV(T,float,val);
+ break;
+#if defined(OTL_BIGINT)
+ case otl_var_bigint:
+ n=OTL_PCONV(T,OTL_BIGINT,val);
+ break;
+#endif
+ default:
+ rc=0;
+ break;
+ }
+ return rc;
+}
+
+#else
+template<OTL_TYPE_NAME T>
+inline int otl_numeric_convert_T(const int ftype,const void* val,T& n)
+{
+ int rc=1;
+ switch(ftype){
+ case otl_var_double:
+ n=OTL_PCONV(T,double,val);
+ break;
+ case otl_var_short:
+ n=OTL_PCONV(T,short,val);
+ break;
+ case otl_var_int:
+ n=OTL_PCONV(T,int,val);
+ break;
+ case otl_var_unsigned_int:
+ n=OTL_PCONV(T,unsigned int,val);
+ break;
+ case otl_var_long_int:
+ n=OTL_PCONV(T,long int,val);
+ break;
+ case otl_var_float:
+ n=OTL_PCONV(T,float,val);
+ break;
+#if defined(OTL_BIGINT)
+ case otl_var_bigint:
+ n=OTL_PCONV(T,OTL_BIGINT,val);
+ break;
+#endif
+ default:
+ rc=0;
+ break;
+ }
+ return rc;
+}
+#endif
+
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+
+class otl_ltstr{
+public:
+
+ bool operator()(const OTL_STRING_CONTAINER& s1, const OTL_STRING_CONTAINER& s2) const
+ {
+ return strcmp(s1.c_str(), s2.c_str()) < 0;
+ }
+
+};
+
+const int otl_max_default_pool_size=32;
+
+#endif
+
+#if defined(OTL_ACE)
+const int otl_max_default_pool_size=32;
+#endif
+
+
+class otl_stream_shell_generic{
+public:
+
+ otl_stream_shell_generic():
+ should_delete(0)
+ {
+ }
+
+ virtual ~otl_stream_shell_generic(){}
+
+ int get_should_delete() const
+ {
+ return should_delete;
+ }
+
+ void set_should_delete(const int ashould_delete)
+ {
+ should_delete=ashould_delete;
+ }
+
+protected:
+
+ int should_delete;
+
+};
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+
+#if defined(OTL_STL)
+#include <map>
+#endif
+
+class otl_stream_pool;
+
+class otl_stream_pool_entry{
+public:
+
+ friend class otl_stream_pool;
+
+#if defined(OTL_ACE)
+ otl_tmpl_vector<otl_stream_shell_generic*> s;
+#else
+ STD_NAMESPACE_PREFIX vector<otl_stream_shell_generic*> s;
+#endif
+
+ otl_stream_pool_entry():
+ s(),
+ cnt(0)
+ {
+ }
+
+ otl_stream_pool_entry(const otl_stream_pool_entry& sc):
+ s(),
+ cnt(0)
+ {
+ copy(sc);
+ }
+
+ otl_stream_pool_entry& operator=(const otl_stream_pool_entry& sc)
+ {
+ copy(sc);
+ return *this;
+ }
+
+ virtual ~otl_stream_pool_entry(){}
+
+ int get_cnt() const
+ {
+ return cnt;
+ }
+
+ void set_cnt(const int acnt)
+ {
+ cnt=acnt;
+ }
+
+private:
+
+ int cnt;
+
+ void copy(const otl_stream_pool_entry& sc)
+ {
+ s.clear();
+#if defined(OTL_ACE)
+ for(int i=0;i<sc.s.size();++i)
+#else
+ for(size_t i=0;i<sc.s.size();++i)
+#endif
+ s.push_back(sc.s[i]);
+ cnt=sc.cnt;
+ }
+
+};
+
+class otl_stream_pool{
+public:
+
+ typedef otl_stream_pool_entry cache_entry_type;
+#if defined(OTL_ACE)
+ typedef
+ ACE_RB_Tree
+ <OTL_STRING_CONTAINER,cache_entry_type,
+ ACE_Less_Than<OTL_STRING_CONTAINER>,
+ ACE_Null_Mutex> sc_type;
+ typedef otl_tmpl_vector<otl_stream_shell_generic*> vec_type;
+ typedef ACE_RB_Tree_Node<OTL_STRING_CONTAINER,cache_entry_type> ace_map_entry;
+#else
+ typedef STD_NAMESPACE_PREFIX
+ map<OTL_STRING_CONTAINER,cache_entry_type,otl_ltstr> sc_type;
+ typedef STD_NAMESPACE_PREFIX vector<otl_stream_shell_generic*> vec_type;
+#endif
+
+protected:
+
+ sc_type sc;
+ int max_size;
+ int size;
+
+public:
+
+ otl_stream_pool():
+ sc(),
+ max_size(otl_max_default_pool_size),
+ size(0)
+ {
+ }
+
+ void init(int amax_size=otl_max_default_pool_size)
+ {
+ if(size==0&&max_size==0)return;
+ if(amax_size<2)
+ amax_size=2;
+#if defined(OTL_ACE)
+ sc_type::iterator elem0=sc.begin();
+ sc_type::iterator elemN=sc.end();
+ for(sc_type::iterator i=elem0; i!=elemN; ++i){
+ cache_entry_type& ce=(*i).item();
+ int sz=ce.s.size();
+ for(int j=0;j<sz;++j){
+ ce.s[j]->set_should_delete(1);
+ delete ce.s[j];
+ ce.s[j]=0;
+ }
+ ce.s.clear();
+ ce.cnt=0;
+ }
+ sc.clear();
+#else
+ sc_type::iterator elem0=sc.begin();
+ sc_type::iterator elemN=sc.end();
+ for(sc_type::iterator i=elem0; i!=elemN; ++i){
+ cache_entry_type& ce=(*i).second;
+ size_t sz=ce.s.size();
+ for(size_t j=0;j<sz;++j){
+ ce.s[j]->set_should_delete(1);
+ delete ce.s[j];
+ ce.s[j]=0;
+ }
+ ce.s.clear();
+ ce.set_cnt(0);
+ }
+ sc.clear();
+#endif
+
+ size=0;
+ max_size=amax_size;
+
+ }
+
+ otl_stream_shell_generic* find(const OTL_STRING_CONTAINER& stmtxt)
+ {
+ otl_stream_shell_generic* s;
+
+#if defined(OTL_ACE)
+ ace_map_entry* ce=0;
+ int found=sc.find(stmtxt,ce);
+ if(found==-1)return 0; // entry not found
+ s=ce->item().s[ce->item().s.size()-1];
+ ce->item().s.pop_back();
+ if(ce->item().s.size()==0){
+ sc.unbind(ce);
+ --size;
+ }
+#else
+ sc_type::iterator cur=sc.find(stmtxt);
+ if(cur==sc.end())
+ return 0; // entry not found
+ cache_entry_type& ce=(*cur).second;
+ s=ce.s[ce.s.size()-1];
+ ce.s.pop_back();
+ if(ce.s.size()==0){
+ sc.erase(cur);
+ --size;
+ }
+#endif
+
+ return s;
+ }
+
+ void remove(const otl_stream_shell_generic* s,const OTL_STRING_CONTAINER& stmtxt)
+ {
+#if defined(OTL_ACE)
+ ace_map_entry* cur=0;
+ int found=sc.find(stmtxt,cur);
+ if(found==-1)
+ return;
+ cache_entry_type& ce=(*cur).item();
+ for(int i=0;i<ce.s.size();++i)
+ if(ce.s[i]==s){
+ if(ce.s.size()>1 && i!=ce.s.size()-1){
+ otl_stream_shell_generic* temp_s=ce.s[i];
+ ce.s[i]=ce.s[ce.s.size()-1];
+ ce.s[ce.s.size()-1]=temp_s;
+ }
+ ce.s.pop_back();
+ --size;
+ return;
+ }
+#else
+ sc_type::iterator cur=sc.find(stmtxt);
+ if(cur==sc.end())
+ return;
+ cache_entry_type& ce=(*cur).second;
+ vec_type::iterator bgn=ce.s.begin();
+ vec_type::iterator end=ce.s.end();
+ for(vec_type::iterator i=bgn;i!=end;++i)
+ if((*i)==s){
+ ce.s.erase(i);
+ --size;
+ return;
+ }
+#endif
+ }
+
+ int get_max_size() const
+ {
+ return max_size;
+ }
+
+ void add(otl_stream_shell_generic* s,const char* stm_text)
+ {
+ OTL_STRING_CONTAINER stmtxt(stm_text);
+
+#if defined(OTL_ACE)
+
+ ace_map_entry* cur=0;
+ int found_in_map=sc.find(stmtxt,cur);
+ if(found_in_map==0){ // entry found
+ bool found=false;
+ cache_entry_type& ce=(*cur).item();
+ int sz=ce.s.size();
+ for(int i=0;i<sz;++i){
+ if(s==ce.s[i]){
+ found=true;
+ break;
+ }
+ }
+ if(!found)
+ ce.s.push_back(s);
+ ++ce.cnt;
+ }else{ // entry not found
+ if(size<max_size-1){ // add new entry
+ cache_entry_type ce;
+ ce.s.push_back(s);
+ ce.cnt=1;
+ sc.bind(stmtxt,ce);
+ ++size;
+ }else{ // erase the least used entry and add new one
+
+ sc_type::iterator elem0=sc.begin();
+ sc_type::iterator elemN=sc.end();
+ int min_cnt=0;
+ ace_map_entry* min_entry=0;
+
+ for(sc_type::iterator i=elem0;i!=elemN;++i){
+ if(i==elem0){ // first element
+ min_entry=&(*i);
+ min_cnt=(*i).item().cnt;
+ }
+ if(min_cnt>(*i).item().cnt){ // found less used entry
+ min_entry=&(*i);
+ min_cnt=(*i).item().cnt;
+ }
+ }
+ cache_entry_type& me=(*min_entry).item();
+ int sz=me.s.size();
+ for(int n=0;n<sz;++n){
+ me.s[n]->set_should_delete(1);
+ otl_stream_shell_generic* tmp=me.s[n];
+ delete tmp;
+ }
+ me.s.clear();
+ sc.unbind(min_entry);
+ cache_entry_type ce;
+ ce.cnt=1;
+ ce.s.push_back(s);
+ sc.bind(stmtxt,ce);
+ }
+ }
+
+#else
+
+ sc_type::iterator cur=sc.find(stmtxt);
+
+ if(cur!=sc.end()){ // entry found
+ bool found=false;
+ cache_entry_type& ce=(*cur).second;
+ size_t sz=ce.s.size();
+ for(size_t i=0;i<sz;++i){
+ if(s==ce.s[i]){
+ found=true;
+ break;
+ }
+ }
+ if(!found)ce.s.push_back(s);
+ ce.set_cnt(ce.get_cnt()+1);
+ }else{ // entry not found
+ if(size<max_size-1){ // add new entry
+ cache_entry_type ce;
+ ce.s.push_back(s);
+ ce.set_cnt(1);
+ sc[stmtxt]=ce;
+ ++size;
+ }else{ // erase the least used entry and add new one
+
+ sc_type::iterator elem0=sc.begin();
+ sc_type::iterator elemN=sc.end();
+ int min_cnt=0;
+ sc_type::iterator min_entry;
+
+ for(sc_type::iterator i=elem0;i!=elemN;++i){
+ if(i==elem0){ // first element
+ min_entry=i;
+ min_cnt=(*i).second.get_cnt();
+ }
+ if(min_cnt>(*i).second.get_cnt()){ // found less used entry
+ min_entry=i;
+ min_cnt=(*i).second.get_cnt();
+ }
+ }
+ cache_entry_type& me=(*min_entry).second;
+ size_t sz=me.s.size();
+ for(size_t n=0;n<sz;++n){
+ me.s[n]->set_should_delete(1);
+ otl_stream_shell_generic* tmp=me.s[n];
+ delete tmp;
+ }
+ me.s.clear();
+ sc.erase(min_entry);
+ cache_entry_type ce;
+ ce.set_cnt(1);
+ ce.s.push_back(s);
+ sc[stmtxt]=ce;
+ }
+ }
+#endif
+ }
+
+ virtual ~otl_stream_pool()
+ {
+ init();
+ }
+
+private:
+
+ otl_stream_pool(const otl_stream_pool&):
+ sc(),
+ max_size(0),
+ size(0)
+ {
+ }
+
+ otl_stream_pool& operator=(const otl_stream_pool&)
+ {
+ return *this;
+ }
+
+};
+
+#endif
+
+
+// =========================== COMMON TEMPLATES ============================
+
+
+#if (defined(OTL_STL)||defined(OTL_VALUE_TEMPLATE_ON)) && defined(OTL_VALUE_TEMPLATE)
+
+template <OTL_TYPE_NAME TData>
+class otl_value{
+public:
+
+ TData v;
+ bool ind;
+
+ otl_value():
+ v(),
+ ind(true)
+ {
+ }
+
+ virtual ~otl_value(){}
+
+ otl_value(const otl_value<TData>& var):
+ v(var.v),
+ ind(var.ind)
+ {
+ }
+
+ otl_value(const TData& var):
+ v(var),
+ ind(false)
+ {
+ }
+
+ otl_value(const otl_null&):
+ v(),
+ ind(true)
+ {
+ }
+
+ otl_value<TData>& operator=(const otl_value<TData>& var)
+ {
+ v=var.v;
+ ind=var.ind;
+ return *this;
+ }
+
+ otl_value<TData>& operator=(const TData& var)
+ {
+ v=var;
+ ind=false;
+ return *this;
+ }
+
+ otl_value<TData>& operator=(const otl_null&)
+ {
+ ind=true;
+ return *this;
+ }
+
+ bool is_null(void)const {return ind;}
+ void set_null(void){ind=true;}
+ void set_non_null(void){ind=false;}
+
+};
+
+template <OTL_TYPE_NAME TData>
+STD_NAMESPACE_PREFIX ostream& operator<<
+ (STD_NAMESPACE_PREFIX ostream& s,
+ const otl_value<TData>& var)
+{
+ if(var.ind)
+ s<<"NULL";
+ else
+ s<<var.v;
+ return s;
+}
+
+#if defined(OTL_DISABLE_OPERATOR_GT_GT_FOR_OTL_VALUE_OTL_DATETIME)
+#else
+inline STD_NAMESPACE_PREFIX ostream& operator<<(
+ STD_NAMESPACE_PREFIX ostream& s,
+ const otl_value<otl_datetime>& var)
+{
+ if(var.ind)
+ s<<"NULL";
+ else{
+#if !defined(OTL_TRACE_LEVEL)
+ s<<var.v.month<<"/"<<var.v.day<<"/"<<var.v.year
+ <<" "<<var.v.hour<<":"<<var.v.minute
+ <<":"<<var.v.second<<"."<<var.v.fraction;
+#else
+ s<<OTL_TRACE_FORMAT_DATETIME(var.v);
+#endif
+ }
+ return s;
+}
+#endif
+
+#endif
+
+template <OTL_TYPE_NAME T>
+class otl_auto_array_ptr{
+public:
+
+ otl_auto_array_ptr():
+ ptr(0),
+ arr_size_(0)
+ {
+ }
+
+ otl_auto_array_ptr(const int arr_size):
+ ptr(new T[arr_size]),
+ arr_size_(arr_size)
+ {
+ }
+
+ void double_size(void)
+ {
+ int old_arr_size=arr_size_;
+ arr_size_*=2;
+ T* temp_ptr=new T[arr_size_];
+ for(int i=0;i<old_arr_size;++i)
+ temp_ptr[i]=ptr[i];
+ delete[] ptr;
+ ptr=temp_ptr;
+ }
+
+ virtual ~otl_auto_array_ptr()
+ {
+ delete[] ptr;
+ }
+
+ T* get_ptr()
+ {
+ return ptr;
+ }
+
+ int get_arr_size() const
+ {
+ return arr_size_;
+ }
+
+private:
+
+ T* ptr;
+ int arr_size_;
+
+ otl_auto_array_ptr(const otl_auto_array_ptr<T>&):
+ ptr(0),
+ arr_size_(0)
+ {
+ }
+
+ otl_auto_array_ptr<T>& operator=(const otl_auto_array_ptr<T>&)
+ {
+ return *this;
+ }
+
+};
+
+template <OTL_TYPE_NAME T>
+class otl_ptr{
+public:
+
+ otl_ptr():
+ ptr(0),
+ arr_flag(0)
+ {
+ }
+
+ void assign(T** var)
+ {
+ ptr=var;
+ arr_flag=0;
+ }
+
+ void assign_array(T** var)
+ {
+ ptr=var;
+ arr_flag=1;
+ }
+
+
+ void disconnect(void)
+ {
+ if(ptr!=0)
+ *ptr=0;
+ ptr=0;
+ }
+
+ void destroy(void)
+ {
+ if(ptr==0)return;
+ if(*ptr!=0){
+ if(arr_flag)
+ delete[] *ptr;
+ else
+ delete *ptr;
+ *ptr=0;
+ }
+ }
+
+ ~otl_ptr()
+ {
+ destroy();
+ }
+
+protected:
+
+ T** ptr;
+ int arr_flag;
+
+private:
+
+ otl_ptr(const otl_ptr&):
+ ptr(0),
+ arr_flag(0)
+ {
+ }
+
+ otl_ptr& operator=(const otl_ptr&)
+ {
+ return *this;
+ }
+
+};
+
+template <OTL_TYPE_NAME T>
+class otl_Tptr{
+public:
+
+ otl_Tptr():
+ ptr(0),
+ do_not_destroy(false)
+ {
+ }
+
+ void assign(T* var)
+ {
+ ptr=var;
+ }
+
+ void disconnect(void)
+ {
+ ptr=0;
+ }
+
+ void destroy(void)
+ {
+ if(do_not_destroy)
+ return;
+ delete ptr;
+ ptr=0;
+ }
+
+ ~otl_Tptr()
+ {
+ destroy();
+ }
+
+ otl_Tptr& operator=(const otl_Tptr& src)
+ {
+ ptr=src.ptr;
+ do_not_destroy=src.do_not_destroy;
+ return *this;
+ }
+
+ void set_do_not_destroy(const bool ado_not_destroy)
+ {
+ do_not_destroy=ado_not_destroy;
+ }
+
+ T* get_ptr()
+ {
+ return ptr;
+ }
+
+protected:
+
+ T* ptr;
+ bool do_not_destroy;
+
+private:
+
+ otl_Tptr(const otl_Tptr&):
+ ptr(0),
+ do_not_destroy(false)
+ {
+ }
+
+};
+
+template <OTL_TYPE_NAME OTLStream,
+ OTL_TYPE_NAME OTLConnect,
+ OTL_TYPE_NAME otl_exception>
+class otl_tmpl_nocommit_stream: public OTLStream{
+public:
+
+ otl_tmpl_nocommit_stream() OTL_NO_THROW
+ : OTLStream()
+ {
+ OTLStream::set_commit(0);
+ }
+
+ otl_tmpl_nocommit_stream
+ (const otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ OTLConnect& pdb,
+ const char* ref_cur_placeholder=0)
+ OTL_THROWS_OTL_EXCEPTION
+ : OTLStream(arr_size,sqlstm,pdb,ref_cur_placeholder)
+ {
+ OTLStream::set_commit(0);
+ }
+
+ void open
+ (otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ OTLConnect& db,
+ const char* ref_cur_placeholder=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ OTLStream::open(arr_size,sqlstm,db,ref_cur_placeholder);
+ OTLStream::set_commit(0);
+ }
+
+};
+
+#if defined(OTL_STL)
+
+class otl_pl_vec_generic{
+public:
+
+ typedef STD_NAMESPACE_PREFIX vector<bool> null_flag_type;
+
+
+ otl_pl_vec_generic():
+ p_v(0),
+ null_flag(),
+ vtype(0),
+ elem_size(0)
+ {
+ }
+
+ virtual int len(void) const
+ {
+ return 0;
+ }
+
+ virtual void set_len(const int /*new_len*/=0,
+ const bool /*set_all_to_null*/=true)
+
+ {
+ }
+
+ bool is_null(const int ndx=0) const
+ {
+ return null_flag[ndx];
+ }
+
+ void set_null(const int ndx=0)
+ {
+ null_flag[ndx]=true;
+ }
+
+ void set_non_null(const int ndx=0)
+ {
+ null_flag[ndx]=false;
+ }
+
+ virtual ~otl_pl_vec_generic(){}
+
+ int get_vtype() const
+ {
+ return vtype;
+ }
+
+ int get_elem_size() const
+ {
+ return elem_size;
+ }
+
+ void* get_p_v()
+ {
+ return p_v;
+ }
+
+protected:
+
+ void* p_v;
+ null_flag_type null_flag;
+ int vtype;
+ int elem_size;
+
+private:
+
+ otl_pl_vec_generic(const otl_pl_vec_generic&):
+ p_v(0),
+ null_flag(),
+ vtype(0),
+ elem_size(0)
+ {
+ }
+
+ otl_pl_vec_generic& operator=(const otl_pl_vec_generic&)
+ {
+ return *this;
+ }
+
+};
+
+template<OTL_TYPE_NAME T,const int type_code,const int T_sz>
+class otl_T_vec: public otl_pl_vec_generic{
+public:
+
+ STD_NAMESPACE_PREFIX vector<T> v;
+
+ otl_T_vec():
+ v()
+ {
+ this->p_v=OTL_RCAST(void*,&v);
+ this->vtype=type_code;
+ this->elem_size=T_sz;
+ }
+
+ virtual ~otl_T_vec(){}
+
+ virtual void set_len
+ (const int new_len=0,
+ const bool set_all_to_null=true)
+ {int i,vsize;
+
+ v.resize(new_len);
+ this->null_flag.resize(new_len);
+ vsize=OTL_SCAST(int,v.size());
+ if(set_all_to_null)
+ for(i=0;i<vsize;++i)
+ this->null_flag[i]=true;
+ }
+
+ virtual int len(void) const
+ {
+ return OTL_SCAST(int,v.size());
+ }
+
+ T& operator[](int ndx)
+ {
+ return v[ndx];
+ }
+
+private:
+
+ otl_T_vec(const otl_T_vec&):
+ v()
+ {
+ }
+
+ otl_T_vec& operator=(const otl_T_vec&)
+ {
+ return *this;
+ }
+
+};
+
+typedef otl_T_vec<double,otl_var_double,sizeof(double)> otl_double_vec;
+typedef otl_T_vec<float,otl_var_float,sizeof(float)> otl_float_vec;
+typedef otl_T_vec<int,otl_var_int,sizeof(int)> otl_int_vec;
+typedef otl_T_vec<short,otl_var_short,sizeof(short)> otl_short_vec;
+typedef otl_T_vec<long,otl_var_long_int,sizeof(long)> otl_long_int_vec;
+typedef otl_T_vec<otl_datetime,otl_var_timestamp,
+ sizeof(otl_oracle_date)> otl_datetime_vec;
+typedef otl_T_vec<OTL_STRING_CONTAINER,otl_var_char,1> otl_string_vec;
+
+#endif
+
+template <OTL_TYPE_NAME T,const int atab_size,const int avtype>
+class otl_tmpl_pl_tab: public otl_pl_tab_generic{
+public:
+
+ T v[atab_size];
+
+ void init(void)
+ {int i;
+ tab_len=0;
+ vtype=avtype;
+ tab_size=atab_size;
+ p_null=null_flag;
+ p_v=OTL_RCAST(unsigned char*,v);
+ elem_size=sizeof(T);
+ for(i=0;i<atab_size;++i)
+ null_flag[i]=0;
+ memset(v,0,sizeof(v));
+ }
+
+ otl_tmpl_pl_tab():
+ v(),
+ null_flag()
+ {
+ init();
+ }
+
+ virtual ~otl_tmpl_pl_tab(){}
+
+private:
+
+ short null_flag[atab_size];
+
+ otl_tmpl_pl_tab& operator=(const otl_tmpl_pl_tab&)
+ {
+ return *this;
+ }
+
+ otl_tmpl_pl_tab(const otl_tmpl_pl_tab&):
+ v(),
+ null_flag()
+ {
+ }
+
+};
+
+template <const int atab_size>
+class otl_int_tab: public otl_tmpl_pl_tab<int,atab_size,otl_var_int>{
+public:
+ otl_int_tab():otl_tmpl_pl_tab<int,atab_size,otl_var_int>(){}
+};
+
+template <const int atab_size>
+class otl_double_tab: public otl_tmpl_pl_tab<double,atab_size,otl_var_double>{
+public:
+ otl_double_tab():otl_tmpl_pl_tab<double,atab_size,otl_var_double>(){}
+};
+
+template <const int atab_size>
+class otl_float_tab: public otl_tmpl_pl_tab<float,atab_size,otl_var_float>{
+public:
+ otl_float_tab():otl_tmpl_pl_tab<float,atab_size,otl_var_float>(){}
+};
+
+template <const int atab_size>
+class otl_unsigned_tab: public otl_tmpl_pl_tab<unsigned,atab_size,otl_var_unsigned_int>{
+public:
+ otl_unsigned_tab():otl_tmpl_pl_tab<unsigned,atab_size,otl_var_unsigned_int>(){}
+};
+
+template <const int atab_size>
+class otl_short_tab: public otl_tmpl_pl_tab<short,atab_size,otl_var_short>{
+public:
+ otl_short_tab():otl_tmpl_pl_tab<short,atab_size,otl_var_short>(){}
+};
+
+template <const int atab_size>
+class otl_long_int_tab: public otl_tmpl_pl_tab<long,atab_size,otl_var_long_int>{
+public:
+ otl_long_int_tab():otl_tmpl_pl_tab<long,atab_size,otl_var_long_int>(){}
+};
+
+template <const int atab_size,const int str_size>
+class otl_cstr_tab: public otl_pl_tab_generic{
+public:
+ typedef unsigned char T[str_size];
+ T v[atab_size];
+
+ void init(void)
+ {int i;
+ tab_len=0;
+ vtype=otl_var_char;
+ tab_size=atab_size;
+ p_null=null_flag;
+ p_v=OTL_RCAST(unsigned char*,v);
+ elem_size=sizeof(T);
+ for(i=0;i<atab_size;++i)
+ null_flag[i]=0;
+ memset(v,0,sizeof(v));
+ }
+
+ otl_cstr_tab():
+ v(),
+ null_flag()
+ {
+ init();
+ }
+
+ virtual ~otl_cstr_tab(){}
+
+private:
+
+ short null_flag[atab_size];
+
+ otl_cstr_tab(const otl_cstr_tab&):
+ v(),
+ null_flag()
+ {
+ }
+
+ otl_cstr_tab& operator=(const otl_cstr_tab&)
+ {
+ return *this;
+ }
+
+};
+
+template <const int atab_size>
+class otl_datetime_tab: public otl_pl_tab_generic{
+public:
+
+ typedef otl_datetime T;
+
+ T v[atab_size];
+
+ void init(void)
+ {int i;
+ tab_len=0;
+ vtype=otl_var_timestamp;
+ tab_size=atab_size;
+ p_null=null_flag;
+ p_v=OTL_RCAST(unsigned char*,v);
+ elem_size=sizeof(otl_oracle_date);
+ for(i=0;i<atab_size;++i)
+ null_flag[i]=0;
+ }
+
+ otl_datetime_tab():
+ v(),
+ null_flag()
+ {
+ init();
+ }
+
+ virtual ~otl_datetime_tab(){}
+
+private:
+
+ short null_flag[atab_size];
+
+};
+
+template <OTL_TYPE_NAME T,const int avtype>
+class otl_tmpl_dyn_pl_tab: public otl_pl_tab_generic{
+public:
+ T* v;
+
+ void init(const int atab_size=1)
+ {int i;
+ tab_len=0;
+ vtype=avtype;
+ tab_size=atab_size;
+ v=new T[tab_size];
+ null_flag=new short[tab_size];
+ p_null=null_flag;
+ p_v=OTL_RCAST(unsigned char*,v);
+ elem_size=sizeof(T);
+ for(i=0;i<atab_size;++i)
+ null_flag[i]=0;
+ memset(v,0,elem_size*tab_size);
+ }
+
+ otl_tmpl_dyn_pl_tab(const int atab_size=1):
+ v(0),
+ null_flag(0)
+ {
+ init(atab_size);
+ }
+
+ virtual ~otl_tmpl_dyn_pl_tab()
+ {
+ delete[] v;
+ delete[] null_flag;
+ }
+
+private:
+
+ short* null_flag;
+
+ otl_tmpl_dyn_pl_tab(const otl_tmpl_dyn_pl_tab<T,avtype>&):
+ v(0),
+ null_flag(0)
+ {
+ }
+
+ otl_tmpl_dyn_pl_tab<T,avtype>& operator=(const otl_tmpl_dyn_pl_tab<T,avtype>&)
+ {
+ return *this;
+ }
+
+};
+
+class otl_dynamic_int_tab: public otl_tmpl_dyn_pl_tab<int,otl_var_int>{
+public:
+ otl_dynamic_int_tab(const int atab_size=1)
+ :otl_tmpl_dyn_pl_tab<int,otl_var_int>(atab_size){}
+};
+
+class otl_dynamic_double_tab: public otl_tmpl_dyn_pl_tab<double,otl_var_double>{
+public:
+ otl_dynamic_double_tab(const int atab_size=1)
+ :otl_tmpl_dyn_pl_tab<double,otl_var_double>(atab_size){}
+};
+
+class otl_dynamic_float_tab: public otl_tmpl_dyn_pl_tab<float,otl_var_float>{
+public:
+ otl_dynamic_float_tab(const int atab_size=1)
+ :otl_tmpl_dyn_pl_tab<float,otl_var_float>(atab_size){}
+};
+
+class otl_dynamic_unsigned_tab: public
+otl_tmpl_dyn_pl_tab<unsigned,otl_var_unsigned_int>{
+public:
+ otl_dynamic_unsigned_tab(const int atab_size=1)
+ :otl_tmpl_dyn_pl_tab<unsigned,otl_var_unsigned_int>(atab_size){}
+};
+
+class otl_dynamic_short_tab: public otl_tmpl_dyn_pl_tab<short,otl_var_short>{
+public:
+ otl_dynamic_short_tab(const int atab_size=1)
+ :otl_tmpl_dyn_pl_tab<short,otl_var_short>(atab_size){}
+};
+
+class otl_dynamic_long_int_tab: public otl_tmpl_dyn_pl_tab<long,otl_var_long_int>{
+public:
+ otl_dynamic_long_int_tab(const int atab_size=1)
+ :otl_tmpl_dyn_pl_tab<long,otl_var_long_int>(atab_size){}
+};
+
+template <const int str_size>
+class otl_dynamic_cstr_tab: public otl_pl_tab_generic{
+public:
+ typedef unsigned char T[str_size];
+ T* v;
+
+ void init(const int atab_size=1)
+ {int i;
+ tab_len=0;
+ vtype=otl_var_char;
+ tab_size=atab_size;
+ v=new T[tab_size];
+ null_flag=new short[tab_size];
+ p_null=null_flag;
+ p_v=OTL_RCAST(unsigned char*,v);
+ elem_size=sizeof(T);
+ for(i=0;i<atab_size;++i)
+ null_flag[i]=0;
+ memset(v,0,elem_size*tab_size);
+ }
+
+ otl_dynamic_cstr_tab(const int atab_size=1):
+ v(0),
+ null_flag(0)
+ {
+ init(atab_size);
+ }
+
+ virtual ~otl_dynamic_cstr_tab()
+ {
+ delete[] v;
+ delete[] null_flag;
+ }
+
+private:
+
+ short* null_flag;
+
+ otl_dynamic_cstr_tab(const otl_dynamic_cstr_tab&):
+ v(0),
+ null_flag(0)
+ {
+ }
+
+ otl_dynamic_cstr_tab& operator=(const otl_dynamic_cstr_tab&)
+ {
+ return *this;
+ }
+
+};
+
+class otl_dynamic_datetime_tab: public otl_pl_tab_generic{
+public:
+
+ typedef otl_datetime T;
+
+ T* v;
+
+ void init(const int atab_size=1)
+ {int i;
+ tab_len=0;
+ vtype=otl_var_timestamp;
+ tab_size=atab_size;
+ v=new T[tab_size];
+ null_flag=new short[tab_size];
+ p_null=null_flag;
+ p_v=OTL_RCAST(unsigned char*,v);
+ elem_size=sizeof(otl_oracle_date);
+ for(i=0;i<atab_size;++i)
+ null_flag[i]=0;
+ }
+
+ otl_dynamic_datetime_tab(const int atab_size=1):
+ otl_pl_tab_generic(),
+ v(0),
+ null_flag(0)
+ {
+ init(atab_size);
+ }
+
+ virtual ~otl_dynamic_datetime_tab()
+ {
+ delete[] v;
+ delete[] null_flag;
+ }
+
+private:
+
+ short* null_flag;
+
+ otl_dynamic_datetime_tab(const otl_dynamic_datetime_tab&):
+ otl_pl_tab_generic(),
+ v(0),
+ null_flag(0)
+ {
+ }
+
+ otl_dynamic_datetime_tab& operator=(const otl_dynamic_datetime_tab&)
+ {
+ return *this;
+ }
+
+};
+
+#define OTL_TMPL_EXCEPTION \
+ otl_tmpl_exception \
+ <TExceptionStruct, \
+ TConnectStruct, \
+ TCursorStruct>
+
+#define OTL_TMPL_CONNECT \
+ otl_tmpl_connect \
+ <TExceptionStruct, \
+ TConnectStruct, \
+ TCursorStruct>
+
+#define OTL_TMPL_CURSOR \
+ otl_tmpl_cursor \
+ <TExceptionStruct,TConnectStruct, \
+ TCursorStruct,TVariableStruct>
+
+#define OTL_TMPL_OUT_STREAM \
+ otl_tmpl_out_stream \
+ <TExceptionStruct,TConnectStruct, \
+ TCursorStruct,TVariableStruct, \
+ TTimestampStruct>
+
+#define OTL_TMPL_SELECT_CURSOR \
+ otl_tmpl_select_cursor \
+ <TExceptionStruct,TConnectStruct, \
+ TCursorStruct,TVariableStruct,TSelectCursorStruct>
+
+#define OTL_TMPL_INOUT_STREAM \
+ otl_tmpl_inout_stream \
+ <TExceptionStruct,TConnectStruct, \
+ TCursorStruct,TVariableStruct, \
+ TTimestampStruct>
+
+#define OTL_TMPL_SELECT_STREAM \
+ otl_tmpl_select_stream \
+ <TExceptionStruct,TConnectStruct,TCursorStruct, \
+ TVariableStruct,TSelectCursorStruct, \
+ TTimestampStruct>
+
+#if defined(OTL_EXCEPTION_IS_DERIVED_FROM_STD_EXCEPTION)
+#if defined(OTL_EXCEPTION_DERIVED_FROM)
+#error OTL_EXCEPTION_DERIVED_FROM is already defined. \
+OTL_EXCEPTION_IS_DERIVED_FROM_STD_EXCEPTION cannot be used
+#endif
+#define OTL_EXCEPTION_DERIVED_FROM std::exception
+#define OTL_EXCEPTION_HAS_MEMBERS \
+ virtual const char* what() const throw() \
+ { \
+ return reinterpret_cast<const char*>(this->msg); \
+ }
+
+#endif
+
+template <OTL_TYPE_NAME TExceptionStruct,
+ OTL_TYPE_NAME TConnectStruct,
+ OTL_TYPE_NAME TCursorStruct>
+#if defined(OTL_EXCEPTION_DERIVED_FROM)
+class otl_tmpl_exception:
+ public OTL_EXCEPTION_DERIVED_FROM,
+ public TExceptionStruct{
+#else
+class otl_tmpl_exception: public TExceptionStruct{
+#endif
+public:
+
+#if defined(OTL_EXCEPTION_HAS_MEMBERS)
+ OTL_EXCEPTION_HAS_MEMBERS
+#endif
+
+#if defined(OTL_EXCEPTION_STM_TEXT_SIZE)
+ char stm_text[OTL_EXCEPTION_STM_TEXT_SIZE];
+#else
+ char stm_text[2048];
+#endif
+ char var_info[256];
+
+ otl_tmpl_exception()
+#if defined(__GNUC__) && (__GNUC__>=3)
+ throw()
+#else
+ OTL_NO_THROW
+#endif
+ {
+ stm_text[0]=0;
+ var_info[0]=0;
+ }
+
+ otl_tmpl_exception(TConnectStruct& conn_struct, const char* sqlstm=0)
+#if defined(__GNUC__) && (__GNUC__>=3)
+ throw()
+#else
+ OTL_NO_THROW
+#endif
+ {
+ stm_text[0]=0;
+ var_info[0]=0;
+ if(sqlstm){
+ OTL_STRNCPY_S(OTL_RCAST(char*,stm_text),
+ sizeof(stm_text),
+ sqlstm,
+ sizeof(stm_text)-1);
+ stm_text[sizeof(stm_text)-1]=0;
+ }
+ conn_struct.error(OTL_SCAST(TExceptionStruct&,*this));
+ OTL_TRACE_EXCEPTION(this->code,this->msg,this->stm_text,this->var_info)
+ }
+
+ otl_tmpl_exception(TCursorStruct& cursor_struct, const char* sqlstm=0)
+#if defined(__GNUC__) && (__GNUC__>=3)
+ throw()
+#else
+ OTL_NO_THROW
+#endif
+ {
+ stm_text[0]=0;
+ var_info[0]=0;
+ if(sqlstm){
+ OTL_STRNCPY_S(OTL_RCAST(char*,stm_text),
+ sizeof(stm_text),
+ sqlstm,
+ sizeof(stm_text)-1);
+ stm_text[sizeof(stm_text)-1]=0;
+ }
+ cursor_struct.error(OTL_SCAST(TExceptionStruct&,*this));
+ OTL_TRACE_EXCEPTION(this->code,this->msg,this->stm_text,this->var_info)
+ }
+
+ otl_tmpl_exception
+ (const char* amsg,
+ const int acode,
+ const char* sqlstm=0,
+ const char* varinfo=0)
+#if defined(__GNUC__) && (__GNUC__>=3)
+ throw()
+#else
+ OTL_NO_THROW
+#endif
+ {
+ stm_text[0]=0;
+ var_info[0]=0;
+ if(sqlstm){
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ OTL_STRCPY_S(OTL_RCAST(char*,stm_text),sizeof(stm_text),sqlstm);
+#else
+ strncpy(OTL_RCAST(char*,stm_text),sqlstm,sizeof(stm_text));
+ stm_text[sizeof(stm_text)-1]=0;
+#endif
+#else
+ strncpy(OTL_RCAST(char*,stm_text),sqlstm,sizeof(stm_text));
+ stm_text[sizeof(stm_text)-1]=0;
+#endif
+ }
+ if(varinfo)
+ OTL_STRCPY_S(OTL_RCAST(char*,var_info),sizeof(var_info),varinfo);
+ TExceptionStruct::init(amsg,acode);
+ OTL_TRACE_EXCEPTION(this->code,this->msg,this->stm_text,this->var_info)
+ }
+
+ virtual ~otl_tmpl_exception()
+#if defined(__GNUC__) && (__GNUC__>=3)
+ throw()
+#else
+ OTL_NO_THROW
+#endif
+ {
+ }
+
+};
+
+template <OTL_TYPE_NAME TExceptionStruct,
+ OTL_TYPE_NAME TConnectStruct,
+ OTL_TYPE_NAME TCursorStruct>
+class otl_tmpl_connect{
+protected:
+
+ TConnectStruct connect_struct;
+ int long_max_size;
+ int retcode;
+ int throw_count;
+
+public:
+
+ void set_retcode(const int aretcode)
+ {
+ retcode=aretcode;
+ }
+
+ int get_retcode() const
+ {
+ return retcode;
+ }
+
+ void reset_throw_count(void)
+ {
+ throw_count=0;
+ }
+
+ void increment_throw_count()
+ {
+ throw_count++;
+ }
+
+ int get_throw_count() const
+ {
+ return throw_count;
+ }
+
+ TConnectStruct& get_connect_struct()
+ {
+ return connect_struct;
+ }
+
+ int connected;
+
+ void set_max_long_size(const int amax_size)
+ {
+ reset_throw_count();
+#if defined(OTL_UNICODE)
+#if defined(OTL_ORA8I)||defined(OTL_ORA9I)||defined(OTL_ORA10G)||defined(OTL_ORA10G_R2)
+ long_max_size=amax_size*sizeof(OTL_WCHAR);
+#else
+ long_max_size=amax_size;
+#endif
+#else
+ long_max_size=amax_size;
+#endif
+ }
+
+ int get_max_long_size(void)
+ {
+ reset_throw_count();
+ return long_max_size;
+ }
+
+ void set_timeout(const int atimeout=0)
+ {
+ reset_throw_count();
+ connect_struct.set_timeout(atimeout);
+ }
+
+ void set_cursor_type(const int acursor_type=0)
+ {
+ reset_throw_count();
+ connect_struct.set_cursor_type(acursor_type);
+ }
+
+ otl_tmpl_connect():
+ connect_struct(),
+ long_max_size(32760),
+ retcode(1),
+ throw_count(0),
+ connected(0)
+ {
+ }
+
+ otl_tmpl_connect(const char* connect_str,const int auto_commit=0):
+ connect_struct(),
+ long_max_size(32760),
+ retcode(1),
+ throw_count(0),
+ connected(0)
+ {
+ rlogon(connect_str,auto_commit);
+ }
+
+ virtual ~otl_tmpl_connect()
+ {
+ logoff();
+ }
+
+ static int otl_initialize(const int threaded_mode=0)
+ {
+ return TConnectStruct::initialize(threaded_mode);
+ }
+
+ void rlogon(const char* connect_str,const int auto_commit=0)
+ {
+ throw_count=0;
+ retcode=connect_struct.rlogon(connect_str,auto_commit);
+ if(retcode)
+ connected=1;
+ else{
+ connected=0;
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ OTL_TMPL_EXCEPTION ex(connect_struct);
+ connect_struct.cleanup();
+ throw ex;
+ }
+ }
+
+ void logoff(void)
+ {
+ if(!connected)return;
+ OTL_TRACE_FUNC(0x1,"otl_connect","logoff","")
+ retcode=connect_struct.logoff();
+ connected=0;
+ if(retcode)return;
+ if(get_throw_count()>0)
+ return;
+ increment_throw_count();
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION(connect_struct);
+ }
+
+ void commit(void)
+ {
+ if(!connected)return;
+ OTL_TRACE_FUNC(0x1,"otl_connect","commit","")
+ reset_throw_count();
+ retcode=connect_struct.commit();
+ if(retcode)return;
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION(connect_struct);
+ }
+
+ void auto_commit_on(void)
+ {
+ if(!connected)return;
+ OTL_TRACE_FUNC(0x1,"otl_connect","auto_commit_on","")
+ reset_throw_count();
+ retcode=connect_struct.auto_commit_on();
+ if(retcode)return;
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION(connect_struct);
+ }
+
+ void auto_commit_off(void)
+ {
+ if(!connected)return;
+ OTL_TRACE_FUNC(0x1,"otl_connect","auto_commit_off","")
+ reset_throw_count();
+ retcode=connect_struct.auto_commit_off();
+ if(retcode)return;
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION(connect_struct);
+ }
+
+ void rollback(void)
+ {
+ if(!connected)return;
+ OTL_TRACE_FUNC(0x1,"otl_connect","rollback","")
+ reset_throw_count();
+ retcode=connect_struct.rollback();
+ if(retcode)return;
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION(connect_struct);
+ }
+
+private:
+
+ otl_tmpl_connect(const otl_tmpl_connect&):
+ connected(0),
+ connect_struct(),
+ long_max_size(32760),
+ retcode(1),
+ throw_count(0)
+ {
+ }
+
+ otl_tmpl_connect& operator=(const otl_tmpl_connect&)
+ {
+ return *this;
+ }
+
+};
+
+template <OTL_TYPE_NAME TVariableStruct>
+class otl_tmpl_variable{
+protected:
+
+ int param_type;
+ int ftype;
+ int elem_size;
+ int array_size;
+ char* name;
+ int pos;
+ int name_pos;
+ int bound;
+
+ int pl_tab_flag;
+
+ TVariableStruct var_struct;
+
+public:
+
+ TVariableStruct& get_var_struct(){return var_struct;}
+ const TVariableStruct& get_const_var_struct() const {return var_struct;}
+ int get_bound() const {return bound;}
+ int get_param_type() const {return param_type;}
+ int get_ftype() const {return ftype;}
+ int get_name_pos() const {return name_pos;}
+ int get_elem_size() const {return elem_size;}
+ int get_pl_tab_flag() const {return pl_tab_flag;}
+ int get_pos() const {return pos;}
+ int get_array_size() const {return array_size;}
+ const char* get_name() const {return name;}
+
+ void set_pos(const int apos)
+ {
+ this->pos=apos;
+ }
+
+ void set_bound(const int abound)
+ {
+ this->bound=abound;
+ }
+
+ void set_name_pos(const int aname_pos)
+ {
+ this->name_pos=aname_pos;
+ }
+
+ void set_ftype(const int aftype)
+ {
+ this->ftype=aftype;
+ }
+
+
+ int actual_elem_size(void)
+ {
+ return var_struct.actual_elem_size();
+ }
+
+ void copy_var_desc(otl_var_desc& v)
+ {
+ v.param_type=param_type;
+ v.ftype=ftype;
+ v.elem_size=elem_size;
+ v.array_size=array_size;
+ v.pos=pos;
+ v.name_pos=name_pos;
+ if(name){
+ OTL_STRNCPY_S(v.name,sizeof(v.name),name,sizeof(v.name)-1);
+ v.name[sizeof(v.name)-1]=0;
+ }else
+ v.name[0]=0;
+ v.pl_tab_flag=pl_tab_flag;
+ }
+
+ otl_tmpl_variable():
+ param_type(0),
+ ftype(0),
+ elem_size(0),
+ array_size(0),
+ name(0),
+ pos(0),
+ name_pos(0),
+ bound(0),
+ pl_tab_flag(0),
+ var_struct()
+ {
+ }
+
+ virtual ~otl_tmpl_variable()
+ {
+ delete[] name;
+ }
+
+ otl_tmpl_variable
+ (const int column_num,
+ const int aftype,
+ const int aelem_size,
+ const short aarray_size):
+ param_type(0),
+ ftype(0),
+ elem_size(0),
+ array_size(0),
+ name(0),
+ pos(0),
+ name_pos(0),
+ bound(0),
+ pl_tab_flag(0),
+ var_struct()
+ {
+ copy_pos(column_num);
+ init(aftype,aelem_size,aarray_size);
+ }
+
+ otl_tmpl_variable
+ (const char* aname,
+ const int aftype,
+ const int aelem_size,
+ const short aarray_size,
+ const int apl_tab_flag=0)
+ {
+ copy_name(aname);
+ init
+ (aftype,
+ aelem_size,
+ aarray_size,
+ 0,
+ apl_tab_flag);
+ }
+
+ void init
+ (const bool select_stm_flag,
+ const int aftype,
+ const int aelem_size,
+ const otl_stream_buffer_size_type aarray_size,
+ const void* connect_struct=0,
+ const int apl_tab_flag=0)
+ {
+ ftype=aftype;
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ if(ftype==otl_var_nchar)
+ ftype=otl_var_char;
+ else if(ftype==otl_var_nclob)
+ ftype=otl_var_clob;
+#endif
+ elem_size=aelem_size;
+ array_size=aarray_size;
+ pl_tab_flag=apl_tab_flag;
+ bound=0;
+ var_struct.init(select_stm_flag,
+ aftype,
+ elem_size,
+ aarray_size,
+ connect_struct,
+ pl_tab_flag);
+ }
+
+ void set_param_type(const int aparam_type=otl_input_param)
+ {
+ param_type=aparam_type;
+ }
+
+ int get_param_type(void)
+ {
+ return param_type;
+ }
+
+ void copy_name(const char* aname)
+ {
+ pos=0;
+ if(name==aname)return;
+ if(name)delete[] name;
+ size_t len=strlen(aname)+1;
+ name=new char[len];
+ OTL_STRCPY_S(name,len,aname);
+ }
+
+ void copy_pos(const int apos)
+ {
+ if(name){
+ delete[] name;
+ name=0;
+ name_pos=0;
+ }
+ pos=apos;
+ }
+
+
+ void set_null(int ndx)
+ {
+ var_struct.set_null(ndx);
+ }
+
+ void set_not_null(int ndx)
+ {
+ var_struct.set_not_null(ndx,elem_size);
+ }
+
+ void set_len(int len, int ndx=0)
+ {
+ var_struct.set_len(len,ndx);
+ }
+
+ int get_len(int ndx=0)
+ {
+ return var_struct.get_len(ndx);
+ }
+
+ int get_pl_tab_len(void)
+ {
+ return this->var_struct.get_pl_tab_len();
+ }
+
+ int get_max_pl_tab_len(void)
+ {
+ return this->var_struct.get_max_pl_tab_len();
+ }
+
+ void set_pl_tab_len(const int pl_tab_len)
+ {
+ this->var_struct.set_pl_tab_len(pl_tab_len);
+ }
+
+ int is_null(int ndx)
+ {
+ return var_struct.is_null(ndx);
+ }
+
+ void* val(int ndx=0)
+ {
+ return var_struct.val(ndx,elem_size);
+ }
+
+ static void map_ftype
+ (otl_column_desc& desc,
+ const int max_long_size,
+ int& aftype,
+ int& aelem_size,
+ otl_select_struct_override& override,
+ const int column_ndx,
+ const int connection_type)
+ {
+ TVariableStruct::map_ftype
+ (desc,
+ max_long_size,
+ aftype,
+ aelem_size,
+ override,
+ column_ndx,
+ connection_type);
+ }
+
+ static int int2ext(int int_type)
+ {
+ return TVariableStruct::int2ext(int_type);
+ }
+
+private:
+
+ otl_tmpl_variable(const otl_tmpl_variable&):
+ param_type(0),
+ ftype(0),
+ elem_size(0),
+ array_size(0),
+ name(0),
+ pos(0),
+ name_pos(0),
+ bound(0),
+ pl_tab_flag(0),
+ var_struct()
+ {
+ }
+
+ otl_tmpl_variable& operator=(const otl_tmpl_variable&)
+ {
+ return *this;
+ }
+
+};
+
+template <OTL_TYPE_NAME TExceptionStruct,
+ OTL_TYPE_NAME TConnectStruct,
+ OTL_TYPE_NAME TCursorStruct,
+ OTL_TYPE_NAME TVariableStruct>
+class otl_tmpl_cursor{
+protected:
+
+ int connected;
+ char* stm_text;
+ char* stm_label;
+
+ TCursorStruct cursor_struct;
+ int vl_len;
+ otl_tmpl_variable<TVariableStruct>** vl;
+ OTL_TMPL_CONNECT* adb;
+ int eof_data;
+ int eof_desc;
+ int retcode;
+ long _rpc;
+ int in_destructor;
+
+public:
+
+ OTL_TMPL_CONNECT* get_adb(){return adb;}
+ void set_adb(OTL_TMPL_CONNECT* aadb)
+ {
+ adb=aadb;
+ }
+
+ TCursorStruct& get_cursor_struct_ref(){return cursor_struct;}
+
+ otl_tmpl_variable<TVariableStruct>** get_vl(){return vl;}
+ int get_vl_len() const {return vl_len;}
+
+ const char* get_stm_label() const
+ {
+ return stm_label;
+ }
+
+ const char* get_stm_text() const
+ {
+ return stm_text;
+ }
+
+ void set_connected(const int aconnected)
+ {
+ connected=aconnected;
+ }
+
+ int& get_eof_data_ref()
+ {
+ return eof_data;
+ }
+
+ TCursorStruct& get_cursor_struct()
+ {
+ return cursor_struct;
+ }
+
+ int get_connected() const
+ {
+ return connected;
+ }
+
+ otl_tmpl_cursor():
+ connected(0),
+ stm_text(0),
+ stm_label(0),
+ cursor_struct(),
+ vl_len(0),
+ vl(0),
+ adb(0),
+ eof_data(),
+ eof_desc(),
+ retcode(1),
+ _rpc(0),
+ in_destructor(0)
+ {
+ }
+
+ otl_tmpl_cursor(OTL_TMPL_CONNECT& connect):
+ connected(0),
+ stm_text(0),
+ stm_label(0),
+ cursor_struct(),
+ vl_len(0),
+ vl(0),
+ adb(&connect),
+ eof_data(),
+ eof_desc(),
+ retcode(1),
+ _rpc(0),
+ in_destructor(0)
+ {
+ open(connect);
+ }
+
+ otl_tmpl_cursor
+ (OTL_TMPL_CONNECT& connect,
+ TVariableStruct* var):
+ connected(0),
+ stm_text(0),
+ stm_label(0),
+ cursor_struct(),
+ vl_len(0),
+ vl(0),
+ adb(&connect),
+ eof_data(),
+ eof_desc(),
+ retcode(1),
+ _rpc(0),
+ in_destructor(0)
+ {
+ open(connect,var);
+ }
+
+ virtual ~otl_tmpl_cursor()
+ {
+ in_destructor=1;
+ close();
+ delete[] stm_label;
+ stm_label=0;
+ delete[] stm_text;
+ stm_text=0;
+ }
+
+ void open
+ (OTL_TMPL_CONNECT& connect,
+ TVariableStruct* var=0)
+ {
+ in_destructor=0;
+ eof_data=0;
+ eof_desc=0;
+ retcode=1;
+ adb=&connect;
+ _rpc=0;
+ if(var==0)
+ retcode=cursor_struct.open(connect.get_connect_struct());
+ else
+ retcode=cursor_struct.open(connect.get_connect_struct(),var);
+ if(retcode){
+ connected=1;
+ return;
+ }
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION(cursor_struct);
+ }
+
+ virtual void close(void)
+ {_rpc=0;
+ if(!connected)return;
+ if(!this->adb)return;
+ if(!adb->connected){
+ connected=0;
+ adb=0;
+ retcode=1;
+ return;
+ }
+ connected=0;
+ retcode=cursor_struct.close();
+ if(retcode){
+ adb=0;
+ return;
+ }
+ if(this->adb->get_throw_count()>0){
+ adb=0;
+ return;
+ }
+ this->adb->increment_throw_count();
+ adb=0;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION(cursor_struct);
+ }
+
+ void parse(void)
+ {_rpc=0;
+ if(!connected)return;
+ retcode=cursor_struct.parse(stm_text);
+ switch(retcode){
+ case 0:
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION(cursor_struct,stm_label?stm_label:stm_text);
+ case 2:
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ char var_info[1];
+ var_info[0]=0;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_17,
+ otl_error_code_17,
+ this->stm_label?this->stm_label:this->stm_text,
+ var_info);
+ }
+ }
+
+ void parse(const char* sqlstm)
+ {
+ if(!connected)return;
+ if(stm_text){
+ delete[] stm_text;
+ stm_text=0;
+ }
+ size_t len=strlen(sqlstm)+1;
+ stm_text=new char[len];
+ OTL_STRCPY_S(stm_text,len,sqlstm);
+ parse();
+ }
+
+ long get_rpc()
+ {
+ return _rpc;
+ }
+
+ void exec(const int iters/*=1*/,
+ const int rowoff/*=0*/,
+ const int otl_sql_exec_from_class/*=otl_sql_exec_from_cursor_class*/)
+ {
+ if(!connected)return;
+ retcode=cursor_struct.exec(iters,rowoff,otl_sql_exec_from_class);
+ _rpc=cursor_struct.get_rpc();
+ if(retcode)return;
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION(cursor_struct,stm_label?stm_label:stm_text);
+ }
+
+ virtual bool valid_binding
+ (const otl_tmpl_variable<TVariableStruct>& v,
+ const int binding_type)
+ {
+ bool rc=true;
+ if(((v.get_ftype()==otl_var_varchar_long||v.get_ftype()==otl_var_raw_long) &&
+ (v.get_const_var_struct().get_otl_adapter()==otl_ora7_adapter||
+ v.get_const_var_struct().get_otl_adapter()==otl_ora8_adapter) &&
+ v.get_array_size()>1) ||
+ ((v.get_ftype()==otl_var_blob||v.get_ftype()==otl_var_clob)&&
+ v.get_const_var_struct().get_otl_adapter()==otl_ora8_adapter&&
+ v.get_array_size()>1 &&
+ binding_type==otl_inout_binding))
+ rc=false;
+ return rc;
+ }
+
+ virtual void bind
+ (const char* name,
+ otl_tmpl_variable<TVariableStruct>& v)
+ {
+ if(!connected)return;
+ if(v.get_bound())return;
+ v.copy_name(name);
+ if(!valid_binding(v,otl_inout_binding)){
+ char var_info[256];
+ otl_var_info_var2
+ (v.get_name(),
+ v.get_ftype(),
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_16,
+ otl_error_code_16,
+ stm_label?stm_label:stm_text,
+ var_info);
+ }
+ retcode=cursor_struct.bind
+ (name,
+ v.get_var_struct(),
+ v.get_elem_size(),
+ v.get_ftype(),
+ v.get_param_type(),
+ v.get_name_pos(),
+ this->adb->get_connect_struct().get_connection_type(),
+ v.get_pl_tab_flag());
+ if(retcode){
+ v.set_bound(1);
+ return;
+ }
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION(cursor_struct,stm_label?stm_label:stm_text);
+ }
+
+ virtual void bind
+ (const int column_num,
+ otl_tmpl_variable<TVariableStruct>& v)
+ {
+ if(!connected)return;
+ v.copy_pos(column_num);
+ if(!valid_binding(v,otl_select_binding)){
+ char var_info[256];
+ otl_var_info_col2
+ (v.get_pos(),
+ v.get_ftype(),
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_16,
+ otl_error_code_16,
+ stm_label?stm_label:stm_text,
+ var_info);
+ }
+ retcode=cursor_struct.bind
+ (column_num,
+ v.get_var_struct(),
+ v.get_elem_size(),
+ v.get_ftype(),
+ v.get_param_type());
+ if(retcode)return;
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION(cursor_struct,stm_label?stm_label:stm_text);
+ }
+
+ virtual void bind(otl_tmpl_variable<TVariableStruct>& v)
+ {
+ if(!connected)return;
+ if(v.get_name()) bind(v.get_name(),v);
+ if(v.get_pos()) bind(v.get_pos(),v);
+ }
+
+
+ static long direct_exec
+ (OTL_TMPL_CONNECT& connect,
+ const char* sqlstm,
+ const int exception_enabled=1)
+#if defined(OTL_ANSI_CPP) && defined(OTL_FUNC_THROW_SPEC_ON)
+ throw(OTL_TMPL_EXCEPTION)
+#endif
+ {
+ connect.reset_throw_count();
+ OTL_TRACE_DIRECT_EXEC
+ try{
+ OTL_TMPL_CURSOR cur(connect);
+ cur.cursor_struct.set_direct_exec(1);
+ cur.parse(sqlstm);
+ cur.exec(1,0,otl_sql_exec_from_cursor_class);
+ return cur.cursor_struct.get_rpc();
+ }catch(OTL_CONST_EXCEPTION OTL_TMPL_EXCEPTION&){
+ if(exception_enabled){
+ connect.increment_throw_count();
+ throw;
+ }
+ }
+ return -1;
+ }
+
+ static void syntax_check
+ (OTL_TMPL_CONNECT& connect,
+ const char* sqlstm)
+#if defined(OTL_ANSI_CPP) && defined(OTL_FUNC_THROW_SPEC_ON)
+ throw(OTL_TMPL_EXCEPTION)
+#endif
+ {
+ connect.reset_throw_count();
+ OTL_TRACE_SYNTAX_CHECK
+ OTL_TMPL_CURSOR cur(connect);
+ cur.cursor_struct.set_direct_exec(1);
+ cur.cursor_struct.set_parse_only(1);
+ cur.parse(sqlstm);
+ }
+
+ int eof(void){return eof_data;}
+
+ int describe_column
+ (otl_column_desc& col,
+ const int column_num)
+ {
+ if(!connected)return 0;
+ retcode=cursor_struct.describe_column
+ (col,column_num,eof_desc);
+ if(eof_desc)return 0;
+ if(retcode)return 1;
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw OTL_TMPL_EXCEPTION(cursor_struct,stm_label?stm_label:stm_text);
+ }
+
+private:
+
+ otl_tmpl_cursor(const otl_tmpl_cursor&):
+ connected(0),
+ stm_text(0),
+ stm_label(0),
+ cursor_struct(),
+ vl_len(0),
+ vl(0),
+ adb(0),
+ eof_data(),
+ eof_desc(),
+ retcode(1),
+ _rpc(0),
+ in_destructor(0)
+ {
+ }
+
+ otl_tmpl_cursor& operator=(const otl_tmpl_cursor&)
+ {
+ return *this;
+ }
+
+
+};
+
+inline int is_num(char c)
+{
+ return c>='0' && c<='9';
+}
+
+template <OTL_TYPE_NAME TVariableStruct,
+ OTL_TYPE_NAME TTimestampStruct,
+ OTL_TYPE_NAME TExceptionStruct,
+ OTL_TYPE_NAME TConnectStruct,
+ OTL_TYPE_NAME TCursorStruct>
+class otl_tmpl_ext_hv_decl{
+private:
+
+ char** hv;
+ short int* inout;
+ int* pl_tab_size;
+ int array_size;
+ int prev_array_size;
+ short int vst[4];
+ int len;
+ char* stm_text_;
+ char* stm_label_;
+ int container_size_;
+ bool has_plsql_tabs_or_refcur_;
+
+public:
+
+ bool has_plsql_tabs_or_refcur() const {return has_plsql_tabs_or_refcur_;}
+ short int get_vst(const int ndx) const {return vst[ndx];}
+ int get_len() const {return len;}
+ short int get_inout(const int ndx) const {return inout[ndx];}
+ int get_pl_tab_size(const int ndx) const {return pl_tab_size[ndx];}
+ const char* stm_label() const {return stm_label_;}
+ const char* stm_text() const {return stm_text_;}
+
+ enum var_status{
+ in=0,
+ out=1,
+ io=2,
+ def=3
+ };
+
+ otl_tmpl_ext_hv_decl(char* stm,
+ int arr_size=1,
+ char* label=0,
+ otl_select_struct_override** select_override=0,
+ OTL_TMPL_CONNECT* adb=0):
+ hv(0),
+ inout(0),
+ pl_tab_size(0),
+ array_size(0),
+ prev_array_size(0),
+ vst(),
+ len(0),
+ stm_text_(0),
+ stm_label_(0),
+ container_size_(0),
+ has_plsql_tabs_or_refcur_(0)
+ {
+ container_size_=otl_var_list_size;
+ hv=new char*[container_size_];
+ inout=new short[container_size_];
+ pl_tab_size=new int[container_size_];
+ has_plsql_tabs_or_refcur_=false;
+
+ int j;
+ array_size=arr_size;
+ prev_array_size=arr_size;
+ stm_text_=stm;
+ stm_label_=label;
+ int i=0;
+ short in_str=0;
+ bool in_comment=false;
+ bool in_one_line_comment=false;
+ char *c=stm;
+ bool in_comment_column_override=false;
+ hv[i]=0;
+ while(*c){
+ switch(*c){
+ case '\'':
+ if(!in_comment&&!in_one_line_comment){
+ if(!in_str)
+ in_str=1;
+ else{
+ if(c[1]=='\'')
+ ++c;
+ else
+ in_str=0;
+ }
+ }
+ break;
+ case '/':
+ if(c[1]=='*' && !in_str && c[2]==':' && c[3]=='#'){
+ in_comment_column_override=true;
+ *c=' ';
+ ++c;
+ *c=' ';
+ ++c;
+ }else if(c[1]=='*'&&!in_str){
+ in_comment=true;
+ ++c;
+ }
+ break;
+ case '-':
+ if(c[1]=='-'&&!in_str){
+ in_one_line_comment=true;
+ ++c;
+ }
+ break;
+ case '*':
+ if(c[1]=='/' && in_comment){
+ in_comment=false;
+ ++c;
+ }else if(c[1]=='/' && in_comment_column_override){
+ *c=' ';
+ ++c;
+ *c=' ';
+ }
+ break;
+ case '\n':
+ if(in_one_line_comment)
+ in_one_line_comment=false;
+ break;
+ }
+ if(*c==':' && !in_str && !in_comment && !in_one_line_comment &&
+ ((c>stm && *(c-1)!='\\') || c==stm)){
+ char* bind_var_ptr=c;
+ short in_out=def;
+ int apl_tab_size=0;
+ char var[64];
+ char* v=var;
+ *v++=*c++;
+ while(is_id(*c))
+ *v++=*c++;
+ while(otl_isspace(*c)&&*c)
+ ++c;
+ if(*c=='<' || (*c=='/' && c[1]=='*')){
+ if(*c=='<')
+ *c=' ';
+ else if(*c=='/'&&c[1]=='*'){
+ *c=' ';
+ ++c;
+ *c=' ';
+ }
+ while(*c!='>' && *c!=',' && *c!='*' && *c){
+ *v++=*c;
+ *c++=' ';
+ }
+ if(*c==','){
+ *c++=' ';
+ if(otl_to_upper(*c)=='I'){
+ if(otl_to_upper(c[2])=='O')
+ in_out=io;
+ else
+ in_out=in;
+ }else if(otl_to_upper(*c)=='O')
+ in_out=out;
+ while(*c!='>' && *c && *c!='*' && (*c!='[' && *c!='(') )
+ *c++=' ';
+ if(*c=='*'){
+ *c=' ';
+ ++c;
+ *c=' ';
+ }
+ if(*c=='[' || *c=='('){
+ char tmp[32];
+ char *t=tmp;
+ *c++=' ';
+ while((*c!=']' && *c!=')') && *c!='>' && *c!='*' && *c){
+ *t++=*c;
+ *c++=' ';
+ }
+ if(*c=='*'){
+ *c=' ';
+ ++c;
+ *c=' ';
+ }
+ *t='\0';
+ apl_tab_size=atoi(tmp);
+ while(*c!='>' && *c!='*' && *c)
+ *c++=' ';
+ if(*c=='*'){
+ *c=' ';
+ ++c;
+ *c=' ';
+ }
+ }
+ }else if(*c=='*' && c[1]=='/'){
+ *c=' ';
+ ++c;
+ *c=' ';
+ }
+ if(*c)*c=' ';
+ *v='\0';
+ if(select_override!=0 && bind_var_ptr[1]=='#'){
+ char* c4=bind_var_ptr+2;
+ char col_num[64];
+ char* col_num_ptr=col_num;
+ while(is_num(*c4) && *c4){
+ *col_num_ptr=*c4;
+ ++col_num_ptr;
+ ++c4;
+ }
+ *col_num_ptr=0;
+ int col_ndx=atoi(col_num);
+ if(col_ndx>0){
+ if(*select_override==0){
+ *select_override=new otl_select_struct_override();
+ }
+ int data_type=otl_var_none;
+ int data_len=0;
+ char name[128];
+ parse_var
+ (adb,
+ var,
+ data_type,
+ data_len,
+ name);
+ (*select_override)->add_override
+ (col_ndx,
+ data_type,
+ data_len);
+ }
+ c4=bind_var_ptr;
+ while(*c4 && *c4!=' '){
+ *c4=' ';
+ ++c4;
+ }
+ }else
+ add_var(i,var,in_out,apl_tab_size);
+ }
+ }
+ if(*c)++c;
+ }
+ for(j=0;j<4;++j)vst[j]=0;
+ i=0;
+ while(hv[i]){
+ switch(inout[i]){
+ case in:
+ ++vst[0];
+ break;
+ case out:
+ ++vst[1];
+ break;
+ case io:
+ ++vst[2];
+ break;
+ case def:
+ ++vst[3];
+ break;
+ }
+ ++i;
+ }
+ len=i;
+ }
+
+ virtual ~otl_tmpl_ext_hv_decl()
+ {int i;
+ for(i=0;hv[i]!=0;++i)
+ delete[] hv[i];
+ delete[] hv;
+ delete[] inout;
+ delete[] pl_tab_size;
+ }
+
+
+ char* operator[](int ndx){return hv[ndx];}
+ short v_status(int ndx){return inout[ndx];}
+ int is_id(char c){return isalnum(c)||c=='_'||c=='#';}
+
+ int name_comp(char* n1,char* n2)
+ {
+ while(*n1!=' '&&*n1!='\0'&&*n2!=' '&&*n2!='\0'){
+ if(otl_to_upper(*n1)!=otl_to_upper(*n2))return 0;
+ ++n1;
+ ++n2;
+ }
+ if((*n1==' '&&*n2!=' ')||(*n2==' '&&*n1!=' '))
+ return 0;
+ return 1;
+ }
+
+ void add_var(int &n,char* v,short in_out,int apl_tab_size=0)
+ {int i;
+ for(i=0;i<n;++i)
+ if(name_comp(hv[i],v))
+ return;
+ char *c=v;
+ bool is_space=false;
+ while(*c){
+ is_space=otl_isspace(*c);
+ if(is_space) break;
+ ++c;
+ }
+ if(is_space && otl_str_case_insensitive_equal((c+1),"REFCUR")){
+ has_plsql_tabs_or_refcur_=true;
+ if(apl_tab_size==0)
+ apl_tab_size=1;
+ }
+ if(apl_tab_size>0)
+ has_plsql_tabs_or_refcur_=true;
+ size_t v_len=strlen(v)+1;
+ hv[n]=new char[v_len];
+ OTL_STRCPY_S(hv[n],v_len,v);
+ inout[n]=in_out;
+ pl_tab_size[n]=apl_tab_size;
+ if(n==container_size_-1){
+ int temp_container_size=container_size_;
+ container_size_*=2;
+ char** temp_hv=new char*[container_size_];
+ short* temp_inout=new short[container_size_];
+ int* temp_pl_tab_size=new int[container_size_];
+ memcpy(temp_hv,hv,sizeof(char*)*temp_container_size);
+ memcpy(temp_inout,inout,sizeof(short)*temp_container_size);
+ memcpy(temp_pl_tab_size,pl_tab_size,sizeof(int)*temp_container_size);
+ delete[] hv;
+ delete[] inout;
+ delete[] pl_tab_size;
+ hv=temp_hv;
+ inout=temp_inout;
+ pl_tab_size=temp_pl_tab_size;
+ }
+ hv[++n]=0;
+ inout[n]=def;
+ pl_tab_size[n]=0;
+ }
+
+ int parse_var
+ (OTL_TMPL_CONNECT* pdb,
+ char* s,
+ int& data_type,
+ int& data_len,
+ char* name)
+ {
+ data_type=otl_var_none;
+ data_len=0;
+#if defined(OTL_BIND_VAR_STRICT_TYPE_CHECKING_ON)
+ char type_arr[256];
+#endif
+ char type=' ';
+ char t2=' ';
+ char t3=' ';
+ char t4=' ';
+ int size=0;
+
+ char *c=name,*c1=s;
+ while(*c1!=' '&&*c1)
+ *c++=*c1++;
+ *c=0;
+ while(*c1==' '&&*c1)
+ ++c1;
+
+#if defined(OTL_BIND_VAR_STRICT_TYPE_CHECKING_ON)
+ char* ct=c1;
+ char* tac=type_arr;
+ size_t ta_len=0;
+ while(*ct && (*ct!='[' && *ct!='(') && ta_len<sizeof(type_arr)){
+ *tac=otl_to_upper(*ct);
+ ++ct;
+ ++tac;
+ ++ta_len;
+ }
+ *tac=0;
+#endif
+ size_t clen=strlen(c1);
+ if(clen>=3){
+ type=otl_to_upper(c1[0]);
+ t2=otl_to_upper(c1[1]);
+ t3=otl_to_upper(c1[2]);
+ t4=otl_to_upper(c1[3]);
+ }
+ if((type=='C'&&t2=='H')||(type=='R'&&t2=='A'&&t3=='W'&&(t4=='['||t4=='('))){
+ char tmp[32];
+ char *t=tmp;
+ while((*c1!='[' && *c1!='(')&&*c1)
+ ++c1;
+ ++c1;
+ while((*c1!=']' && *c1!=')')&&*c1)
+ *t++=*c1++;
+ *t=0;
+ size=atoi(tmp);
+#if defined(OTL_ADD_NULL_TERMINATOR_TO_STRING_SIZE)
+ size+=1;
+#endif
+ }
+
+#if defined(OTL_ORA_UNICODE)
+ if(type=='N'&&t2=='C'&&t3=='H'){
+ char tmp[32];
+ char *t=tmp;
+ while((*c1!='[' && *c1!='(')&&*c1)
+ ++c1;
+ ++c1;
+ while((*c1!=']' && *c1!=')')&&*c1)
+ *t++=*c1++;
+ *t=0;
+ size=atoi(tmp);
+#if defined(OTL_ADD_NULL_TERMINATOR_TO_STRING_SIZE)
+ size+=1;
+#endif
+ }
+#endif
+
+ OTL_CHECK_BIND_VARS
+
+ int rc=1;
+ switch(type){
+ case 'B':
+ if(t2=='L'){
+ data_type=otl_var_blob;
+ if(pdb)
+ data_len=pdb->get_max_long_size();
+ else
+ data_len=0;
+ }
+#if defined(OTL_BIGINT) && \
+ (defined(OTL_ODBC)||defined(OTL_DB2_CLI)||\
+ (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\
+ !defined(OTL_BIGINT_TO_STR)))
+ else if(t2=='I'){
+ data_type=otl_var_bigint;
+ data_len=sizeof(OTL_BIGINT);
+ }
+#elif (defined(OTL_ORA7)||defined(OTL_ORA8)|| \
+ defined(OTL_ORA8I)||defined(OTL_ORA9I)) && \
+ defined(OTL_BIGINT) && defined(OTL_ORA_MAP_BIGINT_TO_LONG)
+ else if(t2=='I'){
+ data_type=otl_var_long_int;
+ data_len=sizeof(long);
+ }
+#elif (defined(OTL_ORA7)||defined(OTL_ORA8)|| \
+ defined(OTL_ORA8I)||defined(OTL_ORA9I)) && \
+ defined(OTL_BIGINT)
+ else if(t2=='I'){
+ data_type=otl_var_char;
+ data_len=otl_bigint_str_size;
+ }
+#endif
+ break;
+ case 'C':
+ if(t2=='H'){
+ data_type=otl_var_char;
+ data_len=size;
+ }else if(t2=='L'){
+ data_type=otl_var_clob;
+ if(pdb)
+ data_len=pdb->get_max_long_size();
+ else
+ data_len=0;
+ }else
+ rc=0;
+ break;
+ case 'D':
+ if(t2=='O'){
+ data_type=otl_var_double;
+ data_len=sizeof(double);
+ }
+ else if(t2=='B'&&t3=='2'){
+ if(t4=='T'){
+ data_type=otl_var_db2time;
+ data_len=sizeof(TTimestampStruct);
+ }
+ else if(t4=='D'){
+ data_type=otl_var_db2date;
+ data_len=sizeof(TTimestampStruct);
+ }else
+ rc=0;
+ }else
+ rc=0;
+ break;
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ case 'N':
+ if(t2=='C'){
+ if(t3=='L'){
+ data_type=otl_var_nclob;
+ if(pdb)
+ data_len=pdb->get_max_long_size();
+ else
+ data_len=0;
+ }else if(t3=='H'){
+ data_type=otl_var_nchar;
+ data_len=size;
+ }
+ }
+ break;
+#endif
+ case 'F':
+ data_type=otl_var_float;
+ data_len=sizeof(float);
+ break;
+ case 'I':
+ data_type=otl_var_int;
+ data_len=sizeof(int);
+ break;
+ case 'U':
+ data_type=otl_var_unsigned_int;
+ data_len=sizeof(unsigned);
+ break;
+ case 'R':
+ if(t2=='E'&&t3=='F'){
+ data_type=otl_var_refcur;
+ data_len=1;
+ }else if(t2=='A'&&t3=='W'&&t4!='_'){
+ data_type=otl_var_raw;
+ data_len=size;
+ }else if(t2=='A'&&t3=='W'&&t4=='_'){
+ data_type=otl_var_raw_long;
+ if(pdb)
+ data_len=pdb->get_max_long_size();
+ else
+ data_len=0;
+ }
+ break;
+ case 'S':
+ data_type=otl_var_short;
+ data_len=sizeof(short);
+ break;
+ case 'L':
+ if(t2=='O'&&t3=='N'){
+ data_type=otl_var_long_int;
+ data_len=sizeof(long);
+ }else if(t2=='T'&&t3=='Z'){
+ data_type=otl_var_ltz_timestamp;
+ data_len=sizeof(TTimestampStruct);
+ }else
+ rc=0;
+ break;
+ case 'T':
+ if(t2=='Z'){
+ data_type=otl_var_tz_timestamp;
+ data_len=sizeof(TTimestampStruct);
+ }else if(t2=='I' && t3=='M'){
+ data_type=otl_var_timestamp;
+ data_len=sizeof(TTimestampStruct);
+ }else
+ rc=0;
+ break;
+ case 'V':
+ data_type=otl_var_varchar_long;
+ if(pdb)
+ data_len=pdb->get_max_long_size();
+ else
+ data_len=0;
+ break;
+ default:
+ return 0;
+ }
+ return rc;
+ }
+
+ otl_tmpl_variable<TVariableStruct>* alloc_var
+ (char* s,
+ const int vstat,
+ const int status,
+ OTL_TMPL_CONNECT& adb,
+ const int apl_tab_size=0)
+ {
+ char name[128];
+#if defined(OTL_BIND_VAR_STRICT_TYPE_CHECKING_ON)
+ char type_arr[256];
+#endif
+ char type=' ';
+ char t2=' ';
+ char t3=' ';
+ char t4=' ';
+ char t5=' ';
+
+ int size=0;
+
+ char *c=name,*c1=s;
+ while(*c1!=' '&&*c1)
+ *c++=*c1++;
+ *c=0;
+ while(*c1==' '&&*c1)
+ ++c1;
+
+#if defined(OTL_BIND_VAR_STRICT_TYPE_CHECKING_ON)
+ char* ct=c1;
+ char* tac=type_arr;
+ size_t ta_len=0;
+ while(*ct && (*ct!='[' && *ct!='(') && ta_len<sizeof(type_arr)){
+ *tac=otl_to_upper(*ct);
+ ++ct;
+ ++tac;
+ ++ta_len;
+ }
+ *tac=0;
+#endif
+ size_t clen=strlen(c1);
+ if(clen>=3){
+ type=otl_to_upper(c1[0]);
+ t2=otl_to_upper(c1[1]);
+ t3=otl_to_upper(c1[2]);
+ t4=otl_to_upper(c1[3]);
+ }
+ if(clen>4)
+ t5=otl_to_upper(c1[4]);
+ if((type=='C'&&t2=='H')||(type=='R'&&t2=='A'&&t3=='W'&&(t4=='['||t4=='('))){
+ char tmp[32];
+ char *t=tmp;
+ while((*c1!='[' && *c1!='(')&&*c1)
+ ++c1;
+ if(*c1)++c1;
+ while((*c1!=']' && *c1!=')')&&*c1)
+ *t++=*c1++;
+ *t=0;
+ if(*tmp==0)
+ // declaration <char> is invalid
+ return 0;
+ size=atoi(tmp);
+#if defined(OTL_ADD_NULL_TERMINATOR_TO_STRING_SIZE)
+ if(type=='C')size+=1;
+#endif
+ if(size<2)
+ // minimum size of <char[XXX]> should be at 2
+ return 0;
+ }
+
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ if(type=='N'&&t2=='C'&&t3=='H'){
+ char tmp[32];
+ char *t=tmp;
+ while((*c1!='[' && *c1!='(')&&*c1)
+ ++c1;
+ if(*c1)++c1;
+ while((*c1!=']' && *c1!=')')&&*c1)
+ *t++=*c1++;
+ *t=0;
+ if(*tmp==0)
+ return 0;
+ size=atoi(tmp);
+#if defined(OTL_ADD_NULL_TERMINATOR_TO_STRING_SIZE)
+ size+=1;
+#endif
+ }
+#endif
+
+
+ if(status==in && (vstat==in||vstat==io))
+ ;
+ else if(status==out && (vstat==out||vstat==io||vstat==def))
+ ;
+ else if(status==def)
+ ;
+ else
+ return 0;
+
+ OTL_CHECK_BIND_VARS
+
+ int pl_tab_flag=0;
+
+ if(apl_tab_size){
+ array_size=apl_tab_size;
+ pl_tab_flag=1;
+ }else
+ array_size=prev_array_size;
+
+ otl_tmpl_variable<TVariableStruct>* v=
+ new otl_tmpl_variable<TVariableStruct>;
+ v->copy_name(name);
+ switch(type){
+ case 'B':
+ if(t2=='L')
+ v->init(false,
+ otl_var_blob,
+ adb.get_max_long_size(),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct());
+#if defined(OTL_BIGINT) && \
+ (defined(OTL_ODBC)||defined(OTL_DB2_CLI)||\
+ (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\
+ !defined(OTL_BIGINT_TO_STR)))
+ else if(t2=='I')
+ v->init(false,
+ otl_var_bigint,sizeof(OTL_BIGINT),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+#elif (defined(OTL_ORA7)||defined(OTL_ORA8)|| \
+ defined(OTL_ORA8I)||defined(OTL_ORA9I)) && \
+ defined(OTL_BIGINT) && defined(OTL_ORA_MAP_BIGINT_TO_LONG)
+ else if(t2=='I')
+ v->init(false,
+ otl_var_long_int,
+ sizeof(long),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),
+ pl_tab_flag);
+#elif (defined(OTL_ORA7)||defined(OTL_ORA8)|| \
+ defined(OTL_ORA8I)||defined(OTL_ORA9I)) && \
+ defined(OTL_BIGINT)
+ else if(t2=='I')
+ v->init(false,
+ otl_var_char,
+ otl_bigint_str_size,
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),
+ pl_tab_flag);
+#endif
+ break;
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ case 'N':
+ if(t2=='C' && (t3=='L'||t3=='H')){
+ if(t3=='L'){
+ v->init(false,otl_var_nclob,
+ adb.get_max_long_size(),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct());
+ v->set_ftype(otl_var_clob);
+ }else if(t3=='H'){
+ v->init(false,otl_var_nchar,
+ size,
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ v->set_ftype(otl_var_char);
+ }
+ }else{
+ delete v;
+ v=0;
+ }
+ break;
+#endif
+ case 'C':
+ if(t2=='H'){
+ v->init(false,otl_var_char,
+ size,
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ if(t5=='Z')
+ v->get_var_struct().set_charz_flag(true);
+ }else if(t2=='L')
+ v->init(false,otl_var_clob,
+ adb.get_max_long_size(),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct());
+ else{
+ delete v;
+ v=0;
+ }
+ break;
+ case 'D':
+ if(t2=='O')
+ v->init(false,otl_var_double,sizeof(double),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ else if(t2=='B'&&t3=='2'){
+ if(t4=='T')
+ v->init(false,otl_var_db2time,sizeof(TTimestampStruct),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ else if(t4=='D')
+ v->init(false,otl_var_db2date,sizeof(TTimestampStruct),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ else{
+ delete v;
+ v=0;
+ }
+ }else{
+ delete v;
+ v=0;
+ }
+ break;
+ case 'F':
+ v->init(false,otl_var_float,
+ sizeof(float),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ break;
+ case 'I':
+ v->init(false,otl_var_int,
+ sizeof(int),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ break;
+ case 'U':
+ v->init(false,otl_var_unsigned_int,
+ sizeof(unsigned),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ break;
+ case 'R':
+ if(t2=='E'&&t3=='F')
+ v->init(false,otl_var_refcur,
+ 1,
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),0);
+ else if(t2=='A'&&t3=='W'&&(t4=='['||t4=='('))
+ v->init(false,otl_var_raw,
+ size,
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ else if(t2=='A'&&t3=='W')
+ v->init(false,otl_var_raw_long,
+ adb.get_max_long_size(),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct());
+ break;
+ case 'S':
+ v->init(false,otl_var_short,
+ sizeof(short),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ break;
+ case 'L':
+ if(t2=='O'&&t3=='N')
+ v->init(false,otl_var_long_int,
+ sizeof(long),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ else if(t2=='T'&&t3=='Z')
+ v->init(false,otl_var_ltz_timestamp,
+ sizeof(TTimestampStruct),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ else{
+ delete v;
+ v=0;
+ }
+ break;
+ case 'T':
+ if(t2=='Z')
+ v->init(false,otl_var_tz_timestamp,sizeof(TTimestampStruct),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ else if(t2=='I' && t3=='M')
+ v->init(false,otl_var_timestamp,sizeof(TTimestampStruct),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct(),pl_tab_flag);
+ else{
+ delete v;
+ v=0;
+ }
+ break;
+ case 'V':
+ v->init(false,otl_var_varchar_long,adb.get_max_long_size(),
+ OTL_SCAST(const otl_stream_buffer_size_type,array_size),
+ &adb.get_connect_struct());
+ break;
+ default:
+ delete v;
+ v=0;
+ break;
+ }
+ return v;
+ }
+
+ void alloc_host_var_list
+ (otl_tmpl_variable<TVariableStruct>** &vl,
+ int& vl_len,
+ OTL_TMPL_CONNECT& adb,
+ const int status=def)
+ {
+ int j;
+ vl_len=0;
+ if(!hv[0]){
+ vl=0;
+ return;
+ }
+ otl_auto_array_ptr<otl_tmpl_variable<TVariableStruct>*>
+ loc_ptr(container_size_);
+ otl_tmpl_variable<TVariableStruct>** tmp_vl=loc_ptr.get_ptr();
+ int i=0;
+ while(hv[i]){
+ otl_tmpl_variable<TVariableStruct>* vp=
+ alloc_var(hv[i],inout[i],status,adb,pl_tab_size[i]);
+ if(vp==0){
+ int j2;
+ for(j2=0;j2<vl_len;++j2)
+ delete tmp_vl[j2];
+ vl_len=0;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_12,
+ otl_error_code_12,
+ stm_label_?stm_label_:stm_text_,
+ hv[i]);
+ }
+ vp->set_name_pos(i+1);
+ if(vp){
+ ++vl_len;
+ tmp_vl[vl_len-1]=vp;
+ }
+ ++i;
+ }
+ if(vl_len>0){
+ vl=new otl_tmpl_variable<TVariableStruct>*[vl_len];
+ for(j=0;j<vl_len;++j)
+ vl[j]=tmp_vl[j];
+ }
+ }
+
+private:
+
+ otl_tmpl_ext_hv_decl
+ (const otl_tmpl_ext_hv_decl
+ <TVariableStruct,
+ TTimestampStruct,
+ TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>&):
+ hv(0),
+ inout(0),
+ pl_tab_size(0),
+ array_size(0),
+ prev_array_size(0),
+ vst(),
+ len(0),
+ stm_text_(0),
+ stm_label_(0),
+ container_size_(0),
+ has_plsql_tabs_or_refcur_(0)
+ {
+ }
+
+otl_tmpl_ext_hv_decl
+ <TVariableStruct,
+ TTimestampStruct,
+ TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>&
+operator=
+(const otl_tmpl_ext_hv_decl
+ <TVariableStruct,
+ TTimestampStruct,
+ TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>&)
+ {
+ return *this;
+ }
+
+};
+
+template <OTL_TYPE_NAME TExceptionStruct,
+ OTL_TYPE_NAME TConnectStruct,
+ OTL_TYPE_NAME TCursorStruct,
+ OTL_TYPE_NAME TVariableStruct,
+ OTL_TYPE_NAME TSelectCursorStruct>
+class otl_tmpl_select_cursor: public OTL_TMPL_CURSOR{
+
+protected:
+
+ int cur_row;
+ int cur_size;
+ int row_count;
+ int array_size;
+ int prefetch_array_size;
+
+ TSelectCursorStruct select_cursor_struct;
+ otl_select_struct_override local_override;
+ void* master_stream_ptr_;
+
+public:
+
+ otl_tmpl_select_cursor
+ (OTL_TMPL_CONNECT& pdb,
+ void* master_stream_ptr,
+ const otl_stream_buffer_size_type arr_size=1,
+ const char* sqlstm_label=0):
+ OTL_TMPL_CURSOR(pdb),
+ cur_row(-1),
+ cur_size(0),
+ row_count(0),
+ array_size(0),
+ prefetch_array_size(0),
+ select_cursor_struct(),
+ local_override(),
+ master_stream_ptr_(master_stream_ptr)
+ {
+ local_override.reset();
+ if(sqlstm_label!=0){
+ if(this->stm_label!=0){
+ delete[] this->stm_label;
+ this->stm_label=0;
+ }
+ size_t len=strlen(sqlstm_label)+1;
+ this->stm_label=new char[len];
+ OTL_STRCPY_S(this->stm_label,len,sqlstm_label);
+ }
+ select_cursor_struct.set_arr_size
+ (arr_size,
+ array_size,
+ prefetch_array_size);
+ select_cursor_struct.init(array_size);
+ }
+
+ otl_tmpl_select_cursor()
+ : OTL_TMPL_CURSOR(),
+ master_stream_ptr_(0)
+ {
+ }
+
+ void open
+ (OTL_TMPL_CONNECT& db,
+ otl_stream_buffer_size_type arr_size=1)
+ {
+ local_override.reset();
+ cur_row=-1;
+ row_count=0;
+ cur_size=0;
+ array_size=arr_size;
+ OTL_TMPL_CURSOR::open(db);
+ }
+
+ void close(void)
+ {
+ local_override.reset();
+ OTL_TMPL_CURSOR::close();
+ }
+
+ int first(void)
+ {
+ if(!OTL_TMPL_CURSOR::connected)return 0;
+ select_cursor_struct.set_prefetch_size(prefetch_array_size);
+ int rc=select_cursor_struct.first
+ (this->cursor_struct,
+ cur_row,cur_size,
+ row_count,
+ this->eof_data,
+ array_size);
+ OTL_TRACE_FIRST_FETCH
+ if(!rc){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw OTL_TMPL_EXCEPTION
+ (this->cursor_struct,
+ this->stm_label?
+ this->stm_label:
+ this->stm_text);
+ }
+ return cur_size!=0;
+ }
+
+ int next_throw(void)
+ {
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+
+ throw OTL_TMPL_EXCEPTION
+ (this->cursor_struct,
+ this->stm_label?
+ this->stm_label:
+ this->stm_text);
+ }
+
+ int next(void)
+ {
+ if(!this->connected)return 0;
+ if(cur_row==-1)return first();
+ int rc=select_cursor_struct.next
+ (this->cursor_struct,
+ cur_row,cur_size,
+ row_count,
+ this->eof_data,
+ array_size);
+ if(!rc){
+ return next_throw();
+ }
+ OTL_TRACE_NEXT_FETCH
+ return cur_size!=0;
+ }
+
+private:
+
+ otl_tmpl_select_cursor
+ (const otl_tmpl_select_cursor&):
+ OTL_TMPL_CURSOR(),
+ cur_row(-1),
+ cur_size(0),
+ row_count(0),
+ array_size(0),
+ prefetch_array_size(0),
+ select_cursor_struct(),
+ local_override()
+ {
+ }
+
+ otl_tmpl_select_cursor& operator=
+ (const otl_tmpl_select_cursor&)
+ {
+ return *this;
+ }
+
+};
+
+#if defined(OTL_ORA8)||defined(OTL_ODBC)
+
+const int otl_lob_stream_read_mode=1;
+const int otl_lob_stream_write_mode=2;
+const int otl_lob_stream_zero_mode=3;
+
+const int otl_lob_stream_first_piece=1;
+const int otl_lob_stream_next_piece=2;
+const int otl_lob_stream_last_piece=3;
+
+class otl_lob_stream_generic{
+protected:
+
+ int mode;
+ int retcode;
+ int ndx;
+ int offset;
+ int lob_len;
+ int in_destructor;
+ int eof_flag;
+ int lob_is_null;
+ bool ora_lob;
+
+public:
+
+ int get_ora_lob() const {return ora_lob;}
+
+
+ otl_lob_stream_generic(const bool aora_lob=true):
+ mode(0),
+ retcode(0),
+ ndx(0),
+ offset(0),
+ lob_len(0),
+ in_destructor(0),
+ eof_flag(0),
+ lob_is_null(0),
+ ora_lob(aora_lob)
+ {
+ }
+
+ virtual ~otl_lob_stream_generic(){}
+
+ virtual void init
+ (void* avar,void* aconnect,void* acursor,int andx,
+ int amode,const int alob_is_null=0) = 0;
+ virtual void set_len(const int new_len=0) = 0;
+ virtual otl_lob_stream_generic& operator<<(const otl_long_string& s) = 0;
+ virtual otl_lob_stream_generic& operator>>(otl_long_string& s) = 0;
+#if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_UNICODE)
+ virtual otl_lob_stream_generic& operator<<(const OTL_STRING_CONTAINER& s) = 0;
+ virtual otl_lob_stream_generic& operator>>(OTL_STRING_CONTAINER& s) = 0;
+ virtual void setStringBuffer(const int chunk_size) = 0;
+#endif
+
+ virtual int eof(void) = 0;
+ virtual int len(void) = 0;
+ virtual bool is_initialized(void) = 0;
+ virtual void close(void) = 0;
+
+private:
+
+ otl_lob_stream_generic(const otl_lob_stream_generic&):
+ mode(0),
+ retcode(0),
+ ndx(0),
+ offset(0),
+ lob_len(0),
+ in_destructor(0),
+ eof_flag(0),
+ lob_is_null(0),
+ ora_lob(false)
+ {
+ }
+
+ otl_lob_stream_generic& operator=(const otl_lob_stream_generic&)
+ {
+ return *this;
+ }
+
+};
+
+#endif
+
+#if defined(__GNUC__) || defined(__SUNPRO_CC) || \
+ (defined(_MSC_VER) && (_MSC_VER <= 1300)) || \
+ defined(__HP_aCC) || defined(__BORLANDC__) || \
+ ((defined(__IBMC__) || defined(__IBMCPP__)) && defined(__xlC__))
+ // Enable the kludge for compilers that do not support template
+ // member functions at all, or have bugs: g++, Forte C++ (Solaris),
+ // Visual C++ 6.0, Visual C++ 7.0, xlC v6, etc.
+#if !defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+#define OTL_NO_TMPL_MEMBER_FUNC_SUPPORT
+#endif
+#endif
+
+template <OTL_TYPE_NAME TExceptionStruct,
+ OTL_TYPE_NAME TConnectStruct,
+ OTL_TYPE_NAME TCursorStruct,
+ OTL_TYPE_NAME TVariableStruct,
+ OTL_TYPE_NAME TSelectCursorStruct,
+ OTL_TYPE_NAME TTimestampStruct>
+class otl_tmpl_select_stream: public OTL_TMPL_SELECT_CURSOR{
+
+protected:
+
+ otl_column_desc* sl_desc;
+ otl_tmpl_variable<TVariableStruct>* sl;
+ int sl_len;
+ int null_fetched;
+ int cur_col;
+ int cur_in;
+ int executed;
+ int eof_status;
+ char var_info[256];
+ otl_select_struct_override* override;
+ int delay_next;
+ bool lob_stream_mode;
+ long _rfc;
+
+public:
+
+ int get_select_row_count() const
+ {
+ return this->cur_row==-1?0:this->cur_size-this->cur_row;
+ }
+
+ int get_prefetched_row_count() const {return this->row_count;}
+ int get_row_count() const {return this->row_count;}
+ int get_sl_len() const {return sl_len;}
+ otl_tmpl_variable<TVariableStruct>* get_sl(){return sl;}
+ otl_column_desc* get_sl_desc(){return sl_desc;}
+ long get_rfc() const {return _rfc;}
+
+ void cleanup(void)
+ {int i;
+ delete[] sl;
+ for(i=0;i<this->vl_len;++i)
+ delete this->vl[i];
+ delete[] this->vl;
+ delete[] sl_desc;
+ }
+
+ virtual ~otl_tmpl_select_stream()
+ {
+ cleanup();
+ }
+
+ otl_tmpl_select_stream
+ (otl_select_struct_override* aoverride,
+ const otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ OTL_TMPL_CONNECT& pdb,
+ const int implicit_select=otl_explicit_select,
+ const char* sqlstm_label=0)
+ : OTL_TMPL_SELECT_CURSOR
+ (pdb,
+ aoverride->get_master_stream_ptr(),
+ arr_size,sqlstm_label),
+ sl_desc(0),
+ sl(0),
+ sl_len(0),
+ null_fetched(0),
+ cur_col(0),
+ cur_in(0),
+ executed(0),
+ eof_status(0),
+ var_info(),
+ override(0),
+ delay_next(0),
+ lob_stream_mode(false),
+ _rfc(0)
+ {
+ int i;
+ this->select_cursor_struct.set_select_type(implicit_select);
+ sl=0;
+ sl_len=0;
+ _rfc=0;
+ null_fetched=0;
+ lob_stream_mode=aoverride->get_lob_stream_mode();
+ this->retcode=0;
+ sl_desc=0;
+ executed=0;
+ cur_in=0;
+ this->stm_text=0;
+ eof_status=1;
+ override=aoverride;
+
+ {
+ size_t len=strlen(sqlstm)+1;
+ this->stm_text=new char[len];
+ OTL_STRCPY_S(this->stm_text,len,sqlstm);
+ otl_select_struct_override* temp_local_override=&this->local_override;
+ otl_tmpl_ext_hv_decl
+ <TVariableStruct,TTimestampStruct,TExceptionStruct,
+ TConnectStruct,TCursorStruct> hvd
+ (this->stm_text,
+ 1,
+ this->stm_label,
+ &temp_local_override,
+ &pdb
+ );
+ hvd.alloc_host_var_list(this->vl,this->vl_len,pdb);
+ }
+
+ try{
+ this->parse();
+ if(!this->select_cursor_struct.get_implicit_cursor()){
+ get_select_list();
+ bind_all();
+ }else{
+ for(i=0;i<this->vl_len;++i)
+ this->bind(*this->vl[i]);
+ }
+ if(this->vl_len==0){
+ rewind();
+ null_fetched=0;
+ }
+ }catch(OTL_CONST_EXCEPTION OTL_TMPL_EXCEPTION&){
+ cleanup();
+ if(this->adb)this->adb->increment_throw_count();
+ throw;
+ }
+
+ }
+
+ void rewind(void)
+ {
+ OTL_TRACE_STREAM_EXECUTION
+ int i;
+ _rfc=0;
+ if(!this->select_cursor_struct.close_select(this->cursor_struct)){
+ throw OTL_TMPL_EXCEPTION
+ (this->cursor_struct,
+ this->stm_label?this->stm_label:this->stm_text);
+ }
+ if(this->select_cursor_struct.get_implicit_cursor()){
+ this->exec(1,0,otl_sql_exec_from_select_cursor_class);
+ if(sl){
+ delete[] sl;
+ sl=0;
+ }
+ get_select_list();
+ for(i=0;i<sl_len;++i)this->bind(sl[i]);
+ }
+ eof_status=this->first();
+ null_fetched=0;
+ cur_col=-1;
+ cur_in=0;
+ executed=1;
+ delay_next=0;
+ }
+
+ void clean(void)
+ {
+ _rfc=0;
+ this->cursor_struct.set_canceled(false);
+ null_fetched=0;
+ cur_col=-1;
+ cur_in=0;
+ executed=0;
+ eof_status=0;
+ delay_next=0;
+ this->cur_row=-1;
+ this->row_count=0;
+ this->cur_size=0;
+ if(!this->select_cursor_struct.close_select(this->cursor_struct)){
+ throw OTL_TMPL_EXCEPTION
+ (this->cursor_struct,
+ this->stm_label?this->stm_label:this->stm_text);
+ }
+ }
+
+ int is_null(void)
+ {
+ return null_fetched;
+ }
+
+ int eof(void)
+ {
+ if(delay_next){
+ look_ahead();
+ delay_next=0;
+ }
+ return !eof_status;
+ }
+
+ int eof_intern(void)
+ {
+ return !eof_status;
+ }
+
+
+ void skip_to_end_of_row()
+ {
+ check_if_executed();
+ if(eof_intern())return;
+ while(cur_col<sl_len-1){
+ ++cur_col;
+ null_fetched=sl[cur_col].is_null(this->cur_row);
+ }
+ eof_status=this->next();
+ cur_col=0;
+ if(!eof_intern())
+ cur_col=-1;
+ ++_rfc;
+ }
+
+ void bind_all(void)
+ {int i;
+ for(i=0;i<this->vl_len;++i)this->bind(*this->vl[i]);
+ for(i=0;i<sl_len;++i)this->bind(sl[i]);
+ }
+
+ void get_select_list(void)
+ {
+ int j;
+ otl_auto_array_ptr<otl_column_desc> loc_ptr(otl_var_list_size);
+ otl_column_desc* sl_desc_tmp=loc_ptr.get_ptr();
+ int sld_tmp_len=0;
+ int ftype,elem_size,i;
+ for(i=1;this->describe_column(sl_desc_tmp[i-1],i);++i){
+ int temp_code_type=
+ otl_tmpl_variable<TVariableStruct>::int2ext
+ (sl_desc_tmp[i-1].dbtype);
+ if(temp_code_type==otl_unsupported_type){
+ otl_var_info_col3
+ (i-1,
+ sl_desc_tmp[i-1].dbtype,
+ sl_desc_tmp[i-1].name,
+ this->var_info,
+ sizeof(this->var_info));
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_27,
+ otl_error_code_27,
+ this->stm_label?
+ this->stm_label:
+ this->stm_text,
+ this->var_info);
+ }
+ ++sld_tmp_len;
+ if(sld_tmp_len==loc_ptr.get_arr_size()){
+ loc_ptr.double_size();
+ sl_desc_tmp=loc_ptr.get_ptr();
+ }
+ }
+ sl_len=sld_tmp_len;
+ if(sl){
+ delete[] sl;
+ sl=0;
+ }
+ sl=new otl_tmpl_variable<TVariableStruct>[sl_len==0?1:sl_len];
+ int max_long_size=this->adb->get_max_long_size();
+ for(j=0;j<sl_len;++j){
+ otl_tmpl_variable<TVariableStruct>::map_ftype
+ (sl_desc_tmp[j],
+ max_long_size,
+ ftype,
+ elem_size,
+ this->local_override.getLen()>0?this->local_override:*override,
+ j+1,
+ this->adb->get_connect_struct().get_connection_type());
+ sl[j].copy_pos(j+1);
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ if(sl_desc_tmp[j].charset_form==2)
+ sl[j].get_var_struct().set_nls_flag(true);
+#endif
+ sl[j].init(true,
+ ftype,
+ elem_size,
+ OTL_SCAST(otl_stream_buffer_size_type,(this->array_size)),
+ &this->adb->get_connect_struct()
+ );
+ sl[j].get_var_struct().set_lob_stream_mode(this->lob_stream_mode);
+ }
+ if(sl_desc){
+ delete[] sl_desc;
+ sl_desc=0;
+ }
+ sl_desc=new otl_column_desc[sl_len==0?1:sl_len];
+ for(j=0;j<sl_len;++j)
+ sl_desc[j]=sl_desc_tmp[j];
+ }
+
+ void check_if_executed_throw(void)
+ {
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_2,
+ otl_error_code_2,
+ this->stm_label?
+ this->stm_label:
+ this->stm_text,
+ 0);
+ }
+
+ void check_if_executed(void)
+ {
+ if(!executed){
+ check_if_executed_throw();
+ }
+ }
+
+ int check_type_throw(int type_code,int actual_data_type)
+ {
+ int out_type_code;
+ if(actual_data_type!=0)
+ out_type_code=actual_data_type;
+ else
+ out_type_code=type_code;
+ otl_var_info_col
+ (sl[cur_col].get_pos(),
+ sl[cur_col].get_ftype(),
+ out_type_code,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_0,
+ otl_error_code_0,
+ this->stm_label?
+ this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ void strict_check_throw(int type_code)
+ {
+ otl_var_info_col
+ (sl[cur_col].get_pos(),
+ sl[cur_col].get_ftype(),
+ type_code,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_0,
+ otl_error_code_0,
+ this->stm_label?
+ this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+#endif
+
+ int check_type(int type_code,int actual_data_type=0)
+ {
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_timestamp:
+ case otl_var_tz_timestamp:
+ case otl_var_ltz_timestamp:
+ if(type_code==otl_var_timestamp)
+ return 1;
+ default:
+ if(sl[cur_col].get_ftype()==type_code)
+ return 1;
+ }
+ return check_type_throw(type_code,actual_data_type);
+ }
+
+ void get_next(void)
+ {
+ if(cur_col<sl_len-1){
+ ++cur_col;
+ null_fetched=sl[cur_col].is_null(this->cur_row);
+ }else{
+ eof_status=this->next();
+ cur_col=0;
+ }
+ }
+
+ void look_ahead(void)
+ {
+ if(cur_col==sl_len-1){
+ eof_status=this->next();
+ cur_col=-1;
+ ++_rfc;
+ }
+ }
+
+ OTL_TMPL_SELECT_STREAM& operator>>(char& c)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ c=*OTL_RCAST(char*,sl[cur_col].val(this->cur_row));
+ look_ahead();
+ }
+ return *this;
+ }
+
+ OTL_TMPL_SELECT_STREAM& operator>>(unsigned char& c)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ c=*OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row));
+ look_ahead();
+ }
+ return *this;
+ }
+
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ OTL_TMPL_SELECT_STREAM& operator>>(OTL_STRING_CONTAINER& s)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_char:
+ if(!eof_intern()){
+#if defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,sl[cur_col].val(this->cur_row)),1);
+#else
+ s=OTL_RCAST(char*,sl[cur_col].val(this->cur_row));
+#endif
+ look_ahead();
+ }
+ break;
+#if defined(OTL_USER_DEFINED_STRING_CLASS_ON) || \
+ defined(OTL_STL) || defined(OTL_ACE)
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ if(!eof_intern()){
+ unsigned char* c=OTL_RCAST(unsigned char*,
+ sl[cur_col].val(this->cur_row));
+ int len=sl[cur_col].get_len(this->cur_row);
+ int buf_sz=sl[cur_col].get_elem_size();
+ if(len>buf_sz)len=buf_sz;
+
+#if (defined(OTL_USER_DEFINED_STRING_CLASS_ON) || defined(OTL_STL)) \
+ && !defined(OTL_ACE)
+ s.assign(OTL_RCAST(char*,c),len);
+#elif defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,c),len,1);
+#endif
+ look_ahead();
+ }
+ break;
+ case otl_var_blob:
+ case otl_var_clob:
+ if(!eof_intern()){
+ int len=0;
+ int max_long_sz=this->adb->get_max_long_size();
+ otl_auto_array_ptr<unsigned char> loc_ptr(max_long_sz);
+ unsigned char* temp_buf=loc_ptr.get_ptr();
+ int rc=sl[cur_col].get_var_struct().get_blob
+ (this->cur_row,
+ temp_buf,
+ max_long_sz,
+ len);
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+#if (defined(OTL_USER_DEFINED_STRING_CLASS_ON) || \
+ defined(OTL_STL)) && !defined(OTL_ACE)
+ s.assign(OTL_RCAST(char*,temp_buf),len);
+#elif defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,temp_buf),len,1);
+#endif
+ look_ahead();
+ }
+ break;
+#endif
+ default:
+ check_type(otl_var_char);
+ } // switch
+ return *this;
+ }
+#endif
+
+ OTL_TMPL_SELECT_STREAM& operator>>(char* s)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,sl[cur_col].val(this->cur_row))
+ );
+ look_ahead();
+ }
+ return *this;
+ }
+
+#if defined(OTL_UNICODE_STRING_TYPE)
+ OTL_TMPL_SELECT_STREAM& operator<<(const OTL_UNICODE_STRING_TYPE& s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy4
+ (OTL_RCAST(unsigned char*,this->vl[cur_in]->val()),
+ OTL_RCAST(unsigned char*,
+ OTL_CCAST(OTL_UNICODE_CHAR_TYPE*,s.c_str())),
+ overflow,
+ this->vl[cur_in]->get_elem_size(),
+ OTL_SCAST(int,s.length())
+ );
+ if(overflow){
+ char temp_var_info[256];
+ otl_var_info_var
+ (this->vl[cur_in]->get_name(),
+ this->vl[cur_in]->get_ftype(),
+ otl_var_char,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_4,
+ otl_error_code_4,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ temp_var_info);
+ }
+ this->vl[cur_in]->set_not_null(0);
+ }
+ get_in_next();
+ return *this;
+ }
+
+#endif
+
+#if defined(OTL_UNICODE_STRING_TYPE)
+ OTL_TMPL_SELECT_STREAM& operator>>(OTL_UNICODE_STRING_TYPE& s)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_char:
+ if(!eof_intern()){
+#if defined(OTL_ODBC) || defined(DB2_CLI)
+ s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row));
+#else
+
+#if defined(OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR)
+ OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST
+ (OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row));
+ OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR(s,temp_s+1,*temp_s);
+#else
+ OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST
+ (OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row));
+ s.assign(temp_s+1,*temp_s);
+#endif
+
+#endif
+ look_ahead();
+ }
+ break;
+ case otl_var_varchar_long:
+ if(!eof_intern()){
+ s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row));
+ look_ahead();
+ }
+ break;
+ case otl_var_clob:
+ if(!eof_intern()){
+ int len=0;
+ int max_long_sz=this->adb->get_max_long_size();
+ otl_auto_array_ptr<unsigned short> loc_ptr(max_long_sz);
+ unsigned char* temp_buf=OTL_RCAST(unsigned char*,loc_ptr.get_ptr());
+
+ int rc=sl[cur_col].get_var_struct().get_blob
+ (this->cur_row,
+ temp_buf,
+ max_long_sz,
+ len);
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,temp_buf);
+ look_ahead();
+ }
+ break;
+ default:
+ check_type(otl_var_char);
+ }
+ return *this;
+ }
+#endif
+
+ OTL_TMPL_SELECT_STREAM& operator>>(unsigned char* s)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ otl_strcpy2(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row)),
+ sl[cur_col].get_len(this->cur_row)
+ );
+ look_ahead();
+ }
+ return *this;
+ }
+
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+#define OTL_D1(T,T_type) \
+ OTL_TMPL_SELECT_STREAM& operator>>(T& n) \
+ { \
+ check_if_executed(); \
+ if(eof_intern())return *this; \
+ get_next(); \
+ if(!eof_intern()){ \
+ int match_found=otl_numeric_convert_T<T,T_type> \
+ (sl[cur_col].get_ftype(), \
+ sl[cur_col].val(this->cur_row), \
+ n); \
+ if(!match_found) \
+ strict_check_throw(T_type); \
+ look_ahead(); \
+ } \
+ return *this; \
+ }
+#else
+#define OTL_D1(T,T_type) \
+ OTL_TMPL_SELECT_STREAM& operator>>(T& n) \
+ { \
+ check_if_executed(); \
+ if(eof_intern())return *this; \
+ get_next(); \
+ if(!eof_intern()){ \
+ int match_found=otl_numeric_convert_T \
+ (sl[cur_col].get_ftype(), \
+ sl[cur_col].val(this->cur_row), \
+ n); \
+ if(!match_found){ \
+ if(check_type(otl_var_double,T_type)) \
+ n=OTL_PCONV(T,double,sl[cur_col].val(this->cur_row)); \
+ } \
+ look_ahead(); \
+ } \
+ return *this; \
+ }
+#endif
+
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+
+ OTL_D1(int,otl_var_int)
+#if defined(OTL_BIGINT)
+ OTL_D1(OTL_BIGINT,otl_var_bigint)
+#endif
+ OTL_D1(unsigned,otl_var_unsigned_int)
+ OTL_D1(long,otl_var_long_int)
+ OTL_D1(short,otl_var_short)
+ OTL_D1(float,otl_var_float)
+ OTL_D1(double,otl_var_double)
+
+#else
+ template<OTL_TYPE_NAME T,const int T_type> OTL_D1(T,T_type)
+#endif
+
+ OTL_TMPL_SELECT_STREAM& operator>>(TTimestampStruct& t)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_timestamp)&&!eof_intern()){
+ TTimestampStruct* tm=
+ OTL_RCAST(TTimestampStruct*,sl[cur_col].val(this->cur_row));
+ int rc=sl[cur_col].get_var_struct().read_dt
+ (&t,tm,sizeof(TTimestampStruct));
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ look_ahead();
+ }
+ return *this;
+ }
+
+ OTL_TMPL_SELECT_STREAM& operator>>(otl_long_string& s)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_raw_long:
+ {
+ if(!eof_intern()){
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row));
+ int len2=sl[cur_col].get_len(this->cur_row);
+ if(len2>s.get_buf_size())
+ len2=s.get_buf_size();
+ otl_memcpy(s.v,c,len2,sl[cur_col].get_ftype());
+ s.set_len(len2);
+ look_ahead();
+ }
+ }
+ break;
+ case otl_var_varchar_long:
+ {
+ if(!eof_intern()){
+ if(sl[cur_col].get_var_struct().get_otl_adapter()==otl_ora8_adapter){
+#if defined(OTL_UNICODE)
+ int len2=0;
+ OTL_CHAR* source=OTL_RCAST(OTL_CHAR*,sl[cur_col].val(this->cur_row));
+ OTL_CHAR* target=OTL_RCAST(OTL_CHAR*,s.v);
+ while(*source && len2<s.get_buf_size()){
+ *target++=*source++;
+ ++len2;
+ }
+ s.null_terminate_string(len2);
+ s.set_len(len2);
+ look_ahead();
+#else
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row));
+ int len2=sl[cur_col].get_len(this->cur_row);
+ if(len2>s.get_buf_size())
+ len2=s.get_buf_size();
+ otl_memcpy(s.v,c,len2,sl[cur_col].get_ftype());
+ s.null_terminate_string(len2);
+ s.set_len(len2);
+ look_ahead();
+#endif
+ }else{
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row));
+ int len2=sl[cur_col].get_len(this->cur_row);
+ if(len2>s.get_buf_size())
+ len2=s.get_buf_size();
+ otl_memcpy(s.v,c,len2,sl[cur_col].get_ftype());
+ s.null_terminate_string(len2);
+ s.set_len(len2);
+ look_ahead();
+ }
+ }
+ }
+ break;
+ case otl_var_raw:
+ {
+ if(!eof_intern()){
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row));
+ if(sl[cur_col].get_var_struct().get_otl_adapter()==otl_ora7_adapter||
+ sl[cur_col].get_var_struct().get_otl_adapter()==otl_ora8_adapter){
+ int len2=OTL_SCAST(int,*OTL_RCAST(unsigned short*,c));
+ otl_memcpy(s.v,c+sizeof(short int),len2,sl[cur_col].get_ftype());
+ s.set_len(len2);
+ }else{
+ int len2=sl[cur_col].get_len(this->cur_row);
+ if(len2>s.get_buf_size())
+ len2=s.get_buf_size();
+ otl_memcpy(s.v,c,len2,sl[cur_col].get_ftype());
+ s.set_len(len2);
+ }
+ look_ahead();
+ }
+ }
+ break;
+ case otl_var_blob:
+ case otl_var_clob:
+ {
+ if(!eof_intern()){
+ int len=0;
+ int rc=sl[cur_col].get_var_struct().get_blob
+ (this->cur_row,s.v,s.get_buf_size(),len);
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ if(len>s.get_buf_size())
+ len=s.get_buf_size();
+ s.set_len(len);
+ if(sl[cur_col].get_ftype()==otl_var_clob)
+ s.null_terminate_string(len);
+ look_ahead();
+ }
+ }
+ break;
+ default:
+ {
+ char tmp_var_info[256];
+ otl_var_info_col
+ (sl[cur_col].get_pos(),
+ sl[cur_col].get_ftype(),
+ otl_var_long_string,
+ tmp_var_info,
+ sizeof(tmp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_0,
+ otl_error_code_0,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ tmp_var_info);
+ }
+ }
+ return *this;
+ }
+
+#if defined(OTL_ORA8)||defined(OTL_ODBC)
+ OTL_TMPL_SELECT_STREAM& operator>>
+ (otl_lob_stream_generic& s)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(s.get_ora_lob() &&
+ (sl[cur_col].get_ftype()==otl_var_blob||
+ sl[cur_col].get_ftype()==otl_var_clob)&&
+ !eof_intern()){
+ s.init
+ (OTL_RCAST(void*,&sl[cur_col]),
+ OTL_RCAST(void*,this->adb),
+ OTL_RCAST(void*,this),
+ this->cur_row,
+ otl_lob_stream_read_mode,
+ this->is_null());
+ delay_next=1;
+ }else if((sl[cur_col].get_ftype()==otl_var_varchar_long||
+ sl[cur_col].get_ftype()==otl_var_raw_long)&&
+ !eof_intern()){
+ s.init
+ (OTL_RCAST(void*,&sl[cur_col]),
+ OTL_RCAST(void*,this->adb),
+ OTL_RCAST(void*,this),
+ this->cur_row,
+ otl_lob_stream_read_mode);
+ delay_next=1;
+ }else{
+ char tmp_var_info[256];
+ otl_var_info_col
+ (sl[cur_col].get_pos(),
+ sl[cur_col].get_ftype(),
+ otl_var_long_string,
+ tmp_var_info,
+ sizeof(tmp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_0,
+ otl_error_code_0,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ tmp_var_info);
+ }
+ return *this;
+ }
+#endif
+
+ int check_in_type_throw(int type_code)
+ {
+ otl_var_info_var
+ (this->vl[cur_in]->get_name(),
+ this->vl[cur_in]->get_ftype(),
+ type_code,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_0,
+ otl_error_code_0,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+
+ int check_in_type(int type_code,int tsize)
+ {
+ switch(this->vl[cur_in]->get_ftype()){
+ case otl_var_char:
+ if(type_code==otl_var_char)
+ return 1;
+ case otl_var_db2date:
+ case otl_var_db2time:
+ case otl_var_timestamp:
+ case otl_var_tz_timestamp:
+ case otl_var_ltz_timestamp:
+ if(type_code==otl_var_timestamp)
+ return 1;
+ default:
+ if(this->vl[cur_in]->get_ftype()==type_code &&
+ this->vl[cur_in]->get_elem_size()==tsize)
+ return 1;
+ }
+ return check_in_type_throw(type_code);
+ }
+
+ void check_in_var_throw(void)
+ {
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_1,
+ otl_error_code_1,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ 0);
+ }
+
+ void check_in_var(void)
+ {
+ if(this->vl_len==0)
+ check_in_var_throw();
+ }
+
+ void get_in_next(void)
+ {
+ if(cur_in==this->vl_len-1)
+ rewind();
+ else{
+ ++cur_in;
+ executed=0;
+ }
+ }
+
+ OTL_TMPL_SELECT_STREAM& operator<<(const otl_null& /* n */)
+ {
+ check_in_var();
+ this->vl[cur_in]->set_null(0);
+ get_in_next();
+ return *this;
+ }
+
+ OTL_TMPL_SELECT_STREAM& operator<<(const char c)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+ char* tmp=OTL_RCAST(char*,this->vl[cur_in]->val());
+ tmp[0]=c;
+ tmp[1]=0;
+ this->vl[cur_in]->set_not_null(0);
+ }
+ get_in_next();
+ return *this;
+ }
+
+ OTL_TMPL_SELECT_STREAM& operator<<(const unsigned char c)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+ unsigned char* tmp=
+ OTL_RCAST(unsigned char*,this->vl[cur_in]->val());
+ tmp[0]=c;
+ tmp[1]=0;
+ this->vl[cur_in]->set_not_null(0);
+ }
+ get_in_next();
+ return *this;
+ }
+
+ OTL_TMPL_SELECT_STREAM& operator<<(const char* s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy
+ (OTL_RCAST(unsigned char*,this->vl[cur_in]->val()),
+ OTL_RCAST(unsigned char*,OTL_CCAST(char*,s)),
+ overflow,
+ this->vl[cur_in]->get_elem_size()
+ );
+ if(overflow){
+ char tmp_var_info[256];
+ otl_var_info_var
+ (this->vl[cur_in]->get_name(),
+ this->vl[cur_in]->get_ftype(),
+ otl_var_char,
+ tmp_var_info,
+ sizeof(tmp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_4,
+ otl_error_code_4,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ tmp_var_info);
+ }
+
+ this->vl[cur_in]->set_not_null(0);
+
+ }
+ get_in_next();
+ return *this;
+ }
+
+ OTL_TMPL_SELECT_STREAM& operator<<(const otl_long_string& s)
+ {
+ check_in_var();
+ switch(this->vl[cur_in]->get_ftype()){
+ case otl_var_varchar_long:
+ {
+ unsigned char* c=OTL_RCAST(unsigned char*,this->vl[cur_in]->val(0));
+ int len=OTL_CCAST(otl_long_string*,&s)->len();
+ this->vl[cur_in]->set_not_null(0);
+ if(len>this->vl[cur_in]->actual_elem_size()){
+ otl_var_info_var
+ (this->vl[cur_in]->get_name(),
+ this->vl[cur_in]->get_ftype(),
+ otl_var_long_string,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_5,
+ otl_error_code_5,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ otl_memcpy(c,s.v,len,this->vl[cur_in]->get_ftype());
+ this->vl[cur_in]->set_len(len,0);
+ }
+ break;
+ case otl_var_raw_long:
+ {
+ unsigned char* c=OTL_RCAST(unsigned char*,this->vl[cur_in]->val(0));
+ int len=OTL_CCAST(otl_long_string*,&s)->len();
+ if(len>this->vl[cur_in]->actual_elem_size()){
+ otl_var_info_var
+ (this->vl[cur_in]->get_name(),
+ this->vl[cur_in]->get_ftype(),
+ otl_var_char,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_5,
+ otl_error_code_5,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ this->vl[cur_in]->set_not_null(0);
+ otl_memcpy(c,s.v,len,this->vl[cur_in]->get_ftype());
+ this->vl[cur_in]->set_len(len,0);
+ }
+ break;
+ case otl_var_raw:
+ {
+ unsigned char* c=OTL_RCAST(unsigned char*,this->vl[cur_in]->val(0));
+ int len=OTL_CCAST(otl_long_string*,&s)->len();
+ if(len>this->vl[cur_in]->actual_elem_size()){
+ otl_var_info_var
+ (this->vl[cur_in]->get_name(),
+ this->vl[cur_in]->get_ftype(),
+ otl_var_raw,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_5,
+ otl_error_code_5,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ this->vl[cur_in]->set_not_null(0);
+ if((this->vl[cur_in]->get_var_struct().get_otl_adapter()==otl_ora7_adapter||
+ this->vl[cur_in]->get_var_struct().get_otl_adapter()==otl_ora8_adapter) &&
+ this->vl[cur_in]->get_ftype()==otl_var_raw){
+ otl_memcpy
+ (c+sizeof(unsigned short),
+ s.v,
+ len,
+ this->vl[cur_in]->get_ftype());
+ *OTL_RCAST(unsigned short*,
+ this->vl[cur_in]->val(0))=OTL_SCAST(unsigned short,len);
+ this->vl[cur_in]->set_len(len,0);
+ }else{
+ otl_memcpy(c,s.v,len,this->vl[cur_in]->get_ftype());
+ this->vl[cur_in]->set_len(len,0);
+ }
+ }
+ break;
+ }
+ get_in_next();
+ return *this;
+ }
+
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ OTL_TMPL_SELECT_STREAM& operator<<(const OTL_STRING_CONTAINER& s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy
+ (OTL_RCAST(unsigned char*,this->vl[cur_in]->val()),
+ OTL_RCAST(unsigned char*,OTL_CCAST(char*,s.c_str())),
+ overflow,
+ this->vl[cur_in]->get_elem_size(),
+ OTL_SCAST(int,s.length())
+ );
+ if(overflow){
+ char temp_var_info[256];
+ otl_var_info_var
+ (this->vl[cur_in]->get_name(),
+ this->vl[cur_in]->get_ftype(),
+ otl_var_char,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_4,
+ otl_error_code_4,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ temp_var_info);
+ }
+
+ this->vl[cur_in]->set_not_null(0);
+
+ }
+ get_in_next();
+ return *this;
+ }
+
+#endif
+
+ OTL_TMPL_SELECT_STREAM& operator<<(const unsigned char* s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy4
+ (OTL_RCAST(unsigned char*,this->vl[cur_in]->val()),
+ OTL_CCAST(unsigned char*,s),
+ overflow,
+ this->vl[cur_in]->get_elem_size()
+ );
+ if(overflow){
+ char temp_var_info[256];
+ otl_var_info_var
+ (this->vl[cur_in]->get_name(),
+ this->vl[cur_in]->get_ftype(),
+ otl_var_char,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_4,
+ otl_error_code_4,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ temp_var_info);
+ }
+
+ this->vl[cur_in]->set_not_null(0);
+
+ }
+ get_in_next();
+ return *this;
+ }
+
+#define OTL_D2(T,T_type) \
+ OTL_TMPL_SELECT_STREAM& operator<<(const T n) \
+ { \
+ check_in_var(); \
+ if(check_in_type(T_type,sizeof(T))){ \
+ *OTL_RCAST(T*,this->vl[cur_in]->val())=n; \
+ } \
+ this->vl[cur_in]->set_not_null(0); \
+ get_in_next(); \
+ return *this; \
+ }
+
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ OTL_D2(int,otl_var_int)
+ OTL_D2(unsigned,otl_var_unsigned_int)
+#if defined(OTL_BIGINT)
+ OTL_D2(OTL_BIGINT,otl_var_bigint)
+#endif
+ OTL_D2(long,otl_var_long_int)
+ OTL_D2(short,otl_var_short)
+ OTL_D2(float,otl_var_float)
+ OTL_D2(double,otl_var_double)
+#else
+ template<OTL_TYPE_NAME T,const int T_type> OTL_D2(T,T_type)
+#endif
+
+ OTL_TMPL_SELECT_STREAM& operator<<(const TTimestampStruct& t)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_timestamp,sizeof(TTimestampStruct))){
+ TTimestampStruct* tm=
+ OTL_RCAST(TTimestampStruct*,this->vl[cur_in]->val());
+ int rc=this->vl[cur_in]->get_var_struct().write_dt
+ (tm,&t,sizeof(TTimestampStruct));
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+
+private:
+
+ otl_tmpl_select_stream
+ (const otl_tmpl_select_stream&):
+ OTL_TMPL_SELECT_CURSOR(),
+ sl_desc(0),
+ sl(0),
+ sl_len(0),
+ null_fetched(0),
+ cur_col(0),
+ cur_in(0),
+ executed(0),
+ eof_status(0),
+ var_info(),
+ override(0),
+ delay_next(0),
+ lob_stream_mode(false),
+ _rfc(0)
+ {
+ }
+
+ otl_tmpl_select_stream& operator=(const otl_tmpl_select_stream&)
+ {
+ return *this;
+ }
+
+};
+
+template <OTL_TYPE_NAME TExceptionStruct,
+ OTL_TYPE_NAME TConnectStruct,
+ OTL_TYPE_NAME TCursorStruct,
+ OTL_TYPE_NAME TVariableStruct,
+ OTL_TYPE_NAME TTimestampStruct>
+class otl_tmpl_out_stream: public OTL_TMPL_CURSOR{
+
+protected:
+
+ int auto_commit_flag;
+ int dirty;
+ int cur_x;
+ int cur_y;
+ otl_stream_buffer_size_type array_size;
+ int in_exception_flag;
+ int in_destruct_flag;
+ int should_delete_flag;
+ char var_info[256];
+ bool flush_flag;
+ bool flush_flag2;
+ bool lob_stream_mode;
+ void* master_stream_ptr_;
+
+public:
+
+ int get_dirty_buf_len() const
+ {
+ if(cur_y==0)
+ return 0;
+ else
+ return cur_y+1;
+ }
+
+ void set_flush_flag(const bool aflush_flag)
+ {
+ flush_flag=aflush_flag;
+ }
+
+ void set_flush_flag2(const bool aflush_flag2)
+ {
+ flush_flag2=aflush_flag2;
+ }
+
+ void cleanup(void)
+ {int i;
+ if(should_delete_flag){
+ for(i=0;i<this->vl_len;++i)
+ delete this->vl[i];
+ }
+ delete[] this->vl;
+ }
+
+ otl_tmpl_out_stream
+ (otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ OTL_TMPL_CONNECT& db,
+ void* master_stream_ptr,
+ const bool alob_stream_mode=false,
+ const char* sqlstm_label=0):
+ OTL_TMPL_CURSOR(db),
+ auto_commit_flag(0),
+ dirty(0),
+ cur_x(0),
+ cur_y(0),
+ array_size(0),
+ in_exception_flag(0),
+ in_destruct_flag(0),
+ should_delete_flag(0),
+ var_info(),
+ flush_flag(0),
+ flush_flag2(0),
+ lob_stream_mode(0),
+ master_stream_ptr_(master_stream_ptr)
+ {
+ int i;
+ if(sqlstm_label!=0){
+ if(this->stm_label!=0){
+ delete[] this->stm_label;
+ this->stm_label=0;
+ }
+ size_t len=strlen(sqlstm_label)+1;
+ this->stm_label=new char[strlen(sqlstm_label)+1];
+ OTL_STRCPY_S(this->stm_label,len,sqlstm_label);
+ }
+ dirty=0;
+ auto_commit_flag=1;
+ flush_flag=true;
+ flush_flag2=true;
+ lob_stream_mode=alob_stream_mode;
+ this->cursor_struct.last_param_data_token=0;
+ this->cursor_struct.last_sql_param_data_status=0;
+ this->cursor_struct.sql_param_data_count=0;
+ cur_x=-1;
+ cur_y=0;
+ should_delete_flag=1;
+ in_exception_flag=0;
+ in_destruct_flag=0;
+ this->stm_text=0;
+ array_size=arr_size;
+ {
+ int len=strlen(sqlstm)+1;
+ this->stm_text=new char[len];
+ OTL_STRCPY_S(this->stm_text,len,sqlstm);
+ otl_tmpl_ext_hv_decl
+ <TVariableStruct,TTimestampStruct,TExceptionStruct,
+ TConnectStruct,TCursorStruct> hvd(this->stm_text,arr_size);
+ hvd.alloc_host_var_list(this->vl,this->vl_len,db);
+ }
+ try{
+ this->parse();
+ for(i=0;i<this->vl_len;++i){
+ if(this->vl[i]->get_var_struct().otl_adapter==otl_odbc_adapter){
+ this->vl[i]->get_var_struct().lob_stream_mode=lob_stream_mode;
+ this->vl[i]->get_var_struct().vparam_type=this->vl[i]->get_param_type();
+ if(this->vl[i]->get_ftype()==otl_var_varchar_long||
+ this->vl[i]->get_ftype()==otl_var_raw_long){
+ this->vl[i]->set_not_null(0);
+ }
+ }
+ bind(*(this->vl[i]));
+ }
+ }catch(OTL_CONST_EXCEPTION OTL_TMPL_EXCEPTION&){
+ cleanup();
+ if(this->adb)this->adb->increment_throw_count();
+ throw;
+ }
+ }
+
+ otl_tmpl_out_stream
+ (OTL_TMPL_CONNECT& pdb,
+ void* master_stream_ptr,
+ const bool alob_stream_mode=false,
+ const char* sqlstm_label=0):
+ OTL_TMPL_CURSOR(pdb),
+ auto_commit_flag(0),
+ dirty(0),
+ cur_x(0),
+ cur_y(0),
+ array_size(0),
+ in_exception_flag(0),
+ in_destruct_flag(0),
+ should_delete_flag(0),
+ var_info(),
+ flush_flag(0),
+ flush_flag2(0),
+ lob_stream_mode(0),
+ master_stream_ptr_(master_stream_ptr)
+ {
+ if(sqlstm_label!=0){
+ if(this->stm_label!=0){
+ delete[] this->stm_label;
+ this->stm_label=0;
+ }
+ size_t len=strlen(sqlstm_label)+1;
+ this->stm_label=new char[len];
+ OTL_STRCPY_S(this->stm_label,len,sqlstm_label);
+ }
+ should_delete_flag=1;
+ in_exception_flag=0;
+ in_destruct_flag=0;
+ dirty=0;
+ auto_commit_flag=1;
+ flush_flag=true;
+ flush_flag2=true;
+ lob_stream_mode=alob_stream_mode;
+ this->cursor_struct.reset_last_param_data_token();
+ this->cursor_struct.reset_last_sql_param_data_status();
+ this->cursor_struct.reset_sql_param_data_count();
+ cur_x=-1;
+ cur_y=0;
+ this->stm_text=0;
+ }
+
+ virtual ~otl_tmpl_out_stream()
+ {in_destruct_flag=1;
+ this->in_destructor=1;
+ if(dirty&&!in_exception_flag&&
+ flush_flag&&flush_flag2)
+ flush();
+ cleanup();
+ in_destruct_flag=0;
+ }
+
+ void reset_to_last_valid_row()
+ {
+ if(cur_y>0){
+ --cur_y;
+ this->in_exception_flag=0;
+ cur_x=this->vl_len-1;
+ }
+ }
+
+ virtual void flush(const int rowoff=0,const bool force_flush=false)
+ {int i,rc;
+
+ this->_rpc=0;
+
+ if(!dirty)return;
+ if(!flush_flag2)return;
+
+ if(force_flush){
+ if(rowoff>cur_y){
+ clean();
+ return;
+ }
+ int temp_rc;
+ OTL_TRACE_STREAM_EXECUTION2
+ this->exec(OTL_SCAST(otl_stream_buffer_size_type,(cur_y+1)),
+ rowoff,
+ otl_sql_exec_from_cursor_class);
+ for(i=0;i<this->vl_len;++i){
+ temp_rc=this->vl[i]->get_var_struct().put_blob();
+ if(temp_rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ }
+ if(auto_commit_flag)
+ this->adb->commit();
+ clean();
+ return;
+ }
+
+#if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ if(otl_uncaught_exception()){
+ clean();
+ return;
+ }
+#elif defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ if(otl_uncaught_exception()){
+ clean();
+ return;
+ }
+#endif
+
+ if(this->retcode==0||this->adb->get_retcode()==0){
+ clean();
+ return;
+ }
+ if(cur_x!=this->vl_len-1){
+ in_exception_flag=1;
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+#if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ if(
+otl_uncaught_exception()){
+ clean();
+ return;
+ }
+#elif defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ if(otl_uncaught_exception()){
+ clean();
+ return;
+ }
+#endif
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_3,
+ otl_error_code_3,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ 0);
+ }
+ if(in_destruct_flag){
+ OTL_TRACE_STREAM_EXECUTION2
+ this->retcode=this->cursor_struct.exec
+ (cur_y+1,
+ rowoff,
+ otl_sql_exec_from_cursor_class);
+ for(i=0;i<this->vl_len;++i){
+ rc=this->vl[i]->get_var_struct().put_blob();
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ }
+ if(!this->retcode){
+ clean();
+ in_exception_flag=1;
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (this->cursor_struct,
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ if(auto_commit_flag){
+ this->adb->set_retcode(this->adb->get_connect_struct().commit());
+ if(!this->adb->get_retcode()){
+ clean();
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ }
+ }else{
+ int temp_rc;
+ OTL_TRACE_STREAM_EXECUTION2
+ this->exec(OTL_SCAST(otl_stream_buffer_size_type,(cur_y+1)),
+ rowoff,
+ otl_sql_exec_from_cursor_class);
+ for(i=0;i<this->vl_len;++i){
+ temp_rc=this->vl[i]->get_var_struct().put_blob();
+ if(temp_rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ }
+ if(auto_commit_flag)
+ this->adb->commit();
+ if(rowoff>0)
+ clean();
+ else
+ clean(0);
+ }
+
+ }
+
+ virtual void clean(const int clean_up_error_flag=0)
+ {
+ if(clean_up_error_flag){
+ this->retcode=1;
+ this->in_exception_flag=0;
+ }
+ if(!dirty)return;
+ cur_x=-1;
+ cur_y=0;
+ dirty=0;
+ }
+
+ void set_commit(int auto_commit=0)
+ {
+ auto_commit_flag=auto_commit;
+ }
+
+ void get_next(void)
+ {
+ if(cur_x<this->vl_len-1)
+ ++cur_x;
+ else{
+ if(cur_y<array_size-1){
+ ++cur_y;
+ cur_x=0;
+ }else{
+ flush();
+ cur_x=0;
+ }
+ }
+ dirty=1;
+ }
+
+ int check_type_throw(int type_code)
+ {
+ in_exception_flag=1;
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ type_code,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_0,
+ otl_error_code_0,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+
+ int check_type(int type_code, int tsize)
+ {
+ switch(this->vl[cur_x]->get_ftype()){
+ case otl_var_char:
+ if(type_code==otl_var_char)return 1;
+ case otl_var_db2time:
+ case otl_var_tz_timestamp:
+ case otl_var_ltz_timestamp:
+ case otl_var_db2date:
+ if(type_code==otl_var_timestamp)return 1;
+ case otl_var_refcur:
+ if(type_code==otl_var_refcur)return 1;
+ default:
+ if(this->vl[cur_x]->get_ftype()==type_code &&
+ this->vl[cur_x]->get_elem_size()==tsize)
+ return 1;
+ }
+ return check_type_throw(type_code);
+ }
+
+ void check_buf(void)
+ {
+ if(cur_x==this->vl_len-1 && cur_y==array_size-1)
+ flush();
+ }
+
+ OTL_TMPL_OUT_STREAM& operator<<(const char c)
+ {
+ if(this->vl_len>0){
+ get_next();
+ if(check_type(otl_var_char,1)){
+ char* tmp=OTL_RCAST(char*,this->vl[cur_x]->val(cur_y));
+ tmp[0]=c;
+ tmp[1]=0;
+ this->vl[cur_x]->set_not_null(cur_y);
+ }
+ check_buf();
+ }
+ return *this;
+ }
+
+ OTL_TMPL_OUT_STREAM& operator<<(const unsigned char c)
+ {
+ if(this->vl_len>0){
+ get_next();
+ if(check_type(otl_var_char,1)){
+ unsigned char* tmp=OTL_RCAST(unsigned char*,this->vl[cur_x]->val(cur_y));
+ tmp[0]=c;
+ tmp[1]=0;
+ this->vl[cur_x]->set_not_null(cur_y);
+ }
+ check_buf();
+ }
+ return *this;
+ }
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ OTL_TMPL_OUT_STREAM& operator<<(const OTL_STRING_CONTAINER& s)
+ {
+ if(this->vl_len>0){
+ get_next();
+
+ switch(this->vl[cur_x]->get_ftype()){
+ case otl_var_char:
+ {
+ int overflow;
+ otl_strcpy
+ (OTL_RCAST(unsigned char*,this->vl[cur_x]->val(cur_y)),
+ OTL_RCAST(unsigned char*,OTL_CCAST(char*,s.c_str())),
+ overflow,
+ this->vl[cur_x]->get_elem_size(),
+ OTL_SCAST(int,s.length()));
+ if(overflow){
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_char,
+ var_info,
+ sizeof(var_info));
+ in_exception_flag=1;
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_4,
+ otl_error_code_4,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ this->vl[cur_x]->set_not_null(cur_y);
+ }
+ break;
+#if defined(OTL_USER_DEFINED_STRING_CLASS_ON) || \
+ defined(OTL_STL) || defined(OTL_ACE)
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ {
+ unsigned char* c=OTL_RCAST(unsigned char*,
+ this->vl[cur_x]->val(cur_y));
+ int len=OTL_SCAST(int,s.length());
+ this->vl[cur_x]->set_not_null(cur_y);
+ if(len>this->vl[cur_x]->actual_elem_size()){
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_char,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_5,
+ otl_error_code_5,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+
+ otl_memcpy(c,
+ OTL_RCAST(unsigned char*,
+ OTL_CCAST(char*,s.c_str())),
+ len,
+ this->vl[cur_x]->get_ftype());
+ this->vl[cur_x]->set_len(len,cur_y);
+ }
+ break;
+ case otl_var_blob:
+ case otl_var_clob:
+ {
+ int len=OTL_SCAST(int,s.length());
+ if(len>this->vl[cur_x]->actual_elem_size()){
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_char,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_5,
+ otl_error_code_5,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ this->vl[cur_x]->set_not_null(cur_y);
+ this->vl[cur_x]->get_var_struct().save_blob
+ (OTL_RCAST(unsigned char*,OTL_CCAST(char*,s.c_str())),len,0);
+ }
+ break;
+#endif
+ default:
+ check_type(otl_var_char,1);
+ } // switch
+ check_buf();
+ }
+ return *this;
+ }
+#endif
+
+#if defined(OTL_UNICODE_STRING_TYPE)
+ OTL_TMPL_OUT_STREAM& operator<<(const OTL_UNICODE_STRING_TYPE& s)
+ {
+ if(this->vl_len>0){
+ get_next();
+ switch(this->vl[cur_x]->get_ftype()){
+ case otl_var_char:
+ {
+ int overflow;
+ otl_strcpy4
+ (OTL_RCAST(unsigned char*,this->vl[cur_x]->val(cur_y)),
+ OTL_RCAST(unsigned char*,
+ OTL_CCAST(OTL_UNICODE_CHAR_TYPE*,s.c_str())),
+ overflow,
+ this->vl[cur_x]->get_elem_size(),
+ OTL_SCAST(int,s.length())
+ );
+ if(overflow){
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_char,
+ var_info,
+ sizeof(var_info));
+ in_exception_flag=1;
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_4,
+ otl_error_code_4,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ this->vl[cur_x]->set_not_null(cur_y);
+ break;
+ }
+ case otl_var_varchar_long:
+ {
+ unsigned char* c=OTL_RCAST(unsigned char*,
+ this->vl[cur_x]->val(cur_y));
+ int len=OTL_SCAST(int,s.length());
+ this->vl[cur_x]->set_not_null(cur_y);
+ if(len>this->vl[cur_x]->actual_elem_size()){
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_char,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_5,
+ otl_error_code_5,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ otl_memcpy(c,
+ OTL_RCAST(unsigned char*,
+ OTL_CCAST(OTL_UNICODE_CHAR_TYPE*,s.c_str())),
+ len,
+ this->vl[cur_x]->get_ftype());
+ this->vl[cur_x]->set_len(len,cur_y);
+ break;
+ }
+ case otl_var_clob:
+ {
+ int len=OTL_SCAST(int,s.length());
+ if(len>this->vl[cur_x]->actual_elem_size()){
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_char,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_5,
+ otl_error_code_5,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ this->vl[cur_x]->set_not_null(cur_y);
+ this->vl[cur_x]->get_var_struct().save_blob
+ (OTL_RCAST(const unsigned char*,s.c_str()),
+ len,
+ 0);
+ }
+ break;
+ default:
+ check_type(otl_var_char,1);
+ }
+ check_buf();
+ }
+ return *this;
+ }
+#endif
+
+ OTL_TMPL_OUT_STREAM& operator<<(const char* s)
+ {
+ if(this->vl_len>0){
+ get_next();
+ if(check_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy
+ (OTL_RCAST(unsigned char*,this->vl[cur_x]->val(cur_y)),
+ OTL_RCAST(unsigned char*,OTL_CCAST(char*,s)),
+ overflow,
+ this->vl[cur_x]->get_elem_size()
+ );
+ if(overflow){
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_char,
+ var_info,
+ sizeof(var_info));
+ in_exception_flag=1;
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_4,
+ otl_error_code_4,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ this->vl[cur_x]->set_not_null(cur_y);
+ }
+ check_buf();
+ }
+ return *this;
+ }
+
+ OTL_TMPL_OUT_STREAM& operator<<(const unsigned char* s)
+ {
+ if(this->vl_len>0){
+ get_next();
+ if(check_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy4
+ (OTL_RCAST(unsigned char*,this->vl[cur_x]->val(cur_y)),
+ OTL_CCAST(unsigned char*,s),
+ overflow,
+ this->vl[cur_x]->get_elem_size()
+ );
+ if(overflow){
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_char,
+ var_info,
+ sizeof(var_info));
+ in_exception_flag=1;
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_4,
+ otl_error_code_4,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ this->vl[cur_x]->set_not_null(cur_y);
+ }
+ check_buf();
+ }
+ return *this;
+ }
+
+#define OTL_D3(T,T_type) \
+ OTL_TMPL_OUT_STREAM& operator<<(const T n) \
+ { \
+ if(this->vl_len>0){ \
+ get_next(); \
+ if(check_type(T_type,sizeof(T))){ \
+ *OTL_RCAST(T*,this->vl[cur_x]->val(cur_y))=n; \
+ this->vl[cur_x]->set_not_null(cur_y); \
+ } \
+ check_buf(); \
+ } \
+ return *this; \
+ }
+
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ OTL_D3(int,otl_var_int)
+#if defined(OTL_BIGINT)
+ OTL_D3(OTL_BIGINT,otl_var_bigint)
+#endif
+ OTL_D3(unsigned,otl_var_unsigned_int)
+ OTL_D3(long,otl_var_long_int)
+ OTL_D3(short,otl_var_short)
+ OTL_D3(float,otl_var_float)
+ OTL_D3(double,otl_var_double)
+#else
+ template<OTL_TYPE_NAME T,const int T_type> OTL_D3(T,T_type)
+#endif
+
+#if defined(OTL_PL_TAB)
+ OTL_TMPL_OUT_STREAM& operator<<(otl_pl_tab_generic& tab)
+ {
+ if(this->vl_len>0){
+ get_next();
+ if(check_type(tab.get_vtype(),tab.get_elem_size())){
+ int i,tmp_len;
+ if(tab.len()<=this->vl[cur_x]->get_array_size())
+ tmp_len=tab.len();
+ else
+ tmp_len=this->vl[cur_x]->get_array_size();
+ this->vl[cur_x]->set_pl_tab_len(tmp_len);
+ if(tab.get_vtype()==otl_var_char){
+ int i2;
+ for(i2=0;i2<tmp_len;++i2){
+ int overflow;
+ otl_strcpy4
+ (OTL_RCAST(unsigned char*,this->vl[cur_x]->val(i2)),
+ OTL_RCAST(unsigned char*,tab.val(i2)),
+ overflow,
+ this->vl[cur_x]->get_elem_size()
+ );
+ if(overflow){
+ char tmp_var_info[256];
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_char,
+ tmp_var_info,
+ sizeof(tmp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_4,
+ otl_error_code_4,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ tmp_var_info);
+ }
+ }
+ }else if(tab.get_vtype()==otl_var_timestamp){
+ otl_datetime* ext_dt=OTL_RCAST(otl_datetime*,tab.get_p_v());
+ otl_oracle_date* int_dt=OTL_RCAST(otl_oracle_date*,
+ this->vl[cur_x]->val());
+ int j;
+ for(j=0;j<tmp_len;++j){
+ convert_date(*int_dt,*ext_dt);
+ ++int_dt;
+ ++ext_dt;
+ }
+ }else
+ memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()),
+ OTL_RCAST(char*,tab.val()),
+ tab.get_elem_size()*tmp_len);
+ for(i=0;i<tmp_len;++i){
+ if(tab.is_null(i))
+ this->vl[cur_x]->set_null(i);
+ else
+ this->vl[cur_x]->set_not_null(i);
+ }
+ }
+ check_buf();
+ }
+ return *this;
+ }
+#endif
+
+#if defined(OTL_PL_TAB) && defined(OTL_STL)
+ OTL_TMPL_OUT_STREAM& operator<<(otl_pl_vec_generic& vec)
+ {
+ if(this->vl_len>0){
+ get_next();
+ if(check_type(vec.get_vtype(),vec.get_elem_size())){
+ int i,tmp_len;
+ if(vec.len()<=this->vl[cur_x]->get_array_size())
+ tmp_len=vec.len();
+ else
+ tmp_len=this->vl[cur_x]->get_array_size();
+ this->vl[cur_x]->set_pl_tab_len(tmp_len);
+ switch(vec.get_vtype()){
+ case otl_var_char:
+ int i2;
+ for(i2=0;i2<tmp_len;++i2){
+ int overflow;
+ otl_strcpy
+ (OTL_RCAST(unsigned char*,this->vl[cur_x]->val(i2)),
+ OTL_RCAST(unsigned char*,
+ OTL_CCAST(char*,(*OTL_RCAST(STD_NAMESPACE_PREFIX
+ vector<OTL_STRING_CONTAINER>*,
+ vec.get_p_v()))[i2].c_str())),
+ overflow,
+ this->vl[cur_x]->get_elem_size(),
+ OTL_SCAST(int,(*OTL_RCAST(STD_NAMESPACE_PREFIX
+ vector<OTL_STRING_CONTAINER>*,
+ vec.get_p_v()))[i2].length())
+ );
+ if(overflow){
+ char temp_var_info[256];
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_char,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_4,
+ otl_error_code_4,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ temp_var_info);
+ }
+ }
+ break;
+ case otl_var_timestamp:
+ {
+ otl_oracle_date* int_dt=OTL_RCAST(otl_oracle_date*,this->vl[cur_x]->val());
+ int j;
+ otl_datetime* ext_dt;
+ for(j=0;j<tmp_len;++j){
+ ext_dt=OTL_RCAST(otl_datetime*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<otl_datetime>*,
+ vec.get_p_v()))[j]);
+ convert_date(*int_dt,*ext_dt);
+ ++int_dt;
+ }
+ }
+ break;
+ case otl_var_int:
+ if(tmp_len>0)
+ memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()),
+ OTL_RCAST(char*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<int>*,
+ vec.get_p_v()))[0]),
+ sizeof(int)*tmp_len);
+ break;
+ case otl_var_double:
+ if(tmp_len>0)
+ memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()),
+ OTL_RCAST(char*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<double>*,
+ vec.get_p_v()))[0]),
+ sizeof(double)*tmp_len);
+ break;
+ case otl_var_float:
+ if(tmp_len>0)
+ memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()),
+ OTL_RCAST(char*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<float>*,
+ vec.get_p_v()))[0]),
+ sizeof(float)*tmp_len);
+ break;
+ case otl_var_unsigned_int:
+ if(tmp_len>0)
+ memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()),
+ OTL_RCAST(char*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<unsigned>*,
+ vec.get_p_v()))[0]),
+ sizeof(unsigned)*tmp_len);
+ break;
+ case otl_var_short:
+ if(tmp_len>0)
+ memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()),
+ OTL_RCAST(char*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<short>*,
+ vec.get_p_v()))[0]),
+ sizeof(short)*tmp_len);
+ break;
+ case otl_var_long_int:
+ if(tmp_len>0)
+ memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()),
+ OTL_RCAST(char*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<long int>*,
+ vec.get_p_v()))[0]),
+ sizeof(long int)*tmp_len);
+ break;
+ }
+ for(i=0;i<tmp_len;++i){
+ if(vec.is_null(i))
+ this->vl[cur_x]->set_null(i);
+ else
+ this->vl[cur_x]->set_not_null(i);
+ }
+ }
+ check_buf();
+ }
+ return *this;
+ }
+#endif
+
+ OTL_TMPL_OUT_STREAM& operator<<(const otl_null& /* n */)
+ {
+ if(this->vl_len>0){
+ get_next();
+ this->vl[cur_x]->set_null(cur_y);
+ check_buf();
+ }
+ return *this;
+ }
+
+ OTL_TMPL_OUT_STREAM& operator<<(const TTimestampStruct& t)
+ {
+ if(this->vl_len>0){
+ get_next();
+ if(check_type(otl_var_timestamp,sizeof(TTimestampStruct))){
+ TTimestampStruct* tm=
+ OTL_RCAST(TTimestampStruct*,this->vl[cur_x]->val(cur_y));
+ this->vl[cur_x]->set_not_null(cur_y);
+ int rc=this->vl[cur_x]->get_var_struct().write_dt
+ (tm,&t,sizeof(TTimestampStruct));
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ }
+ check_buf();
+ }
+ return *this;
+ }
+
+ OTL_TMPL_OUT_STREAM& operator<<(const otl_long_string& s)
+ {
+ if(this->vl_len>0){
+ get_next();
+
+ switch(this->vl[cur_x]->get_ftype()){
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ case otl_var_raw:
+ {
+ unsigned char* c=OTL_RCAST(unsigned char*,this->vl[cur_x]->val(cur_y));
+ int len=OTL_CCAST(otl_long_string*,&s)->len();
+ this->vl[cur_x]->set_not_null(cur_y);
+ if(len>this->vl[cur_x]->actual_elem_size()){
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_long_string,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_5,
+ otl_error_code_5,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ if((this->vl[cur_x]->get_var_struct().get_otl_adapter()==otl_ora7_adapter||
+ this->vl[cur_x]->get_var_struct().get_otl_adapter()==otl_ora8_adapter) &&
+ this->vl[cur_x]->get_ftype()==otl_var_raw){
+ otl_memcpy
+ (c+sizeof(unsigned short),
+ s.v,
+ len,
+ this->vl[cur_x]->get_ftype());
+ *OTL_RCAST(unsigned short*,
+ this->vl[cur_x]->val(cur_y))=OTL_SCAST(unsigned short,len);
+ this->vl[cur_x]->set_len(len,cur_y);
+ }else{
+ otl_memcpy(c,s.v,len,this->vl[cur_x]->get_ftype());
+ this->vl[cur_x]->set_len(len,cur_y);
+ }
+ }
+ break;
+ case otl_var_blob:
+ case otl_var_clob:
+ {
+ int len=OTL_CCAST(otl_long_string*,&s)->len();
+ if(len>this->vl[cur_x]->actual_elem_size()){
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_long_string,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_5,
+ otl_error_code_5,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ this->vl[cur_x]->set_not_null(cur_y);
+ this->vl[cur_x]->get_var_struct().save_blob
+ (s.v,len,s.get_extern_buffer_flag());
+ }
+ break;
+ }
+ check_buf();
+ }
+ return *this;
+ }
+
+#if defined(OTL_ORA8)||defined(OTL_ODBC)
+#define OTL_TMPL_CUR_DUMMY OTL_TMPL_CURSOR
+
+ OTL_TMPL_OUT_STREAM& operator<<
+ (otl_lob_stream_generic& s)
+ {
+ if(this->vl_len>0){
+ get_next();
+ if(((s.get_ora_lob() &&
+ this->vl[cur_x]->get_ftype()==otl_var_blob)||
+ this->vl[cur_x]->get_ftype()==otl_var_clob)||
+ (this->vl[cur_x]->get_ftype()==otl_var_varchar_long||
+ this->vl[cur_x]->get_ftype()==otl_var_raw_long)){
+ s.init
+ (this->vl[cur_x],
+ this->adb,
+ OTL_RCAST(OTL_TMPL_CUR_DUMMY*,this),
+ 0,
+ otl_lob_stream_write_mode);
+ if(!s.get_ora_lob())
+ this->vl[cur_x]->set_not_null(cur_y);
+ }
+ check_buf();
+ }else{
+ char temp_var_info[256];
+ otl_var_info_var
+ (this->vl[cur_x]->get_name(),
+ this->vl[cur_x]->get_ftype(),
+ otl_var_long_string,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_0,
+ otl_error_code_0,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ temp_var_info);
+ }
+ return *this;
+ }
+#undef OTL_TMPL_CUR_DUMMY
+#endif
+
+ otl_tmpl_out_stream():
+ OTL_TMPL_CURSOR(),
+ auto_commit_flag(0),
+ dirty(0),
+ cur_x(0),
+ cur_y(0),
+ array_size(0),
+ in_exception_flag(0),
+ in_destruct_flag(0),
+ should_delete_flag(0),
+ var_info(),
+ flush_flag(0),
+ flush_flag2(0),
+ lob_stream_mode(0),
+ master_stream_ptr_(0)
+ {
+ }
+
+private:
+
+ otl_tmpl_out_stream
+ (const otl_tmpl_out_stream&):
+ OTL_TMPL_CURSOR(),
+ auto_commit_flag(0),
+ dirty(0),
+ cur_x(0),
+ cur_y(0),
+ array_size(0),
+ in_exception_flag(0),
+ in_destruct_flag(0),
+ should_delete_flag(0),
+ var_info(),
+ flush_flag(0),
+ flush_flag2(0),
+ lob_stream_mode(0),
+ master_stream_ptr_(0)
+ {
+ }
+
+ otl_tmpl_out_stream& operator=
+ (const otl_tmpl_out_stream&)
+ {
+ return *this;
+ }
+
+};
+
+template <OTL_TYPE_NAME TExceptionStruct,
+ OTL_TYPE_NAME TConnectStruct,
+ OTL_TYPE_NAME TCursorStruct,
+ OTL_TYPE_NAME TVariableStruct,
+ OTL_TYPE_NAME TTimestampStruct>
+class otl_tmpl_inout_stream: public OTL_TMPL_OUT_STREAM{
+
+protected:
+
+ otl_tmpl_variable<TVariableStruct>** in_vl;
+ int iv_len;
+ int cur_in_x;
+ int cur_in_y;
+ int in_y_len;
+ int null_fetched;
+ otl_tmpl_variable<TVariableStruct>** avl;
+ int avl_len;
+ char var_info[256];
+
+public:
+
+ int get_iv_len() const {return iv_len;}
+ otl_tmpl_variable<TVariableStruct>** get_in_vl(){return in_vl;}
+
+ void cleanup(void)
+ {int i;
+ for(i=0;i<avl_len;++i){
+ delete avl[i];
+ }
+ delete[] avl;
+ delete[] in_vl;
+ }
+
+ otl_tmpl_inout_stream
+ (otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ OTL_TMPL_CONNECT& pdb,
+ void* master_stream_ptr,
+ const bool alob_stream_mode=false,
+ const char* sqlstm_label=0)
+ : OTL_TMPL_OUT_STREAM
+ (pdb,
+ master_stream_ptr,
+ alob_stream_mode,
+ sqlstm_label),
+ in_vl(0),
+ iv_len(0),
+ cur_in_x(0),
+ cur_in_y(0),
+ in_y_len(0),
+ null_fetched(0),
+ avl(0),
+ avl_len(0),
+ var_info()
+ {
+ int i,j;
+ this->dirty=0;
+ this->auto_commit_flag=1;
+ this->adb=&pdb;
+ this->in_exception_flag=0;
+ this->stm_text=0;
+ this->array_size=arr_size;
+ this->should_delete_flag=0;
+
+ {
+ size_t len=strlen(sqlstm)+1;
+ this->stm_text=new char[len];
+ OTL_STRCPY_S(this->stm_text,len,sqlstm);
+ otl_tmpl_ext_hv_decl
+ <TVariableStruct,TTimestampStruct,TExceptionStruct,
+ TConnectStruct,TCursorStruct> hvd(this->stm_text,arr_size);
+ if(hvd.has_plsql_tabs_or_refcur() && arr_size>1){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_33,
+ otl_error_code_33,
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ if(hvd.get_vst(otl_tmpl_ext_hv_decl
+ <TVariableStruct,TTimestampStruct,TExceptionStruct,
+ TConnectStruct,TCursorStruct>::def)==hvd.get_len()){
+ this->should_delete_flag=1;
+ hvd.alloc_host_var_list(this->vl,this->vl_len,pdb);
+ }else{
+ for(i=0;i<hvd.get_len();++i){
+ if(hvd.get_inout(i)==
+ otl_tmpl_ext_hv_decl
+ <TVariableStruct,
+ TTimestampStruct,
+ TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>::in)
+ ++this->vl_len;
+ else if(hvd.get_inout(i)==
+ otl_tmpl_ext_hv_decl
+ <TVariableStruct,
+ TTimestampStruct,
+ TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>::out)
+ ++iv_len;
+ else if(hvd.get_inout(i)==
+ otl_tmpl_ext_hv_decl
+ <TVariableStruct,
+ TTimestampStruct,
+ TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>::io){
+ ++this->vl_len;
+ ++iv_len;
+ }
+ }
+ if(this->vl_len>0){
+ this->vl=new otl_tmpl_variable<TVariableStruct>*[this->vl_len];
+ }
+ if(iv_len>0){
+ in_vl=new otl_tmpl_variable<TVariableStruct>*[iv_len];
+ }
+ if(hvd.get_len()>0){
+ avl=new otl_tmpl_variable<TVariableStruct>*[hvd.get_len()];
+ }
+ iv_len=0;
+ this->vl_len=0;
+ avl_len=hvd.get_len();
+ for(j=0;j<avl_len;++j){
+#if defined(OTL_STREAM_LEGACY_BUFFER_SIZE_TYPE)
+ if(hvd.pl_tab_size[j]>32767){
+ char tmp_var_info[256];
+ otl_var_info_var
+ (hvd[j],
+ otl_var_none,
+ otl_var_none,
+ tmp_var_info,
+ sizeof(tmp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_6,
+ otl_error_code_6,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ tmp_var_info);
+ }
+#endif
+ otl_tmpl_variable<TVariableStruct>* v=hvd.alloc_var
+ (hvd[j],
+ hvd.get_inout(j),
+ otl_tmpl_ext_hv_decl
+ <TVariableStruct,TTimestampStruct,TExceptionStruct,
+ TConnectStruct,TCursorStruct>::def,
+ pdb,
+ hvd.get_pl_tab_size(j));
+ if(v==0){
+ int k;
+ for(k=0;k<j;++k){
+ delete avl[k];
+ avl[k]=0;
+ }
+ delete[] avl;
+ avl=0;
+ this->vl_len=0;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_12,
+ otl_error_code_12,
+ hvd.stm_label()?hvd.stm_label():hvd.stm_text(),
+ hvd[j]);
+ }
+ v->set_name_pos(j+1);
+ avl[j]=v;
+ if(hvd.get_inout(j)==
+ otl_tmpl_ext_hv_decl
+ <TVariableStruct,
+ TTimestampStruct,
+ TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>::in){
+ ++this->vl_len;
+ this->vl[this->vl_len-1]=v;
+ v->set_param_type(otl_input_param);
+ }else if(hvd.get_inout(j)==
+ otl_tmpl_ext_hv_decl
+ <TVariableStruct,
+ TTimestampStruct,
+ TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>::out){
+ ++iv_len;
+ in_vl[iv_len-1]=v;
+ v->set_param_type(otl_output_param);
+ }else if(hvd.get_inout(j)==
+ otl_tmpl_ext_hv_decl
+ <TVariableStruct,
+ TTimestampStruct,
+ TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>::io){
+ ++this->vl_len;
+ ++iv_len;
+ this->vl[this->vl_len-1]=v;
+ in_vl[iv_len-1]=v;
+ v->set_param_type(otl_inout_param);
+ }
+ }
+ }
+ }
+ try{
+ this->parse();
+ for(i=0;i<this->vl_len;++i){
+ if(this->vl[i]->get_var_struct().get_otl_adapter()==otl_odbc_adapter){
+ this->vl[i]->get_var_struct().set_lob_stream_mode(this->lob_stream_mode);
+ this->vl[i]->get_var_struct().set_vparam_type(this->vl[i]->get_param_type());
+ if(this->vl[i]->get_ftype()==otl_var_varchar_long||
+ this->vl[i]->get_ftype()==otl_var_raw_long){
+ this->vl[i]->set_not_null(0);
+ }
+ }
+ this->bind(*(this->vl[i]));
+ }
+ for(j=0;j<iv_len;++j)
+ this->bind(*in_vl[j]);
+ rewind();
+ }catch(OTL_CONST_EXCEPTION OTL_TMPL_EXCEPTION&){
+ cleanup();
+ if(this->adb)this->adb->increment_throw_count();
+ throw;
+ }
+
+ }
+
+ virtual ~otl_tmpl_inout_stream()
+ {this->in_destructor=1;
+ if(!this->in_exception_flag)
+ flush();
+ cleanup();
+ }
+
+ int eof(void)
+ {
+ if(iv_len==0)return 1;
+ if(in_y_len==0)return 1;
+ if(cur_in_y<=in_y_len-1)return 0;
+ return 1;
+ }
+
+ void flush(const int rowoff=0, const bool force_flush=false)
+ {
+ if(this->vl_len==0)return;
+ in_y_len=this->cur_y+1;
+ cur_in_y=0;
+ cur_in_x=0;
+ if(!this->in_exception_flag)
+ OTL_TMPL_OUT_STREAM::flush(rowoff,force_flush);
+ }
+
+ void clean(const int clean_up_error_flag=0)
+ {
+ if(this->vl_len!=0) {
+ in_y_len=this->cur_y+1;
+ cur_in_y=0;
+ cur_in_x=0;
+ }
+ OTL_TMPL_OUT_STREAM::clean(clean_up_error_flag);
+ }
+
+ void rewind(void)
+ {
+ flush();
+ cur_in_x=0;
+ cur_in_y=0;
+ this->cur_x=-1;
+ this->cur_y=0;
+ in_y_len=0;
+ null_fetched=0;
+ if(this->vl_len==0){
+ this->exec(this->array_size,0,otl_sql_exec_from_cursor_class);
+ in_y_len=this->array_size;
+ cur_in_y=0;
+ cur_in_x=0;
+ }
+ }
+
+ int is_null(void)
+ {
+ return null_fetched;
+ }
+
+ void skip_to_end_of_row()
+ {
+ if(eof())return;
+ if(iv_len==0)return;
+ if(in_y_len==0)return;
+ if(cur_in_y<in_y_len-1){
+ ++cur_in_y;
+ cur_in_x=0;
+ }else{
+ cur_in_y=0;
+ cur_in_x=0;
+ in_y_len=0;
+ }
+ }
+
+ void get_in_next(void)
+ {
+ if(iv_len==0)return;
+ if(in_y_len==0)return;
+ if(cur_in_x<iv_len-1)
+ ++cur_in_x;
+ else{
+ if(cur_in_y<in_y_len-1){
+ ++cur_in_y;
+ cur_in_x=0;
+ }else{
+ cur_in_y=0;
+ cur_in_x=0;
+ in_y_len=0;
+ }
+ }
+ }
+
+ int check_in_type_throw(int type_code)
+ {
+ this->in_exception_flag=1;
+ otl_var_info_var
+ (in_vl[cur_in_x]->get_name(),
+ in_vl[cur_in_x]->get_ftype(),
+ type_code,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_0,
+ otl_error_code_0,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+
+ int check_in_type(int type_code,int tsize)
+ {
+ switch(in_vl[cur_in_x]->get_ftype()){
+ case otl_var_refcur:
+ if(type_code==otl_var_refcur)
+ return 1;
+ case otl_var_db2time:
+ case otl_var_db2date:
+ if(type_code==otl_var_timestamp)
+ return 1;
+ case otl_var_char:
+ if(type_code==otl_var_char)
+ return 1;
+ default:
+ if(in_vl[cur_in_x]->get_ftype()==type_code &&
+ in_vl[cur_in_x]->get_elem_size()==tsize)
+ return 1;
+ }
+ return check_in_type_throw(type_code);
+ }
+
+ int is_null_intern(void)
+ {
+ if(iv_len==0)return 0;
+ if(in_y_len==0)return 0;
+ if(in_y_len>0)
+ return in_vl[cur_in_x]->is_null(cur_in_y);
+ return 0;
+ }
+
+
+ OTL_TMPL_INOUT_STREAM& operator>>(char& c)
+ {
+ if(eof())return *this;
+ if(check_in_type(otl_var_char,1)){
+ c=*OTL_RCAST(char*,in_vl[cur_in_x]->val(cur_in_y));
+ null_fetched=is_null_intern();
+ }
+ get_in_next();
+ return *this;
+ }
+
+ OTL_TMPL_INOUT_STREAM& operator>>(unsigned char& c)
+ {
+ if(eof())return *this;
+ if(check_in_type(otl_var_char,1)){
+ c=*OTL_RCAST(unsigned char*,in_vl[cur_in_x]->val(cur_in_y));
+ null_fetched=is_null_intern();
+ }
+ get_in_next();
+ return *this;
+ }
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ OTL_TMPL_INOUT_STREAM& operator>>(OTL_STRING_CONTAINER& s)
+ {
+ if(eof())return *this;
+ switch(in_vl[cur_in_x]->get_ftype()){
+ case otl_var_char:
+ {
+#if defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,in_vl[cur_in_x]->val(cur_in_y)),1);
+#else
+ s=OTL_RCAST(char*,in_vl[cur_in_x]->val(cur_in_y));
+#endif
+ null_fetched=is_null_intern();
+ }
+ break;
+#if defined(USER_DEFINED_STRING_CLASS) || \
+ defined(OTL_STL) || defined(OTL_ACE)
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ {
+ unsigned char* c=
+ OTL_RCAST(unsigned char*,in_vl[cur_in_x]->val(cur_in_y));
+ int len=in_vl[cur_in_x]->get_len();
+#if (defined(USER_DEFINED_STRING_CLASS) || defined(OTL_STL)) && !defined(OTL_ACE)
+ s.assign(OTL_RCAST(char*,c),len);
+#elif defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,c),len,1);
+#endif
+ null_fetched=is_null_intern();
+ }
+ break;
+ case otl_var_blob:
+ case otl_var_clob:
+ {
+ int len=0;
+ int max_long_sz=this->adb->get_max_long_size();
+ otl_auto_array_ptr<unsigned char> loc_ptr(max_long_sz);
+ unsigned char* temp_buf=loc_ptr.get_ptr();
+ int rc=in_vl[cur_in_x]->get_var_struct().get_blob
+ (cur_in_y,
+ temp_buf,
+ max_long_sz,
+ len);
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+#if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_ACE)
+ s.assign(OTL_RCAST(char*,temp_buf),len);
+#elif defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,temp_buf),len,1);
+#endif
+
+ null_fetched=is_null_intern();
+ }
+ break;
+#endif
+ default:
+ check_in_type(otl_var_char,1);
+ } // switch
+ get_in_next();
+ return *this;
+ }
+#endif
+
+ OTL_TMPL_INOUT_STREAM& operator>>(char* s)
+ {
+ if(eof())return *this;
+ if(check_in_type(otl_var_char,1)){
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,in_vl[cur_in_x]->val(cur_in_y)));
+ null_fetched=is_null_intern();
+ }
+ get_in_next();
+ return *this;
+ }
+
+#if defined(OTL_UNICODE_STRING_TYPE)
+ OTL_TMPL_INOUT_STREAM& operator>>(OTL_UNICODE_STRING_TYPE& s)
+ {
+ if(eof())return *this;
+ if(check_in_type(otl_var_char,1)){
+#if defined(OTL_ODBC) || defined(DB2_CLI)
+ s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,in_vl[cur_in_x]->val(cur_in_y));
+#else
+#if defined(OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR)
+ OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST
+ (OTL_UNICODE_CHAR_TYPE*,in_vl[cur_in_x]->val(cur_in_y));
+ OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR(s,temp_s+1,*temp_s);
+#else
+ OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST
+ (OTL_UNICODE_CHAR_TYPE*,in_vl[cur_in_x]->val(cur_in_y));
+ s.assign(temp_s+1,*temp_s);
+#endif
+#endif
+
+
+ null_fetched=is_null_intern();
+ }
+ get_in_next();
+ return *this;
+ }
+#endif
+
+ OTL_TMPL_INOUT_STREAM& operator>>(unsigned char* s)
+ {
+ if(eof())return *this;
+ if(check_in_type(otl_var_char,1)){
+ otl_strcpy2(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(unsigned char*,in_vl[cur_in_x]->val(cur_in_y)),
+ in_vl[cur_in_x]->get_len(cur_in_y)
+ );
+ null_fetched=is_null_intern();
+ }
+ get_in_next();
+ return *this;
+ }
+
+#define OTL_D4(T,T_type) \
+ OTL_TMPL_INOUT_STREAM& operator>>(T& n) \
+ { \
+ if(eof())return *this; \
+ if(check_in_type(T_type,sizeof(T))){ \
+ n=*OTL_RCAST(T*,in_vl[cur_in_x]->val(cur_in_y)); \
+ null_fetched=is_null_intern(); \
+ } \
+ get_in_next(); \
+ return *this; \
+ }
+
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ OTL_D4(int,otl_var_int)
+ OTL_D4(unsigned,otl_var_unsigned_int)
+#if defined(OTL_BIGINT)
+ OTL_D4(OTL_BIGINT,otl_var_bigint)
+#endif
+ OTL_D4(long,otl_var_long_int)
+ OTL_D4(short,otl_var_short)
+ OTL_D4(float,otl_var_float)
+ OTL_D4(double,otl_var_double)
+#else
+ template<OTL_TYPE_NAME T,const int T_type> OTL_D4(T,T_type)
+#endif
+
+#if defined(OTL_PL_TAB)
+ OTL_TMPL_INOUT_STREAM& operator>>(otl_pl_tab_generic& tab)
+ {
+ if(eof())return *this;
+ if(check_in_type(tab.get_vtype(),tab.get_elem_size())){
+ int i,tmp_len;
+ tmp_len=in_vl[cur_in_x]->get_pl_tab_len();
+ if(tab.get_tab_size()<tmp_len)
+ tmp_len=tab.get_tab_size();
+ tab.set_len(tmp_len);
+ if(tab.get_vtype()==otl_var_char){
+ for(i=0;i<tmp_len;++i){
+ int overflow;
+ otl_strcpy3
+ (OTL_RCAST(unsigned char*,tab.val(i)),
+ OTL_RCAST(unsigned char*,in_vl[cur_in_x]->val(i)),
+ in_vl[cur_in_x]->get_len(i),
+ overflow,
+ tab.get_elem_size()
+ );
+ }
+ }else if(tab.get_vtype()==otl_var_timestamp){
+ otl_datetime* ext_dt=OTL_RCAST(otl_datetime*,tab.get_p_v());
+ otl_oracle_date* int_dt=
+ OTL_RCAST(otl_oracle_date*,in_vl[cur_in_x]->val());
+ int j;
+ for(j=0;j<tmp_len;++j){
+ convert_date(*ext_dt,*int_dt);
+ ++int_dt;
+ ++ext_dt;
+ }
+ }else
+ memcpy(OTL_RCAST(char*,tab.val()),
+ OTL_RCAST(char*,in_vl[cur_in_x]->val()),
+ tab.get_elem_size()*tmp_len);
+ for(i=0;i<tmp_len;++i){
+ if(in_vl[cur_in_x]->is_null(i))
+ tab.set_null(i);
+ else
+ tab.set_non_null(i);
+ }
+ null_fetched=0;
+ }
+ get_in_next();
+ return *this;
+ }
+#endif
+
+#if defined(OTL_PL_TAB) && defined(OTL_STL)
+ OTL_TMPL_INOUT_STREAM& operator>>(otl_pl_vec_generic& vec)
+ {
+ if(eof())return *this;
+ if(check_in_type(vec.get_vtype(),vec.get_elem_size())){
+ int i,tmp_len;
+ tmp_len=in_vl[cur_in_x]->get_pl_tab_len();
+ vec.set_len(tmp_len);
+ if(tmp_len>0){
+ switch(vec.get_vtype()){
+ case otl_var_char:
+ for(i=0;i<tmp_len;++i){
+ (*OTL_RCAST(STD_NAMESPACE_PREFIX vector<OTL_STRING_CONTAINER>*,vec.get_p_v()))[i]=
+ OTL_RCAST(char*,in_vl[cur_in_x]->val(i));
+ }
+ break;
+ case otl_var_timestamp:
+ {
+ otl_datetime* ext_dt;
+ otl_oracle_date* int_dt=
+ OTL_RCAST(otl_oracle_date*,in_vl[cur_in_x]->val());
+ int j;
+ for(j=0;j<tmp_len;++j){
+ ext_dt=OTL_RCAST
+ (otl_datetime*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<otl_datetime>*,vec.get_p_v()))[j]);
+ convert_date(*ext_dt,*int_dt);
+ ++int_dt;
+ }
+ }
+ break;
+ case otl_var_int:
+ memcpy(OTL_RCAST
+ (char*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<int>*,vec.get_p_v()))[0]),
+ OTL_RCAST(char*,in_vl[cur_in_x]->val()),
+ sizeof(int)*tmp_len);
+ break;
+ case otl_var_double:
+ memcpy(OTL_RCAST(char*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<double>*,
+ vec.get_p_v()))[0]),
+ OTL_RCAST(char*,in_vl[cur_in_x]->val()),
+ sizeof(double)*tmp_len);
+ break;
+ case otl_var_float:
+ memcpy(OTL_RCAST(char*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<float>*,
+ vec.get_p_v()))[0]),
+ OTL_RCAST(char*,in_vl[cur_in_x]->val()),
+ sizeof(float)*tmp_len);
+ break;
+ case otl_var_unsigned_int:
+ memcpy(OTL_RCAST(char*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<unsigned>*,
+ vec.get_p_v()))[0]),
+ OTL_RCAST(char*,in_vl[cur_in_x]->val()),
+ sizeof(unsigned)*tmp_len);
+ break;
+ case otl_var_short:
+ memcpy(OTL_RCAST(char*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<short>*,
+ vec.get_p_v()))[0]),
+ OTL_RCAST(char*,in_vl[cur_in_x]->val()),
+ sizeof(short)*tmp_len);
+ break;
+ case otl_var_long_int:
+ memcpy(OTL_RCAST(char*,
+ &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector<long int>*,
+ vec.get_p_v()))[0]),
+ OTL_RCAST(char*,in_vl[cur_in_x]->val()),
+ sizeof(long int)*tmp_len);
+ break;
+ }
+
+ }
+ for(i=0;i<tmp_len;++i){
+ if(in_vl[cur_in_x]->is_null(i))
+ vec.set_null(i);
+ else
+ vec.set_non_null(i);
+ }
+ null_fetched=0;
+ }
+ get_in_next();
+ return *this;
+ }
+#endif
+
+
+ OTL_TMPL_INOUT_STREAM& operator>>(TTimestampStruct& t)
+ {
+ if(eof())return *this;
+ if(check_in_type(otl_var_timestamp,sizeof(TTimestampStruct))){
+ TTimestampStruct* tm=
+ OTL_RCAST(TTimestampStruct*,in_vl[cur_in_x]->val(cur_in_y));
+ int rc=in_vl[cur_in_x]->get_var_struct().read_dt
+ (&t,tm,sizeof(TTimestampStruct));
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ null_fetched=is_null_intern();
+ }
+ get_in_next();
+ return *this;
+ }
+
+ OTL_TMPL_INOUT_STREAM& operator>>(otl_long_string& s)
+ {
+ int len=0;
+ if(eof())return *this;
+ switch(in_vl[cur_in_x]->get_ftype()){
+ case otl_var_raw:
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ {
+ unsigned char* c=OTL_RCAST(unsigned char*,in_vl[cur_in_x]->val(cur_in_y));
+ len=in_vl[cur_in_x]->get_len();
+ if(len>s.get_buf_size())
+ len=s.get_buf_size();
+ otl_memcpy(s.v,c,len,in_vl[cur_in_x]->get_ftype());
+ s.set_len(len);
+ if(in_vl[cur_in_x]->get_ftype()==otl_var_varchar_long)
+ s.null_terminate_string(len);
+ null_fetched=is_null_intern();
+ }
+ break;
+ case otl_var_clob:
+ case otl_var_blob:
+ {
+ int rc=in_vl[cur_in_x]->get_var_struct().get_blob
+ (cur_in_y,s.v,s.get_buf_size(),len);
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ if(len>s.get_buf_size())
+ len=s.get_buf_size();
+ s.set_len(len);
+ if(in_vl[cur_in_x]->get_ftype()==otl_var_clob)
+ s.null_terminate_string(len);
+ null_fetched=is_null_intern();
+ }
+ break;
+ default:
+ {
+ char temp_var_info[256];
+ otl_var_info_var
+ (in_vl[cur_in_x]->get_name(),
+ in_vl[cur_in_x]->get_ftype(),
+ otl_var_long_string,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_0,
+ otl_error_code_0,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ temp_var_info);
+ }
+ }
+ get_in_next();
+ return *this;
+ }
+
+#if defined(OTL_ORA8)||defined(OTL_ODBC)
+ OTL_TMPL_INOUT_STREAM& operator>>
+ (otl_lob_stream_generic& s)
+ {
+ if(eof())return *this;
+ if((s.get_ora_lob() &&
+ in_vl[cur_in_x]->get_ftype()==otl_var_clob)||
+ in_vl[cur_in_x]->get_ftype()==otl_var_blob){
+ null_fetched=is_null_intern();
+ s.init
+ (OTL_RCAST(void*,in_vl[cur_in_x]),
+ OTL_RCAST(void*,this->adb),
+ OTL_RCAST(void*,this),
+ 0,
+ otl_lob_stream_read_mode,
+ this->is_null());
+ }else if(in_vl[cur_in_x]->get_ftype()==otl_var_varchar_long||
+ in_vl[cur_in_x]->get_ftype()==otl_var_raw_long){
+ s.init
+ (OTL_RCAST(void*,in_vl[cur_in_x]),
+ OTL_RCAST(void*,this->adb),
+ OTL_RCAST(void*,this),
+ 0,
+ otl_lob_stream_read_mode);
+ }else{
+ char tmp_var_info[256];
+ otl_var_info_var
+ (in_vl[cur_in_x]->get_name(),
+ in_vl[cur_in_x]->get_ftype(),
+ otl_var_long_string,
+ tmp_var_info,
+ sizeof(tmp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_0,
+ otl_error_code_0,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ tmp_var_info);
+ }
+ get_in_next();
+ return *this;
+ }
+#endif
+
+ otl_tmpl_inout_stream():
+ OTL_TMPL_OUT_STREAM(),
+ in_vl(0),
+ iv_len(0),
+ cur_in_x(0),
+ cur_in_y(0),
+ in_y_len(0),
+ null_fetched(0),
+ avl(0),
+ avl_len(0),
+ var_info()
+ {
+ }
+
+
+private:
+
+ otl_tmpl_inout_stream
+ (const otl_tmpl_inout_stream&):
+ OTL_TMPL_OUT_STREAM(),
+ in_vl(0),
+ iv_len(0),
+ cur_in_x(0),
+ cur_in_y(0),
+ in_y_len(0),
+ null_fetched(0),
+ avl(0),
+ avl_len(0),
+ var_info()
+ {
+ }
+
+ otl_tmpl_inout_stream& operator=(const otl_tmpl_inout_stream&)
+ {
+ return *this;
+ }
+
+};
+
+// ==================== OTL-Adapter for ODBC/CLI =========================
+
+#if defined(OTL_ODBC)
+
+#if !defined(OTL_DB2_CLI) && !defined(OTL_ODBC_zOS)
+
+// in case if it's ODBC for Windows (!OTL_ODBC_UNIX), and windows.h is
+// not included yet (_WINDOWS_ not defined yet), then include the file
+// explicitly
+#if !defined(OTL_ODBC_UNIX) && !defined(_WINDOWS_)
+#include <windows.h>
+#endif
+
+#if defined(OTL_ODBC_UNIX) && defined(OTL_INFORMIX_CLI)
+#include <infxsql.h>
+
+#define OTL_HENV SQLHANDLE
+#define OTL_HDBC SQLHANDLE
+#define OTL_SQLHANDLE SQLHANDLE
+#define OTL_SQLRETURN SQLRETURN
+#define OTL_SQLSMALLINT SQLSMALLINT
+#define OTL_SQLCHAR_PTR SQLCHAR*
+#define OTL_SQLINTEGER_PTR SQLINTEGER*
+#define OTL_SQLSMALLINT_PTR SQLSMALLINT*
+#define OTL_SQLINTEGER SQLINTEGER
+#define OTL_SQLHSTMT SQLHSTMT
+#define OTL_SQLUSMALLINT SQLUSMALLINT
+#define OTL_SQLPOINTER SQLPOINTER
+#define OTL_SQLCHAR SQLCHAR
+#define OTL_SQLUINTEGER SQLUINTEGER
+#define OTL_SQLLEN SQLINTEGER
+#define OTL_SQLLEN_PTR SQLINTEGER*
+#define OTL_SQLULEN SQLUINTEGER
+#define OTL_SQLULEN_PTR SQLUINTEGER*
+
+#else
+#include <sql.h>
+#include <sqlext.h>
+#endif
+
+#else
+#include <sqlcli1.h>
+#endif
+
+#if defined(OTL_ODBC) && !defined(OTL_DB2_CLI)
+#define OTL_SQL_XML (-152)
+#endif
+
+#if defined(OTL_ODBC) && defined(OTL_DB2_CLI)
+#if defined(SQL_XML)
+#define OTL_SQL_XML SQL_XML
+#else
+#define OTL_SQL_XML (-370)
+#endif
+#endif
+
+#if defined(OTL_ODBC)
+
+#if (ODBCVER >= 0x0300)
+#define OTL_SQL_TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT
+#define OTL_SQL_TIME_STRUCT SQL_TIME_STRUCT
+#define OTL_SQL_DATE_STRUCT SQL_DATE_STRUCT
+#else
+#define OTL_SQL_TIMESTAMP_STRUCT TIMESTAMP_STRUCT
+#define OTL_SQL_TIME_STRUCT TIME_STRUCT
+#define OTL_SQL_DATE_STRUCT DATE_STRUCT
+#endif
+
+#if defined(OTL_DB2_CLI)
+
+#define OTL_HENV SQLHANDLE
+#define OTL_HDBC SQLHANDLE
+#define OTL_SQLHANDLE SQLHANDLE
+#define OTL_SQLRETURN SQLRETURN
+#define OTL_SQLSMALLINT SQLSMALLINT
+#define OTL_SQLCHAR_PTR SQLCHAR*
+#define OTL_SQLINTEGER_PTR SQLINTEGER*
+#define OTL_SQLSMALLINT_PTR SQLSMALLINT*
+#define OTL_SQLINTEGER SQLINTEGER
+#define OTL_SQLHSTMT SQLHSTMT
+#define OTL_SQLUSMALLINT SQLUSMALLINT
+#define OTL_SQLPOINTER SQLPOINTER
+#define OTL_SQLCHAR SQLCHAR
+#define OTL_SQLUINTEGER SQLUINTEGER
+
+#if defined(OTL_IODBC_BSD)
+
+#define OTL_SQLLEN SQLLEN
+#define OTL_SQLULEN SQLULEN
+#define OTL_SQLULEN_PTR SQLULEN*
+#define OTL_SQLLEN_PTR SQLLEN*
+
+#else // #if defined(OTL_IODBC_BSD)
+
+#define OTL_SQLLEN SQLINTEGER
+#define OTL_SQLLEN_PTR SQLINTEGER*
+#define OTL_SQLULEN SQLUINTEGER
+#define OTL_SQLULEN_PTR SQLUINTEGER*
+
+#endif // #if defined(OTL_IODBC_BSD)
+
+#else // #if defined(OTL_DB2_CLI)
+
+#if (ODBCVER >= 0x0300)
+
+#define OTL_HENV SQLHANDLE
+#define OTL_HDBC SQLHANDLE
+#define OTL_SQLHANDLE SQLHANDLE
+#define OTL_SQLRETURN SQLRETURN
+#define OTL_SQLSMALLINT SQLSMALLINT
+#define OTL_SQLCHAR_PTR SQLCHAR*
+#define OTL_SQLINTEGER_PTR SQLINTEGER*
+#define OTL_SQLSMALLINT_PTR SQLSMALLINT*
+#define OTL_SQLINTEGER SQLINTEGER
+#define OTL_SQLHSTMT SQLHSTMT
+#define OTL_SQLUSMALLINT SQLUSMALLINT
+#define OTL_SQLPOINTER SQLPOINTER
+#define OTL_SQLCHAR SQLCHAR
+#define OTL_SQLUINTEGER SQLUINTEGER
+
+#if defined(OTL_IODBC_BSD)
+
+#define OTL_SQLLEN SQLLEN
+#define OTL_SQLLEN_PTR SQLLEN*
+#define OTL_SQLULEN SQLULEN
+#define OTL_SQLULEN_PTR SQLULEN*
+
+#else // #if defined(OTL_IODBC_BSD)
+
+#if (defined(_MSC_VER)&&(_MSC_VER==1200)) // VC 6++
+#define OTL_SQLLEN SQLINTEGER
+#define OTL_SQLLEN_PTR SQLINTEGER*
+#define OTL_SQLULEN SQLUINTEGER
+#define OTL_SQLULEN_PTR SQLUINTEGER*
+#else
+
+#if !defined(OTL_SQLLEN)
+#define OTL_SQLLEN SQLLEN
+#define OTL_SQLLEN_PTR SQLLEN*
+#define OTL_SQLULEN SQLULEN
+#define OTL_SQLULEN_PTR SQLULEN*
+#endif
+
+#endif
+
+#endif // #if defined(OTL_IODBC_BSD)
+
+#else // #if (ODBCVER >= 0x0300)
+
+#define OTL_HENV HENV
+#define OTL_HDBC HDBC
+#define OTL_SQLHANDLE HSTMT
+#define OTL_SQLRETURN SQLRETURN
+#define OTL_SQLSMALLINT SQLSMALLINT
+#define OTL_SQLCHAR_PTR SQLCHAR*
+#define OTL_SQLINTEGER_PTR SQLINTEGER*
+#define OTL_SQLSMALLINT_PTR SQLSMALLINT*
+#define OTL_SQLINTEGER SQLINTEGER
+#define OTL_SQLHSTMT SQLHSTMT
+#define OTL_SQLUSMALLINT SQLUSMALLINT
+#define OTL_SQLPOINTER SQLPOINTER
+#define OTL_SQLCHAR SQLCHAR
+#define OTL_SQLUINTEGER SQLUINTEGER
+
+#if defined(OTL_IODBC_BSD)
+
+#define OTL_SQLLEN SQLLEN
+#define OTL_SQLLEN_PTR SQLLEN*
+#define OTL_SQLULEN SQLULEN
+#define OTL_SQLULEN_PTR SQLULEN*
+
+#else // #if defined(OTL_IODBC_BSD)
+
+#if (defined(_MSC_VER)&&(_MSC_VER==1200)) // VC 6++
+#define OTL_SQLLEN SQLINTEGER
+#define OTL_SQLLEN_PTR SQLINTEGER*
+#define OTL_SQLULEN SQLUINTEGER
+#define OTL_SQLULEN_PTR SQLUINTEGER*
+#else
+#define OTL_SQLLEN SQLLEN
+#define OTL_SQLLEN_PTR SQLLEN*
+#define OTL_SQLULEN SQLULEN
+#define OTL_SQLULEN_PTR SQLULEN*
+#endif
+
+#endif // #if defined(OTL_IODBC_BSD)
+
+#endif
+
+#endif
+
+#endif
+
+OTL_ODBC_NAMESPACE_BEGIN
+
+#if (defined(UNICODE) || defined(_UNICODE)) && defined(OTL_ODBC)
+
+inline void otl_convert_char_to_SQLWCHAR(SQLWCHAR* dst, const unsigned char* src)
+{
+ while(*src)
+ *dst++=OTL_SCAST(SQLWCHAR,*src++);
+ *dst=0;
+}
+
+inline void otl_convert_SQLWCHAR_to_char(unsigned char* dst, const SQLWCHAR*src)
+{
+ while(*src)
+ *dst++=OTL_SCAST(unsigned char,*src++);
+ *dst=0;
+}
+
+inline size_t otl_strlen(const SQLWCHAR* s)
+{
+ size_t len=0;
+ while(*s){
+ ++s;
+ ++len;
+ }
+ return len;
+}
+
+#endif
+
+typedef OTL_SQL_TIMESTAMP_STRUCT otl_time;
+const int otl_odbc_date_prec=23;
+#if defined(OTL_ODBC_MSSQL_2008)
+const int otl_odbc_date_scale=7;
+#elif defined(OTL_ODBC_MSSQL_2005)
+const int otl_odbc_date_scale=3;
+#else
+const int otl_odbc_date_scale=0;
+#endif
+
+const int OTL_MAX_MSG_ARR=512;
+
+class otl_exc{
+public:
+
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
+ SQLWCHAR msg[1000];
+ SQLWCHAR sqlstate[1000];
+#else
+ unsigned char msg[1000];
+ unsigned char sqlstate[1000];
+#endif
+ int code;
+
+#if defined(OTL_EXTENDED_EXCEPTION)
+
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
+ SQLWCHAR** msg_arr;
+ SQLWCHAR** sqlstate_arr;
+#else
+ char** msg_arr;
+ char** sqlstate_arr;
+#endif
+
+ int* code_arr;
+ int arr_len;
+
+#endif
+
+ enum{disabled=0,enabled=1};
+
+ otl_exc():
+ msg(),
+ sqlstate(),
+ code(0)
+#if defined(OTL_EXTENDED_EXCEPTION)
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
+ ,msg_arr(0),
+ sqlstate_arr(0),
+#else
+ ,msg_arr(0),
+ sqlstate_arr(0),
+#endif
+ code_arr(0),
+ arr_len(0)
+#endif
+ {
+ sqlstate[0]=0;
+ msg[0]=0;
+ }
+
+#if defined(OTL_EXTENDED_EXCEPTION)
+ otl_exc(const otl_exc& ex):
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
+ msg(),
+ sqlstate(),
+#else
+ msg(),
+ sqlstate(),
+#endif
+ code(0),
+#if defined(OTL_EXTENDED_EXCEPTION)
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
+ msg_arr(0),
+ sqlstate_arr(0),
+#else
+ msg_arr(0),
+ sqlstate_arr(0),
+#endif
+ code_arr(0),
+ arr_len(0)
+#endif
+ {
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
+ otl_strcpy(OTL_RCAST(unsigned char*,msg),
+ OTL_RCAST(const unsigned char*,
+ OTL_CCAST(SQLWCHAR*,ex.msg)));
+ otl_strcpy(OTL_RCAST(unsigned char*,
+ OTL_CCAST(SQLWCHAR*,sqlstate)),
+ OTL_RCAST(const unsigned char*,
+ OTL_CCAST(SQLWCHAR*,ex.sqlstate)));
+ code=ex.code;
+ arr_len=0;
+ msg_arr=0;
+ sqlstate_arr=0;
+ code_arr=0;
+ if(ex.arr_len>0){
+ sqlstate_arr=new SQLWCHAR*[ex.arr_len];
+ msg_arr=new SQLWCHAR*[ex.arr_len];
+ code_arr=new int[ex.arr_len];
+ int i;
+ size_t msg_len, sqlstate_len;
+ for(i=0;i<ex.arr_len;++i){
+ msg_len=otl_strlen(ex.msg_arr[i]);
+ sqlstate_len=otl_strlen(ex.sqlstate_arr[i]);
+ msg_arr[i]=new SQLWCHAR[msg_len+1];
+ sqlstate_arr[i]=new SQLWCHAR[sqlstate_len+1];
+ otl_strcpy(OTL_RCAST(unsigned char*,msg_arr[i]),
+ OTL_RCAST(const unsigned char*,
+ OTL_CCAST(SQLWCHAR*,ex.msg_arr[i])));
+ otl_strcpy(OTL_RCAST(unsigned char*,sqlstate_arr[i]),
+ OTL_RCAST(const unsigned char*,
+ OTL_CCAST(SQLWCHAR*,ex.sqlstate_arr[i])));
+ code_arr[i]=ex.code_arr[i];
+ }
+ arr_len=ex.arr_len;
+ }
+#else
+ OTL_STRCPY_S(OTL_RCAST(char*,msg),
+ sizeof(msg),
+ OTL_RCAST(const char*,ex.msg));
+ OTL_STRCPY_S(OTL_RCAST(char*,sqlstate),
+ sizeof(sqlstate),
+ OTL_RCAST(const char*,ex.sqlstate));
+ code=ex.code;
+ arr_len=0;
+ msg_arr=0;
+ sqlstate_arr=0;
+ code_arr=0;
+ if(ex.arr_len>0){
+ sqlstate_arr=new char*[ex.arr_len];
+ msg_arr=new char*[ex.arr_len];
+ code_arr=new int[ex.arr_len];
+ int i;
+ size_t msg_len, sqlstate_len;
+ for(i=0;i<ex.arr_len;++i){
+ msg_len=strlen(ex.msg_arr[i]);
+ sqlstate_len=strlen(ex.sqlstate_arr[i]);
+ msg_arr[i]=new char[msg_len+1];
+ sqlstate_arr[i]=new char[sqlstate_len+1];
+ OTL_STRCPY_S(msg_arr[i],msg_len+1,ex.msg_arr[i]);
+ OTL_STRCPY_S(sqlstate_arr[i],sqlstate_len+1,ex.sqlstate_arr[i]);
+ code_arr[i]=ex.code_arr[i];
+ }
+ arr_len=ex.arr_len;
+ }
+#endif
+ }
+#endif
+
+ void init(const char* amsg, const int acode)
+ {
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
+ otl_convert_char_to_SQLWCHAR(msg,OTL_RCAST(unsigned char*,OTL_CCAST(char*,amsg)));
+#else
+ OTL_STRCPY_S(OTL_RCAST(char*,msg),sizeof(msg),amsg);
+#endif
+ code=acode;
+ sqlstate[0]=0;
+#if defined(OTL_EXTENDED_EXCEPTION)
+ msg_arr=0;
+ sqlstate_arr=0;
+ code_arr=0;
+ arr_len=0;
+#endif
+ }
+
+ virtual ~otl_exc()
+ {
+#if defined(OTL_EXTENDED_EXCEPTION)
+ int i;
+ if(arr_len>0){
+ for(i=0;i<arr_len;++i){
+ delete[] msg_arr[i];
+ delete[] sqlstate_arr[i];
+ }
+ delete[] msg_arr;
+ delete[] sqlstate_arr;
+ delete[] code_arr;
+ arr_len=0;
+ msg_arr=0;
+ sqlstate_arr=0;
+ code_arr=0;
+ }
+#endif
+ }
+
+private:
+
+ otl_exc& operator=(const otl_exc&)
+ {
+ return *this;
+ }
+
+};
+
+#if (ODBCVER >= 0x0300)
+#if defined(OTL_EXTENDED_EXCEPTION)
+inline void otl_fill_exception(
+ otl_exc& exception_struct,
+ OTL_SQLHANDLE handle,
+ OTL_SQLSMALLINT htype
+)
+{
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
+ OTL_SQLRETURN rc;
+ OTL_SQLSMALLINT msg_len=0;
+ SQLWCHAR* tmp_msg_arr[OTL_MAX_MSG_ARR];
+ SQLWCHAR* tmp_sqlstate_arr[OTL_MAX_MSG_ARR];
+ int tmp_code_arr[OTL_MAX_MSG_ARR];
+ int tmp_arr_len=0;
+ OTL_SQLSMALLINT tmp_msg_len=0;
+ OTL_SQLSMALLINT tmp_sqlstate_len=0;
+ int tmp_code;
+ SQLWCHAR tmp_msg[SQL_MAX_MESSAGE_LENGTH];
+ SQLWCHAR tmp_sqlstate[1000];
+
+ otl_strcpy(OTL_RCAST(unsigned char*,tmp_msg),
+ OTL_RCAST(const unsigned char*,
+ OTL_CCAST(SQLWCHAR*,exception_struct.msg)));
+ otl_strcpy(OTL_RCAST(unsigned char*,tmp_sqlstate),
+ OTL_RCAST(const unsigned char*,
+ OTL_CCAST(SQLWCHAR*,exception_struct.sqlstate)));
+ tmp_code=exception_struct.code;
+
+ do{
+ tmp_sqlstate_len=OTL_SCAST(OTL_SQLSMALLINT,otl_strlen(tmp_sqlstate));
+ tmp_msg_len=OTL_SCAST(OTL_SQLSMALLINT,otl_strlen(tmp_msg));
+ ++tmp_arr_len;
+ tmp_msg_arr[tmp_arr_len-1]=new SQLWCHAR[tmp_msg_len+1];
+ tmp_sqlstate_arr[tmp_arr_len-1]=new SQLWCHAR[tmp_sqlstate_len+1];
+ otl_strcpy(OTL_RCAST(unsigned char*,tmp_msg_arr[tmp_arr_len-1]),
+ OTL_RCAST(const unsigned char*,
+ OTL_CCAST(SQLWCHAR*,tmp_msg)));
+ otl_strcpy(OTL_RCAST(unsigned char*,tmp_sqlstate_arr[tmp_arr_len-1]),
+ OTL_RCAST(const unsigned char*,
+ OTL_CCAST(SQLWCHAR*,tmp_sqlstate)));
+ tmp_code_arr[tmp_arr_len-1]=tmp_code;
+ rc=SQLGetDiagRec
+ (htype,
+ handle,
+ OTL_SCAST(OTL_SQLSMALLINT,tmp_arr_len+1),
+ OTL_RCAST(SQLWCHAR*,tmp_sqlstate),
+ OTL_RCAST(OTL_SQLINTEGER_PTR,&tmp_code),
+ OTL_RCAST(SQLWCHAR*,tmp_msg),
+ SQL_MAX_MESSAGE_LENGTH-1,
+ OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len));
+ tmp_msg[msg_len]=0;
+ if((rc==SQL_NO_DATA||rc==SQL_INVALID_HANDLE||
+ rc==SQL_ERROR)&&tmp_arr_len==1){
+ int i;
+ for(i=0;i<tmp_arr_len;++i){
+ delete[] tmp_msg_arr[i];
+ delete[] tmp_sqlstate_arr[i];
+ }
+ return;
+ }
+ }while(rc!=SQL_NO_DATA&&rc!=SQL_INVALID_HANDLE&&
+ rc!=SQL_ERROR&&tmp_arr_len<OTL_MAX_MSG_ARR);
+
+ exception_struct.arr_len=tmp_arr_len;
+ exception_struct.msg_arr=new SQLWCHAR*[tmp_arr_len];
+ exception_struct.sqlstate_arr=new SQLWCHAR*[tmp_arr_len];
+ exception_struct.code_arr=new int[tmp_arr_len];
+ memcpy(exception_struct.msg_arr,tmp_msg_arr,tmp_arr_len*sizeof(SQLWCHAR*));
+ memcpy(exception_struct.sqlstate_arr,
+ tmp_sqlstate_arr,
+ tmp_arr_len*sizeof(SQLWCHAR*));
+ memcpy(exception_struct.code_arr,
+ tmp_code_arr,
+ tmp_arr_len*sizeof(int));
+#elif defined(UNICODE)||defined(_UNICODE)
+ OTL_SQLRETURN rc;
+ OTL_SQLSMALLINT msg_len=0;
+ char* tmp_msg_arr[OTL_MAX_MSG_ARR];
+ char* tmp_sqlstate_arr[OTL_MAX_MSG_ARR];
+ int tmp_code_arr[OTL_MAX_MSG_ARR];
+ int tmp_arr_len=0;
+ OTL_SQLSMALLINT tmp_msg_len=0;
+ OTL_SQLSMALLINT tmp_sqlstate_len=0;
+ int tmp_code;
+ SQLWCHAR tmp_msg[SQL_MAX_MESSAGE_LENGTH];
+ SQLWCHAR tmp_sqlstate[1000];
+
+ otl_convert_char_to_SQLWCHAR
+ (tmp_msg,
+ OTL_RCAST(const unsigned char*,exception_struct.msg));
+ otl_convert_char_to_SQLWCHAR
+ (tmp_sqlstate,
+ OTL_RCAST(const unsigned char*,exception_struct.sqlstate));
+ tmp_code=exception_struct.code;
+
+ do{
+ tmp_sqlstate_len=OTL_SCAST(OTL_SQLSMALLINT,otl_strlen(tmp_sqlstate));
+ tmp_msg_len=OTL_SCAST(OTL_SQLSMALLINT,otl_strlen(tmp_msg));
+ ++tmp_arr_len;
+ tmp_msg_arr[tmp_arr_len-1]=new char[tmp_msg_len+1];
+ tmp_sqlstate_arr[tmp_arr_len-1]=new char[tmp_sqlstate_len+1];
+ otl_convert_SQLWCHAR_to_char
+ (OTL_RCAST(unsigned char*,tmp_msg_arr[tmp_arr_len-1]),tmp_msg);
+ otl_convert_SQLWCHAR_to_char
+ (OTL_RCAST(unsigned char*,tmp_sqlstate_arr[tmp_arr_len-1]),tmp_sqlstate);
+ tmp_code_arr[tmp_arr_len-1]=tmp_code;
+ rc=SQLGetDiagRec
+ (htype,
+ handle,
+ OTL_SCAST(OTL_SQLSMALLINT,tmp_arr_len+1),
+ tmp_sqlstate,
+ OTL_RCAST(OTL_SQLINTEGER_PTR,&tmp_code),
+ tmp_msg,
+ SQL_MAX_MESSAGE_LENGTH-1,
+ OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len));
+ tmp_msg[msg_len]=0;
+ if((rc==SQL_NO_DATA||rc==SQL_INVALID_HANDLE||
+ rc==SQL_ERROR)&&tmp_arr_len==1){
+ int i;
+ for(i=0;i<tmp_arr_len;++i){
+ delete[] tmp_msg_arr[i];
+ delete[] tmp_sqlstate_arr[i];
+ }
+ return;
+ }
+ }while(rc!=SQL_NO_DATA&&rc!=SQL_INVALID_HANDLE&&
+ rc!=SQL_ERROR&&tmp_arr_len<OTL_MAX_MSG_ARR);
+
+ exception_struct.arr_len=tmp_arr_len;
+ exception_struct.msg_arr=new char*[tmp_arr_len];
+ exception_struct.sqlstate_arr=new char*[tmp_arr_len];
+ exception_struct.code_arr=new int[tmp_arr_len];
+ memcpy(exception_struct.msg_arr,tmp_msg_arr,tmp_arr_len*sizeof(char*));
+ memcpy(exception_struct.sqlstate_arr,tmp_sqlstate_arr,tmp_arr_len*sizeof(char*));
+ memcpy(exception_struct.code_arr,tmp_code_arr,tmp_arr_len*sizeof(int));
+
+#else
+
+ OTL_SQLRETURN rc;
+ OTL_SQLSMALLINT msg_len=0;
+ char* tmp_msg_arr[OTL_MAX_MSG_ARR];
+ char* tmp_sqlstate_arr[OTL_MAX_MSG_ARR];
+ int tmp_code_arr[OTL_MAX_MSG_ARR];
+ int tmp_arr_len=0;
+ OTL_SQLSMALLINT tmp_msg_len=0;
+ OTL_SQLSMALLINT tmp_sqlstate_len=0;
+ int tmp_code;
+ char tmp_msg[SQL_MAX_MESSAGE_LENGTH];
+ char tmp_sqlstate[1000];
+
+ OTL_STRCPY_S(tmp_msg,
+ sizeof(tmp_msg),
+ OTL_RCAST(char*,exception_struct.msg));
+ OTL_STRCPY_S(tmp_sqlstate,
+ sizeof(tmp_sqlstate),
+ OTL_RCAST(char*,exception_struct.sqlstate));
+ tmp_code=exception_struct.code;
+
+ do{
+ tmp_sqlstate_len=OTL_SCAST(OTL_SQLSMALLINT,strlen(tmp_sqlstate));
+ tmp_msg_len=OTL_SCAST(OTL_SQLSMALLINT,strlen(tmp_msg));
+ ++tmp_arr_len;
+ tmp_msg_arr[tmp_arr_len-1]=new char[tmp_msg_len+1];
+ tmp_sqlstate_arr[tmp_arr_len-1]=new char[tmp_sqlstate_len+1];
+ OTL_STRCPY_S(tmp_msg_arr[tmp_arr_len-1],tmp_msg_len+1,tmp_msg);
+ OTL_STRCPY_S(tmp_sqlstate_arr[tmp_arr_len-1],
+ tmp_sqlstate_len+1,
+ tmp_sqlstate);
+ tmp_code_arr[tmp_arr_len-1]=tmp_code;
+ void* temp_ptr=&tmp_code;
+ rc=SQLGetDiagRec
+ (htype,
+ handle,
+ OTL_SCAST(OTL_SQLSMALLINT,tmp_arr_len+1),
+ OTL_RCAST(OTL_SQLCHAR_PTR,tmp_sqlstate),
+ OTL_RCAST(OTL_SQLINTEGER_PTR,temp_ptr),
+ OTL_RCAST(OTL_SQLCHAR_PTR,tmp_msg),
+ SQL_MAX_MESSAGE_LENGTH-1,
+ OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len));
+ tmp_msg[msg_len]=0;
+ if((rc==SQL_NO_DATA||rc==SQL_INVALID_HANDLE||
+ rc==SQL_ERROR)&&tmp_arr_len==1){
+ int i;
+ for(i=0;i<tmp_arr_len;++i){
+ delete[] tmp_msg_arr[i];
+ delete[] tmp_sqlstate_arr[i];
+ }
+ return;
+ }
+ }while(rc!=SQL_NO_DATA&&rc!=SQL_INVALID_HANDLE&&
+ rc!=SQL_ERROR&&tmp_arr_len<OTL_MAX_MSG_ARR);
+
+ exception_struct.arr_len=tmp_arr_len;
+ exception_struct.msg_arr=new char*[tmp_arr_len];
+ exception_struct.sqlstate_arr=new char*[tmp_arr_len];
+ exception_struct.code_arr=new int[tmp_arr_len];
+ memcpy(exception_struct.msg_arr,tmp_msg_arr,tmp_arr_len*sizeof(char*));
+ memcpy(exception_struct.sqlstate_arr,tmp_sqlstate_arr,tmp_arr_len*sizeof(char*));
+ memcpy(exception_struct.code_arr,tmp_code_arr,tmp_arr_len*sizeof(int));
+#endif
+}
+#endif
+#endif
+
+const int OTL_DEFAULT_ODBC_CONNECT=1;
+const int OTL_TIMESTEN_ODBC_CONNECT=2;
+const int OTL_MSSQL_2005_ODBC_CONNECT=3;
+const int OTL_POSTGRESQL_ODBC_CONNECT=4;
+const int OTL_ENTERPRISE_DB_ODBC_CONNECT=5;
+const int OTL_MYODBC35_ODBC_CONNECT=6;
+const int OTL_MSSQL_2008_ODBC_CONNECT=7;
+
+class otl_cur;
+class otl_connect;
+class otl_sel;
+
+class otl_conn{
+protected:
+
+ friend class otl_connect;
+ friend class otl_cur;
+ friend class otl_sel;
+
+ OTL_HENV henv;
+ OTL_HDBC hdbc;
+ int timeout;
+ int cursor_type;
+ int status;
+ int long_max_size;
+ bool extern_lda;
+
+#if defined(OTL_ODBC_zOS)
+ bool logoff_commit;
+#endif
+
+#if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO)
+ bool throws_on_sql_success_with_info;
+#endif
+
+ int connection_type;
+
+public:
+
+
+ void cleanup(void){}
+
+ OTL_HENV& get_henv(){return henv;}
+ OTL_HDBC& get_hdbc(){return hdbc;}
+
+ int get_connection_type(void)
+ {
+ return connection_type;
+ }
+
+ static int initialize(const int /* threaded_mode */=0)
+ {
+ return 1;
+ }
+
+ otl_conn():
+ henv(0),
+ hdbc(0),
+ timeout(0),
+ cursor_type(0),
+ status(SQL_SUCCESS),
+ long_max_size(32760),
+ extern_lda(false)
+#if defined(OTL_ODBC_zOS)
+ ,logoff_commit(true)
+#endif
+#if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO)
+ ,throws_on_sql_success_with_info(false)
+#endif
+ ,connection_type(OTL_DEFAULT_ODBC_CONNECT)
+ {
+ }
+
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
+ int rlogon(const SQLWCHAR* username,
+ const SQLWCHAR* passwd,
+ const SQLWCHAR* tnsname,
+ const int auto_commit)
+ {
+ if(extern_lda){
+ extern_lda=false;
+ henv=0;
+ hdbc=0;
+ }
+ OTL_TRACE_RLOGON_ODBC_W
+ (0x1,
+ L"otl_connect",
+ L"rlogon",
+ OTL_RCAST(const OTL_UNICODE_CHAR_TYPE*,tnsname),
+ OTL_RCAST(const OTL_UNICODE_CHAR_TYPE*,username),
+ OTL_RCAST(const OTL_UNICODE_CHAR_TYPE*,passwd),
+ auto_commit);
+ if(henv==0||hdbc==0){
+ status=SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv);
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+ status=SQLSetEnvAttr
+ (henv,
+ SQL_ATTR_ODBC_VERSION,
+ OTL_RCAST(void*,SQL_OV_ODBC3),
+ SQL_NTS);
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+ status=SQLAllocHandle(SQL_HANDLE_DBC,henv,&hdbc);
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+ }
+ if(auto_commit){
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_AUTOCOMMIT,
+ OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_ON),
+ SQL_IS_POINTER);
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+ }else{
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_AUTOCOMMIT,
+ OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_OFF),
+ SQL_IS_POINTER);
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+ }
+ if(timeout>0){
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_LOGIN_TIMEOUT,
+ OTL_RCAST(void*,OTL_SCAST(size_t,timeout)),
+ 0);
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+ }
+
+#if defined(OTL_DB2_CLI)
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_LONGDATA_COMPAT,
+ OTL_RCAST(SQLPOINTER,SQL_LD_COMPAT_YES),
+ SQL_IS_INTEGER);
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+#endif
+#if defined(OTL_ENABLE_MSSQL_MARS)
+#define OTL_SQL_COPT_SS_BASE 1200
+#define OTL_SQL_COPT_SS_MARS_ENABLED (OTL_SQL_COPT_SS_BASE+24)
+#define OTL_SQL_MARS_ENABLED_YES 1L
+#if !defined(OTL_DB2_CLI) && (ODBCVER >= 0x0300)
+ SQLSetConnectAttr
+ (hdbc,
+ OTL_SQL_COPT_SS_MARS_ENABLED,
+ OTL_RCAST(SQLPOINTER,OTL_SQL_MARS_ENABLED_YES),
+ SQL_IS_UINTEGER);
+#endif
+#endif
+ status=SQLConnect
+ (hdbc,
+ OTL_CCAST(SQLWCHAR*,tnsname),SQL_NTS,
+ OTL_CCAST(SQLWCHAR*,username),SQL_NTS,
+ OTL_CCAST(SQLWCHAR*,passwd),SQL_NTS);
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+ }
+#endif
+
+ int ext_logon(OTL_HENV ahenv,
+ OTL_HDBC ahdbc,
+ const int
+#ifndef OTL_ODBC_MYSQL
+ auto_commit
+#endif
+ )
+ {
+ if(!extern_lda){
+#if (ODBCVER >= 0x0300)
+ if(hdbc!=0){
+ status=SQLFreeHandle(SQL_HANDLE_DBC,hdbc);
+ }
+#else
+ if(hdbc!=0)
+ status=SQLFreeConnect(hdbc);
+#endif
+ hdbc=0;
+#if (ODBCVER >= 0x0300)
+ if(henv!=0){
+ status=SQLFreeHandle(SQL_HANDLE_ENV,henv);
+ }
+#else
+ if(henv!=0)
+ status=SQLFreeEnv(henv);
+#endif
+ henv=0;
+ }
+ extern_lda=true;
+ henv=ahenv;
+ hdbc=ahdbc;
+#ifndef OTL_ODBC_MYSQL
+#if (ODBCVER >= 0x0300)
+ if(auto_commit)
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_AUTOCOMMIT,
+ OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_ON),
+ SQL_IS_POINTER);
+ else
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_AUTOCOMMIT,
+ OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_OFF),
+ SQL_IS_POINTER);
+#else
+ if(auto_commit)
+ status=SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,1);
+ else
+ status=SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,0);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+#endif
+
+#if defined(OTL_DB2_CLI)
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_LONGDATA_COMPAT,
+ OTL_RCAST(SQLPOINTER,SQL_LD_COMPAT_YES),
+ SQL_IS_INTEGER);
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+#endif
+
+ return 1;
+
+ }
+
+ virtual ~otl_conn()
+ {
+ if(extern_lda){
+ hdbc=0;
+ henv=0;
+ extern_lda=false;
+ }else{
+#if (ODBCVER >= 0x0300)
+ if(hdbc!=0){
+ status=SQLFreeHandle(SQL_HANDLE_DBC,hdbc);
+ }
+#else
+ if(hdbc!=0)
+ status=SQLFreeConnect(hdbc);
+#endif
+ hdbc=0;
+#if (ODBCVER >= 0x0300)
+ if(henv!=0){
+ status=SQLFreeHandle(SQL_HANDLE_ENV,henv);
+ }
+#else
+ if(henv!=0)
+ status=SQLFreeEnv(henv);
+#endif
+ henv=0;
+ }
+ }
+
+ void set_timeout(const int atimeout=0)
+ {
+ timeout=atimeout;
+ }
+
+ void set_cursor_type(const int acursor_type=0)
+ {
+ cursor_type=acursor_type;
+ }
+
+ int rlogon(const char* connect_str,
+ const int
+#ifndef OTL_ODBC_MYSQL
+ auto_commit
+#endif
+ )
+ {
+ char username[256];
+ char passwd[256];
+ char tnsname[1024];
+ char* tnsname_ptr=0;
+ char* c=OTL_CCAST(char*,connect_str);
+ char* username_ptr=username;
+ char* passwd_ptr=passwd;
+ char temp_connect_str[512];
+
+ if(extern_lda){
+ extern_lda=false;
+ henv=0;
+ hdbc=0;
+ }
+ memset(username,0,sizeof(username));
+ memset(passwd,0,sizeof(passwd));
+ memset(tnsname,0,sizeof(tnsname));
+
+ char* c1=OTL_CCAST(char*,connect_str);
+ int oracle_format=0;
+ char prev_c=' ';
+ while(*c1){
+ if(*c1=='@' && prev_c!='\\'){
+ oracle_format=1;
+ break;
+ }
+ prev_c=*c1;
+ ++c1;
+ }
+
+ if(oracle_format){
+ while(*c && *c!='/' && (OTL_SCAST(unsigned,username_ptr-username)<
+ sizeof(username)-1)){
+ *username_ptr=*c;
+ ++c;
+ ++username_ptr;
+ }
+ *username_ptr=0;
+
+ if(*c=='/')++c;
+ prev_c=' ';
+ while(*c && !(*c=='@' && prev_c!='\\') &&
+ (OTL_SCAST(unsigned,passwd_ptr-passwd)<sizeof(passwd)-1)){
+ if(prev_c=='\\')--passwd_ptr;
+ *passwd_ptr=*c;
+ prev_c=*c;
+ ++c;
+ ++passwd_ptr;
+ }
+ *passwd_ptr=0;
+
+ if(*c=='@'){
+ ++c;
+ tnsname_ptr=tnsname;
+ while(*c && (OTL_SCAST(unsigned,tnsname_ptr-tnsname)<sizeof(tnsname)-1)){
+ *tnsname_ptr=*c;
+ ++c;
+ ++tnsname_ptr;
+ }
+ *tnsname_ptr=0;
+ }
+ }else{
+ c1=OTL_CCAST(char*,connect_str);
+ char* c2=temp_connect_str;
+ while(*c1 && (OTL_SCAST(unsigned,c2-temp_connect_str)
+ <sizeof(temp_connect_str)-1)){
+ *c2=otl_to_upper(*c1);
+ ++c1;
+ ++c2;
+ }
+ *c2=0;
+ c1=temp_connect_str;
+ char entry_name[256];
+ char entry_value[256];
+ while(*c1 && (OTL_SCAST(unsigned,c1-temp_connect_str)<
+ sizeof(temp_connect_str)-1)){
+ c2=entry_name;
+ while(*c1 && *c1!='=' &&
+ (OTL_SCAST(unsigned,c1-temp_connect_str)<
+ sizeof(temp_connect_str)-1)){
+ *c2=*c1;
+ ++c1;
+ ++c2;
+ }
+ *c2=0;
+ if(*c1) ++c1;
+ c2=entry_value;
+ prev_c=' ';
+ while(*c1&&*c1!=';' &&
+ (OTL_SCAST(unsigned,c2-entry_value)<
+ sizeof(entry_value)-1)){
+ if(prev_c=='\\')
+ --c2;
+ *c2=*c1;
+ prev_c=*c1;
+ ++c1;
+ ++c2;
+ }
+ *c2=0;
+ if(*c1) ++c1;
+ if(strcmp(entry_name,"DSN")==0)
+ OTL_STRCPY_S(tnsname,sizeof(tnsname),entry_value);
+ if(strcmp(entry_name,"UID")==0)
+ OTL_STRCPY_S(username,sizeof(username),entry_value);
+ if(strcmp(entry_name,"PWD")==0)
+ OTL_STRCPY_S(passwd,sizeof(passwd),entry_value);
+ }
+ }
+#ifndef OTL_ODBC_MYSQL
+ OTL_TRACE_RLOGON_ODBC
+ (0x1,
+ "otl_connect",
+ "rlogon",
+ tnsname,
+ username,
+ passwd,
+ auto_commit)
+#else
+ OTL_TRACE_RLOGON_ODBC
+ (0x1,
+ "otl_connect",
+ "rlogon",
+ tnsname,
+ username,
+ passwd,
+ 0)
+#endif
+ if(henv==0||hdbc==0){
+#if (ODBCVER >= 0x0300)
+ status=SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv);
+#else
+ status=SQLAllocEnv(&henv);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+
+#if (ODBCVER >= 0x0300)
+ status=SQLSetEnvAttr
+ (henv,
+ SQL_ATTR_ODBC_VERSION,
+ OTL_RCAST(void*,SQL_OV_ODBC3),
+ SQL_NTS);
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+#endif
+
+#if (ODBCVER >= 0x0300)
+ status=SQLAllocHandle(SQL_HANDLE_DBC,henv,&hdbc);
+#else
+ status=SQLAllocConnect(henv, &hdbc);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+ }else
+ status=SQL_SUCCESS;
+
+#ifndef OTL_ODBC_MYSQL
+#if (ODBCVER >= 0x0300)
+ if(auto_commit)
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_AUTOCOMMIT,
+ OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_ON),
+ SQL_IS_POINTER);
+ else
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_AUTOCOMMIT,
+ OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_OFF),
+ SQL_IS_POINTER);
+#else
+ if(auto_commit)
+ status=SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,1);
+ else
+ status=SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,0);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+#endif
+#if (ODBCVER >= 0x0300)
+ if(timeout>0)
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_LOGIN_TIMEOUT,
+ OTL_RCAST(void*,OTL_SCAST(size_t,timeout)),
+ 0);
+#else
+ if (timeout>0)
+ status=SQLSetConnectOption(hdbc,SQL_LOGIN_TIMEOUT,timeout);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+
+
+#if defined(OTL_DB2_CLI)
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_LONGDATA_COMPAT,
+ OTL_RCAST(SQLPOINTER,SQL_LD_COMPAT_YES),
+ SQL_IS_INTEGER);
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+#endif
+
+#if defined(OTL_ENABLE_MSSQL_MARS)
+#define OTL_SQL_COPT_SS_BASE 1200
+#define OTL_SQL_COPT_SS_MARS_ENABLED (OTL_SQL_COPT_SS_BASE+24)
+#define OTL_SQL_MARS_ENABLED_YES 1L
+#if !defined(OTL_DB2_CLI) && (ODBCVER >= 0x0300)
+ SQLSetConnectAttr
+ (hdbc,
+ OTL_SQL_COPT_SS_MARS_ENABLED,
+ OTL_RCAST(SQLPOINTER,OTL_SQL_MARS_ENABLED_YES),
+ SQL_IS_UINTEGER);
+#endif
+#endif
+
+ if(oracle_format){
+#if defined(OTL_ODBC_zOS)
+ if(tnsname[0]==0 && username[0]==0 && passwd[0]==0){
+ status=SQLConnect
+ (hdbc,
+ 0L,SQL_NTS,
+ 0L,SQL_NTS,
+ 0L,SQL_NTS);
+ logoff_commit = false;
+ }else
+ status=SQLConnect
+ (hdbc,
+ OTL_RCAST(unsigned char*,tnsname),SQL_NTS,
+ OTL_RCAST(unsigned char*,username),SQL_NTS,
+ OTL_RCAST(unsigned char*,passwd),SQL_NTS);
+#else
+
+#if defined(UNICODE) || defined(_UNICODE)
+ {
+ SQLWCHAR* temp_tnsname=new SQLWCHAR[strlen(tnsname)+1];
+ SQLWCHAR* temp_username=new SQLWCHAR[strlen(username)+1];
+ SQLWCHAR* temp_passwd=new SQLWCHAR[strlen(passwd)+1];
+ otl_convert_char_to_SQLWCHAR(temp_tnsname,OTL_RCAST(unsigned char*,tnsname));
+ otl_convert_char_to_SQLWCHAR(temp_username,OTL_RCAST(unsigned char*,username));
+ otl_convert_char_to_SQLWCHAR(temp_passwd,OTL_RCAST(unsigned char*,passwd));
+ status=SQLConnect
+ (hdbc,
+ temp_tnsname,SQL_NTS,
+ temp_username,SQL_NTS,
+ temp_passwd,SQL_NTS);
+ delete[] temp_tnsname;
+ delete[] temp_username;
+ delete[] temp_passwd;
+ }
+#else
+ status=SQLConnect
+ (hdbc,
+ OTL_RCAST(unsigned char*,tnsname),SQL_NTS,
+ OTL_RCAST(unsigned char*,username),SQL_NTS,
+ OTL_RCAST(unsigned char*,passwd),SQL_NTS);
+#endif
+
+#endif
+ }else{
+ char* tc2=temp_connect_str;
+ const char* tc1=connect_str;
+ prev_c=' ';
+ while(*tc1 && (OTL_SCAST(unsigned,tc2-temp_connect_str)<
+ sizeof(temp_connect_str)-1)){
+ if(*tc1=='@' && prev_c=='\\')
+ --tc2;
+ *tc2=*tc1;
+ prev_c=*tc1;
+ ++tc1;
+ ++tc2;
+ }
+ *tc2=0;
+ SQLSMALLINT out_len=0;
+#if (defined(UNICODE)||defined(_UNICODE))
+ {
+ size_t len=strlen(temp_connect_str);
+ SQLWCHAR* temp_connect_str2=new SQLWCHAR[len+1];
+ SQLWCHAR out_str[2048];
+ otl_convert_char_to_SQLWCHAR(temp_connect_str2,OTL_RCAST(unsigned char*,temp_connect_str));
+ status=SQLDriverConnect
+ (hdbc,
+ 0,
+ temp_connect_str2,
+ OTL_SCAST(short,len),
+ out_str,
+ sizeof(out_str)/sizeof(SQLWCHAR),
+ &out_len,
+ SQL_DRIVER_NOPROMPT);
+ delete[] temp_connect_str2;
+ }
+#else
+ SQLCHAR out_str[2048];
+ status=SQLDriverConnect
+ (hdbc,
+ 0,
+ OTL_RCAST(SQLCHAR*,OTL_CCAST(char*,temp_connect_str)),
+ OTL_SCAST(short,strlen(temp_connect_str)),
+ out_str,
+ sizeof(out_str),
+ &out_len,
+ SQL_DRIVER_NOPROMPT);
+#endif
+ }
+
+ if(status == SQL_SUCCESS_WITH_INFO || status == SQL_SUCCESS)
+ return 1;
+ else
+ return 0;
+
+ }
+
+ int set_transaction_isolation_level
+ (const long int
+#ifndef OTL_ODBC_MYSQL
+ level
+#endif
+ )
+ {
+#ifndef OTL_ODBC_MYSQL
+#if (ODBCVER >= 0x0300)
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_TXN_ISOLATION,
+ OTL_RCAST(SQLPOINTER,OTL_SCAST(size_t,level)),
+ SQL_IS_POINTER);
+#else
+ status=SQLSetConnectOption(hdbc,SQL_TXN_ISOLATION,level);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+#else
+ return 1;
+#endif
+
+ }
+
+ int auto_commit_on(void)
+ {
+#if defined(OTL_ODBC_MYSQL)
+ return 1;
+#else
+#if (ODBCVER >= 0x0300)
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_AUTOCOMMIT,
+ OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_ON),
+ SQL_IS_POINTER);
+#else
+ status=SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,1);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+#endif
+ }
+
+ int auto_commit_off(void)
+ {
+#if defined(OTL_ODBC_MYSQL)
+ return 1;
+#else
+#if (ODBCVER >= 0x0300)
+ status=SQLSetConnectAttr
+ (hdbc,
+ SQL_ATTR_AUTOCOMMIT,
+ OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_OFF),
+ SQL_IS_POINTER);
+#else
+ status=SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,0);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+#endif
+ }
+
+
+ int logoff(void)
+ {
+ if(extern_lda){
+ extern_lda=false;
+ henv=0;
+ hdbc=0;
+ return 1;
+ }else{
+#if defined(OTL_ODBC_zOS)
+ if(logoff_commit)
+ commit();
+#else
+ commit();
+#endif
+ status=SQLDisconnect(hdbc);
+#if defined(OTL_ODBC_LOGOFF_FREES_HANDLES)
+#if (ODBCVER >= 0x0300)
+ if(hdbc!=0){
+ SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
+ hdbc=0;
+ }
+ if(henv!=0){
+ SQLFreeHandle(SQL_HANDLE_ENV, henv);
+ henv=0;
+ }
+ #else
+ if(hdbc!=0){
+ SQLFreeConnect(hdbc);
+ hdbc=0;
+ }
+ if(henv!=0){
+ SQLFreeEnv(henv);
+ henv=0;
+ }
+#endif
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+
+ }
+ }
+
+ void error(otl_exc& exception_struct)
+ {OTL_SQLRETURN rc;
+ OTL_SQLSMALLINT msg_len=0;
+
+#if (ODBCVER >= 0x0300)
+
+#if (defined(UNICODE)||defined(_UNICODE))
+
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
+
+ rc=SQLGetDiagRec
+#if defined(OTL_ODBC_zOS)
+ (hdbc==0?SQL_HANDLE_ENV:SQL_HANDLE_DBC,
+ hdbc==0?henv:hdbc,
+#else
+ (SQL_HANDLE_DBC,
+ hdbc,
+#endif
+ 1,
+ &exception_struct.sqlstate[0],
+ OTL_RCAST(OTL_SQLINTEGER_PTR,&exception_struct.code),
+ &exception_struct.msg[0],
+ SQL_MAX_MESSAGE_LENGTH-1,
+ OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len));
+ exception_struct.msg[msg_len]=0;
+
+#else
+
+ {
+ SQLWCHAR temp_msg[SQL_MAX_MESSAGE_LENGTH];
+ SQLWCHAR temp_sqlstate[1000];
+
+ rc=SQLGetDiagRec
+#if defined(OTL_ODBC_zOS)
+ (hdbc==0?SQL_HANDLE_ENV:SQL_HANDLE_DBC,
+ hdbc==0?henv:hdbc,
+#else
+ (SQL_HANDLE_DBC,
+ hdbc,
+#endif
+ 1,
+ temp_sqlstate,
+ OTL_RCAST(OTL_SQLINTEGER_PTR,&exception_struct.code),
+ temp_msg,
+ SQL_MAX_MESSAGE_LENGTH-1,
+ OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len));
+ temp_msg[msg_len]=0;
+ otl_convert_SQLWCHAR_to_char
+ (OTL_RCAST(unsigned char*,&exception_struct.sqlstate[0]),
+ temp_sqlstate);
+ otl_convert_SQLWCHAR_to_char
+ (OTL_RCAST(unsigned char*,&exception_struct.msg[0]),
+ temp_msg);
+ }
+
+#endif
+
+#else
+ void* temp_ptr=&exception_struct.code;
+ rc=SQLGetDiagRec
+#if defined(OTL_ODBC_zOS)
+ (hdbc==0?SQL_HANDLE_ENV:SQL_HANDLE_DBC,
+ hdbc==0?henv:hdbc,
+#else
+ (SQL_HANDLE_DBC,
+ hdbc,
+#endif
+ 1,
+ OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.sqlstate[0]),
+ OTL_RCAST(OTL_SQLINTEGER_PTR,temp_ptr),
+ OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.msg[0]),
+ SQL_MAX_MESSAGE_LENGTH-1,
+ OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len));
+#endif
+
+#else
+ rc=SQLError(henv,
+ hdbc,
+ 0, // hstmt
+ OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.sqlstate[0]),
+ OTL_RCAST(OTL_SQLINTEGER_PTR,&exception_struct.code),
+ OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.msg[0]),
+ SQL_MAX_MESSAGE_LENGTH-1,
+ OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len));
+#endif
+ exception_struct.msg[msg_len]=0;
+
+ if(rc==SQL_INVALID_HANDLE||rc==SQL_ERROR)
+ exception_struct.msg[0]=0;
+#if (ODBCVER >= 0x0300)
+#if defined(OTL_EXTENDED_EXCEPTION)
+ else if(rc!=SQL_NO_DATA)
+#if defined(OTL_ODBC_zOS)
+ {
+ if(hdbc)
+ otl_fill_exception(exception_struct,hdbc,SQL_HANDLE_DBC);
+ else
+ otl_fill_exception(exception_struct,henv,SQL_HANDLE_ENV);
+ }
+#else
+ otl_fill_exception(exception_struct,hdbc,SQL_HANDLE_DBC);
+#endif
+#endif
+#endif
+
+ }
+
+ int commit(void)
+ {
+#ifndef OTL_ODBC_MYSQL
+#if (ODBCVER >= 0x0300)
+ status=SQLEndTran(SQL_HANDLE_DBC,hdbc,SQL_COMMIT);
+#else
+ status=SQLTransact(henv,hdbc,SQL_COMMIT);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+#else
+ return 1;
+#endif
+ }
+
+ int rollback(void)
+ {
+#ifndef OTL_ODBC_MYSQL
+#if (ODBCVER >= 0x0300)
+ status=SQLEndTran(SQL_HANDLE_DBC,hdbc,SQL_ROLLBACK);
+#else
+ status=SQLTransact(henv,hdbc,SQL_ROLLBACK);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+#else
+ return 1;
+#endif
+ }
+
+private:
+
+ otl_conn(const otl_conn&):
+ henv(0),
+ hdbc(0),
+ timeout(0),
+ cursor_type(0),
+ status(SQL_SUCCESS),
+ long_max_size(32760),
+ extern_lda(false)
+#if defined(OTL_ODBC_zOS)
+ ,logoff_commit(true)
+#endif
+#if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO)
+ ,throws_on_sql_success_with_info(false)
+#endif
+ ,connection_type(OTL_DEFAULT_ODBC_CONNECT)
+ {
+ }
+
+ otl_conn& operator=(const otl_conn&)
+ {
+ return *this;
+ }
+
+
+};
+
+class otl_var;
+class otl_cur;
+class otl_sel;
+
+class otl_cur0{
+protected:
+
+ friend class otl_sel;
+ friend class otl_var;
+ OTL_SQLHSTMT cda;
+ int last_param_data_token;
+ int last_sql_param_data_status;
+ int sql_param_data_count;
+
+public:
+
+ otl_cur0():
+ cda(0),
+ last_param_data_token(0),
+ last_sql_param_data_status(0),
+ sql_param_data_count(0)
+ {
+ }
+
+ virtual ~otl_cur0(){}
+
+ OTL_SQLHSTMT get_cda(){return cda;}
+
+private:
+
+ otl_cur0(const otl_cur0&):
+ cda(0),
+ last_param_data_token(0),
+ last_sql_param_data_status(0),
+ sql_param_data_count(0)
+ {
+ }
+
+ otl_cur0& operator=(const otl_cur0&)
+ {
+ return *this;
+ }
+
+
+};
+
+class otl_cur;
+
+class otl_var{
+private:
+
+ friend class otl_cur;
+ unsigned char* p_v;
+ OTL_SQLLEN_PTR p_len;
+ int ftype;
+ int act_elem_size;
+ bool lob_stream_mode;
+ int lob_stream_flag;
+ int vparam_type;
+ int lob_len;
+ int lob_pos;
+ int lob_ftype;
+ int otl_adapter;
+ bool charz_flag;
+
+public:
+
+ int get_otl_adapter() const {return otl_adapter;}
+
+ void set_lob_stream_mode(const bool alob_stream_mode)
+ {
+ lob_stream_mode=alob_stream_mode;
+ }
+
+ void set_vparam_type(const int avparam_type)
+ {
+ vparam_type=avparam_type;
+ }
+
+ void set_charz_flag(const bool acharz_flag)
+ {
+ charz_flag=acharz_flag;
+ }
+
+
+ otl_var():
+ p_v(0),
+ p_len(0),
+ ftype(0),
+ act_elem_size(0),
+ lob_stream_mode(false),
+ lob_stream_flag(0),
+ vparam_type(-1),
+ lob_len(0),
+ lob_pos(0),
+ lob_ftype(0),
+ otl_adapter(otl_odbc_adapter),
+ charz_flag(false)
+ {
+ }
+
+ virtual ~otl_var()
+ {
+ delete[] p_v;
+ delete[] p_len;
+ }
+
+ int write_dt(void* trg, const void* src, const int sz)
+ {
+ memcpy(trg,src,sz);
+ return 1;
+ }
+
+ int read_dt(void* trg, const void* src, const int sz)
+ {
+ memcpy(trg,src,sz);
+ return 1;
+ }
+
+ void set_lob_stream_flag(const int flg=1)
+ {
+ lob_stream_flag=flg;
+ }
+
+ int get_pl_tab_len(void)
+ {
+ return 0;
+ }
+
+ int get_max_pl_tab_len(void)
+ {
+ return 0;
+ }
+
+ void set_pl_tab_len(const int /* pl_tab_len */)
+ {
+ }
+
+ int write_blob
+ (const otl_long_string& s,
+ const int /* alob_len */,
+ int& aoffset,
+ otl_cur0& cur)
+ {
+ SQLRETURN rc=0;
+ SQLINTEGER temp_len=0;
+ SQLPOINTER pToken=0;
+ int param_number=0;
+
+ if(!lob_stream_flag&&!lob_stream_mode)return 1;
+ if(aoffset==1){
+ if(cur.sql_param_data_count==0){
+ rc=SQLParamData(cur.cda, &pToken);
+ param_number=OTL_SCAST(int,OTL_RCAST(size_t,pToken));
+ ++cur.sql_param_data_count;
+ cur.last_sql_param_data_status=rc;
+ cur.last_param_data_token=param_number;
+ if(rc!=SQL_SUCCESS&&rc!=SQL_SUCCESS_WITH_INFO&&
+ rc!=SQL_NEED_DATA)
+ return 0;
+ }
+ }
+ if(ftype==otl_var_raw_long)
+ temp_len=s.len();
+ else
+ temp_len=s.len()*sizeof(OTL_CHAR);
+ rc=SQLPutData(cur.cda,s.v,temp_len);
+ if(rc!=SQL_SUCCESS&&rc!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else{
+ aoffset+=s.len();
+ return 1;
+ }
+ }
+
+ int clob_blob(otl_cur0& cur)
+ {
+ SQLRETURN rc=0;
+ SQLPOINTER pToken=0;
+ int param_number=0;
+
+ if(!(cur.last_param_data_token==0&&cur.sql_param_data_count>0)){
+ rc=SQLParamData(cur.cda, &pToken);
+ param_number=OTL_SCAST(int,OTL_RCAST(size_t,pToken));
+ ++cur.sql_param_data_count;
+ cur.last_sql_param_data_status=rc;
+ cur.last_param_data_token=param_number;
+ if(rc!=SQL_SUCCESS&&rc!=SQL_SUCCESS_WITH_INFO&&
+#if (ODBCVER >= 0x0300)
+ rc!=SQL_NO_DATA &&
+#endif
+ rc!=SQL_NEED_DATA)
+ return 0;
+ }
+ return 1;
+ }
+
+ int read_blob
+ (otl_cur0& cur,
+ otl_long_string& s,
+ const int andx,
+ int& aoffset,
+ int& eof_flag)
+ {
+ SQLRETURN rc=0;
+ OTL_SQLLEN retLen=0;
+ int chunkLen=0;
+ if(!lob_stream_flag&&!lob_stream_mode)return 1;
+ int buf_size=s.get_buf_size()*sizeof(OTL_CHAR);
+ if(ftype==otl_var_raw_long)
+ buf_size=s.get_buf_size();
+ rc=SQLGetData
+ (cur.cda,
+ OTL_SCAST(SQLSMALLINT,lob_pos),
+ OTL_SCAST(SQLSMALLINT,lob_ftype),
+ s.v,
+ buf_size,
+ &retLen);
+ if(rc==SQL_SUCCESS_WITH_INFO||rc==SQL_SUCCESS){
+ if(retLen==SQL_NULL_DATA){
+ chunkLen=0;
+ p_len[andx]=SQL_NULL_DATA;
+ }else if(retLen>buf_size||retLen==SQL_NO_TOTAL)
+ chunkLen=s.get_buf_size();
+ else{
+ if(ftype==otl_var_raw_long)
+ chunkLen=OTL_SCAST(int,retLen);
+ else
+ chunkLen=OTL_SCAST(int,retLen)/sizeof(OTL_CHAR);
+ }
+#if defined(OTL_UNICODE)
+ if(lob_ftype==SQL_C_WCHAR)
+ s.set_len(chunkLen-1);
+#else
+ if(lob_ftype==SQL_C_CHAR)
+ s.set_len(chunkLen-1);
+#endif
+ else
+ s.set_len(chunkLen);
+ if(lob_len==0&&aoffset==1&&
+ retLen!=SQL_NULL_DATA&&
+ retLen!=SQL_NO_TOTAL)
+ lob_len=OTL_SCAST(int,retLen);
+ aoffset+=chunkLen;
+ if(chunkLen<s.get_buf_size()||rc==SQL_SUCCESS){
+ s.set_len(chunkLen);
+ eof_flag=1;
+ }else
+ eof_flag=0;
+ return 1;
+ }
+#if (ODBCVER >= 0x0300)
+ else if(rc==SQL_NO_DATA)
+#else
+ else if(rc==SQL_NO_DATA_FOUND)
+#endif
+ return 1;
+ else
+ return 0;
+ }
+
+
+ int get_blob_len(const int /* ndx */,int& alen)
+ {
+ alen=lob_len;
+ return 1;
+ }
+
+ int put_blob(void)
+ {
+ return 1;
+ }
+
+ int get_blob
+ (const int /* ndx */,
+ unsigned char* /* abuf */,
+ const int /* buf_size */,
+ int& /* len */)
+ {
+ return 1;
+ }
+
+ int save_blob
+ (const unsigned char* /* abuf */,
+ const int /* len */,
+ const int /* extern_buffer_flag */)
+ {
+ return 1;
+ }
+
+ int actual_elem_size(void)
+ {
+ return act_elem_size;
+ }
+
+ void init
+ (const bool,
+ const int aftype,
+ int& aelem_size,
+ const otl_stream_buffer_size_type aarray_size,
+ const void* /* connect_struct */=0,
+ const int /*apl_tab_size*/=0)
+ {int i;
+ size_t byte_size=0;
+ ftype=aftype;
+ act_elem_size=aelem_size;
+ byte_size=aelem_size*OTL_SCAST(size_t,aarray_size);
+#if defined(OTL_UNICODE)
+ if(aftype==otl_var_char||aftype==otl_var_varchar_long){
+ byte_size*=sizeof(OTL_CHAR);
+ p_v=new unsigned char[byte_size];
+ }
+ else
+ p_v=new unsigned char[byte_size];
+#else
+ p_v=new unsigned char[byte_size];
+#endif
+ p_len=new OTL_SQLLEN[aarray_size];
+ memset(p_v,0,byte_size);
+ for(i=0;i<aarray_size;++i){
+ if(ftype==otl_var_char)
+ p_len[i]=OTL_SCAST(OTL_SQLLEN,SQL_NTS);
+ else if(ftype==otl_var_varchar_long||ftype==otl_var_raw_long)
+ p_len[i]=0;
+ else
+ p_len[i]=OTL_SCAST(OTL_SQLLEN,aelem_size);
+ }
+ }
+
+ void set_null(int ndx)
+ {
+ p_len[ndx]=SQL_NULL_DATA;
+ }
+
+ void set_not_null(int ndx, int pelem_size)
+ {
+ set_len(pelem_size,ndx);
+ }
+
+ void set_len(int len, int ndx)
+ {
+ switch(ftype){
+ case otl_var_char:
+ p_len[ndx]=SQL_NTS;
+ break;
+ case otl_var_varchar_long:
+ if(lob_stream_mode &&
+ (vparam_type==otl_input_param||
+ vparam_type==otl_inout_param))
+ p_len[ndx]=SQL_DATA_AT_EXEC;
+ else
+#if defined(OTL_UNICODE)
+ p_len[ndx]=OTL_SCAST(OTL_SQLLEN,len*sizeof(OTL_CHAR));
+#else
+ p_len[ndx]=OTL_SCAST(OTL_SQLLEN,len);
+#endif
+ break;
+ case otl_var_raw_long:
+ if(lob_stream_mode &&
+ (vparam_type==otl_input_param||
+ vparam_type==otl_inout_param))
+ p_len[ndx]=SQL_DATA_AT_EXEC;
+ else
+ p_len[ndx]=OTL_SCAST(OTL_SQLLEN,len);
+ break;
+ default:
+ p_len[ndx]=OTL_SCAST(OTL_SQLLEN,len);
+ break;
+ }
+ }
+
+ int get_len(int ndx)
+ {
+ if(p_len[ndx]==SQL_NULL_DATA)
+ return 0;
+ else
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_varchar_long || ftype==otl_var_char)
+ return OTL_SCAST(int,p_len[ndx])/sizeof(OTL_CHAR);
+ else
+ return OTL_SCAST(int,p_len[ndx]);
+#else
+ return OTL_SCAST(int,p_len[ndx]);
+#endif
+ }
+
+ int is_null(int ndx)
+ {
+ return p_len[ndx]==SQL_NULL_DATA;
+ }
+
+ void* val(int ndx,int pelem_size)
+ {
+#if defined(OTL_UNICODE)
+ switch(ftype){
+ case otl_var_char:
+ case otl_var_varchar_long:
+ return OTL_RCAST(void*,
+ &p_v[(OTL_SCAST(size_t,ndx))*pelem_size*sizeof(OTL_CHAR)]);
+ default:
+ return OTL_RCAST(void*,&p_v[(OTL_SCAST(size_t,ndx))*pelem_size]);
+ }
+#else
+ return OTL_RCAST(void*,&p_v[(OTL_SCAST(size_t,ndx))*pelem_size]);
+#endif
+ }
+
+#define OTL_SQL_UNICODE_CHAR (-95)
+#define OTL_SQL_UNICODE_VARCHAR (-96)
+#define OTL_SQL_UNICODE_LONGVARCHAR (-97)
+
+#define OTL_SQL_SS_TIME2 (-154)
+#define OTL_SQL_SS_TIMESTAMPOFFSET (-155)
+
+ static int int2ext(int int_type)
+ {
+ switch(int_type){
+#if defined(OTL_UNICODE)
+ case SQL_VARCHAR: return SQL_C_WCHAR;
+ case SQL_WVARCHAR: return SQL_C_WCHAR;
+ case SQL_CHAR: return SQL_C_WCHAR;
+ case SQL_WCHAR: return SQL_C_WCHAR;
+ case SQL_LONGVARCHAR: return SQL_WLONGVARCHAR;
+ case SQL_WLONGVARCHAR: return SQL_WLONGVARCHAR;
+ case OTL_SQL_UNICODE_VARCHAR: return SQL_C_WCHAR;
+ case OTL_SQL_UNICODE_CHAR: return SQL_C_WCHAR;
+ case OTL_SQL_UNICODE_LONGVARCHAR: return SQL_WLONGVARCHAR;
+#else
+ case SQL_CHAR: return SQL_C_CHAR;
+ case SQL_VARCHAR: return SQL_C_CHAR;
+#if defined(SQL_WCHAR)
+ case SQL_WCHAR: return SQL_C_CHAR;
+#else
+ case -8: return SQL_C_CHAR;
+#endif
+#if defined(SQL_WVARCHAR)
+ case SQL_WVARCHAR: return SQL_C_CHAR;
+#else
+ case -9: return SQL_C_CHAR;
+#endif
+ case SQL_LONGVARCHAR: return SQL_LONGVARCHAR;
+#if defined(SQL_WLONGVARCHAR)
+ case SQL_WLONGVARCHAR: return SQL_LONGVARCHAR;
+#else
+ case -10: return SQL_LONGVARCHAR;
+#endif
+ case OTL_SQL_UNICODE_VARCHAR: return SQL_C_CHAR;
+ case OTL_SQL_UNICODE_CHAR: return SQL_C_CHAR;
+ case OTL_SQL_UNICODE_LONGVARCHAR: return SQL_LONGVARCHAR;
+#endif
+#if (ODBCVER >= 0x0300)
+ case SQL_TYPE_DATE: return SQL_C_TIMESTAMP;
+ case SQL_TYPE_TIMESTAMP: return SQL_C_TIMESTAMP;
+ case SQL_TYPE_TIME: return SQL_C_TIMESTAMP;
+ case OTL_SQL_SS_TIME2: return SQL_C_TIMESTAMP;
+#if defined(OTL_UNICODE)
+ case OTL_SQL_SS_TIMESTAMPOFFSET: return SQL_C_WCHAR;
+#else
+ case OTL_SQL_SS_TIMESTAMPOFFSET: return SQL_C_CHAR;
+#endif
+#else
+ case SQL_DATE: return SQL_C_TIMESTAMP;
+ case SQL_TIMESTAMP: return SQL_C_TIMESTAMP;
+ case SQL_TIME: return SQL_C_TIMESTAMP;
+#endif
+#if defined(OTL_BIGINT)
+ case SQL_BIGINT: return SQL_C_SBIGINT;
+#else
+ case SQL_BIGINT: return SQL_C_DOUBLE;
+#endif
+ case SQL_DECIMAL: return SQL_C_DOUBLE;
+ case SQL_DOUBLE: return SQL_C_DOUBLE;
+ case SQL_FLOAT: return SQL_C_DOUBLE;
+ case SQL_INTEGER: return SQL_C_SLONG;
+ case SQL_NUMERIC: return SQL_C_DOUBLE;
+ case SQL_REAL: return SQL_C_DOUBLE;
+ case SQL_SMALLINT: return SQL_C_SSHORT;
+ case SQL_BIT: return SQL_C_SSHORT;
+ case SQL_TINYINT: return SQL_C_SSHORT;
+ case SQL_LONGVARBINARY: return SQL_LONGVARBINARY;
+#if defined(OTL_MAP_SQL_VARBINARY_TO_RAW_LONG)
+ case SQL_VARBINARY: return SQL_LONGVARBINARY;
+#else
+ case SQL_VARBINARY: return SQL_C_BINARY;
+#endif
+#if (ODBCVER >= 0x0350)
+#if defined(OTL_MAP_SQL_GUID_TO_CHAR)
+#if defined(OTL_UNICODE)
+ case SQL_GUID: return SQL_C_WCHAR;
+#else
+ case SQL_GUID: return SQL_C_CHAR;
+#endif
+#else
+ case SQL_GUID: return SQL_C_BINARY;
+#endif
+#endif
+#if defined(OTL_MAP_SQL_BINARY_TO_CHAR)
+#if defined(OTL_UNICODE)
+ case SQL_BINARY: // MS SQL TIMESTAMP, BINARY
+ return SQL_C_WCHAR;
+#else
+ case SQL_BINARY: // MS SQL TIMESTAMP, BINARY
+ return SQL_C_CHAR;
+#endif
+#else
+ case SQL_BINARY:
+ return SQL_C_BINARY;
+#endif
+#if (ODBCVER >= 0x0350)
+ case OTL_SQL_XML:
+#if defined(OTL_UNICODE)
+ return SQL_C_WCHAR;
+#else
+ return SQL_C_CHAR;
+#endif
+#endif
+ default: return otl_unsupported_type;
+ }
+ }
+
+ static int datatype_size(int ftype,int maxsz,int int_type,int max_long_size)
+ {
+ switch(ftype){
+#if defined(OTL_UNICODE)
+ case SQL_C_WCHAR:
+#endif
+ case SQL_C_CHAR:
+ switch(int_type){
+ case SQL_BINARY: // MS SQL TIMESTAMP
+ return 17;
+#if defined(OTL_UNICODE)
+ case SQL_WLONGVARCHAR:
+#endif
+ case SQL_LONGVARCHAR:
+ return max_long_size*sizeof(OTL_CHAR);
+ case SQL_LONGVARBINARY:
+ return max_long_size;
+ case SQL_DATE:
+ return 40;
+#if (ODBCVER >= 0x0300)
+ case SQL_TYPE_TIMESTAMP:
+#else
+ case SQL_TIMESTAMP:
+#endif
+ return 40;
+#if (ODBCVER >= 0x0300)
+ case SQL_TYPE_TIME:
+#else
+ case SQL_TIME:
+#endif
+ return 40;
+#if (ODBCVER >= 0x0350)
+#if defined(OTL_MAP_SQL_GUID_TO_SQL_VARBINARY)
+ case SQL_GUID:
+ return 16;
+#else
+ case SQL_GUID:
+ return 40;
+#endif
+#endif
+ default:
+ return (maxsz+1);
+ }
+#if defined(OTL_BIGINT)
+ case SQL_C_SBIGINT:
+ return sizeof(OTL_BIGINT);
+#endif
+ case SQL_C_DOUBLE:
+ return sizeof(double);
+ case SQL_C_SLONG:
+ return sizeof(int);
+ case SQL_C_SSHORT:
+ return sizeof(short int);
+ case SQL_C_TIMESTAMP:
+ return sizeof(OTL_SQL_TIMESTAMP_STRUCT);
+ case SQL_C_TIME:
+ return sizeof(OTL_SQL_TIME_STRUCT);
+ case SQL_C_DATE:
+ return sizeof(OTL_SQL_DATE_STRUCT);
+#if defined(OTL_UNICODE)
+ case SQL_WLONGVARCHAR:
+ return max_long_size;
+#endif
+ case SQL_LONGVARCHAR:
+ return max_long_size;
+ case SQL_LONGVARBINARY:
+ return max_long_size;
+ case SQL_C_BINARY:
+ return maxsz;
+ default:
+ return 0;
+ }
+ }
+
+ static void map_ftype
+ (otl_column_desc& desc,
+ const int max_long_size,
+ int& ftype,
+ int& elem_size,
+ otl_select_struct_override& override,
+ const int column_ndx,
+ const int
+#if !defined(OTL_ODBC_TIMESTEN) && defined(OTL_ODBC_MULTI_MODE)
+ connection_type
+#endif
+ )
+ {
+ int ndx=override.find(column_ndx);
+ if(ndx==-1){
+#if defined(OTL_ODBC_MSSQL_2005) && !defined(OTL_ODBC_MULTI_MODE)
+ if(desc.prec==0 && desc.dbtype==SQL_VARBINARY)
+ ftype=SQL_LONGVARBINARY;
+ else
+#elif defined(OTL_ODBC_MULTI_MODE)
+ if((connection_type==OTL_MSSQL_2005_ODBC_CONNECT ||
+ connection_type==OTL_MSSQL_2008_ODBC_CONNECT)&&
+ desc.prec==0 && desc.dbtype==SQL_VARBINARY)
+ ftype=SQL_LONGVARBINARY;
+ else
+#endif
+ ftype=int2ext(desc.dbtype);
+ if(desc.dbsize==0){
+#if !defined(OTL_UNICODE)
+ if(ftype==SQL_C_CHAR)
+ ftype=SQL_LONGVARCHAR;
+#else
+ if(ftype==SQL_C_CHAR)
+ ftype=SQL_LONGVARCHAR;
+ else if(ftype==SQL_C_WCHAR)
+ ftype=SQL_WLONGVARCHAR;
+#endif
+ elem_size=max_long_size*sizeof(OTL_CHAR);
+ }else{
+ elem_size=datatype_size
+ (ftype,
+ OTL_SCAST(int,desc.dbsize),
+ desc.dbtype,
+ max_long_size);
+ }
+ switch(ftype){
+#if defined(OTL_UNICODE)
+ case SQL_C_WCHAR:
+ ftype=otl_var_char;
+ break;
+ case SQL_WLONGVARCHAR:
+ ftype=otl_var_varchar_long;
+ break;
+#else
+ case SQL_C_CHAR:
+ ftype=otl_var_char;
+ break;
+ case SQL_LONGVARCHAR:
+ ftype=otl_var_varchar_long;
+ break;
+#endif
+ case SQL_C_DOUBLE:
+ if(override.get_all_mask() & otl_all_num2str){
+ ftype=otl_var_char;
+ elem_size=otl_num_str_size;
+ }else
+ ftype=otl_var_double;
+ break;
+#if defined(OTL_BIGINT)
+ case SQL_C_SBIGINT:
+ if(override.get_all_mask() & otl_all_num2str){
+ ftype=otl_var_char;
+ elem_size=otl_num_str_size;
+ }else
+ ftype=otl_var_bigint;
+ break;
+#endif
+ case SQL_C_SLONG:
+ if(override.get_all_mask() & otl_all_num2str){
+ ftype=otl_var_char;
+ elem_size=otl_num_str_size;
+ }else
+ ftype=otl_var_int;
+ break;
+ case SQL_C_SSHORT:
+ if(override.get_all_mask() & otl_all_num2str){
+ ftype=otl_var_char;
+ elem_size=otl_num_str_size;
+ }else
+ ftype=otl_var_short;
+ break;
+ case SQL_LONGVARBINARY:
+ ftype=otl_var_raw_long;
+ break;
+ case SQL_C_DATE:
+ case SQL_C_TIME:
+ case SQL_C_TIMESTAMP:
+ if(override.get_all_mask() & otl_all_date2str){
+ ftype=otl_var_char;
+ elem_size=otl_date_str_size;
+ }else
+ ftype=otl_var_timestamp;
+ break;
+ case SQL_C_BINARY:
+ ftype=otl_var_raw;
+ break;
+ default:
+ ftype=0;
+ break;
+ }
+ }else{
+ ftype=override.get_col_type(ndx);
+ switch(ftype){
+ case otl_var_char:
+ elem_size=override.get_col_size(ndx)*sizeof(OTL_CHAR);
+ break;
+ case otl_var_raw:
+ elem_size=override.get_col_size(ndx);
+ break;
+ case otl_var_double:
+ elem_size=sizeof(double);
+ break;
+ case otl_var_float:
+ elem_size=sizeof(float);
+ break;
+ case otl_var_int:
+ elem_size=sizeof(int);
+ break;
+#if defined(OTL_BIGINT)
+ case otl_var_bigint:
+ elem_size=sizeof(OTL_BIGINT);
+ break;
+#endif
+ case otl_var_unsigned_int:
+ elem_size=sizeof(unsigned);
+ break;
+ case otl_var_short:
+ elem_size=sizeof(short);
+ break;
+ case otl_var_long_int:
+ elem_size=sizeof(double);
+ break;
+ default:
+ elem_size=override.get_col_size(ndx);
+ break;
+ }
+ }
+ desc.otl_var_dbtype=ftype;
+ }
+
+private:
+
+ otl_var(const otl_var&):
+ p_v(0),
+ p_len(0),
+ ftype(0),
+ act_elem_size(0),
+ lob_stream_mode(false),
+ lob_stream_flag(0),
+ vparam_type(-1),
+ lob_len(0),
+ lob_pos(0),
+ lob_ftype(0),
+ otl_adapter(otl_odbc_adapter),
+ charz_flag(false)
+ {
+ }
+
+ otl_var& operator=(const otl_var&)
+ {
+ return *this;
+ }
+
+};
+
+#if defined(OTL_ODBC_zOS)||defined(OTL_ODBC_TIMESTEN)|| \
+ (defined(SQL_TXN_READ_COMMITTED) && \
+ !defined(SQL_TRANSACTION_READ_COMMITTED))
+const long otl_tran_read_uncommitted=SQL_TXN_READ_UNCOMMITTED;
+const long otl_tran_read_committed=SQL_TXN_READ_COMMITTED;
+const long otl_tran_repeatable_read=SQL_TXN_REPEATABLE_READ;
+const long otl_tran_serializable=SQL_TXN_SERIALIZABLE;
+#else
+const long otl_tran_read_uncommitted=SQL_TRANSACTION_READ_UNCOMMITTED;
+const long otl_tran_read_committed=SQL_TRANSACTION_READ_COMMITTED;
+const long otl_tran_repeatable_read=SQL_TRANSACTION_REPEATABLE_READ;
+const long otl_tran_serializable=SQL_TRANSACTION_SERIALIZABLE;
+#endif
+
+class otl_sel;
+
+class otl_cur: public otl_cur0{
+private:
+
+ friend class otl_sel;
+ int status;
+ otl_conn* adb;
+ int direct_exec_flag;
+ long _rpc;
+ bool canceled;
+ int last_iters;
+
+public:
+
+ void set_canceled(const bool acanceled)
+ {
+ canceled=acanceled;
+ }
+
+ void reset_last_param_data_token()
+ {
+ last_param_data_token=0;
+ }
+
+ void reset_last_sql_param_data_status()
+ {
+ last_sql_param_data_status=0;
+ }
+
+ void reset_sql_param_data_count()
+ {
+ sql_param_data_count=0;
+ }
+
+
+ otl_cur():
+ otl_cur0(),
+ status(0),
+ adb(0),
+ direct_exec_flag(0),
+ _rpc(0),
+ canceled(false),
+ last_iters(0)
+ {
+ cda=0;
+ last_param_data_token=0;
+ last_sql_param_data_status=0;
+ sql_param_data_count=0;
+ }
+
+ virtual ~otl_cur(){}
+
+ int cancel(void)
+ {
+ status=SQLCancel(cda);
+ canceled=true;
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+ }
+
+ int open(otl_conn& /* connect */,otl_var* /* var */)
+ {
+ return 1;
+ }
+
+ void set_direct_exec(const int flag)
+ {
+ direct_exec_flag=flag;
+ }
+
+ void set_parse_only(const int /*flag*/){}
+
+ int open(otl_conn& connect)
+ {
+ last_iters=0;
+ direct_exec_flag=0;
+ adb=&connect;
+#if (ODBCVER >= 0x0300)
+ status=SQLAllocHandle(SQL_HANDLE_STMT,connect.hdbc,&cda);
+#else
+ status=SQLAllocStmt(connect.hdbc,&cda);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+ if(connect.timeout>0){
+#if (ODBCVER >= 0x0300)
+ status=SQLSetStmtAttr
+ (cda,
+ SQL_ATTR_QUERY_TIMEOUT,
+ OTL_RCAST(void*,OTL_SCAST(size_t,connect.timeout)),
+ SQL_NTS);
+#else
+ status=SQLSetStmtOption(cda,SQL_QUERY_TIMEOUT,connect.timeout);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ }
+ if(connect.cursor_type!=0){ // other than default
+#if (ODBCVER >= 0x0300)
+ status=SQLSetStmtAttr
+ (cda,
+ SQL_ATTR_CURSOR_TYPE,
+ OTL_RCAST(void*,OTL_SCAST(size_t,connect.cursor_type)),
+ SQL_NTS);
+#else
+ status=SQLSetStmtOption(cda,SQL_CURSOR_TYPE,connect.cursor_type);
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ }
+ return 1;
+ }
+
+ int close(void)
+ {
+ last_iters=0;
+#if (ODBCVER >= 0x0300)
+ status=SQLFreeHandle(SQL_HANDLE_STMT,cda);
+#else
+ status=SQLFreeStmt(cda,SQL_DROP);
+#endif
+ adb=0;
+ cda=0;
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+ }
+
+SQLRETURN sql_row_count(OTL_SQLLEN* total_rpc)
+{
+#if defined(OTL_ODBC_ALTERNATE_RPC)
+ OTL_SQLLEN rpc=0;
+ SQLRETURN rc;
+ do{
+ rc=SQLRowCount(cda,&rpc);
+ if(rc!=SQL_SUCCESS)
+ return rc;
+ *total_rpc+=rpc;
+ rc=SQLMoreResults(cda);
+ }while(rc==SQL_SUCCESS);
+ return SQL_SUCCESS;
+#else
+ return SQLRowCount(cda,total_rpc);
+#endif
+}
+
+
+ int parse(char* stm_text)
+ {
+#if !defined(OTL_ODBC_TIMESTEN)
+ short in_str=0;
+#endif
+ bool do_not_call_sql_row_count=false;
+#if defined(OTL_ODBC_SQL_STATEMENT_WITH_DIAG_REC_OUTPUT)
+ if(OTL_ODBC_SQL_STATEMENT_WITH_DIAG_REC_OUTPUT (stm_text)){
+ do_not_call_sql_row_count=true;
+ direct_exec_flag=1;
+ }
+#endif
+ char *c=stm_text;
+ if(*c=='$'){
+ ++c;
+ _rpc=0;
+ direct_exec_flag=1;
+ const int ctl_arr_size=6;
+ struct{
+ OTL_SQLCHAR_PTR name_ptr;
+ OTL_SQLSMALLINT name_len;
+ OTL_SQLCHAR name[512];
+ } ctl_arr[ctl_arr_size];
+#if (defined(UNICODE)||defined(_UNICODE))
+ struct{
+ SQLWCHAR name_ptr;
+ OTL_SQLSMALLINT name_len;
+ SQLWCHAR name[512];
+ } ctl_arr_W[ctl_arr_size];
+#endif
+ int i=0;
+ for(i=0;i<ctl_arr_size;++i){
+ ctl_arr[i].name_ptr=0;
+ ctl_arr[i].name_len=0;
+ ctl_arr[i].name[0]=0;
+#if (defined(UNICODE)||defined(_UNICODE))
+ ctl_arr_W[i].name_ptr=0;
+ ctl_arr_W[i].name_len=0;
+ ctl_arr_W[i].name[0]=0;
+#endif
+ }
+ char func_name[256];
+ int par_num=0;
+ char par_val[512];
+ size_t par_val_len=0;
+ size_t fn_len=0;
+ bool func_found=false;
+ while(*c && *c!=' ' && fn_len<sizeof(func_name)){
+ ++fn_len;
+ func_name[fn_len-1]=*c;
+ ++c;
+ }
+ if(fn_len<sizeof(func_name)-1){
+ ++fn_len;
+ func_name[fn_len-1]=0;
+ }else
+ func_name[sizeof(func_name)-1]=0;
+ while(*c==' ')++c;
+ while(*c){
+ if(*c=='$'){
+ ++c;
+ par_num=OTL_SCAST(int,*c-'0')-1;
+ ++c;
+ while(*c && *c==' ')++c;
+ if(*c==':' && ((c>stm_text && *(c-1)!='\\' )|| c==stm_text)){
+ ++c;
+ while(*c && *c==' ')++c;
+ if(*c=='\''){
+ par_val_len=0;
+ ++c;
+ while(*c && *c!='\'' && par_val_len<sizeof(par_val)){
+ ++par_val_len;
+ par_val[par_val_len-1]=*c;
+ ++c;
+ }
+ if(par_val_len<sizeof(par_val)-1){
+ ++par_val_len;
+ par_val[par_val_len-1]=0;
+ }else
+ par_val[sizeof(par_val)-1]=0;
+ if(par_num>=0 && par_num<ctl_arr_size){
+ ctl_arr[par_num].name_ptr=ctl_arr[par_num].name;
+ ctl_arr[par_num].name_len=SQL_NTS;
+ OTL_STRCPY_S(OTL_RCAST(char*,ctl_arr[par_num].name),
+ sizeof(ctl_arr[par_num].name),
+ OTL_RCAST(const char*,par_val));
+ }
+ }
+ ++c;
+ while(*c && *c==' ')++c;
+ }
+ }else
+ ++c;
+ }
+ status=SQL_SUCCESS;
+ if(strcmp(func_name,"SQLTables")==0){
+#if (defined(UNICODE)||defined(_UNICODE))
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[0].name,OTL_RCAST(unsigned char*,ctl_arr[0].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[1].name,OTL_RCAST(unsigned char*,ctl_arr[1].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[2].name,OTL_RCAST(unsigned char*,ctl_arr[2].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[3].name,OTL_RCAST(unsigned char*,ctl_arr[3].name));
+#if !defined(OTL_UNICODE_USE_ANSI_ODBC_FUNCS_FOR_DATA_DICT)
+ status=SQLTables
+ (cda,
+ ctl_arr_W[0].name,SQL_NTS,
+ ctl_arr_W[1].name,SQL_NTS,
+ ctl_arr_W[2].name,SQL_NTS,
+ ctl_arr_W[3].name,SQL_NTS);
+#else
+ status=SQLTablesA
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len,
+ ctl_arr[3].name_ptr,ctl_arr[3].name_len);
+#endif
+
+#else
+ status=SQLTables
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len,
+ ctl_arr[3].name_ptr,ctl_arr[3].name_len);
+#endif
+ func_found=true;
+ }else if(strcmp(func_name,"SQLGetTypeInfo")==0){
+ status=SQLGetTypeInfo
+ (cda,
+ SQL_ALL_TYPES);
+ func_found=true;
+ }else if(strcmp(func_name,"SQLColumns")==0){
+#if (defined(UNICODE)||defined(_UNICODE))
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[0].name,OTL_RCAST(unsigned char*,ctl_arr[0].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[1].name,OTL_RCAST(unsigned char*,ctl_arr[1].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[2].name,OTL_RCAST(unsigned char*,ctl_arr[2].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[3].name,OTL_RCAST(unsigned char*,ctl_arr[3].name));
+
+#if !defined(OTL_UNICODE_USE_ANSI_ODBC_FUNCS_FOR_DATA_DICT)
+ status=SQLColumns
+ (cda,
+ ctl_arr_W[0].name,SQL_NTS,
+ ctl_arr_W[1].name,SQL_NTS,
+ ctl_arr_W[2].name,SQL_NTS,
+ ctl_arr_W[3].name,SQL_NTS);
+#else
+ status=SQLColumnsA
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len,
+ ctl_arr[3].name_ptr,ctl_arr[3].name_len);
+#endif
+
+#else
+ status=SQLColumns
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len,
+ ctl_arr[3].name_ptr,ctl_arr[3].name_len);
+#endif
+ func_found=true;
+ }else if(strcmp(func_name,"SQLProcedures")==0){
+#if (defined(UNICODE)||defined(_UNICODE))
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[0].name,OTL_RCAST(unsigned char*,ctl_arr[0].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[1].name,OTL_RCAST(unsigned char*,ctl_arr[1].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[2].name,OTL_RCAST(unsigned char*,ctl_arr[2].name));
+
+#if !defined(OTL_UNICODE_USE_ANSI_ODBC_FUNCS_FOR_DATA_DICT)
+ status=SQLProcedures
+ (cda,
+ ctl_arr_W[0].name,SQL_NTS,
+ ctl_arr_W[1].name,SQL_NTS,
+ ctl_arr_W[2].name,SQL_NTS);
+#else
+ status=SQLProceduresA
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len);
+#endif
+
+#else
+ status=SQLProcedures
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len);
+#endif
+ func_found=true;
+ }else if(strcmp(func_name,"SQLColumnPrivileges")==0){
+#if (defined(UNICODE)||defined(_UNICODE))
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[0].name,OTL_RCAST(unsigned char*,ctl_arr[0].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[1].name,OTL_RCAST(unsigned char*,ctl_arr[1].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[2].name,OTL_RCAST(unsigned char*,ctl_arr[2].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[3].name,OTL_RCAST(unsigned char*,ctl_arr[3].name));
+#if !defined(OTL_UNICODE_USE_ANSI_ODBC_FUNCS_FOR_DATA_DICT)
+ status=SQLColumnPrivileges
+ (cda,
+ ctl_arr_W[0].name,SQL_NTS,
+ ctl_arr_W[1].name,SQL_NTS,
+ ctl_arr_W[2].name,SQL_NTS,
+ ctl_arr_W[3].name,SQL_NTS);
+#else
+ status=SQLColumnPrivilegesA
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len,
+ ctl_arr[3].name_ptr,ctl_arr[3].name_len);
+#endif
+
+#else
+ status=SQLColumnPrivileges
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len,
+ ctl_arr[3].name_ptr,ctl_arr[3].name_len);
+#endif
+ func_found=true;
+ }else if(strcmp(func_name,"SQLTablePrivileges")==0){
+#if (defined(UNICODE)||defined(_UNICODE))
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[0].name,OTL_RCAST(unsigned char*,ctl_arr[0].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[1].name,OTL_RCAST(unsigned char*,ctl_arr[1].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[2].name,OTL_RCAST(unsigned char*,ctl_arr[2].name));
+
+#if !defined(OTL_UNICODE_USE_ANSI_ODBC_FUNCS_FOR_DATA_DICT)
+ status=SQLTablePrivileges
+ (cda,
+ ctl_arr_W[0].name,SQL_NTS,
+ ctl_arr_W[1].name,SQL_NTS,
+ ctl_arr_W[2].name,SQL_NTS);
+#else
+ status=SQLTablePrivilegesA
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len);
+#endif
+
+#else
+ status=SQLTablePrivileges
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len);
+#endif
+ func_found=true;
+ }else if(strcmp(func_name,"SQLPrimaryKeys")==0){
+#if (defined(UNICODE)||defined(_UNICODE))
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[0].name,OTL_RCAST(unsigned char*,ctl_arr[0].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[1].name,OTL_RCAST(unsigned char*,ctl_arr[1].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[2].name,OTL_RCAST(unsigned char*,ctl_arr[2].name));
+
+#if !defined(OTL_UNICODE_USE_ANSI_ODBC_FUNCS_FOR_DATA_DICT)
+ status=SQLPrimaryKeys
+ (cda,
+ ctl_arr_W[0].name,SQL_NTS,
+ ctl_arr_W[1].name,SQL_NTS,
+ ctl_arr_W[2].name,SQL_NTS);
+#else
+ status=SQLPrimaryKeysA
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len);
+#endif
+
+#else
+ status=SQLPrimaryKeys
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len);
+#endif
+ func_found=true;
+ }else if(strcmp(func_name,"SQLProcedureColumns")==0){
+#if (defined(UNICODE)||defined(_UNICODE))
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[0].name,OTL_RCAST(unsigned char*,ctl_arr[0].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[1].name,OTL_RCAST(unsigned char*,ctl_arr[1].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[2].name,OTL_RCAST(unsigned char*,ctl_arr[2].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[3].name,OTL_RCAST(unsigned char*,ctl_arr[3].name));
+
+#if !defined(OTL_UNICODE_USE_ANSI_ODBC_FUNCS_FOR_DATA_DICT)
+ status=SQLProcedureColumns
+ (cda,
+ ctl_arr_W[0].name,SQL_NTS,
+ ctl_arr_W[1].name,SQL_NTS,
+ ctl_arr_W[2].name,SQL_NTS,
+ ctl_arr_W[3].name,SQL_NTS);
+#else
+ status=SQLProcedureColumnsA
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len,
+ ctl_arr[3].name_ptr,ctl_arr[3].name_len);
+#endif
+
+#else
+ status=SQLProcedureColumns
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len,
+ ctl_arr[3].name_ptr,ctl_arr[3].name_len);
+#endif
+ func_found=true;
+ }else if(strcmp(func_name,"SQLForeignKeys")==0){
+#if (defined(UNICODE)||defined(_UNICODE))
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[0].name,OTL_RCAST(unsigned char*,ctl_arr[0].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[1].name,OTL_RCAST(unsigned char*,ctl_arr[1].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[2].name,OTL_RCAST(unsigned char*,ctl_arr[2].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[3].name,OTL_RCAST(unsigned char*,ctl_arr[3].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[4].name,OTL_RCAST(unsigned char*,ctl_arr[4].name));
+ otl_convert_char_to_SQLWCHAR
+ (ctl_arr_W[5].name,OTL_RCAST(unsigned char*,ctl_arr[5].name));
+
+#if !defined(OTL_UNICODE_USE_ANSI_ODBC_FUNCS_FOR_DATA_DICT)
+ status=SQLForeignKeys
+ (cda,
+ ctl_arr_W[0].name,SQL_NTS,
+ ctl_arr_W[1].name,SQL_NTS,
+ ctl_arr_W[2].name,SQL_NTS,
+ ctl_arr_W[3].name,SQL_NTS,
+ ctl_arr_W[4].name,SQL_NTS,
+ ctl_arr_W[5].name,SQL_NTS);
+#else
+ status=SQLForeignKeysA
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len,
+ ctl_arr[3].name_ptr,ctl_arr[3].name_len,
+ ctl_arr[4].name_ptr,ctl_arr[4].name_len,
+ ctl_arr[5].name_ptr,ctl_arr[5].name_len);
+#endif
+
+#else
+ status=SQLForeignKeys
+ (cda,
+ ctl_arr[0].name_ptr,ctl_arr[0].name_len,
+ ctl_arr[1].name_ptr,ctl_arr[1].name_len,
+ ctl_arr[2].name_ptr,ctl_arr[2].name_len,
+ ctl_arr[3].name_ptr,ctl_arr[3].name_len,
+ ctl_arr[4].name_ptr,ctl_arr[4].name_len,
+ ctl_arr[5].name_ptr,ctl_arr[5].name_len);
+#endif
+ func_found=true;
+ }
+ if(!func_found)return 2;
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+ }
+
+ if(direct_exec_flag){
+ _rpc=0;
+#if (defined(UNICODE)||defined(_UNICODE))
+ {
+ SQLWCHAR* temp_stm_text=new SQLWCHAR[strlen(stm_text)+1];
+ otl_convert_char_to_SQLWCHAR(temp_stm_text,OTL_RCAST(unsigned char*,stm_text));
+ status=SQLExecDirect
+ (cda,
+ temp_stm_text,
+ SQL_NTS);
+ delete[] temp_stm_text;
+ }
+#else
+ status=SQLExecDirect
+ (cda,
+ OTL_RCAST(OTL_SQLCHAR_PTR,stm_text),
+ SQL_NTS);
+#endif
+
+#if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO)
+ if(adb && adb->throws_on_sql_success_with_info &&
+ status==SQL_SUCCESS_WITH_INFO)
+ return 0;
+#endif
+
+ if(status!=SQL_SUCCESS&&
+ status!=SQL_SUCCESS_WITH_INFO&&
+#if (ODBCVER >= 0x0300)
+ status!=SQL_NO_DATA
+#else
+ status!=SQL_NO_DATA_FOUND
+#endif
+ )
+ return 0;
+ else{
+ _rpc=0;
+ if(!do_not_call_sql_row_count){
+ OTL_SQLLEN tmp_rpc=0;
+ SQLRETURN diag_status=sql_row_count(&tmp_rpc);
+ if(diag_status==SQL_SUCCESS||
+ diag_status==SQL_SUCCESS_WITH_INFO)
+ _rpc=OTL_SCAST(long,tmp_rpc);
+ }
+ return 1;
+ }
+ }
+
+#if !defined(OTL_ODBC_TIMESTEN)
+ // Converting : notation into ODBC's native notation ?
+ while(*c){
+ if(*c=='\''){
+ if(!in_str)
+ in_str=1;
+ else{
+ if(c[1]=='\'')
+ ++c;
+ else
+ in_str=0;
+ }
+ }
+ if(*c==':' && !in_str &&
+ ((c>stm_text && *(c-1)!='\\' )|| c==stm_text)){
+ *c='?';
+ ++c;
+ while(isdigit(*c)||isalpha(*c)||*c=='_'){
+ *c=' ';
+ ++c;
+ }
+ }else if(*c==':' && !in_str &&
+ ((c>stm_text && *(c-1)=='\\' )|| c==stm_text)){
+ char* c_1=c-1;
+ char* c_=c;
+ while(*c_){
+ *c_1=*c_;
+ ++c_1;
+ ++c_;
+ }
+ if(c_1>c-1)
+ *c_1=0;
+ --c;
+ }
+ ++c;
+ }
+#endif
+
+#if defined(OTL_DB2_CLI)
+
+ OTL_SQLINTEGER temp_isolation_level=0;
+ status=SQLGetStmtAttr
+ (cda,
+ SQL_ATTR_TXN_ISOLATION,
+ OTL_RCAST(SQLPOINTER,&temp_isolation_level),
+ SQL_IS_POINTER,
+ 0);
+ if(OTL_SCAST(long,temp_isolation_level)==otl_tran_read_committed||
+ OTL_SCAST(long,temp_isolation_level)==otl_tran_read_uncommitted){
+ status=SQLSetStmtAttr
+ (cda,
+ SQL_ATTR_CLOSE_BEHAVIOR,
+ OTL_RCAST(void*,SQL_CC_RELEASE),
+ SQL_NTS);
+ if(status!=SQL_SUCCESS&&
+ status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ }
+#endif
+
+#if (defined(UNICODE)||defined(_UNICODE))
+ {
+ SQLWCHAR* temp_stm_text=new SQLWCHAR[strlen(stm_text)+1];
+ otl_convert_char_to_SQLWCHAR(temp_stm_text,OTL_RCAST(unsigned char*,stm_text));
+ status=SQLPrepare
+ (cda,
+ temp_stm_text,
+ SQL_NTS);
+ delete[] temp_stm_text;
+ }
+#else
+ status=SQLPrepare
+ (cda,
+ OTL_RCAST(OTL_SQLCHAR_PTR,stm_text),
+ SQL_NTS);
+#endif
+
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+ }
+
+ int exec(const int iters,
+ const int /*rowoff*/,
+#if defined(OTL_ODBC_ALTERNATE_RPC)
+ const int otl_sql_exec_from_class)
+#else
+ const int /*otl_sql_exec_from_class*/)
+#endif
+ {
+#if (ODBCVER >= 0x0300)
+#else
+ OTL_SQLUINTEGER irows;
+#endif
+ if(direct_exec_flag){
+ return 1;
+ }else{
+#if !defined(OTL_ODBC_MYSQL) && !defined(OTL_ODBC_XTG_IBASE6)
+#if (ODBCVER >= 0x0300)
+ if(last_iters>1||iters>1||_rpc>1){
+ last_iters=iters;
+ size_t temp_iters=OTL_SCAST(size_t,iters);
+ status=SQLSetStmtAttr
+ (cda,
+ SQL_ATTR_PARAMSET_SIZE,
+ OTL_RCAST(void*,temp_iters),
+ SQL_NTS);
+ if(status!=SQL_SUCCESS&&
+ status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ }
+#else
+ if(last_iters>1||iters>1||_rpc>1){
+ last_iters=iters;
+ status=SQLParamOptions
+ (cda,
+ OTL_SCAST(OTL_SQLUINTEGER,iters),
+ &irows);
+ if(status!=SQL_SUCCESS&&
+ status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ }
+#endif
+#endif
+ _rpc=0;
+
+ last_param_data_token=0;
+ last_sql_param_data_status=0;
+ sql_param_data_count=0;
+
+ status=SQLExecute(cda);
+ if(canceled)return 0;
+#if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO)
+ if(adb && adb->throws_on_sql_success_with_info &&
+ status==SQL_SUCCESS_WITH_INFO)
+ return 0;
+#endif
+ if(status!=SQL_SUCCESS&&
+ status!=SQL_SUCCESS_WITH_INFO&&
+#if (ODBCVER >= 0x0300)
+ status!=SQL_NO_DATA&&
+#else
+ status!=SQL_NO_DATA_FOUND&&
+#endif
+ status!=SQL_NEED_DATA)return 0;
+ if(status==SQL_NEED_DATA){
+ _rpc=iters;
+ return 1;
+ }
+ OTL_SQLLEN tmp_rpc=0;
+ SQLRETURN diag_status=0;
+#if defined(OTL_ODBC_ALTERNATE_RPC)
+ if(otl_sql_exec_from_class==otl_sql_exec_from_cursor_class){
+ diag_status=sql_row_count(&tmp_rpc);
+ if(diag_status==SQL_SUCCESS||diag_status==SQL_SUCCESS_WITH_INFO)
+ _rpc=OTL_SCAST(long,tmp_rpc);
+ return 1;
+ }else{
+ _rpc=0;
+ return 1;
+ }
+#else
+ diag_status=sql_row_count(&tmp_rpc);
+ if(diag_status==SQL_SUCCESS||diag_status==SQL_SUCCESS_WITH_INFO)
+ _rpc=OTL_SCAST(long,tmp_rpc);
+ return 1;
+#endif
+ }
+ }
+
+ long get_rpc()
+ {
+ return _rpc;
+ }
+
+ int tmpl_ftype2odbc_ftype(const int ftype)
+ {
+ switch(ftype){
+#if defined(OTL_UNICODE)
+ case otl_var_char:
+ return SQL_C_WCHAR;
+ case otl_var_varchar_long:
+ return SQL_WLONGVARCHAR;
+#else
+ case otl_var_char:
+ return SQL_C_CHAR;
+ case otl_var_varchar_long:
+ return SQL_LONGVARCHAR;
+#endif
+ case otl_var_double:
+ return SQL_C_DOUBLE;
+#if defined(OTL_BIGINT)
+ case otl_var_bigint:
+ return SQL_C_SBIGINT;
+#endif
+ case otl_var_float:
+ return SQL_C_FLOAT;
+ case otl_var_int:
+ return SQL_C_SLONG;
+ case otl_var_long_int:
+#if defined(OTL_MAP_LONG_TO_SQL_C_SBIGINT) && \
+ ((ODBCVER >= 0x0300) || defined(OTL_ODBC_TIMESTEN))
+ {
+ static bool long_is_8_bytes=sizeof(long)==8;
+ if(long_is_8_bytes)
+ return SQL_C_SBIGINT;
+ else
+ return SQL_C_SLONG;
+ }
+#else
+ return SQL_C_SLONG;
+#endif
+ case otl_var_unsigned_int:
+ return SQL_C_ULONG;
+ case otl_var_short:
+ return SQL_C_SSHORT;
+ case otl_var_timestamp:
+ case otl_var_db2time:
+ case otl_var_db2date:
+ return SQL_C_TIMESTAMP;
+ case otl_var_raw_long:
+ return SQL_LONGVARBINARY;
+ case otl_var_raw:
+ return SQL_C_BINARY;
+ default:
+ return 0;
+ }
+ }
+
+ int otl_map_ext2int(int ftype)
+ {
+ switch(ftype){
+#if defined(OTL_UNICODE)
+ case SQL_WLONGVARCHAR: return SQL_WLONGVARCHAR;
+ case SQL_C_WCHAR: return SQL_WVARCHAR;
+#else
+ case SQL_LONGVARCHAR: return SQL_LONGVARCHAR;
+ case SQL_C_CHAR: return SQL_VARCHAR;
+#endif
+ case SQL_LONGVARBINARY: return SQL_LONGVARBINARY;
+ case SQL_C_DATE: return SQL_DATE;
+#if (ODBCVER >= 0x0300)
+ case SQL_C_TIME: return SQL_TYPE_TIME;
+ case SQL_C_TIMESTAMP: return SQL_TYPE_TIMESTAMP;
+#else
+ case SQL_C_TIME: return SQL_TIME;
+ case SQL_C_TIMESTAMP: return SQL_TIMESTAMP;
+#endif
+ case SQL_C_DOUBLE: return SQL_DOUBLE;
+#if defined(OTL_BIGINT)
+ case SQL_C_SBIGINT: return SQL_BIGINT;
+#endif
+ case SQL_C_FLOAT: return SQL_FLOAT;
+ case SQL_C_SLONG: return SQL_INTEGER;
+ case SQL_C_SSHORT: return SQL_SMALLINT;
+ case SQL_C_ULONG: return SQL_DOUBLE;
+ case SQL_C_BINARY: return SQL_VARBINARY;
+ default: return -1;
+ }
+ }
+
+ int bind
+ (const char* /* name */,
+ otl_var& v,
+ const int aelem_size,
+ const int aftype,
+ const int aparam_type,
+ const int name_pos,
+ const int
+#if !defined(OTL_ODBC_TIMESTEN) && defined(OTL_ODBC_MULTI_MODE)
+ connection_type
+#endif
+ ,
+ const int /* apl_tab_size */)
+ {OTL_SQLSMALLINT ftype=OTL_SCAST(OTL_SQLSMALLINT,tmpl_ftype2odbc_ftype(aftype));
+ OTL_SQLSMALLINT ftype_save=ftype;
+ int param_type;
+ int parm_pos=name_pos;
+ v.vparam_type=aparam_type;
+ switch(aparam_type){
+ case otl_input_param:
+ param_type=SQL_PARAM_INPUT;
+ break;
+ case otl_output_param:
+ param_type=SQL_PARAM_OUTPUT;
+ break;
+ case otl_inout_param:
+ param_type=SQL_PARAM_INPUT_OUTPUT;
+ break;
+ default:
+ param_type=SQL_PARAM_INPUT;
+ break;
+ }
+#if defined(OTL_UNICODE)
+ if(ftype==SQL_WLONGVARCHAR){
+ ftype=SQL_C_WCHAR;
+#else
+ if(ftype==SQL_LONGVARCHAR){
+ ftype=SQL_C_CHAR;
+#endif
+ }else if(ftype==SQL_LONGVARBINARY){
+ ftype=SQL_C_BINARY;
+ }
+ int sqltype=otl_map_ext2int(ftype_save);
+ int mapped_sqltype=sqltype;
+
+ if(aftype==otl_var_db2date)
+#if (ODBCVER >= 0x0300)
+ mapped_sqltype=SQL_TYPE_DATE;
+#else
+ mapped_sqltype=SQL_DATE;
+#endif
+ else if(aftype==otl_var_db2time)
+#if (ODBCVER >= 0x0300)
+ mapped_sqltype=SQL_TYPE_TIME;
+#else
+ mapped_sqltype=SQL_TIME;
+#endif
+ if(v.lob_stream_mode&&
+ (ftype_save==SQL_LONGVARBINARY||
+#if defined(OTL_UNICODE)
+ ftype_save==SQL_WLONGVARCHAR)){
+#else
+ ftype_save==SQL_LONGVARCHAR)){
+#endif
+ // in case of "stream mode" the variable
+ // gets bound in a special way
+#if defined(OTL_ODBC_MSSQL_2005) && !defined(OTL_ODBC_MULTI_MODE)
+ switch(ftype_save){
+ case SQL_LONGVARBINARY:
+ mapped_sqltype=SQL_VARBINARY;
+ break;
+#if defined(OTL_UNICODE)
+ case SQL_WLONGVARCHAR:
+ mapped_sqltype=SQL_WVARCHAR;
+ break;
+#else
+ case SQL_LONGVARCHAR:
+ mapped_sqltype=SQL_VARCHAR;
+ break;
+#endif
+ }
+#elif defined(OTL_ODBC_MULTI_MODE)
+ if(connection_type==OTL_MSSQL_2005_ODBC_CONNECT||
+ connection_type==OTL_MSSQL_2008_ODBC_CONNECT){
+ switch(ftype_save){
+ case SQL_LONGVARBINARY:
+ mapped_sqltype=SQL_VARBINARY;
+ break;
+#if defined(OTL_UNICODE)
+ case SQL_WLONGVARCHAR:
+ mapped_sqltype=SQL_WVARCHAR;
+ break;
+#else
+ case SQL_LONGVARCHAR:
+ mapped_sqltype=SQL_VARCHAR;
+ break;
+#endif
+ }
+ }
+#endif
+ status=SQLBindParameter
+ (cda,
+ OTL_SCAST(OTL_SQLUSMALLINT,parm_pos),
+ OTL_SCAST(OTL_SQLSMALLINT,param_type),
+ ftype,
+ OTL_SCAST(OTL_SQLSMALLINT,mapped_sqltype),
+#if (ODBCVER >= 0x0300)
+
+#if defined(OTL_ODBC_MSSQL_2005) && !defined(OTL_ODBC_MULTI_MODE)
+ 0,
+#elif defined(OTL_ODBC_MULTI_MODE)
+ (connection_type==OTL_MSSQL_2005_ODBC_CONNECT||
+ connection_type==OTL_MSSQL_2008_ODBC_CONNECT) ? 0 :
+ (sqltype==SQL_TYPE_TIMESTAMP?otl_odbc_date_prec:aelem_size),
+#else
+ sqltype==SQL_TYPE_TIMESTAMP?otl_odbc_date_prec:aelem_size,
+#endif
+#else
+ sqltype==SQL_TIMESTAMP?otl_odbc_date_prec:aelem_size,
+#endif
+#if (ODBCVER >= 0x0300)
+ sqltype==SQL_TYPE_TIMESTAMP ?
+#if defined(OTL_ODBC_MULTI_MODE)
+ ((connection_type==OTL_MSSQL_2008_ODBC_CONNECT)? 7 :
+ (connection_type==OTL_MSSQL_2005_ODBC_CONNECT)? 3 :
+ otl_odbc_date_scale) : 0,
+#else
+ otl_odbc_date_scale : 0,
+#endif
+#else
+ sqltype==SQL_TIMESTAMP?otl_odbc_date_scale:0,
+#endif
+ OTL_RCAST(OTL_SQLPOINTER,OTL_SCAST(size_t,parm_pos)),
+ 0,
+ v.p_len);
+ }else{
+ int temp_column_size=0;
+#if (ODBCVER >= 0x0300)
+ if(sqltype==SQL_TYPE_TIMESTAMP)
+ temp_column_size=otl_odbc_date_prec;
+#if defined(OTL_UNICODE)
+ else if(ftype==SQL_C_WCHAR)
+ temp_column_size=(aelem_size-1)*sizeof(OTL_CHAR);
+#else
+ else if(ftype==SQL_C_CHAR)
+ temp_column_size=aelem_size-1;
+#endif
+ else
+ temp_column_size=aelem_size;
+#else
+ if(sqltype==SQL_TIMESTAMP)
+ temp_column_size=otl_odbc_date_prec;
+ else if(ftype==SQL_C_CHAR)
+ temp_column_size=aelem_size-1;
+ else
+ temp_column_size=aelem_size;
+#endif
+ OTL_SQLINTEGER buflen=0;
+#if defined(OTL_UNICODE)
+ if(ftype==SQL_C_WCHAR)
+ buflen=aelem_size*sizeof(OTL_CHAR);
+ else
+#endif
+ buflen=aelem_size;
+ status=SQLBindParameter
+ (cda,
+ OTL_SCAST(OTL_SQLUSMALLINT,parm_pos),
+ OTL_SCAST(OTL_SQLSMALLINT,param_type),
+ ftype,
+ OTL_SCAST(OTL_SQLSMALLINT,mapped_sqltype),
+ temp_column_size,
+#if (ODBCVER >= 0x0300)
+ sqltype==SQL_TYPE_TIMESTAMP ?
+#if defined(OTL_ODBC_MULTI_MODE)
+ ((connection_type==OTL_MSSQL_2008_ODBC_CONNECT)? 7 :
+ (connection_type==OTL_MSSQL_2005_ODBC_CONNECT)? 3 :
+ otl_odbc_date_scale) : 0,
+#else
+ otl_odbc_date_scale : 0,
+#endif
+#else
+ sqltype==SQL_TIMESTAMP?otl_odbc_date_scale:0,
+#endif
+ OTL_RCAST(OTL_SQLPOINTER,v.p_v),
+ buflen,
+ v.p_len);
+ }
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+ }
+
+ int bind
+ (const int column_num,
+ otl_var& v,
+ const int elem_size,
+ const int aftype,
+ const int param_type)
+ {SWORD ftype=OTL_SCAST(SWORD,tmpl_ftype2odbc_ftype(aftype));
+ v.vparam_type=param_type;
+ SWORD ftype_save=ftype;
+#if defined(OTL_UNICODE)
+ if(ftype==SQL_WLONGVARCHAR){
+ ftype=SQL_C_WCHAR;
+#else
+ if(ftype==SQL_LONGVARCHAR){
+ ftype=SQL_C_CHAR;
+#endif
+ }else if(ftype==SQL_LONGVARBINARY){
+ ftype=SQL_C_BINARY;
+ }
+ if(v.lob_stream_mode&&
+ (ftype_save==SQL_LONGVARBINARY||
+#if defined(OTL_UNICODE)
+ ftype_save==SQL_WLONGVARCHAR)){
+#else
+ ftype_save==SQL_LONGVARCHAR)){
+#endif
+ // in case of "stream mode" the variable
+ // remains unbound
+ v.lob_ftype=ftype;
+ v.lob_pos=column_num;
+ return 1;
+ }else{
+ SQLINTEGER buflen=elem_size;
+#if defined(OTL_UNICODE)
+ if(ftype==SQL_C_WCHAR||ftype==SQL_WLONGVARCHAR)
+ buflen=elem_size*sizeof(OTL_CHAR);
+#endif
+ status=SQLBindCol
+ (cda,
+ OTL_SCAST(unsigned short,column_num),
+ ftype,
+ OTL_RCAST(PTR,v.p_v),
+ buflen,
+ &v.p_len[0]);
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ else
+ return 1;
+ }
+
+ }
+
+ int describe_column
+ (otl_column_desc& col,
+ const int column_num,
+ int& eof_desc)
+ {
+ OTL_SQLCHAR name[256];
+ OTL_SQLSMALLINT nlen;
+ OTL_SQLSMALLINT dbtype;
+ OTL_SQLLEN dbsize;
+ OTL_SQLSMALLINT scale;
+ OTL_SQLULEN prec;
+ OTL_SQLSMALLINT nullok;
+ OTL_SQLSMALLINT icols;
+
+ eof_desc=0;
+ status=SQLNumResultCols(cda,&icols);
+ if(status!=SQL_SUCCESS&&
+ status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+ if(column_num>icols){
+ eof_desc=1;
+ return 0;
+ }
+#if (defined(UNICODE)||defined(_UNICODE))
+ {
+ SQLWCHAR temp_name[256];
+ status=SQLDescribeCol
+ (cda,
+ OTL_SCAST(unsigned short,column_num),
+ temp_name,
+ sizeof(temp_name),
+ &nlen,
+ &dbtype,
+ &prec,
+ &scale,
+ &nullok);
+ otl_convert_SQLWCHAR_to_char(OTL_RCAST(unsigned char*,name),temp_name);
+ }
+#else
+ status=SQLDescribeCol
+ (cda,
+ OTL_SCAST(unsigned short,column_num),
+ name,
+ sizeof(name),
+ &nlen,
+ &dbtype,
+ &prec,
+ &scale,
+ &nullok);
+#endif
+ if(!(status == SQL_SUCCESS ||
+ status == SQL_SUCCESS_WITH_INFO))
+ return 0;
+ dbsize=prec;
+ col.set_name(OTL_RCAST(char*,name));
+
+#if defined(OTL_DB2_CLI) && defined(OTL_DB2_CLI_MAP_LONG_VARCHAR_TO_VARCHAR)
+#if defined(OTL_UNICODE)
+#error OTL_DB2_CLI_MAP_LONG_VARCHAR_TO_VARCHAR is not supported when \
+OTL_UNICODE is defined
+#else
+ if(dbtype==SQL_LONGVARCHAR &&
+ dbsize <= OTL_DB2_CLI_MAP_LONG_VARCHAR_TO_VARCHAR){
+ dbtype=SQL_VARCHAR;
+ }
+#endif
+#endif
+
+ col.dbtype=dbtype;
+ col.dbsize=dbsize;
+ col.scale=scale;
+ col.prec=prec;
+ col.nullok=nullok;
+ return 1;
+ }
+
+ void error(otl_exc& exception_struct)
+ {OTL_SQLRETURN rc;
+ OTL_SQLSMALLINT msg_len=0;
+#if (ODBCVER >= 0x0300)
+
+#if (defined(UNICODE)||defined(_UNICODE))
+ {
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
+ rc=SQLGetDiagRec
+ (SQL_HANDLE_STMT,
+ cda,
+ 1,
+ &exception_struct.sqlstate[0],
+ OTL_RCAST(OTL_SQLINTEGER_PTR,&exception_struct.code),
+ &exception_struct.msg[0],
+ SQL_MAX_MESSAGE_LENGTH-1,
+ OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len));
+ exception_struct.msg[msg_len]=0;
+#else
+ SQLWCHAR temp_sqlstate[1000];
+ SQLWCHAR temp_msg[SQL_MAX_MESSAGE_LENGTH];
+ rc=SQLGetDiagRec
+ (SQL_HANDLE_STMT,
+ cda,
+ 1,
+ temp_sqlstate,
+ OTL_RCAST(OTL_SQLINTEGER_PTR,&exception_struct.code),
+ temp_msg,
+ SQL_MAX_MESSAGE_LENGTH-1,
+ OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len));
+ temp_msg[msg_len]=0;
+ otl_convert_SQLWCHAR_to_char
+ (OTL_RCAST(unsigned char*,&exception_struct.sqlstate[0]),
+ temp_sqlstate);
+ otl_convert_SQLWCHAR_to_char
+ (OTL_RCAST(unsigned char*,&exception_struct.msg[0]),
+ temp_msg);
+#endif
+ }
+#else
+ void* temp_ptr=&exception_struct.code;
+ rc=SQLGetDiagRec
+ (SQL_HANDLE_STMT,
+ cda,
+ 1,
+ OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.sqlstate[0]),
+ OTL_RCAST(OTL_SQLINTEGER_PTR,temp_ptr),
+ OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.msg[0]),
+ SQL_MAX_MESSAGE_LENGTH-1,
+ OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len));
+#endif
+
+#else
+ rc=SQLError(adb->henv,
+ adb->hdbc,
+ cda,
+ OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.sqlstate[0]),
+ OTL_RCAST(OTL_SQLINTEGER_PTR,&exception_struct.code),
+ OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.msg[0]),
+ SQL_MAX_MESSAGE_LENGTH-1,
+ OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len));
+#endif
+
+ exception_struct.msg[msg_len]=0;
+
+ if(rc==SQL_INVALID_HANDLE||rc==SQL_ERROR)
+ exception_struct.msg[0]=0;
+#if (ODBCVER >= 0x0300)
+#if defined(OTL_EXTENDED_EXCEPTION)
+ else if(rc!=SQL_NO_DATA)
+ otl_fill_exception(exception_struct,cda,SQL_HANDLE_STMT);
+#endif
+#endif
+ }
+private:
+
+ otl_cur(const otl_cur&):
+ otl_cur0(),
+ status(0),
+ adb(0),
+ direct_exec_flag(0),
+ _rpc(0),
+ canceled(false),
+ last_iters(0)
+ {
+ }
+
+ otl_cur& operator=(const otl_cur&)
+ {
+ return *this;
+ }
+
+};
+
+class otl_sel{
+private:
+
+ int implicit_cursor;
+ int status;
+ int prefetch_array_size;
+
+#if defined(OTL_ODBC_UNIX)
+#if defined(SIZEOF_LONG)
+#if (SIZEOF_LONG==8)
+#if !defined(BUILD_REAL_64_BIT_MODE)
+ OTL_SQLULEN crow;
+#else
+ OTL_SQLUINTEGER crow;
+#endif
+#else // (SIZEOF_LONG==8)
+ OTL_SQLULEN crow;
+#endif
+#else // defined(SIZEOF_LONG)
+ OTL_SQLULEN crow;
+#endif
+#else // defined(OTL_ODBC_UNIX)
+ OTL_SQLULEN crow;
+#endif
+
+ int in_sequence;
+#if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) || (ODBCVER<0x0300)
+ OTL_SQLUSMALLINT* row_status;
+ int row_status_arr_size;
+#endif
+
+public:
+
+ int get_implicit_cursor() const {return implicit_cursor;
+}
+ void set_arr_size
+ (const int input_arr_size,
+ int& out_array_size,
+ int& out_prefetch_array_size)
+ {
+#if defined(OTL_ODBC_TIMESTEN)
+ out_array_size=1;
+ out_prefetch_array_size=input_arr_size;
+#else
+ out_array_size=input_arr_size;
+ out_prefetch_array_size=0;
+#endif
+ }
+
+ int close_select(otl_cur& cur)
+ {
+ if(!in_sequence)return 1;
+#if defined(OTL_DB2_CLI)
+ status=SQLCloseCursor(cur.cda);
+#else
+ status=SQLFreeStmt(cur.cda,SQL_CLOSE);
+#endif
+ in_sequence=0;
+ if(status==SQL_ERROR)
+ return 0;
+ else
+ return 1;
+ }
+
+ otl_sel():
+ implicit_cursor(0),
+ status(0),
+ prefetch_array_size(0),
+ crow(0),
+ in_sequence(0)
+#if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) || (ODBCVER<0x0300)
+ ,row_status(0)
+ ,row_status_arr_size(0)
+#endif
+ {
+ }
+
+ virtual ~otl_sel()
+ {
+#if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) || (ODBCVER<0x0300)
+ if(row_status!=0){
+ delete[] row_status;
+ row_status=0;
+ row_status_arr_size=0;
+ }
+#endif
+ }
+
+#if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) || (ODBCVER<0x0300)
+ void alloc_row_status(const int array_size)
+ {
+ if(row_status==0){
+ row_status=new OTL_SQLUSMALLINT[array_size];
+ row_status_arr_size=array_size;
+ memset(row_status,0,sizeof(OTL_SQLUSMALLINT)*array_size);
+ }else if(row_status!=0 && array_size!=row_status_arr_size){
+ delete[] row_status;
+ row_status=new OTL_SQLUSMALLINT[array_size];
+ row_status_arr_size=array_size;
+ memset(row_status,0,sizeof(OTL_SQLUSMALLINT)*array_size);
+ }
+ }
+#endif
+
+ void set_select_type(const int atype)
+ {
+ implicit_cursor=atype;
+ }
+
+ void init(const int /* array_size */)
+ {
+ }
+
+ void set_prefetch_size(const int aprefetch_array_size)
+ {
+ prefetch_array_size=aprefetch_array_size;
+ }
+
+ int first
+ (otl_cur& cur,
+ int& cur_row,
+ int& cur_size,
+ int& row_count,
+ int& eof_data,
+ const int
+#if !defined(OTL_ODBC_XTG_IBASE6)
+ array_size
+#endif
+ )
+ {
+#if defined(OTL_ODBC_XTG_IBASE6)
+
+ cur_row=-1;
+ eof_data=0;
+ if(!implicit_cursor){
+ status=SQLExecute(cur.cda);
+ if(cur.canceled)return 0;
+#if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO)
+ if(cur.adb && cur.adb->throws_on_sql_success_with_info &&
+ status==SQL_SUCCESS_WITH_INFO)
+ return 0;
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+ }
+ crow=0;
+ status=SQLFetch(cur.cda);
+ if(cur.canceled)return 0;
+ if(status==SQL_SUCCESS||status==SQL_SUCCESS_WITH_INFO){
+ crow=1;
+ in_sequence=1;
+ }
+
+#else
+
+#if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON)
+ alloc_row_status(array_size);
+#endif
+ cur_row=-1;
+ eof_data=0;
+#if (ODBCVER >= 0x0300)
+ status=SQLSetStmtAttr
+ (cur.cda,
+ SQL_ATTR_ROW_ARRAY_SIZE,
+ OTL_RCAST(void*,OTL_SCAST(size_t,array_size)),
+ SQL_NTS);
+#else
+#if defined(OTL_ODBC_TIMESTEN)
+ status=SQLSetStmtOption(cur.cda,TT_PREFETCH_COUNT,prefetch_array_size);
+#else
+ status=SQLSetStmtOption(cur.cda,SQL_ROWSET_SIZE,array_size);
+#endif
+#endif
+ if(cur.canceled)return 0;
+ if(status!=SQL_SUCCESS&&
+ status!=SQL_SUCCESS_WITH_INFO)
+ return 0;
+#if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON)
+#else
+#if (ODBCVER >= 0x0300)
+
+ status=SQLSetStmtAttr(cur.cda,SQL_ATTR_ROWS_FETCHED_PTR,&crow,SQL_NTS);
+ if(cur.canceled)return 0;
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+
+#else
+#endif
+#endif
+ if(!implicit_cursor){
+ status=SQLExecute(cur.cda);
+ if(cur.canceled)return 0;
+#if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO)
+ if(cur.adb && cur.adb->throws_on_sql_success_with_info &&
+ status==SQL_SUCCESS_WITH_INFO)
+ return 0;
+#endif
+ if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0;
+ }
+#if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON)
+ if(array_size==1){
+ crow=0;
+ status=SQLFetch(cur.cda);
+ if(cur.canceled)return 0;
+ if(status==SQL_SUCCESS||status==SQL_SUCCESS_WITH_INFO){
+ crow=1;
+ in_sequence=1;
+ }
+ }else{
+ status=SQLExtendedFetch
+ (cur.cda,
+ SQL_FETCH_NEXT,
+ 1,
+ &crow,
+ row_status);
+ }
+#else
+#if (ODBCVER >= 0x0300)
+ status=SQLFetchScroll(cur.cda,SQL_FETCH_NEXT,1);
+#else
+ {
+ alloc_row_status(array_size);
+ status=SQLExtendedFetch
+ (cur.cda,
+ SQL_FETCH_NEXT,
+ 1,
+ &crow,
+ row_status);
+ }
+#endif
+
+#endif
+
+#endif
+
+ in_sequence=1;
+ if(cur.canceled)return 0;
+ if(status==SQL_ERROR||
+ status==SQL_INVALID_HANDLE)
+ return 0;
+ if(status==SQL_NO_DATA_FOUND){
+ eof_data=1;
+ cur_row=-1;
+ crow=0;
+ row_count=0;
+ cur_size=0;
+#if defined(OTL_DB2_CLI)
+ status=SQLCloseCursor(cur.cda);
+#else
+ status=SQLFreeStmt(cur.cda,SQL_CLOSE);
+#endif
+ in_sequence=0;
+ if(status==SQL_ERROR)return 0;
+ return 1;
+ }
+ row_count=OTL_SCAST(int,crow);
+ cur_size=row_count;
+ if(cur_size!=0)cur_row=0;
+ return 1;
+ }
+
+#if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON)
+ int next
+ (otl_cur& cur,
+ int& cur_row,
+ int& cur_size,
+ int& row_count,
+ int& eof_data,
+ const int array_size)
+ {
+ alloc_row_status(array_size);
+#else
+ int next
+ (otl_cur& cur,
+ int& cur_row,
+ int& cur_size,
+ int& row_count,
+ int& eof_data,
+#if (ODBCVER >= 0x0300)
+ const int /* array_size */)
+#else
+ const int array_size)
+#endif
+ {
+#endif
+ if(cur_row<cur_size-1){
+ ++cur_row;
+ return 1;
+ }else{
+ if(eof_data){
+ cur_row=-1;
+ cur_size=0;
+ in_sequence=0;
+#if defined(OTL_DB2_CLI)
+ status=SQLCloseCursor(cur.cda);
+#else
+ status=SQLFreeStmt(cur.cda,SQL_CLOSE);
+#endif
+ if(status==SQL_ERROR)return 0;
+ return 1;
+ }
+#if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON)
+ if(array_size==1){
+ crow=0;
+ status=SQLFetch(cur.cda);
+ if(cur.canceled)return 0;
+ if(status==SQL_SUCCESS||status==SQL_SUCCESS_WITH_INFO){
+ crow=1;
+ in_sequence=1;
+ }
+ }else{
+ status=SQLExtendedFetch
+ (cur.cda,
+ SQL_FETCH_NEXT,
+ 1,
+ &crow,
+ row_status);
+ }
+#else
+#if (ODBCVER >= 0x0300)
+ status=SQLFetchScroll(cur.cda,SQL_FETCH_NEXT,1);
+#else
+ {
+ alloc_row_status(array_size);
+ status=SQLExtendedFetch
+ (cur.cda,
+ SQL_FETCH_NEXT,
+ 1,
+ &crow,
+ row_status);
+ }
+#endif
+#endif
+ in_sequence=1;
+ if(cur.canceled)return 0;
+ if(status==SQL_ERROR||
+// status==SQL_SUCCESS_WITH_INFO||
+ status==SQL_INVALID_HANDLE)
+ return 0;
+ if(status==SQL_NO_DATA_FOUND){
+ eof_data=1;
+ cur_row=-1;
+ cur_size=0;
+ in_sequence=0;
+#if defined(OTL_DB2_CLI)
+ status=SQLCloseCursor(cur.cda);
+#else
+ status=SQLFreeStmt(cur.cda,SQL_CLOSE);
+#endif
+ if(status==SQL_ERROR)return 0;
+ return 1;
+ }
+ cur_size=OTL_SCAST(int,crow);
+ row_count+=OTL_SCAST(int,crow);
+ if(cur_size!=0)cur_row=0;
+ return 1;
+ }
+ }
+
+private:
+
+ otl_sel(const otl_sel&):
+ implicit_cursor(0),
+ status(0),
+ prefetch_array_size(0),
+ crow(0),
+ in_sequence(0)
+#if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) || (ODBCVER<0x0300)
+ ,row_status(0)
+ ,row_status_arr_size(0)
+#endif
+ {
+ }
+
+ otl_sel& operator=(const otl_sel&)
+ {
+ return *this;
+ }
+
+};
+
+typedef otl_tmpl_connect
+ <otl_exc,
+ otl_conn,
+ otl_cur> otl_odbc_connect;
+
+typedef otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var> otl_cursor;
+
+typedef otl_tmpl_exception
+ <otl_exc,
+ otl_conn,
+ otl_cur> otl_exception;
+
+typedef otl_tmpl_select_stream
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var,
+ otl_sel,
+ otl_time> otl_select_stream;
+
+typedef otl_tmpl_inout_stream
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var,
+ otl_time> otl_inout_stream;
+
+class otl_stream;
+class otl_connect: public otl_odbc_connect{
+public:
+
+ void set_connection_mode(const int connection_mode)
+ {
+ connect_struct.connection_type=connection_mode;
+ }
+
+ int get_connection_mode(void)
+ {
+ return connect_struct.connection_type;
+ }
+
+protected:
+
+ friend class otl_stream;
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ otl_stream_pool sc;
+#endif
+
+public:
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+
+ void set_stream_pool_size(const int max_size=otl_max_default_pool_size)
+ {
+ sc.init(max_size);
+ }
+
+#endif
+
+ void commit(void)
+ {
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ if(!auto_commit_){
+ (*this)<<"commit tran";
+ otl_odbc_connect::commit();
+ (*this)<<"begin tran";
+ }
+#else
+ otl_odbc_connect::commit();
+#endif
+ }
+
+ void rollback(void)
+ {
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ if(!auto_commit_){
+ (*this)<<"rollback tran";
+ otl_odbc_connect::rollback();
+ (*this)<<"begin tran";
+ }
+#else
+ otl_odbc_connect::rollback();
+#endif
+ }
+
+ long direct_exec
+ (const char* sqlstm,
+ const int exception_enabled=1)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ return otl_cursor::direct_exec(*this,sqlstm,exception_enabled);
+ }
+
+ void syntax_check(const char* sqlstm)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ otl_cursor::syntax_check(*this,sqlstm);
+ }
+
+ otl_connect() OTL_NO_THROW :
+ otl_odbc_connect(),
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ sc(),
+#endif
+ cmd_(0)
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ ,auto_commit_(false)
+#endif
+ {
+ }
+
+ otl_connect(const char* connect_str, const int aauto_commit=0)
+ OTL_THROWS_OTL_EXCEPTION:
+ otl_odbc_connect(connect_str, aauto_commit),
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ sc(),
+#endif
+ cmd_(0)
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ ,auto_commit_(false)
+#endif
+ {
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ if(aauto_commit)
+ auto_commit_=true;
+ else
+ auto_commit_=false;
+#endif
+ }
+
+ otl_connect(OTL_HENV ahenv,OTL_HDBC ahdbc,const int auto_commit=0)
+ OTL_THROWS_OTL_EXCEPTION:
+ otl_odbc_connect(),
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ sc(),
+#endif
+ cmd_(0)
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ ,auto_commit_(false)
+#endif
+ {
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ if(auto_commit)
+ auto_commit_=true;
+ else
+ auto_commit_=false;
+#endif
+ rlogon(ahenv,ahdbc,auto_commit);
+ }
+
+ const char* getCmd(void) const
+ {
+ return cmd_;
+ }
+
+ otl_connect& operator<<(const char* cmd)
+ {
+ if(!connected){
+ this->rlogon(cmd);
+ }else{
+ otl_cursor::direct_exec(*this,cmd);
+ }
+ return *this;
+ }
+
+ otl_connect& operator<<=(const char* cmd)
+ {
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+ size_t cmd_len=strlen(cmd);
+ cmd_=new char[cmd_len+1];
+ OTL_STRCPY_S(cmd_,cmd_len+1,cmd);
+ return *this;
+ }
+
+#if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO)
+ void set_throw_on_sql_success_with_info(const bool throw_flag=false)
+ {
+ this->get_connect_struct().throws_on_sql_success_with_info=throw_flag;
+ }
+#endif
+
+ void rlogon(OTL_HENV ahenv,OTL_HDBC ahdbc,const int auto_commit=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(this->connected){
+ throw otl_exception(otl_error_msg_30,otl_error_code_30);
+ }
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ if(auto_commit)
+ auto_commit_=true;
+ else
+ auto_commit_=false;
+#endif
+ retcode=connect_struct.ext_logon(ahenv,ahdbc,auto_commit);
+ if(retcode)
+ connected=1;
+ else{
+ connected=0;
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ if(!auto_commit_){
+ (*this)<<"begin tran";
+ }
+#endif
+ }
+
+#if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON)
+ void rlogon(const OTL_UNICODE_CHAR_TYPE* username,
+ const OTL_UNICODE_CHAR_TYPE* passwd,
+ const OTL_UNICODE_CHAR_TYPE* dns,
+ const int auto_commit=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(this->connected){
+ throw otl_exception(otl_error_msg_30,otl_error_code_30);
+ }
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ if(auto_commit)
+ auto_commit_=true;
+ else
+ auto_commit_=false;
+#endif
+ retcode=connect_struct.rlogon
+ (OTL_RCAST(const SQLWCHAR*,username),
+ OTL_RCAST(const SQLWCHAR*,passwd),
+ OTL_RCAST(const SQLWCHAR*,dns),
+ auto_commit);
+ if(retcode)
+ connected=1;
+ else{
+ connected=0;
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ if(!auto_commit_){
+ (*this)<<"begin tran";
+ }
+#endif
+ }
+#endif
+
+ virtual ~otl_connect()
+#if !defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ OTL_THROWS_OTL_EXCEPTION
+#endif
+ {
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+#if defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ try{
+ logoff();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ }
+#endif
+ }
+
+ void rlogon(const char* connect_str, const int aauto_commit=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(this->connected){
+ throw otl_exception(otl_error_msg_30,otl_error_code_30);
+ }
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ if(aauto_commit)
+ auto_commit_=true;
+ else
+ auto_commit_=false;
+#endif
+ otl_odbc_connect::rlogon(connect_str,aauto_commit);
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ if(!auto_commit_){
+ (*this)<<"begin tran";
+ }
+#endif
+ }
+
+ void logoff(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ if(connected)
+ sc.init(sc.get_max_size());
+#endif
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ if(!auto_commit_) rollback();
+#endif
+ otl_odbc_connect::logoff();
+ }
+
+ void set_transaction_isolation_level(const long int level)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ retcode=connect_struct.set_transaction_isolation_level(level);
+ if(!retcode){
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+ }
+
+private:
+
+ char* cmd_;
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ bool auto_commit_;
+#endif
+
+ otl_connect(const otl_connect&) OTL_NO_THROW :
+ otl_odbc_connect(),
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ sc(),
+#endif
+ cmd_(0)
+#if defined(OTL_FREETDS_ODBC_WORKAROUNDS)
+ ,auto_commit_(false)
+#endif
+ {
+ }
+
+ otl_connect& operator=(const otl_connect&)
+ {
+ return *this;
+ }
+
+};
+
+const int otl_odbc_no_stream=0;
+const int otl_odbc_io_stream=1;
+const int otl_odbc_select_stream=2;
+
+class otl_stream_shell: public otl_stream_shell_generic{
+public:
+
+ otl_select_stream* ss;
+ otl_inout_stream* io;
+ otl_connect* adb;
+
+ int auto_commit_flag;
+
+ otl_var_desc* iov;
+ int iov_len;
+ int next_iov_ndx;
+
+ otl_var_desc* ov;
+ int ov_len;
+ int next_ov_ndx;
+
+ bool flush_flag;
+ int stream_type;
+ bool lob_stream_flag;
+
+ otl_select_struct_override override;
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ OTL_STRING_CONTAINER orig_sql_stm;
+#endif
+
+ otl_stream_shell():
+ otl_stream_shell_generic(),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ flush_flag(false),
+ stream_type(otl_odbc_no_stream),
+ lob_stream_flag(0),
+ override()
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ ,orig_sql_stm()
+#endif
+ {
+ should_delete=0;
+ }
+
+ otl_stream_shell(const int ashould_delete):
+ otl_stream_shell_generic(),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ flush_flag(true),
+ stream_type(otl_odbc_no_stream),
+ lob_stream_flag(false),
+ override()
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ ,orig_sql_stm()
+#endif
+ {
+ should_delete=ashould_delete;
+ }
+
+ virtual ~otl_stream_shell()
+ {
+ if(should_delete){
+ delete[] iov;
+ delete[] ov;
+
+ iov=0; iov_len=0;
+ ov=0; ov_len=0;
+ next_iov_ndx=0;
+ next_ov_ndx=0;
+ override.setLen(0);
+ flush_flag=true;
+
+ delete ss;
+ delete io;
+ ss=0; io=0;
+ adb=0;
+ }
+ }
+
+private:
+
+ otl_stream_shell(const otl_stream_shell&):
+ otl_stream_shell_generic(),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ flush_flag(false),
+ stream_type(otl_odbc_no_stream),
+ lob_stream_flag(0),
+ override()
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ ,orig_sql_stm()
+#endif
+ {
+ should_delete=0;
+ }
+
+ otl_stream_shell& operator=(const otl_stream_shell&)
+ {
+ return *this;
+ }
+
+};
+
+template <OTL_TYPE_NAME TExceptionStruct,
+ OTL_TYPE_NAME TConnectStruct,
+ OTL_TYPE_NAME TCursorStruct,
+ OTL_TYPE_NAME TVariableStruct>
+class otl_tmpl_lob_stream: public otl_lob_stream_generic{
+public:
+
+ typedef otl_tmpl_exception
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct> otl_exception;
+
+ typedef otl_tmpl_variable<TVariableStruct>* p_bind_var;
+ typedef otl_tmpl_connect
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>* p_connect;
+
+ typedef otl_tmpl_cursor
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct,
+ TVariableStruct>* p_cursor;
+
+private:
+
+ p_bind_var bind_var;
+ p_connect connect;
+ p_cursor cursor;
+ otl_long_string* temp_buf;
+ char* temp_char_buf;
+ bool written_to_flag;
+ bool closed_flag;
+
+public:
+
+ void init
+ (void* avar,void* aconnect,void* acursor,
+ int andx,int amode,const int alob_is_null=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ closed_flag=false;
+ if(written_to_flag){
+ retcode=bind_var->get_var_struct().clob_blob(cursor->get_cursor_struct());
+ written_to_flag=false;
+ if(!retcode){
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (cursor->get_cursor_struct(),
+ cursor->get_stm_label()?cursor->get_stm_label():
+ cursor->get_stm_text());
+ }
+
+ }
+ connect=OTL_RCAST(p_connect,aconnect);
+ bind_var=OTL_RCAST(p_bind_var,avar);
+ cursor=OTL_RCAST(p_cursor,acursor);
+ mode=amode;
+ retcode=0;
+ lob_is_null=alob_is_null;
+ ndx=andx;
+ offset=0;
+ lob_len=0;
+ eof_flag=0;
+ in_destructor=0;
+ if(bind_var)
+ bind_var->get_var_struct().set_lob_stream_flag();
+ }
+
+ void set_len(void) OTL_NO_THROW
+ {
+ }
+
+ void set_len(const int /*new_len*/) OTL_NO_THROW
+ {
+ }
+
+ otl_tmpl_lob_stream() OTL_NO_THROW:
+ otl_lob_stream_generic(false),
+ bind_var(0),
+ connect(0),
+ cursor(0),
+ temp_buf(0),
+ temp_char_buf(0),
+ written_to_flag(false),
+ closed_flag(false)
+ {
+ init(0,0,0,0,otl_lob_stream_zero_mode);
+ }
+
+ ~otl_tmpl_lob_stream()
+#if !defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ OTL_THROWS_OTL_EXCEPTION
+#endif
+ {
+ in_destructor=1;
+ if(temp_buf){
+ delete temp_buf;
+ temp_buf=0;
+ }
+ if(temp_char_buf){
+ delete[] temp_char_buf;
+ temp_char_buf=0;
+ }
+#if defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ try{
+ if(!closed_flag)
+ close();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ }
+#else
+ if(!closed_flag)
+ close();
+#endif
+ }
+
+#if (defined(OTL_STL) || defined(OTL_ACE) || \
+ defined(OTL_USER_DEFINED_STRING_CLASS_ON)) && !defined(OTL_UNICODE)
+ otl_lob_stream_generic& operator<<(const OTL_STRING_CONTAINER& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ otl_long_string temp_s(s.c_str(),
+ OTL_SCAST(int,s.length()),
+ OTL_SCAST(int,s.length()));
+ (*this)<<temp_s;
+ return *this;
+ }
+
+ void setStringBuffer(const int chunk_size)
+ {
+ delete[] temp_char_buf;
+ temp_char_buf=0;
+ delete temp_buf;
+ temp_buf=0;
+ temp_char_buf=new char[chunk_size+1];
+ temp_buf=new otl_long_string(temp_char_buf,chunk_size);
+ }
+
+ otl_lob_stream_generic& operator>>(OTL_STRING_CONTAINER& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ const int TEMP_BUF_SIZE=4096;
+ if(!temp_char_buf)temp_char_buf=new char[TEMP_BUF_SIZE];
+ if(!temp_buf)temp_buf=new otl_long_string(temp_char_buf,TEMP_BUF_SIZE-1);
+ int iters=0;
+ while(!this->eof()){
+ ++iters;
+ (*this)>>(*temp_buf);
+ temp_char_buf[temp_buf->len()]=0;
+ if(iters>1)
+ s+=temp_char_buf;
+ else
+ s=temp_char_buf;
+ }
+ return *this;
+ }
+
+#endif
+
+ otl_lob_stream_generic& operator<<(const otl_long_string& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(mode!=otl_lob_stream_write_mode){
+ const char* stm=0;
+ char var_info[256];
+ var_info[0]=0;
+ if(cursor!=0){
+ if(cursor->get_stm_label())
+ stm=cursor->get_stm_label();
+ else
+ stm=cursor->get_stm_text();
+ }
+ if(bind_var!=0){
+ otl_var_info_var
+ (bind_var->get_name(),
+ bind_var->get_ftype(),
+ otl_var_long_string,
+ var_info,
+ sizeof(var_info));
+ }
+ char* vinfo=0;
+ if(var_info[0]!=0)
+ vinfo=&var_info[0];
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_tmpl_exception
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>
+ (otl_error_msg_9,
+ otl_error_code_9,
+ stm,
+ vinfo);
+ }
+ if(offset==0)offset=1;
+ retcode=bind_var->get_var_struct().write_blob
+ (s,lob_len,offset,cursor->get_cursor_struct());
+ written_to_flag=true;
+ if(retcode)
+ return *this;
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (cursor->get_cursor_struct(),
+ cursor->get_stm_label()?cursor->get_stm_label():
+ cursor->get_stm_text());
+ }
+
+ otl_lob_stream_generic& operator>>(otl_long_string& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(mode!=otl_lob_stream_read_mode){
+ const char* stm=0;
+ char var_info[256];
+ var_info[0]=0;
+ if(cursor!=0){
+ if(cursor->get_stm_label())
+ stm=cursor->get_stm_label();
+ else
+ stm=cursor->get_stm_text();
+ }
+ if(bind_var!=0){
+ otl_var_info_var
+ (bind_var->get_name(),
+ bind_var->get_ftype(),
+ otl_var_long_string,
+ var_info,
+ sizeof(var_info));
+ }
+ char* vinfo=0;
+ if(var_info[0]!=0)
+ vinfo=&var_info[0];
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (otl_error_msg_10,
+ otl_error_code_10,
+ stm,
+ vinfo);
+ }
+ if(offset==0)offset=1;
+ retcode=bind_var->get_var_struct().read_blob
+ (cursor->get_cursor_struct(),s,ndx,offset,eof_flag);
+ if(retcode){
+ if(eof())
+ close();
+ return *this;
+ }
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw OTL_TMPL_EXCEPTION
+ (cursor->get_cursor_struct(),
+ cursor->get_stm_label()?cursor->get_stm_label():
+ cursor->get_stm_text());
+ }
+
+ int eof(void) OTL_NO_THROW
+ {
+ if(mode!=otl_lob_stream_read_mode)return 1;
+ if(lob_is_null)return 1;
+ return eof_flag;
+ }
+
+ int len(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if(cursor==0||connect==0||bind_var==0||lob_is_null)return 0;
+ int alen;
+ retcode=bind_var->get_var_struct().get_blob_len(ndx,alen);
+ if(retcode)return alen;
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw OTL_TMPL_EXCEPTION
+ (connect->get_connect_struct(),
+ cursor->get_stm_label()?cursor->get_stm_label():
+ cursor->get_stm_text());
+ }
+
+ bool is_initialized(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if(cursor==0||connect==0||bind_var==0||lob_is_null)
+ return false;
+ else
+ return true;
+ }
+
+ void close(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if(in_destructor){
+ if(mode==otl_lob_stream_read_mode){
+ bind_var->get_var_struct().set_lob_stream_flag(0);
+ bind_var->set_not_null(0);
+ } if(mode==otl_lob_stream_write_mode){
+ retcode=bind_var->get_var_struct().clob_blob(cursor->get_cursor_struct());
+ closed_flag=true;
+ written_to_flag=false;
+ if(!retcode){
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (cursor->get_cursor_struct(),
+ cursor->get_stm_label()?cursor->get_stm_label():
+ cursor->get_stm_text());
+ }
+ }
+ return;
+ }
+ if(mode==otl_lob_stream_zero_mode)return;
+ if(mode==otl_lob_stream_read_mode){
+ bind_var->get_var_struct().set_lob_stream_flag(0);
+ bind_var->set_not_null(0);
+ init(0,0,0,0,otl_lob_stream_zero_mode);
+ }else{
+ // write mode
+ if(mode==otl_lob_stream_write_mode){
+ retcode=bind_var->get_var_struct().clob_blob(cursor->get_cursor_struct());
+ written_to_flag=false;
+ closed_flag=true;
+ if(!retcode){
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw OTL_TMPL_EXCEPTION
+ (cursor->get_cursor_struct(),
+ cursor->get_stm_label()?cursor->get_stm_label():
+ cursor->get_stm_text());
+ }
+ }
+ bind_var->get_var_struct().set_lob_stream_flag(0);
+ bind_var->set_not_null(0);
+ }
+ }
+
+private:
+
+ otl_tmpl_lob_stream(const otl_tmpl_lob_stream&) OTL_NO_THROW:
+ otl_lob_stream_generic(false),
+ bind_var(0),
+ connect(0),
+ cursor(0),
+ temp_buf(0),
+ temp_char_buf(0),
+ written_to_flag(false),
+ closed_flag(false)
+ {
+ }
+
+ otl_tmpl_lob_stream& operator=(const otl_tmpl_lob_stream&)
+ {
+ return *this;
+ }
+
+
+};
+
+typedef otl_tmpl_lob_stream
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var> otl_lob_stream;
+
+class otl_stream{
+private:
+
+ otl_stream_shell* shell;
+ otl_ptr<otl_stream_shell> shell_pt;
+ int connected;
+
+ otl_select_stream** ss;
+ otl_inout_stream** io;
+ otl_connect** adb;
+
+ int* auto_commit_flag;
+
+ otl_var_desc** iov;
+ int* iov_len;
+ int* next_iov_ndx;
+
+ otl_var_desc** ov;
+ int* ov_len;
+ int* next_ov_ndx;
+
+ otl_select_struct_override* override;
+ int end_marker;
+ int oper_int_called;
+ int last_eof_rc;
+ bool last_oper_was_read_op;
+
+public:
+
+#if defined(OTL_ODBC_SQL_STATEMENT_WITH_DIAG_REC_OUTPUT)
+
+ OTL_SQLHSTMT get_stm_handle(){return (*io)->get_cursor_struct().get_cda();}
+
+#if defined(_UNICODE) || defined(UNICODE)
+ typedef SQLWCHAR sqlchar_type;
+#else
+ typedef SQLCHAR sqlchar_type;
+#endif
+
+ bool get_next_diag_rec
+ (short int& rec_ndx,
+ sqlchar_type* sqlstate_buf,
+ sqlchar_type* msg_buf,
+ short int msg_buf_size,
+ int& native_err)
+ {
+ OTL_SQLINTEGER rc;
+ SQLSMALLINT msg_len;
+ rc=SQLGetDiagRec
+ (SQL_HANDLE_STMT,
+ get_stm_handle(),
+ OTL_SCAST(OTL_SQLSMALLINT,rec_ndx),
+ OTL_RCAST(sqlchar_type*,sqlstate_buf),
+ OTL_RCAST(OTL_SQLINTEGER_PTR,&native_err),
+ OTL_RCAST(sqlchar_type*,msg_buf),
+ msg_buf_size,
+ OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len));
+ bool result=rc==SQL_NO_DATA||rc<0;
+ msg_buf[msg_len]=0;
+ ++rec_ndx;
+ return result;
+ }
+
+#endif
+
+protected:
+
+ int buf_size_;
+
+ void reset_end_marker(void)
+ {
+ last_eof_rc=0;
+ end_marker=-1;
+ oper_int_called=0;
+ }
+
+ void throw_end_of_row()
+#if defined(__GNUC__) && (__GNUC__>=4)
+ __attribute__ ((noreturn))
+#endif
+ {
+ throw otl_exception
+ (otl_error_msg_34,
+ otl_error_code_34,
+ this->get_stm_text());
+ }
+
+public:
+
+ int get_prefetched_row_count() const
+ {
+ if(*ss){
+ (*adb)->reset_throw_count();
+ return (*ss)->get_prefetched_row_count();
+ }
+ return 0;
+ }
+
+ bool get_lob_stream_flag() const
+ {
+ if(!shell)
+ return false;
+ else
+ return shell->lob_stream_flag;
+ }
+
+ int get_adb_max_long_size() const
+ {
+ return this->shell->adb->get_max_long_size();
+ }
+
+ void check_end_of_row()
+ {
+ if(next_ov_ndx==0||(*next_ov_ndx)!=0)
+ throw_end_of_row();
+ if(next_iov_ndx==0||(*next_iov_ndx)!=0)
+ throw_end_of_row();
+ }
+
+ otl_stream_shell* get_shell(){return shell;}
+ int get_connected() const {return connected;}
+
+ int get_dirty_buf_len() const
+ {
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ return 0;
+ case otl_odbc_io_stream:
+ return (*io)->get_dirty_buf_len();
+ case otl_odbc_select_stream:
+ return (*ss)->get_select_row_count();
+ default:
+ return 0;
+ }
+ }
+
+ const char* get_stm_text(void)
+ {
+ const char* no_stm_text=OTL_NO_STM_TEXT;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ return no_stm_text;
+ case otl_odbc_io_stream:
+ return (*io)->get_stm_label()?(*io)->get_stm_label():(*io)->get_stm_text();
+ case otl_odbc_select_stream:
+ return (*ss)->get_stm_label()?(*ss)->get_stm_label():(*ss)->get_stm_text();
+ default:
+ return no_stm_text;
+ }
+ }
+
+
+
+ void setBufSize(int buf_size)
+ {
+ buf_size_=buf_size;
+ }
+
+ int getBufSize(void) const
+ {
+ return buf_size_;
+ }
+
+ long get_rpc() OTL_THROWS_OTL_EXCEPTION
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ return (*io)->get_rpc();
+ }else if((*ss)){
+ (*adb)->reset_throw_count();
+ return (*ss)->get_rfc();
+ }else
+ return 0;
+ }
+
+ void skip_to_end_of_row()
+ {
+ if(next_ov_ndx==0)
+ return;
+ if((*ov_len)==0)return;
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->skip_to_end_of_row();
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->skip_to_end_of_row();
+ break;
+ }
+ while ((*next_ov_ndx)<(*ov_len)-1)
+ ++(*next_ov_ndx);
+ }
+
+
+ operator int(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if(shell && shell->lob_stream_flag){
+ if(this->adb&&*this->adb)(*this->adb)->increment_throw_count();
+ if(this->adb&&*this->adb&&(*this->adb)->get_throw_count()>1)return 0;
+ const char* stm_label=0;
+ const char* stm_text=0;
+ if((*io)){
+ stm_label=(*io)->get_stm_label();
+ stm_text=(*io)->get_stm_text();
+ }else if((*ss)){
+ stm_label=(*ss)->get_stm_label();
+ stm_text=(*ss)->get_stm_text();
+ }
+ throw otl_exception
+ (otl_error_msg_24,
+ otl_error_code_24,
+ stm_label?stm_label:stm_text);
+ }
+ if(!last_oper_was_read_op){
+ if(this->adb&&*this->adb)(*this->adb)->increment_throw_count();
+ if(this->adb&&*this->adb&&(*this->adb)->get_throw_count()>1)return 0;
+ const char* stm_label=0;
+ const char* stm_text=0;
+ if((*io)){
+ stm_label=(*io)->get_stm_label();
+ stm_text=(*io)->get_stm_text();
+ }else if((*ss)){
+ stm_label=(*ss)->get_stm_label();
+ stm_text=(*ss)->get_stm_text();
+ }
+ throw otl_exception
+ (otl_error_msg_18,
+ otl_error_code_18,
+ stm_label?stm_label:stm_text);
+ }
+ if(end_marker==1)return 0;
+ int rc=0;
+ int temp_eof=eof();
+ if(temp_eof && end_marker==-1 && oper_int_called==0){
+ end_marker=1;
+ if(last_eof_rc==1)
+ rc=0;
+ else
+ rc=1;
+ }else if(!temp_eof && end_marker==-1)
+ rc=1;
+ else if(temp_eof && end_marker==-1){
+ end_marker=0;
+ rc=1;
+ }else if(temp_eof && end_marker==0){
+ end_marker=1;
+ rc=0;
+ }
+ if(!oper_int_called)oper_int_called=1;
+ return rc;
+ }
+
+ void cancel(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if((*ss)){
+ (*adb)->reset_throw_count();
+ int status=(*ss)->get_cursor_struct().cancel();
+ if(status==0)
+ throw otl_exception((*ss)->get_cursor_struct());
+ }else if((*io)){
+ (*adb)->reset_throw_count();
+ int status=(*io)->get_cursor_struct().cancel();
+ if(status==0)
+ throw otl_exception((*io)->get_cursor_struct());
+ }
+ }
+
+ void create_var_desc(void)
+ {int i;
+ delete[] (*iov);
+ delete[] (*ov);
+ (*iov)=0; (*iov_len)=0;
+ (*ov)=0; (*ov_len)=0;
+ if((*ss)){
+ if((*ss)->get_vl_len()>0){
+ (*iov)=new otl_var_desc[(*ss)->get_vl_len()];
+ (*iov_len)=(*ss)->get_vl_len();
+ for(i=0;i<(*ss)->get_vl_len();++i)
+ (*ss)->get_vl()[i]->copy_var_desc((*iov)[i]);
+ }
+ if((*ss)->get_sl_len()>0){
+ (*ov)=new otl_var_desc[(*ss)->get_sl_len()];
+ (*ov_len)=(*ss)->get_sl_len();
+ for(i=0;i<(*ss)->get_sl_len();++i){
+ (*ss)->get_sl()[i].copy_var_desc((*ov)[i]);
+ if((*ss)->get_sl_desc()!=0)
+ (*ov)[i].copy_name((*ss)->get_sl_desc()[i].name);
+ }
+ }
+ }else if((*io)){
+ if((*io)->get_vl_len()>0){
+ (*iov)=new otl_var_desc[(*io)->get_vl_len()];
+ (*iov_len)=(*io)->get_vl_len();
+ for(i=0;i<(*io)->get_vl_len();++i)
+ (*io)->get_vl()[i]->copy_var_desc((*iov)[i]);
+ }
+ if((*io)->get_iv_len()>0){
+ (*ov)=new otl_var_desc[(*io)->get_iv_len()];
+ (*ov_len)=(*io)->get_iv_len();
+ for(i=0;i<(*io)->get_iv_len();++i)
+ (*io)->get_in_vl()[i]->copy_var_desc((*ov)[i]);
+ }
+ }
+ }
+
+ void set_column_type(const int column_ndx,
+ const int col_type,
+ const int col_size=0)
+ OTL_NO_THROW
+ {
+ if(shell==0){
+ init_stream();
+ shell->flush_flag=true;
+ }
+ override->add_override(column_ndx,col_type,col_size);
+ }
+
+ void set_all_column_types(const unsigned mask=0)
+ OTL_NO_THROW
+ {
+ if(shell==0){
+ init_stream();
+ shell->flush_flag=true;
+ }
+ override->set_all_column_types(mask);
+ }
+
+ void set_flush(const bool flush_flag=true)
+ OTL_NO_THROW
+ {
+ if(shell==0)init_stream();
+ shell->flush_flag=flush_flag;
+ }
+
+ void set_lob_stream_mode(const bool lob_stream_flag=false)
+ OTL_NO_THROW
+ {
+ if(shell==0)return;
+ shell->lob_stream_flag=lob_stream_flag;
+ }
+
+ void inc_next_ov(void)
+ {
+ if((*ov_len)==0)return;
+ if((*next_ov_ndx)<(*ov_len)-1)
+ ++(*next_ov_ndx);
+ else
+ (*next_ov_ndx)=0;
+ }
+
+ void inc_next_iov(void)
+ {
+ if((*iov_len)==0)return;
+ if((*next_iov_ndx)<(*iov_len)-1)
+ ++(*next_iov_ndx);
+ else
+ (*next_iov_ndx)=0;
+ }
+
+ otl_var_desc* describe_in_vars(int& desc_len)
+ OTL_NO_THROW
+ {
+ desc_len=0;
+ if(shell==0)return 0;
+ if(shell->iov==0)return 0;
+ desc_len=shell->iov_len;
+ return shell->iov;
+ }
+
+ otl_var_desc* describe_out_vars(int& desc_len)
+ OTL_NO_THROW
+ {
+ desc_len=0;
+ if(shell==0)return 0;
+ if(shell->ov==0)return 0;
+ desc_len=shell->ov_len;
+ return shell->ov;
+ }
+
+ otl_var_desc* describe_next_in_var(void)
+ OTL_NO_THROW
+ {
+ if(shell==0)return 0;
+ if(shell->iov==0)return 0;
+ return &(shell->iov[shell->next_iov_ndx]);
+ }
+
+ otl_var_desc* describe_next_out_var(void)
+ OTL_NO_THROW
+ {
+ if(shell==0)return 0;
+ if(shell->ov==0)return 0;
+ return &(shell->ov[shell->next_ov_ndx]);
+ }
+
+ void init_stream(void)
+ {
+ buf_size_=1;
+ last_oper_was_read_op=false;
+ shell=0;
+ shell=new otl_stream_shell(0);
+ shell_pt.assign(&shell);
+ connected=0;
+
+ ss=&(shell->ss);
+ io=&(shell->io);
+ adb=&(shell->adb);
+ auto_commit_flag=&(shell->auto_commit_flag);
+ iov=&(shell->iov);
+ iov_len=&(shell->iov_len);
+ next_iov_ndx=&(shell->next_iov_ndx);
+ ov=&(shell->ov);
+ ov_len=&(shell->ov_len);
+ next_ov_ndx=&(shell->next_ov_ndx);
+ override=&(shell->override);
+
+ (*io)=0;
+ (*ss)=0;
+ (*adb)=0;
+ (*ov)=0;
+ (*ov_len)=0;
+ (*next_iov_ndx)=0;
+ (*next_ov_ndx)=0;
+ (*auto_commit_flag)=1;
+ (*iov)=0;
+ (*iov_len)=0;
+
+ }
+
+ otl_stream
+ (const otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ otl_connect& db,
+ const int implicit_select=otl_explicit_select,
+ const char* sqlstm_label=0)
+ OTL_THROWS_OTL_EXCEPTION:
+ shell(0),
+ shell_pt(),
+ connected(0),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ override(0),
+ end_marker(0),
+ oper_int_called(0),
+ last_eof_rc(0),
+ last_oper_was_read_op(false),
+ buf_size_(0)
+ {
+ init_stream();
+
+ (*io)=0; (*ss)=0;
+ (*iov)=0; (*iov_len)=0;
+ (*ov)=0; (*ov_len)=0;
+ (*auto_commit_flag)=1;
+ (*next_iov_ndx)=0;
+ (*next_ov_ndx)=0;
+ (*adb)=&db;
+ shell->flush_flag=true;
+ open(arr_size,sqlstm,db,implicit_select,sqlstm_label);
+ }
+
+ otl_stream() OTL_NO_THROW:
+ shell(0),
+ shell_pt(),
+ connected(0),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ override(0),
+ end_marker(0),
+ oper_int_called(0),
+ last_eof_rc(0),
+ last_oper_was_read_op(false),
+ buf_size_(0)
+ {
+ init_stream();
+ shell->flush_flag=true;
+ }
+
+ virtual ~otl_stream()
+#if !defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ OTL_THROWS_OTL_EXCEPTION
+#endif
+ {
+ if(!connected)return;
+ try{
+ if((*io)!=0&&shell->flush_flag==false)
+ (*io)->set_flush_flag2(false);
+ close();
+ if(shell!=0){
+ if((*io)!=0)
+ (*io)->set_flush_flag2(true);
+ }
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ if(shell!=0){
+ if((*io)!=0)
+ (*io)->set_flush_flag2(true);
+ }
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ clean(1);
+ if(shell!=0)
+ shell->set_should_delete(1);
+ shell_pt.destroy();
+#else
+ shell_pt.destroy();
+#endif
+#if !defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ throw;
+#endif
+ }
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ if((adb && (*adb) && (*adb)->get_throw_count()>0)
+#if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ || otl_uncaught_exception()
+#endif
+ ){
+ //
+ }
+#elif defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ if(otl_uncaught_exception()){
+ //
+ }
+#else
+ shell_pt.destroy();
+#endif
+ }
+
+ int eof(void) OTL_NO_THROW
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ return (*io)->eof();
+ }else if((*ss)){
+ (*adb)->reset_throw_count();
+ return (*ss)->eof();
+ }else
+ return 1;
+ }
+
+ void reset_to_last_valid_row()
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->reset_to_last_valid_row();
+ }
+ }
+
+ void flush(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->flush();
+ }
+ }
+
+ void clean(const int clean_up_error_flag=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->clean(clean_up_error_flag);
+ }else if((*ss)){
+ (*adb)->reset_throw_count();
+ (*ss)->clean();
+ }
+ }
+
+ void rewind(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->rewind();
+ }else if((*ss)){
+ (*adb)->reset_throw_count();
+ (*ss)->rewind();
+ }
+ }
+
+
+ int is_null(void) OTL_NO_THROW
+ {
+ if((*io))
+ return (*io)->is_null();
+ else if((*ss))
+ return (*ss)->is_null();
+ else
+ return 0;
+ }
+
+ void set_commit(int auto_commit=0) OTL_NO_THROW
+ {
+ (*auto_commit_flag)=auto_commit;
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->set_commit(auto_commit);
+ }
+ }
+
+ const char* assign_stream_type
+ (const char* stm_text,
+ const char* stm_label)
+ {
+ const char* temp_stm_text=0;
+ temp_stm_text=stm_label?stm_label:stm_text;
+ return temp_stm_text;
+ }
+
+ void open
+ (const otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ otl_connect& db,
+ const int implicit_select=otl_explicit_select,
+ const char* sqlstm_label=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ reset_end_marker();
+ otl_stream_buffer_size_type temp_arr_size=arr_size;
+ if(this->good()){
+ const char* temp_stm_text=assign_stream_type(sqlstm,sqlstm_label);
+ throw otl_exception
+ (otl_error_msg_29,
+ otl_error_code_29,
+ temp_stm_text);
+ }
+ if(shell==0)
+ init_stream();
+ buf_size_=arr_size;
+ OTL_TRACE_STREAM_OPEN
+
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ char temp_buf[128];
+ otl_itoa(arr_size,temp_buf);
+ OTL_STRING_CONTAINER sql_stm=
+ OTL_STRING_CONTAINER(temp_buf)+
+ OTL_STRING_CONTAINER("===>")+
+ sqlstm;
+ otl_stream_shell* temp_shell=OTL_RCAST(otl_stream_shell*,db.sc.find(sql_stm));
+ if(temp_shell){
+ if(shell!=0)shell_pt.destroy();
+ shell=temp_shell;
+ ss=&(shell->ss);
+ io=&(shell->io);
+ if((*io)!=0)(*io)->set_flush_flag2(true);
+ adb=&(shell->adb);
+ auto_commit_flag=&(shell->auto_commit_flag);
+ iov=&(shell->iov);
+ iov_len=&(shell->iov_len);
+ next_iov_ndx=&(shell->next_iov_ndx);
+ ov=&(shell->ov);
+ ov_len=&(shell->ov_len);
+ next_ov_ndx=&(shell->next_ov_ndx);
+ override=&(shell->override);
+ try{
+ if((*iov_len)==0)this->rewind();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ if((*adb))
+ (*adb)->sc.remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ throw;
+ }
+ connected=1;
+ return;
+ }
+ shell->orig_sql_stm=sql_stm;
+#endif
+
+ delete[] (*iov);
+ delete[] (*ov);
+
+ (*iov)=0; (*iov_len)=0;
+ (*ov)=0; (*ov_len)=0;
+ (*next_iov_ndx)=0;
+ (*next_ov_ndx)=0;
+
+ char tmp[7];
+ char* c=OTL_CCAST(char*,sqlstm);
+
+ override->set_lob_stream_mode(shell->lob_stream_flag);
+ while(otl_isspace(*c)||(*c)=='(')++c;
+ OTL_STRNCPY_S(tmp,sizeof(tmp),c,6);
+ tmp[6]=0;
+ c=tmp;
+ while(*c){
+ *c=OTL_SCAST(char,otl_to_upper(*c));
+ ++c;
+ }
+ if(adb==0)adb=&(shell->adb);
+ (*adb)=&db;
+ (*adb)->reset_throw_count();
+ try{
+#if (defined(OTL_ODBC_POSTGRESQL) && !defined(OTL_ODBC_ALTERNATE_RPC) || \
+ defined(OTL_ODBC_SELECT_STM_EXECUTE_BEFORE_DESCRIBE)) && \
+ !defined(OTL_ODBC_MULTI_MODE)
+ if((strncmp(tmp,"SELECT",6)==0||
+ strncmp(tmp,"WITH",4)==0)){
+ override->set_master_stream_ptr(OTL_RCAST(void*,this));
+ (*ss)=new otl_select_stream(override,
+ temp_arr_size,
+ sqlstm,
+ db,otl_implicit_select,
+ sqlstm_label);
+ shell->stream_type=otl_odbc_select_stream;
+ }
+#elif defined(OTL_ODBC_MULTI_MODE)
+#if defined(OTL_ODBC_ALTERNATE_RPC)
+ bool alternate_rpc=true;
+#else
+ bool alternate_rpc=false;
+#endif
+ int connect_type=(*adb)->get_connect_struct().get_connection_type();
+ if((connect_type==OTL_POSTGRESQL_ODBC_CONNECT&&!alternate_rpc ||
+ connect_type==OTL_ENTERPRISE_DB_ODBC_CONNECT ||
+ connect_type==OTL_MYODBC35_ODBC_CONNECT) &&
+ (strncmp(tmp,"SELECT",6)==0||
+ strncmp(tmp,"WITH",4)==0)){
+ override->set_master_stream_ptr(OTL_RCAST(void*,this));
+ (*ss)=new otl_select_stream(override,
+ temp_arr_size,
+ sqlstm,
+ db,otl_implicit_select,
+ sqlstm_label);
+ shell->stream_type=otl_odbc_select_stream;
+ }else if((strncmp(tmp,"SELECT",6)==0||
+ strncmp(tmp,"WITH",4)==0)&&
+ !implicit_select){
+ (*ss)=new otl_select_stream(override,temp_arr_size,sqlstm,
+ db,otl_explicit_select,
+ sqlstm_label);
+ shell->stream_type=otl_odbc_select_stream;
+ }
+#else
+ if((strncmp(tmp,"SELECT",6)==0||
+ strncmp(tmp,"WITH",4)==0)&&
+ !implicit_select){
+#if defined(OTL_ODBC_TIMESTEN)
+ if(temp_arr_size>128||temp_arr_size<0){
+ const char* temp_stm_text=assign_stream_type(sqlstm,sqlstm_label);
+ throw otl_exception
+ (otl_error_msg_31,
+ otl_error_code_31,
+ temp_stm_text);
+ }
+#endif
+ override->set_master_stream_ptr(OTL_RCAST(void*,this));
+ (*ss)=new otl_select_stream(override,temp_arr_size,sqlstm,
+ db,otl_explicit_select,
+ sqlstm_label);
+ shell->stream_type=otl_odbc_select_stream;
+ }
+#endif
+ else if(tmp[0]=='$'){
+ override->set_master_stream_ptr(OTL_RCAST(void*,this));
+ (*ss)=new otl_select_stream
+ (override,temp_arr_size,
+ sqlstm,db,
+ 1,sqlstm_label);
+ shell->stream_type=otl_odbc_select_stream;
+ }else{
+ if(implicit_select){
+#if defined(OTL_ODBC_TIMESTEN)
+ if(temp_arr_size>128||temp_arr_size<0){
+ const char* temp_stm_text=assign_stream_type(sqlstm,sqlstm_label);
+ throw otl_exception
+ (otl_error_msg_31,
+ otl_error_code_31,
+ temp_stm_text);
+ }
+#endif
+ override->set_master_stream_ptr(OTL_RCAST(void*,this));
+ (*ss)=new otl_select_stream(override,temp_arr_size,
+ sqlstm,db,
+ 1,sqlstm_label);
+ shell->stream_type=otl_odbc_select_stream;
+ }else{
+ (*io)=new otl_inout_stream
+ (arr_size,sqlstm,db,
+ OTL_RCAST(void*,this),
+ shell->lob_stream_flag,
+ sqlstm_label);
+ (*io)->set_flush_flag(shell->flush_flag);
+ shell->stream_type=otl_odbc_io_stream;
+ }
+ }
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ shell_pt.destroy();
+ throw;
+ }
+ if((*io))(*io)->set_commit((*auto_commit_flag));
+ create_var_desc();
+ connected=1;
+ }
+
+ void intern_cleanup(void)
+ {
+ delete[] (*iov);
+ delete[] (*ov);
+
+ (*iov)=0; (*iov_len)=0;
+ (*ov)=0; (*ov_len)=0;
+ (*next_iov_ndx)=0;
+ (*next_ov_ndx)=0;
+ override->setLen(0);
+ override->set_lob_stream_mode(false);
+
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ try{
+ (*io)->flush();
+ (*io)->close();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ clean(1);
+ (*io)->close();
+ delete (*io);
+ (*io)=0;
+ shell->stream_type=otl_odbc_no_stream;
+ throw;
+ }
+ delete (*io);
+ (*io)=0;
+ shell->stream_type=otl_odbc_no_stream;
+ break;
+ case otl_odbc_select_stream:
+ try{
+ (*ss)->close();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ delete (*ss);
+ (*ss)=0;
+ shell->stream_type=otl_odbc_no_stream;
+ throw;
+ }
+ delete (*ss);
+ (*ss)=0;
+ shell->stream_type=otl_odbc_no_stream;
+ break;
+ }
+ (*ss)=0; (*io)=0;
+ if(adb!=0)(*adb)=0;
+ adb=0;
+ }
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ void close(const bool save_in_stream_pool=true)
+ OTL_THROWS_OTL_EXCEPTION
+#else
+ void close(void)
+ OTL_THROWS_OTL_EXCEPTION
+#endif
+ {
+ if(shell==0)return;
+
+ OTL_TRACE_FUNC(0x4,"otl_stream","close","")
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ if(save_in_stream_pool&&(*adb)&&
+#if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ !(otl_uncaught_exception())&&
+#elif defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ !(otl_uncaught_exception())&&
+#endif
+ (*adb)->get_throw_count()==0){
+ try{
+ this->flush();
+ this->clean(1);
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ this->clean(1);
+ throw;
+ }
+ if((*adb) && (*adb)->get_throw_count()>0){
+ (*adb)->sc.remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ return;
+ }
+#if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ if(otl_uncaught_exception()){
+ if((*adb))
+ (*adb)->sc.remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ return;
+ }
+#elif defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ if(otl_uncaught_exception()){
+ if((*adb))
+ (*adb)->sc.remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ return;
+ }
+#endif
+ (*adb)->sc.add(shell,shell->orig_sql_stm.c_str());
+ shell_pt.disconnect();
+ connected=0;
+ }else{
+ if((*adb))
+ (*adb)->sc.remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ }
+#else
+ intern_cleanup();
+ connected=0;
+#endif
+ }
+
+ otl_column_desc* describe_select(int& desc_len)
+ OTL_NO_THROW
+ {
+ desc_len=0;
+ if((*ss)){
+ (*adb)->reset_throw_count();
+ desc_len=(*ss)->get_sl_len();
+ return (*ss)->get_sl_desc();
+ }
+ return 0;
+ }
+
+ int good(void) OTL_NO_THROW
+ {
+ if(!connected)return 0;
+ if((*io)||(*ss)){
+ (*adb)->reset_throw_count();
+ return 1;
+ }else
+ return 0;
+ }
+
+ otl_stream& operator<<(otl_lob_stream& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ if((*io)){
+ (*io)->operator<<(s);
+ inc_next_iov();
+ }
+ return *this;
+ }
+
+ otl_stream& operator>>(otl_stream& (*pf) (otl_stream&))
+ {
+ (*pf)(*this);
+ return *this;
+ }
+
+ otl_stream& operator<<(otl_stream& (*pf) (otl_stream&))
+ {
+ (*pf)(*this);
+ return *this;
+ }
+
+ otl_stream& operator>>(otl_lob_stream& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(otl_time& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ }
+ return *this;
+ }
+
+ otl_stream& operator<<(const otl_time& n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ (*io)->operator<<(n);
+ break;
+ case otl_odbc_select_stream:
+ (*ss)->operator<<(n);
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ return *this;
+ }
+
+ otl_stream& operator>>(otl_datetime& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+#if defined(OTL_ODBC_STRING_TO_TIMESTAMP)
+ if(describe_next_out_var()->ftype==otl_var_char){
+#if defined(OTL_UNICODE)
+#if defined(OTL_UNICODE_CHAR_TYPE)
+ OTL_UNICODE_CHAR_TYPE tmp_str[100];
+#else
+ OTL_CHAR tmp_str[100];
+#endif
+#else
+ char tmp_str[100];
+#endif
+ (*this)>>tmp_str;
+#if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_DATETIME_NULL_TO_VAL;
+ else
+ OTL_ODBC_STRING_TO_TIMESTAMP(tmp_str,s);
+#else
+ OTL_ODBC_STRING_TO_TIMESTAMP(tmp_str,s);
+#endif
+#if defined(OTL_ODBC_TIME_ZONE)
+ OTL_TRACE_WRITE
+ (OTL_TRACE_FORMAT_TZ_DATETIME(s),
+ "operator >>",
+ "otl_datetime&");
+#else
+ OTL_TRACE_WRITE
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator >>",
+ "otl_datetime&");
+#endif
+ return *this;
+ }else{
+ otl_time tmp;
+ (*this)>>tmp;
+#if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_DATETIME_NULL_TO_VAL;
+ else{
+ s.year=tmp.year;
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour;
+ s.minute=tmp.minute;
+ s.second=tmp.second;
+ s.fraction=otl_from_fraction(tmp.fraction,s.frac_precision);
+ }
+#else
+ s.year=tmp.year;
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour;
+ s.minute=tmp.minute;
+ s.second=tmp.second;
+ s.fraction=otl_from_fraction(tmp.fraction,s.frac_precision);
+#endif
+ }
+#else
+ otl_time tmp;
+ (*this)>>tmp;
+#if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_DATETIME_NULL_TO_VAL;
+ else{
+ s.year=tmp.year;
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour;
+ s.minute=tmp.minute;
+ s.second=tmp.second;
+ s.fraction=otl_from_fraction(tmp.fraction,s.frac_precision);
+ }
+#else
+ s.year=tmp.year;
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour;
+ s.minute=tmp.minute;
+ s.second=tmp.second;
+ s.fraction=otl_from_fraction(tmp.fraction,s.frac_precision);
+#endif
+
+#endif
+ OTL_TRACE_WRITE
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator >>",
+ "otl_datetime&");
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const otl_datetime& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ otl_time tmp;
+ last_oper_was_read_op=false;
+ reset_end_marker();
+#if defined(OTL_ODBC_TIMESTAMP_TO_STRING)
+ if(describe_next_in_var()->ftype==otl_var_char){
+#if defined(OTL_UNICODE)
+#if defined(OTL_UNICODE_CHAR_TYPE)
+ OTL_UNICODE_CHAR_TYPE tmp_str[100];
+#else
+ OTL_CHAR tmp_str[100];
+#endif
+#else
+ char tmp_str[100];
+#endif
+ OTL_ODBC_TIMESTAMP_TO_STRING(s,tmp_str);
+#if defined(OTL_ODBC_TIME_ZONE)
+ OTL_TRACE_READ
+ (OTL_TRACE_FORMAT_TZ_DATETIME(s),
+ "operator <<",
+ "otl_datetime&");
+#else
+ OTL_TRACE_READ
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator <<",
+ "otl_datetime&");
+#endif
+ (*this)<<tmp_str;
+ return *this;
+ }else{
+ tmp.year=OTL_SCAST(SQLSMALLINT,s.year);
+ tmp.month=OTL_SCAST(SQLSMALLINT,s.month);
+ tmp.day=OTL_SCAST(SQLSMALLINT,s.day);
+ tmp.hour=OTL_SCAST(SQLSMALLINT,s.hour);
+ tmp.minute=OTL_SCAST(SQLSMALLINT,s.minute);
+ tmp.second=OTL_SCAST(SQLSMALLINT,s.second);
+ tmp.fraction=otl_to_fraction(s.fraction,s.frac_precision);
+ (*this)<<tmp;
+ OTL_TRACE_READ(OTL_TRACE_FORMAT_DATETIME(s),
+ "operator >>",
+ "otl_datetime&");
+ inc_next_iov();
+ return *this;
+ }
+#else
+ tmp.year=OTL_SCAST(SQLSMALLINT,s.year);
+ tmp.month=OTL_SCAST(SQLSMALLINT,s.month);
+ tmp.day=OTL_SCAST(SQLSMALLINT,s.day);
+ tmp.hour=OTL_SCAST(SQLSMALLINT,s.hour);
+ tmp.minute=OTL_SCAST(SQLSMALLINT,s.minute);
+ tmp.second=OTL_SCAST(SQLSMALLINT,s.second);
+ tmp.fraction=otl_to_fraction(s.fraction,s.frac_precision);
+ (*this)<<tmp;
+ OTL_TRACE_READ(OTL_TRACE_FORMAT_DATETIME(s),
+ "operator <<",
+ "otl_datetime&");
+ inc_next_iov();
+ return *this;
+#endif
+ }
+
+#if !defined(OTL_UNICODE)
+ otl_stream& operator>>(char& c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(c);
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(c);
+ break;
+ }
+#if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL)
+ if((*this).is_null())
+ c=OTL_DEFAULT_CHAR_NULL_TO_VAL;
+#endif
+ OTL_TRACE_WRITE("'"<<c<<"'","operator >>","char&")
+ inc_next_ov();
+ return *this;
+ }
+#endif
+
+#if !defined(OTL_UNICODE)
+ otl_stream& operator>>(unsigned char& c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(c);
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(c);
+ break;
+ }
+#if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL)
+ if((*this).is_null())
+ c=OTL_DEFAULT_CHAR_NULL_TO_VAL;
+#endif
+ OTL_TRACE_WRITE("'"<<c<<"'","operator >>","unsigned char&")
+ inc_next_ov();
+ return *this;
+ }
+#endif
+
+#if !defined(OTL_UNICODE)
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ otl_stream& operator>>(OTL_STRING_CONTAINER& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ }
+
+#if defined(OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL)
+ if((*this).is_null()){
+ OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL(s);
+ }
+#elif defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_STRING_NULL_TO_VAL;
+#endif
+
+ OTL_TRACE_WRITE(s,"operator >>","OTL_STRING_CONTAINER&")
+ inc_next_ov();
+ return *this;
+ }
+#endif
+#endif
+
+#if !defined(OTL_UNICODE)
+ otl_stream& operator>>(char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ }
+#if defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL));
+#endif
+ OTL_TRACE_WRITE(s,"operator >>","char*")
+ inc_next_ov();
+ return *this;
+ }
+#endif
+
+#if defined(OTL_UNICODE_STRING_TYPE)
+ otl_stream& operator>>(OTL_UNICODE_STRING_TYPE& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ }
+
+#if defined(OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL)
+ if((*this).is_null()){
+ OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL(s);
+ }
+#elif defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,OTL_DEFAULT_STRING_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(s.c_str(),
+ "operator >>",
+ "OTL_UNICODE_STRING_TYPE&");
+ inc_next_ov();
+ return *this;
+ }
+#endif
+
+ otl_stream& operator>>(unsigned char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ }
+#if defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ otl_strcpy
+ (OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(unsigned char*,
+ OTL_CCAST(char*,OTL_DEFAULT_STRING_NULL_TO_VAL)));
+#endif
+#if defined(OTL_UNICODE)
+ OTL_TRACE_WRITE(OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,s),
+ "operator >>",
+ OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*")
+#else
+ OTL_TRACE_WRITE(s,"operator >>","unsigned char*")
+#endif
+ inc_next_ov();
+ return *this;
+ }
+
+#if defined(OTL_UNICODE)
+
+ otl_stream& operator>>(OTL_UNICODE_CHAR_TYPE& c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ OTL_UNICODE_CHAR_TYPE s[1024];
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(OTL_RCAST(unsigned char*,s));
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(OTL_RCAST(unsigned char*,s));
+ break;
+ }
+ c=s[0];
+#if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL)
+ if((*this).is_null())
+ c=OTL_DEFAULT_CHAR_NULL_TO_VAL;
+#endif
+ OTL_TRACE_WRITE(c,"operator >>",
+ OTL_UNICODE_CHAR_TYPE_TRACE_NAME "")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(OTL_UNICODE_CHAR_TYPE* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(OTL_RCAST(unsigned char*,s));
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(OTL_RCAST(unsigned char*,s));
+ break;
+ }
+#if defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL));
+#endif
+ OTL_TRACE_WRITE(OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,s),
+ "operator >>",
+ OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*")
+ inc_next_ov();
+ return *this;
+ }
+
+#endif
+
+ otl_stream& operator>>(int& n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(n);
+#else
+ (*io)->operator>><int,otl_var_int>(n);
+#endif
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(n);
+#else
+ (*ss)->operator>><int,otl_var_int>(n);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ n=OTL_SCAST(int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(n,"operator >>","int&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(unsigned& u)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(u);
+#else
+ (*io)->operator>><unsigned,otl_var_unsigned_int>(u);
+#endif
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(u);
+#else
+ (*ss)->operator>><unsigned,otl_var_unsigned_int>(u);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ u=OTL_SCAST(unsigned int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(u,"operator >>","unsigned&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(short& sh)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(sh);
+#else
+ (*io)->operator>><short,otl_var_short>(sh);
+#endif
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(sh);
+#else
+ (*ss)->operator>><short,otl_var_short>(sh);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ sh=OTL_SCAST(short int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(sh,"operator >>","short int&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(long int& l)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(l);
+#else
+ (*io)->operator>><long,otl_var_long_int>(l);
+#endif
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(l);
+#else
+ (*ss)->operator>><long,otl_var_long_int>(l);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ l=OTL_SCAST(long int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(l,"operator >>","long int&")
+ inc_next_ov();
+ return *this;
+ }
+
+#if defined(OTL_BIGINT)
+ otl_stream& operator>>(OTL_BIGINT& l)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_STR_TO_BIGINT) && defined(OTL_BIGINT_TO_STR)
+ {
+ otl_var_desc* var_desc=describe_next_out_var();
+ if(var_desc){
+ if(var_desc->ftype==otl_var_char){
+ char temp_val[otl_bigint_str_size];
+#if defined(OTL_UNICODE)
+ OTL_CHAR unitemp_val[otl_bigint_str_size];
+ (*ss)->operator>>(OTL_RCAST(unsigned char*,unitemp_val));
+ OTL_CHAR* uc=unitemp_val;
+ char* c=temp_val;
+ while(*uc){
+ *c=OTL_SCAST(char,*uc);
+ ++c; ++uc;
+ }
+ *c=0;
+#else
+ (*ss)->operator>>(temp_val);
+#endif
+ OTL_STR_TO_BIGINT(temp_val,l);
+ }else
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(l);
+#else
+ (*io)->operator>><OTL_BIGINT,otl_var_bigint>(l);
+#endif
+ }
+ }
+#else
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(l);
+#else
+ (*io)->operator>><OTL_BIGINT,otl_var_bigint>(l);
+#endif
+#endif
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_STR_TO_BIGINT) && defined(OTL_BIGINT_TO_STR)
+ {
+ otl_var_desc* var_desc=describe_next_out_var();
+ if(var_desc){
+ if(var_desc->ftype==otl_var_char){
+ char temp_val[otl_bigint_str_size];
+ (*ss)->operator>>(temp_val);
+ OTL_STR_TO_BIGINT(temp_val,l);
+ }else
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(l);
+#else
+ (*ss)->operator>><OTL_BIGINT,otl_var_bigint>(l);
+#endif
+ }
+ }
+#else
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(l);
+#else
+ (*ss)->operator>><OTL_BIGINT,otl_var_bigint>(l);
+#endif
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ l=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+
+#if defined(_MSC_VER) && defined(OTL_TRACE_LEVEL)
+ // VC ++
+ {
+ char temp_str[otl_bigint_str_size];
+ _i64toa(l,temp_str,10);
+ OTL_TRACE_WRITE(temp_str,"operator >>","BIGINT&")
+ }
+#elif !defined(_MSC_VER) && defined(OTL_TRACE_LEVEL)
+ OTL_TRACE_WRITE(l,"operator >>","BIGINT&")
+#endif
+ inc_next_ov();
+ return *this;
+ }
+#endif
+
+ otl_stream& operator>>(float& f)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(f);
+#else
+ (*io)->operator>><float,otl_var_float>(f);
+#endif
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(f);
+#else
+ (*ss)->operator>><float,otl_var_float>(f);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ f=OTL_SCAST(float,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(f,"operator >>","float&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(double& d)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(d);
+#else
+ (*io)->operator>><double,otl_var_double>(d);
+#endif
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(d);
+#else
+ (*ss)->operator>><double,otl_var_double>(d);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ d=OTL_SCAST(double,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(d,"operator >>","double&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(otl_long_string& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_odbc_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ }
+ OTL_TRACE_WRITE(" string length: "<<s.len(),"operator >>","otl_long_string&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const char c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ (*io)->operator<<(c);
+ break;
+ case otl_odbc_select_stream:
+ (*ss)->operator<<(c);
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ OTL_TRACE_READ("'"<<c<<"'","operator <<","char");
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const unsigned char c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("'"<<c<<"'","operator <<","unsigned char");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ (*io)->operator<<(c);
+ break;
+ case otl_odbc_select_stream:
+ (*ss)->operator<<(c);
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+#if defined(OTL_UNICODE)
+
+ otl_stream& operator<<(const OTL_UNICODE_CHAR_TYPE* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ
+ ("\""<<OTL_RCAST(const OTL_UNICODE_CHAR_TYPE*,s)<<"\"",
+ "operator <<",
+ OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ (*io)->operator<<(OTL_RCAST(const unsigned char*,s));
+ break;
+ case otl_odbc_select_stream:
+ (*ss)->operator<<(OTL_RCAST(const unsigned char*,s));
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const OTL_UNICODE_CHAR_TYPE c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ OTL_UNICODE_CHAR_TYPE s[2];
+ s[0]=c;
+ s[1]=0;
+ (*this)<<s;
+ return *this;
+ }
+
+#endif
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ otl_stream& operator<<(const OTL_STRING_CONTAINER& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("\""<<s<<"\"","operator <<","OTL_STRING_CONTAINER&");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ (*io)->operator<<(s);
+ break;
+ case otl_odbc_select_stream:
+ (*ss)->operator<<(s);
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+#endif
+
+#if defined(OTL_UNICODE_STRING_TYPE)
+ otl_stream& operator<<(const OTL_UNICODE_STRING_TYPE& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("\""<<s.c_str()<<"\"","operator <<","OTL_UNICODE_STRING_TYPE&");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ (*io)->operator<<(s);
+ break;
+ case otl_odbc_select_stream:
+ (*ss)->operator<<(s);
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+#endif
+
+#if !defined(OTL_UNICODE)
+ otl_stream& operator<<(const char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("\""<<s<<"\"","operator <<","char*");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ (*io)->operator<<(s);
+ break;
+ case otl_odbc_select_stream:
+ (*ss)->operator<<(s);
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+#endif
+
+ otl_stream& operator<<(const unsigned char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+#if defined(OTL_UNICODE)
+ OTL_TRACE_READ
+ ("\""<<OTL_RCAST(const OTL_UNICODE_CHAR_TYPE*,s)<<"\"",
+ "operator <<",
+ OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*");
+#else
+ OTL_TRACE_READ("\""<<s<<"\"","operator <<","unsigned char*");
+#endif
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ (*io)->operator<<(s);
+ break;
+ case otl_odbc_select_stream:
+ (*ss)->operator<<(s);
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const int n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(n,"operator <<","int");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(n);
+#else
+ (*io)->operator<<<int,otl_var_int>(n);
+#endif
+ break;
+ case otl_odbc_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(n);
+#else
+ (*ss)->operator<<<int,otl_var_int>(n);
+#endif
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+#if defined(OTL_BIGINT)
+ otl_stream& operator<<(const OTL_BIGINT n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+#if defined(_MSC_VER) && defined(OTL_TRACE_LEVEL)
+ // VC ++
+ {
+ char temp_str[otl_bigint_str_size];
+ _i64toa(n,temp_str,10);
+ OTL_TRACE_READ(temp_str,"operator <<","BIGINT")
+ }
+#elif !defined(_MSC_VER) && defined(OTL_TRACE_LEVEL)
+ OTL_TRACE_READ(n,"operator <<","BIGINT");
+#endif
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+#if defined(OTL_STR_TO_BIGINT) && defined(OTL_BIGINT_TO_STR)
+ {
+ otl_var_desc* var_desc=describe_next_in_var();
+ if(var_desc){
+ if(var_desc->ftype==otl_var_char){
+ char temp_val[otl_bigint_str_size];
+ OTL_BIGINT_TO_STR(n,temp_val);
+#if defined(OTL_UNICODE)
+ OTL_CHAR unitemp_val[otl_bigint_str_size];
+ OTL_CHAR* uc=unitemp_val;
+ char* c=temp_val;
+ while(*c){
+ *uc=OTL_SCAST(OTL_CHAR,*c);
+ ++c; ++uc;
+ }
+ *uc=0;
+ (*io)->operator<<(OTL_RCAST(const unsigned char*,unitemp_val));
+#else
+ (*io)->operator<<(temp_val);
+#endif
+ }else
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(n);
+#else
+ (*io)->operator<<<OTL_BIGINT,otl_var_bigint>(n);
+#endif
+ }
+ }
+#else
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(n);
+#else
+ (*io)->operator<<<OTL_BIGINT,otl_var_bigint>(n);
+#endif
+#endif
+ break;
+ case otl_odbc_select_stream:
+#if defined(OTL_STR_TO_BIGINT) && defined(OTL_BIGINT_TO_STR)
+ {
+ otl_var_desc* var_desc=describe_next_in_var();
+ if(var_desc){
+ if(var_desc->ftype==otl_var_char){
+ char temp_val[otl_bigint_str_size];
+ OTL_BIGINT_TO_STR(n,temp_val);
+ (*ss)->operator<<(temp_val);
+ }else
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(n);
+#else
+ (*ss)->operator<<<OTL_BIGINT,otl_var_bigint>(n);
+#endif
+ }
+ }
+#else
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(n);
+#else
+ (*ss)->operator<<<OTL_BIGINT,otl_var_bigint>(n);
+#endif
+#endif
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+#endif
+
+ otl_stream& operator<<(const unsigned u)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(u,"operator <<","unsigned int");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(u);
+#else
+ (*io)->operator<<<unsigned,otl_var_unsigned_int>(u);
+#endif
+ break;
+ case otl_odbc_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(u);
+#else
+ (*ss)->operator<<<unsigned,otl_var_unsigned_int>(u);
+#endif
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const short sh)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(sh,"operator <<","short int");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(sh);
+#else
+ (*io)->operator<<<short,otl_var_short>(sh);
+#endif
+ break;
+ case otl_odbc_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(sh);
+#else
+ (*ss)->operator<<<short,otl_var_short>(sh);
+#endif
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const long int l)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(l,"operator <<","long int");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(l);
+#else
+ (*io)->operator<<<long,otl_var_long_int>(l);
+#endif
+ break;
+ case otl_odbc_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(l);
+#else
+ (*ss)->operator<<<long,otl_var_long_int>(l);
+#endif
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const float f)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(f,"operator <<","float");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(f);
+#else
+ (*io)->operator<<<float,otl_var_float>(f);
+#endif
+ break;
+ case otl_odbc_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(f);
+#else
+ (*ss)->operator<<<float,otl_var_float>(f);
+#endif
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const double d)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(d,"operator <<","double");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(d);
+#else
+ (*io)->operator<<<double,otl_var_double>(d);
+#endif
+ break;
+ case otl_odbc_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(d);
+#else
+ (*ss)->operator<<<double,otl_var_double>(d);
+#endif
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const otl_null& n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("NULL","operator <<","otl_null&");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ (*io)->operator<<(n);
+ break;
+ case otl_odbc_select_stream:
+ (*ss)->operator<<(n);
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const otl_long_string& d)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(" len= "<<d.len(),"operator <<","otl_long_string&");
+ switch(shell->stream_type){
+ case otl_odbc_no_stream:
+ break;
+ case otl_odbc_io_stream:
+ (*io)->operator<<(d);
+ break;
+ case otl_odbc_select_stream:
+ (*ss)->operator<<(d);
+ if(!(*ov)&&(*ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+private:
+
+ otl_stream& operator=(const otl_stream&)
+ {
+ return *this;
+ }
+
+ otl_stream(const otl_stream&):
+ shell(0),
+ shell_pt(),
+ connected(0),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ override(0),
+ end_marker(0),
+ oper_int_called(0),
+ last_eof_rc(0),
+ last_oper_was_read_op(false),
+ buf_size_(0)
+ {
+ }
+
+#if !defined(OTL_STREAM_NO_PRIVATE_BOOL_OPERATORS)
+ otl_stream& operator>>(bool&)
+ OTL_NO_THROW
+ {
+ return *this;
+ }
+
+ otl_stream& operator<<(const bool)
+ OTL_NO_THROW
+ {
+ return *this;
+ }
+
+#endif
+
+#if !defined(OTL_STREAM_NO_PRIVATE_UNSIGNED_LONG_OPERATORS)
+ otl_stream& operator>>(unsigned long int&)
+ OTL_NO_THROW
+ {
+ return *this;
+ }
+
+ otl_stream& operator<<(const unsigned long int)
+ OTL_NO_THROW
+ {
+ return *this;
+ }
+#endif
+
+};
+
+inline otl_connect& operator>>(otl_connect& connect, otl_stream& s)
+{
+ const char* cmd=connect.getCmd();
+ const char* invalid_cmd="*** INVALID COMMAND ***";
+ if(!cmd)
+ cmd=invalid_cmd;
+ s.open(s.getBufSize(),cmd,connect);
+ return connect;
+}
+
+#if (defined(OTL_STL)||defined(OTL_VALUE_TEMPLATE_ON)) && defined(OTL_VALUE_TEMPLATE)
+template <OTL_TYPE_NAME TData>
+otl_stream& operator<<(otl_stream& s, const otl_value<TData>& var)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ if(var.ind)
+ s<<otl_null();
+ else
+ s<<var.v;
+ return s;
+}
+
+template <OTL_TYPE_NAME TData>
+otl_stream& operator>>(otl_stream& s, otl_value<TData>& var)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ s>>var.v;
+ if(s.is_null())
+ var.ind=true;
+ else
+ var.ind=false;
+ return s;
+}
+
+#endif
+
+
+class otl_nocommit_stream: public otl_stream{
+public:
+
+ otl_nocommit_stream() OTL_NO_THROW
+ : otl_stream()
+ {
+ set_commit(0);
+ }
+
+ otl_nocommit_stream
+ (const otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ otl_connect& db,
+ const int implicit_select=otl_explicit_select)
+ OTL_THROWS_OTL_EXCEPTION
+ : otl_stream(arr_size,sqlstm,db,implicit_select)
+ {
+ set_commit(0);
+ }
+
+ void open
+ (otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ otl_connect& db,
+ const int implicit_select=otl_explicit_select)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ otl_stream::open(arr_size,sqlstm,db,implicit_select);
+ set_commit(0);
+ }
+
+};
+
+inline otl_stream& endr(otl_stream& s)
+{
+ s.check_end_of_row();
+ return s;
+}
+
+OTL_ODBC_NAMESPACE_END
+#endif
+
+// ==================== OTL-Adapter for Oracle 7 =====================
+#if defined(OTL_ORA7)
+
+#if defined(OTL_UNICODE)
+#error OTL_ORA7 and OTL_UNICODE are incompatible
+#endif
+
+#if defined(OTL_ORA_TEXT_ON)
+#define text OTL_ORA_TEXT
+#endif
+
+extern "C"{
+#include <ociapr.h>
+}
+
+OTL_ORA7_NAMESPACE_BEGIN
+
+ const int inVarChar2=1;
+ const int inNumber=2;
+ const int inLong=8;
+ const int inRowId=11;
+ const int inDate=12;
+ const int inRaw=23;
+ const int inLongRaw=24;
+ const int inChar=96;
+ const int inMslabel=106;
+
+ const int extVarChar2=inVarChar2;
+ const int extNumber=inNumber;
+ const int extInt=3;
+ const int extFloat=4;
+ const int extCChar=5;
+ const int extVarNum=6;
+ const int extLong=inLong;
+ const int extVarChar=9;
+ const int extRowId=inRowId;
+ const int extDate=inDate;
+ const int extVarRaw=15;
+ const int extRaw=extVarRaw;
+ const int extLongRaw=inLongRaw;
+ const int extUInt=68;
+ const int extLongVarChar=94;
+ const int extLongVarRaw=95;
+ const int extChar=inChar;
+ const int extCharZ=97;
+ const int extMslabel=inMslabel;
+
+typedef otl_oracle_date otl_time0;
+
+class otl_exc{
+public:
+ unsigned char msg[1000];
+ int code;
+ char sqlstate[32];
+
+#if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET)
+ int error_offset;
+#endif
+
+#if defined(OTL_EXTENDED_EXCEPTION)
+ char** msg_arr;
+ char** sqlstate_arr;
+ int* code_arr;
+ int arr_len;
+#endif
+
+
+ enum{disabled=0,enabled=1};
+
+ otl_exc():
+ msg(),
+ code(0),
+ sqlstate()
+#if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET)
+ ,error_offset(0)
+#endif
+#if defined(OTL_EXTENDED_EXCEPTION)
+ ,msg_arr(0),
+ sqlstate_arr(0),
+ code_arr(0),
+ arr_len(0)
+#endif
+ {
+ sqlstate[0]=0;
+ msg[0]=0;
+ code=0;
+#if defined(OTL_EXTENDED_EXCEPTION)
+ msg_arr=0;
+ sqlstate_arr=0;
+ code_arr=0;
+ arr_len=0;
+#endif
+ }
+
+ virtual ~otl_exc(){}
+
+ void init(const char* amsg, const int acode)
+ {
+ OTL_STRCPY_S(OTL_RCAST(char*,msg),sizeof(msg),amsg);
+ code=acode;
+#if defined(OTL_EXTENDED_EXCEPTION)
+ msg_arr=0;
+ sqlstate_arr=0;
+ code_arr=0;
+ arr_len=0;
+#endif
+ }
+
+};
+
+class otl_cur;
+
+class otl_conn{
+private:
+
+ friend class otl_cur;
+ Lda_Def* lda;
+ unsigned char hda[512];
+ int extern_lda;
+
+public:
+
+ int get_connection_type(void)
+ {
+ return 0;
+ }
+
+ void cleanup(void){}
+
+ static int initialize(const int threaded_mode=0)
+ {
+ if(threaded_mode)
+ return !opinit(1);
+ else
+ return 1;
+ }
+
+ otl_conn():
+ lda(new Lda_Def),
+ hda(),
+ extern_lda(0)
+ {
+ memset(lda,0,sizeof(*lda));
+ memset(hda,0,sizeof(hda));
+ }
+
+ virtual ~otl_conn()
+ {
+ delete lda;
+ }
+
+ void set_timeout(const int /*atimeout*/=0){}
+ void set_cursor_type(const int /*acursor_type*/=0){}
+
+ int ext_logon(Lda_Def* ext_lda,const int auto_commit)
+ {int rc;
+ if(!extern_lda)delete lda;
+ lda=ext_lda;
+ extern_lda=1;
+ if(auto_commit){
+ rc=ocon(lda);
+ if(rc)
+ return 0;
+ else
+ return 1;
+ }
+ return 1;
+ }
+
+ int rlogon(const char* connect_str,const int auto_commit)
+ {
+ if(!extern_lda)delete lda;
+ OTL_TRACE_RLOGON_ORA7
+ (0x1,
+ "otl_connect",
+ "rlogon",
+ connect_str,
+ auto_commit)
+ lda=new Lda_Def;
+ extern_lda=0;
+ memset(lda,0,sizeof(*lda));
+ memset(hda,0,sizeof(hda));
+ int rc=olog(lda,
+ hda,
+ OTL_RCAST(unsigned char*,OTL_CCAST(char*,connect_str)),
+ -1,
+ 0,
+ -1,
+ 0,
+ -1,
+ 0
+ );
+ if(rc)return 0;
+ if(!auto_commit)return 1;
+ rc=ocon(lda);
+ if(rc)
+ return 0;
+ else
+ return 1;
+ }
+
+ int logoff(void)
+ {
+ if(extern_lda){
+ lda=0;
+ extern_lda=0;
+ return 1;
+ }else{
+ if(!lda)return 1;
+ if(lda->rc==3113||lda->rc==1041||lda->rc==1033||lda->rc==1034){
+ delete lda;
+ lda=0;
+ return 1;
+ }
+ int rc=ologof(lda);
+ delete lda;
+ lda=0;
+ return !rc;
+ }
+ }
+
+ void error(otl_exc& exception_struct)
+ {
+ if(!lda){
+ exception_struct.code=3113;
+ OTL_STRCPY_S(OTL_RCAST(char*,exception_struct.msg),
+ sizeof(exception_struct.msg),
+ "ORA-03113: end-of-file on communication channel"
+ );
+ return;
+ }
+ size_t len;
+ exception_struct.code=lda->rc;
+ oerhms
+ (lda,
+ lda->rc,
+ exception_struct.msg,
+ sizeof(exception_struct.msg)
+ );
+ len = strlen(OTL_RCAST(const char*,exception_struct.msg));
+ exception_struct.msg[len]=0;
+ }
+
+ int commit(void)
+ {
+ return !ocom(lda);
+ }
+
+ int auto_commit_on(void)
+ {
+ return !ocon(lda);
+ }
+
+ int auto_commit_off(void)
+ {
+ return !ocof(lda);
+ }
+
+ int rollback(void)
+ {
+ return !orol(lda);
+ }
+
+private:
+
+ otl_conn(const otl_conn&):
+ lda(0),
+ hda(),
+ extern_lda(0)
+ {
+ }
+
+ otl_conn& operator=(const otl_conn&)
+ {
+ return *this;
+ }
+
+};
+
+class otl_cur;
+
+class otl_var{
+private:
+
+ friend class otl_cur;
+ ub1* p_v;
+ sb2* p_ind;
+ ub2* p_rlen;
+ ub2* p_rcode;
+ int ftype;
+ int act_elem_size;
+ int array_size;
+ ub4 max_tab_len;
+ ub4 cur_tab_len;
+ int pl_tab_flag;
+ int vparam_type;
+ int lob_len;
+ int lob_pos;
+ int lob_ftype;
+ int otl_adapter;
+ bool lob_stream_mode;
+ bool charz_flag;
+ sb2 null_ind;
+
+public:
+
+ int get_otl_adapter() const {return otl_adapter;}
+ void set_lob_stream_mode(const bool alob_stream_mode)
+ {
+ lob_stream_mode=alob_stream_mode;
+ }
+
+ void set_vparam_type(const int avparam_type)
+ {
+ vparam_type=avparam_type;
+ }
+
+ void set_charz_flag(const bool acharz_flag)
+ {
+ charz_flag=acharz_flag;
+ }
+
+ otl_var():
+ p_v(0),
+ p_ind(0),
+ p_rlen(0),
+ p_rcode(0),
+ ftype(0),
+ act_elem_size(0),
+ array_size(0),
+ max_tab_len(0),
+ cur_tab_len(0),
+ pl_tab_flag(0),
+ vparam_type(-1),
+ lob_len(0),
+ lob_pos(0),
+ lob_ftype(0),
+ otl_adapter(otl_ora7_adapter),
+ lob_stream_mode(false),
+ charz_flag(false),
+ null_ind(0)
+ {
+ }
+
+ virtual ~otl_var()
+ {
+ delete[] p_v;
+ delete[] p_ind;
+ delete[] p_rlen;
+ delete[] p_rcode;
+ }
+
+ int write_dt(void* trg, const void* src, const int sz)
+ {
+ memcpy(trg,src,sz);
+ return 1;
+ }
+
+ int read_dt(void* trg, const void* src, const int sz)
+ {
+ memcpy(trg,src,sz);
+ return 1;
+ }
+
+ int actual_elem_size(void)
+ {
+ return act_elem_size;
+ }
+
+ void init
+ (const bool,
+ const int aftype,
+ int& aelem_size,
+ const otl_stream_buffer_size_type aarray_size,
+ const void* /*connect_struct*/=0,
+ const int apl_tab_flag=0)
+ {
+ int i,elem_size;
+ ftype=aftype;
+ pl_tab_flag=apl_tab_flag;
+ act_elem_size=aelem_size;
+ if(aftype==otl_var_varchar_long||aftype==otl_var_raw_long){
+ elem_size=aelem_size+sizeof(sb4);
+ array_size=1;
+ }else if(aftype==otl_var_raw){
+ elem_size=aelem_size+sizeof(short int);
+ array_size=aarray_size;
+ }else{
+ elem_size=aelem_size;
+ array_size=aarray_size;
+ }
+
+ p_v=new ub1[elem_size*OTL_SCAST(unsigned,array_size)];
+ p_ind=new sb2[array_size];
+ p_rlen=new ub2[array_size];
+ p_rcode=new ub2[array_size];
+ memset(p_v,0,elem_size*OTL_SCAST(unsigned,array_size));
+
+ if(aftype==otl_var_varchar_long||aftype==otl_var_raw_long){
+ if(aelem_size>32760)
+ p_ind[0]=0;
+ else
+ p_ind[0]=OTL_SCAST(short,aelem_size);
+ p_rcode[0]=0;
+ }else{
+ for(i=0;i<array_size;++i){
+ p_ind[i]=OTL_SCAST(short,aelem_size);
+ p_rlen[i]=OTL_SCAST(short,elem_size);
+ p_rcode[i]=0;
+ }
+ }
+ max_tab_len=OTL_SCAST(ub4,array_size);
+ cur_tab_len=OTL_SCAST(ub4,array_size);
+ switch(ftype){
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ null_ind=0;
+ break;
+ case otl_var_raw:
+ null_ind=OTL_SCAST(short,aelem_size);
+ break;
+ default:
+ null_ind=OTL_SCAST(short,aelem_size);
+ break;
+ }
+ }
+
+ void set_pl_tab_len(const int apl_tab_len)
+ {
+ max_tab_len=OTL_SCAST(ub4,array_size);
+ cur_tab_len=OTL_SCAST(ub4,apl_tab_len);
+ }
+
+ int get_pl_tab_len(void)
+ {
+ return OTL_SCAST(int,cur_tab_len);
+ }
+
+ int get_max_pl_tab_len(void)
+ {
+ return OTL_SCAST(int,max_tab_len);
+ }
+
+ int put_blob(void)
+ {
+ return 1;
+ }
+
+ int get_blob
+ (const int /* ndx */,
+ unsigned char* /* abuf */,
+ const int /* buf_size */,
+ int& /* len */)
+ {
+ return 1;
+ }
+
+ int save_blob
+ (const unsigned char* /* abuf */,
+ const int /* len */,
+ const int /* extern_buffer_flag */)
+ {
+ return 1;
+ }
+
+ void set_null(int ndx)
+ {
+ p_ind[ndx]=-1;
+ }
+
+ void set_not_null(int ndx, int /*pelem_size*/)
+ {
+ p_ind[ndx]=null_ind;
+ }
+
+ void set_len(int len, int ndx)
+ {
+ switch(ftype){
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ *OTL_RCAST(sb4*,p_v)=len;
+ break;
+ default:
+ p_rlen[ndx]=OTL_SCAST(short,len);
+ }
+ }
+
+
+ int get_len(int ndx)
+ {
+ if(ftype==otl_var_varchar_long||ftype==otl_var_raw_long)
+ return *OTL_RCAST(sb4*,p_v);
+ else
+ return p_rlen[ndx];
+ }
+
+ int is_null(int ndx)
+ {
+ return p_ind[ndx]==-1;
+ }
+
+ void* val(int ndx,int pelem_size)
+ {
+ switch(ftype){
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ return OTL_RCAST(void*,(p_v+sizeof(sb4)));
+ case otl_var_raw:
+ return OTL_RCAST(void*,&p_v[(OTL_SCAST(unsigned,ndx))*
+ (pelem_size+sizeof(short int))]);
+ default:
+ return OTL_RCAST(void*,&p_v[(OTL_SCAST(unsigned,ndx))*pelem_size]);
+ }
+ }
+
+ static int int2ext(int int_type)
+ {
+ switch(int_type){
+ case inVarChar2: return extCChar;
+ case inNumber: return extFloat;
+ case inLong: return extLongVarChar;
+ case inRowId: return extCChar;
+ case inDate: return extDate;
+ case inRaw: return extRaw;
+ case inLongRaw: return extLongVarRaw;
+ case inChar: return extCChar;
+ default:
+ return otl_unsupported_type;
+ }
+ }
+
+ static int datatype_size(int aftype,int maxsz,int int_type,int max_long_size)
+ {
+ switch(aftype){
+ case extCChar:
+ switch(int_type){
+ case inRowId:
+ return 30;
+ case inDate:
+ return otl_oracle_date_size;
+ case inRaw:
+ return max_long_size;
+ default:
+ return maxsz+1;
+ }
+ case extLongVarChar:
+ return max_long_size;
+ case extLongVarRaw:
+ return max_long_size;
+ case extFloat:
+ return sizeof(double);
+ case extDate:
+ return otl_oracle_date_size;
+ case extRaw:
+ return maxsz;
+ default:
+ return 0;
+ }
+ }
+
+ static void map_ftype
+ (otl_column_desc& desc,
+ const int max_long_size,
+ int& aftype,
+ int& elem_size,
+ otl_select_struct_override& override,
+ const int column_ndx,
+ const int /*connection_type*/)
+ {int ndx=override.find(column_ndx);
+ if(ndx==-1){
+ aftype=int2ext(desc.dbtype);
+ elem_size=datatype_size
+ (aftype,
+ OTL_SCAST(int,desc.dbsize),
+ desc.dbtype,
+ max_long_size);
+ switch(aftype){
+ case extCChar:
+ aftype=otl_var_char;
+ break;
+ case extRaw:
+ aftype=otl_var_raw;
+ break;
+ case extFloat:
+ if(override.get_all_mask() & otl_all_num2str){
+ aftype=otl_var_char;
+ elem_size=otl_num_str_size;
+ }else
+ aftype=otl_var_double;
+ break;
+ case extLongVarChar:
+ aftype=otl_var_varchar_long;
+ break;
+ case extLongVarRaw:
+ aftype=otl_var_raw_long;
+ break;
+ case extDate:
+ if(override.get_all_mask() & otl_all_date2str){
+ aftype=otl_var_char;
+ elem_size=otl_date_str_size;
+ }else
+ aftype=otl_var_timestamp;
+ break;
+ }
+ }else{
+ aftype=override.get_col_type(ndx);
+ switch(aftype){
+ case otl_var_char:
+ elem_size=override.get_col_size(ndx);
+ break;
+ case otl_var_raw:
+ elem_size=override.get_col_size(ndx);
+ break;
+ case otl_var_double:
+ elem_size=sizeof(double);
+ break;
+ case otl_var_float:
+ elem_size=sizeof(float);
+ break;
+ case otl_var_int:
+ elem_size=sizeof(int);
+ break;
+ case otl_var_unsigned_int:
+ elem_size=sizeof(unsigned);
+ break;
+ case otl_var_short:
+ elem_size=sizeof(short);
+ break;
+ case otl_var_long_int:
+ elem_size=sizeof(long);
+ break;
+ default:
+ elem_size=override.get_col_size(ndx);
+ break;
+ }
+ }
+ desc.otl_var_dbtype=aftype;
+ }
+
+private:
+
+ otl_var(const otl_var&):
+ p_v(0),
+ p_ind(0),
+ p_rlen(0),
+ p_rcode(0),
+ ftype(0),
+ act_elem_size(0),
+ array_size(0),
+ max_tab_len(0),
+ cur_tab_len(0),
+ pl_tab_flag(0),
+ vparam_type(-1),
+ lob_len(0),
+ lob_pos(0),
+ lob_ftype(0),
+ otl_adapter(otl_ora7_adapter),
+ lob_stream_mode(false),
+ charz_flag(false),
+ null_ind(0)
+ {
+ }
+
+ otl_var& operator=(const otl_var&)
+ {
+ return *this;
+ }
+
+};
+
+class otl_sel;
+class otl_ref_cursor;
+class otl_ref_select_stream;
+
+class otl_cur{
+private:
+
+ friend class otl_sel;
+ friend class otl_ref_cursor;
+ friend class otl_ref_select_stream;
+
+ Cda_Def cda;
+
+ ub4* rpc; // reference to "rows processed count"
+ ub2* ft; // reference to "OCI function code"
+ ub2* rc; // reference to "V7 return code"
+ ub2* peo; // reference to "parse error offset"
+ int last_param_data_token;
+ int last_sql_param_data_status;
+ int sql_param_data_count;
+ bool canceled;
+
+public:
+
+ void set_canceled(const bool acanceled)
+ {
+ canceled=acanceled;
+ }
+
+ void reset_last_param_data_token()
+ {
+ last_param_data_token=0;
+ }
+
+ void reset_last_sql_param_data_status()
+ {
+ last_sql_param_data_status=0;
+ }
+
+ void reset_sql_param_data_count()
+ {
+ sql_param_data_count=0;
+ }
+
+ otl_cur& operator=(const otl_cur& cur)
+ {
+ *rpc=*cur.rpc;
+ *ft=*cur.ft;
+ *rc=*cur.rc;
+ *peo=*cur.peo;
+ memcpy(OTL_RCAST(void*,&cda),
+ OTL_RCAST(void*,OTL_CCAST(cda_def *,&cur.cda)),
+ sizeof(cda));
+ return *this;
+ }
+
+ otl_cur():
+ cda(),
+ rpc(&cda.rpc),
+ ft(&cda.ft),
+ rc(&cda.rc),
+ peo(&cda.peo),
+ last_param_data_token(),
+ last_sql_param_data_status(0),
+ sql_param_data_count(0),
+ canceled(false)
+ {
+ memset(&cda,0,sizeof(cda));
+ }
+
+ virtual ~otl_cur(){}
+
+ int open(otl_conn& /* connect */,otl_var* /* var */)
+ {
+ return 1;
+ }
+
+ long get_rpc()
+ {
+ return *rpc;
+ }
+
+ void set_direct_exec(const int /* flag */){}
+ void set_parse_only(const int /*flag*/){}
+
+
+ int open(otl_conn& connect)
+ {
+ memset(&cda,0,sizeof(cda));
+ return !oopen(&cda,connect.lda,0,-1,-1,0,-1);
+ }
+
+ int close(void)
+ {
+ if(cda.rc==3113||cda.rc==1041||cda.rc==1033||cda.rc==1034)
+ return 1;
+ return !oclose(&cda);
+ }
+
+ int parse(const char* stm_text)
+ {
+ return !oparse(&cda,OTL_RCAST(unsigned char*,OTL_CCAST(char*,stm_text)),-1,0,1);
+ }
+
+ int exec(const int iters,
+ const int /*rowoff*/,
+ const int /*otl_sql_exec_from_class*/)
+ {
+ int temp_rc=oexn(&cda,iters,0);
+ return !temp_rc;
+ }
+
+ int fetch(const otl_stream_buffer_size_type iters,int& eof_data)
+ {int temp_rc=ofen(&cda,iters);
+ eof_data=0;
+ if(cda.rc==1403){
+ eof_data=1;
+ return 1;
+ }else if(temp_rc==0)
+ return 1;
+ else
+ return 0;
+ }
+
+ int tmpl_ftype2ora_ftype(const int ftype)
+ {
+ switch(ftype){
+ case otl_var_char:
+ return extCChar;
+ case otl_var_double:
+ return extFloat;
+ case otl_var_float:
+ return extFloat;
+ case otl_var_int:
+ return extInt;
+ case otl_var_long_int:
+ return extInt;
+ case otl_var_unsigned_int:
+ return extUInt;
+ case otl_var_short:
+ return extInt;
+ case otl_var_timestamp:
+ return extDate;
+ case otl_var_varchar_long:
+ return extLongVarChar;
+ case otl_var_raw_long:
+ return extLongVarRaw;
+ case otl_var_raw:
+ return extRaw;
+ default:
+ return 0;
+ }
+ }
+
+ int bind
+ (const char* name,
+ otl_var& v,
+ const int elem_size,
+ const int ftype,
+ const int /* param_type */,
+ const int /* name_pos */,
+ const int /*connection_type*/,
+ const int apl_tab_flag)
+ {
+ if(apl_tab_flag)
+ return !obndra(&cda,
+ OTL_RCAST(unsigned char*,OTL_CCAST(char*,name)),
+ -1,
+ OTL_RCAST(ub1*,v.p_v),
+ ftype==otl_var_raw?elem_size+sizeof(short):elem_size,
+ v.charz_flag?extCharZ:tmpl_ftype2ora_ftype(ftype),
+ -1,
+ v.p_ind,
+ v.p_rlen,
+ v.p_rcode,
+ v.max_tab_len,
+ &v.cur_tab_len,
+ 0,
+ -1,
+ -1);
+ else
+ return !obndrv
+ (&cda,
+ OTL_RCAST(unsigned char*,OTL_CCAST(char*,name)),
+ -1,
+ OTL_RCAST(ub1*,v.p_v),
+ ftype==otl_var_raw?elem_size+sizeof(short):elem_size,
+ tmpl_ftype2ora_ftype(ftype),
+ -1,
+ v.p_ind,
+ 0,
+ -1,
+ -1);
+ }
+
+ int bind
+ (const int column_num,
+ otl_var& v,
+ const int elem_size,
+ const int ftype,
+ const int /* param_type */)
+ {
+ return !odefin
+ (&cda,
+ column_num,
+ OTL_RCAST(ub1*,v.p_v),
+ ftype==otl_var_raw?elem_size+sizeof(short):elem_size,
+ tmpl_ftype2ora_ftype(ftype),
+ -1,
+ v.p_ind,
+ 0,
+ -1,
+ -1,
+ v.p_rlen,
+ v.p_rcode);
+ }
+
+ int describe_column
+ (otl_column_desc& col,
+ const int column_num,
+ int& eof_desc)
+ {
+ sb1 name[241];
+ sb4 nlen;
+ sb4 dbsize;
+ sb2 dbtype;
+
+ sb2 scale;
+ sb2 prec;
+ sb4 dsize;
+ sb2 nullok;
+
+ nlen=sizeof(name)-1;
+ int temp_rc=odescr
+ (&cda,
+ column_num,
+ &dbsize,
+ &dbtype,
+ &name[0],
+ &nlen,
+ &dsize,
+ &prec,
+ &scale,
+ &nullok);
+ if(temp_rc==0)name[nlen]=0;
+ eof_desc=0;
+ if(cda.rc==1007){
+ eof_desc=1;
+ return 0;
+ }
+ if(temp_rc==0){
+ col.set_name(OTL_RCAST(char*,name));
+ col.dbtype=dbtype;
+ col.dbsize=dbsize;
+ col.scale=scale;
+ col.prec=prec;
+ col.nullok=nullok;
+ return 1;
+ }else
+ return 0;
+ }
+
+ void error(otl_exc& exception_struct)
+ {
+ size_t len;
+ exception_struct.code=cda.rc;
+ oerhms
+ (&cda,
+ cda.rc,
+ exception_struct.msg,
+ sizeof(exception_struct.msg)
+ );
+ len=strlen(OTL_RCAST(const char*,exception_struct.msg));
+ exception_struct.msg[len]=0;
+#if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET)
+ ub2 error_offset=cda.peo;
+ exception_struct.error_offset=OTL_SCAST(int,error_offset);
+#endif
+ }
+
+private:
+
+ otl_cur(const otl_cur&):
+ cda(),
+ rpc(&cda.rpc),
+ ft(&cda.ft),
+ rc(&cda.rc),
+ peo(&cda.peo),
+ last_param_data_token(),
+ last_sql_param_data_status(0),
+ sql_param_data_count(0),
+ canceled(false)
+ {
+ }
+
+};
+
+class otl_sel{
+private:
+
+ int implicit_cursor;
+
+public:
+
+ int get_implicit_cursor() const {return implicit_cursor;}
+
+ void set_arr_size
+ (const int input_arr_size,
+ int& out_array_size,
+ int& out_prefetch_array_size)
+ {
+ out_array_size=input_arr_size;
+ out_prefetch_array_size=0;
+ }
+
+ void set_prefetch_size(const int /*aprefetch_array_size*/)
+ {
+ }
+
+ int close_select(otl_cur& /* cur */)
+ {
+ int rc=1;
+ return rc;
+ }
+
+ otl_sel():
+ implicit_cursor(0)
+ {
+ }
+
+ virtual ~otl_sel(){}
+
+ void set_select_type(const int /* atype */)
+ {
+ implicit_cursor=0;
+ }
+
+ void init(const int /* array_size */){}
+
+ int first
+ (otl_cur& cur,
+ int& cur_row,
+ int& cur_size,
+ int& row_count,
+ int& eof_data,
+ const int array_size)
+ {int rc;
+ eof_data=0;
+ cur_row=-1;
+ rc=cur.exec(1,0,otl_sql_exec_from_select_cursor_class);
+ if(rc==0)return 0;
+ rc=cur.fetch(OTL_SCAST(otl_stream_buffer_size_type,array_size),eof_data);
+ if(rc==0)return 0;
+ row_count=*cur.rpc;
+ cur_size=row_count;
+ if(cur_size!=0)cur_row=0;
+ return 1;
+ }
+
+ int next
+ (otl_cur& cur,
+ int& cur_row,
+ int& cur_size,
+ int& row_count,
+ int& eof_data,
+ const int array_size)
+ {int rc;
+ if(cur_row<cur_size-1){
+ ++cur_row;
+ return 1;
+ }else{
+ if(eof_data){
+ cur_row=-1;
+ cur_size=0;
+ return 1;
+ }
+ rc=cur.fetch(OTL_SCAST(otl_stream_buffer_size_type,array_size),eof_data);
+ if(rc==0)return 0;
+ cur_size=*cur.rpc-row_count;
+ row_count=*cur.rpc;
+ if(cur_size!=0)cur_row=0;
+ return 1;
+ }
+ }
+
+};
+
+typedef otl_tmpl_connect
+ <otl_exc,
+ otl_conn,
+ otl_cur> otl_ora7_connect;
+
+typedef otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var> otl_cursor;
+
+typedef otl_tmpl_exception
+ <otl_exc,
+ otl_conn,
+ otl_cur> otl_exception;
+
+typedef otl_tmpl_inout_stream
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var,
+ otl_time0> otl_inout_stream;
+
+typedef otl_tmpl_select_stream
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var,
+ otl_sel,
+ otl_time0> otl_select_stream;
+
+
+typedef otl_tmpl_ext_hv_decl
+ <otl_var,
+ otl_time0,
+ otl_exc,
+ otl_conn,
+ otl_cur> otl_ext_hv_decl;
+
+class otl_stream_shell;
+
+class otl_connect: public otl_ora7_connect{
+public:
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ otl_stream_pool sc;
+
+ void set_stream_pool_size(const int max_size=otl_max_default_pool_size)
+ {
+ sc.init(max_size);
+ }
+
+#endif
+
+ long direct_exec
+ (const char* sqlstm,
+ const int exception_enabled=1)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ return otl_cursor::direct_exec(*this,sqlstm,exception_enabled);
+ }
+
+ void syntax_check(const char* sqlstm)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ otl_cursor::syntax_check(*this,sqlstm);
+ }
+
+ otl_connect() OTL_NO_THROW :
+ otl_ora7_connect(), cmd_(0)
+ {
+ }
+
+ otl_connect(const char* connect_str, const int aauto_commit=0)
+ OTL_THROWS_OTL_EXCEPTION
+ : otl_ora7_connect(connect_str, aauto_commit), cmd_(0)
+ {
+ }
+
+ virtual ~otl_connect()
+#if !defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ OTL_THROWS_OTL_EXCEPTION
+#endif
+ {
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+#if defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ try{
+ logoff();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ }
+#endif
+ }
+
+ void rlogon(Lda_Def* alda)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(this->connected){
+ throw otl_exception(otl_error_msg_30,otl_error_code_30);
+ }
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+ connected=0;
+ long_max_size=32760;
+ retcode=connect_struct.ext_logon(alda,0);
+ if(retcode)
+ connected=1;
+ else{
+ connected=0;
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+ }
+
+ void rlogon(const char* connect_str, const int aauto_commit=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(this->connected){
+ throw otl_exception(otl_error_msg_30,otl_error_code_30);
+ }
+ otl_ora7_connect::rlogon(connect_str,aauto_commit);
+ }
+
+ void logoff(void)
+ {
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ if(connected)
+ sc.init(sc.get_max_size());
+#endif
+ otl_ora7_connect::logoff();
+ }
+
+ const char* getCmd(void) const
+ {
+ return cmd_;
+ }
+
+ otl_connect& operator<<(const char* cmd)
+ {
+ if(!connected){
+ this->rlogon(cmd);
+ }else{
+ otl_cursor::direct_exec(*this,cmd);
+ }
+ return *this;
+ }
+
+ otl_connect& operator<<=(const char* cmd)
+ {
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+ size_t cmd_len=strlen(cmd);
+ cmd_=new char[cmd_len+1];
+ OTL_STRCPY_S(cmd_,cmd_len+1,cmd);
+ return *this;
+ }
+
+private:
+
+ char* cmd_;
+
+ otl_connect& operator=(const otl_connect&)
+ {
+ return *this;
+ }
+
+ otl_connect(const otl_connect&)
+ :otl_ora7_connect(),cmd_(0){}
+
+};
+
+
+// ============ OTL Reference Cursor Streams for Oracle 7 =================
+
+typedef otl_tmpl_variable<otl_var> otl_generic_variable;
+typedef otl_generic_variable* otl_p_generic_variable;
+
+class otl_ref_select_stream;
+
+class otl_ref_cursor: public
+otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>{
+private:
+
+ friend class otl_ref_select_stream;
+ int cur_row;
+ int cur_size;
+ int row_count;
+ int array_size;
+ otl_select_struct_override local_override;
+
+public:
+
+ otl_ref_cursor
+ (otl_connect& db,
+ const char* cur_placeholder_name,
+ void* master_stream_ptr,
+ const otl_stream_buffer_size_type arr_size=1)
+ :otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>(db),
+ cur_row(-1),
+ cur_size(0),
+ row_count(0),
+ array_size(arr_size),
+ local_override(),
+ sel_cur(),
+ rvl_len(otl_var_list_size),
+ rvl(new otl_p_generic_variable[rvl_len]),
+ vl_cur_len(0),
+ cur_placeholder(),
+ master_stream_ptr_(master_stream_ptr)
+ {
+ local_override.reset();
+ for(int i=0;i<rvl_len;++i)
+ rvl[i]=0;
+ OTL_STRCPY_S(cur_placeholder,sizeof(cur_placeholder),cur_placeholder_name);
+ }
+
+ otl_ref_cursor():
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>(),
+ cur_row(-1),
+ cur_size(0),
+ row_count(0),
+ array_size(0),
+ local_override(),
+ sel_cur(),
+ rvl_len(0),
+ rvl(0),
+ vl_cur_len(0),
+ cur_placeholder(),
+ master_stream_ptr_(0)
+ {
+ local_override.reset();
+ }
+
+ virtual ~otl_ref_cursor()
+ {
+ this->in_destructor=1;
+ delete[] rvl;
+ rvl=0;
+ }
+
+ void open
+ (otl_connect& db,
+ const char* cur_placeholder_name,
+ const otl_stream_buffer_size_type arr_size=1)
+ {
+ int i;
+ local_override.reset();
+ cur_row=-1;
+ row_count=0;
+ cur_size=0;
+ array_size=arr_size;
+ rvl_len=otl_var_list_size;
+ vl_cur_len=0;
+ rvl=new otl_p_generic_variable[rvl_len];
+ for(i=0;i<rvl_len;++i)rvl[i]=0;
+ OTL_STRCPY_S(cur_placeholder,sizeof(cur_placeholder),cur_placeholder_name);
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::open(db);
+ }
+
+ void close(void)
+ {
+ local_override.reset();
+ delete[] rvl;
+ rvl=0;
+ if(sel_cur.get_connected() && sel_cur.get_adb()==0)
+ sel_cur.set_adb(adb);
+ sel_cur.close();
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::close();
+ }
+
+ int first(void)
+ {int i,rc;
+ rc=obndrv
+ (&this->cursor_struct.cda,
+ OTL_RCAST(unsigned char*,cur_placeholder),
+ -1,
+ OTL_RCAST(ub1*,&sel_cur.get_cursor_struct_ref().cda),
+ sizeof(sel_cur.get_cursor_struct_ref().cda),
+ 102,-1,0,0,-1,-1);
+ if(rc!=0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_exception(cursor_struct,stm_label?stm_label:stm_text);
+ }
+ if(cur_row==-2)
+ ; // Special case -- calling describe_select() between parse() and first()
+ else{
+// Executing the PLSQL master block
+ exec(1,0,otl_sql_exec_from_select_cursor_class);
+ sel_cur.set_connected(1);
+ }
+ cur_row=-1;
+ for(i=0;i<vl_cur_len;++i)
+ sel_cur.bind(i+1,*rvl[i]);
+ rc=sel_cur.get_cursor_struct_ref().fetch
+ (OTL_SCAST(otl_stream_buffer_size_type,array_size),
+ sel_cur.get_eof_data_ref());
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_exception(sel_cur.get_cursor_struct_ref(),stm_label?stm_label:stm_text);
+ }
+ row_count=sel_cur.get_cursor_struct_ref().cda.rpc;
+ OTL_TRACE_FIRST_FETCH
+ cur_size=row_count;
+ if(cur_size!=0)cur_row=0;
+ return cur_size!=0;
+ }
+
+ int next(void)
+ {int rc;
+ if(cur_row<0)return first();
+ if(cur_row<cur_size-1)
+ ++cur_row;
+ else{
+ if(sel_cur.eof()){
+ cur_row=-1;
+ return 0;
+ }
+ rc=sel_cur.get_cursor_struct_ref().fetch
+ (OTL_SCAST(otl_stream_buffer_size_type,array_size),
+ sel_cur.get_eof_data_ref());
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_exception(sel_cur.get_cursor_struct_ref(),
+ stm_label?stm_label:stm_text);
+ }
+ cur_size=sel_cur.get_cursor_struct_ref().cda.rpc-row_count;
+ row_count=sel_cur.get_cursor_struct_ref().cda.rpc;
+ OTL_TRACE_NEXT_FETCH2
+ if(cur_size!=0)cur_row=0;
+ }
+ return cur_size!=0;
+ }
+
+ void bind
+ (const int column_num,
+ otl_generic_variable& v)
+ {
+ if(!connected)return;
+ ++vl_cur_len;
+ if(vl_cur_len==rvl_len){
+ int temp_rvl_len=rvl_len*2;
+ otl_p_generic_variable* temp_rvl=
+ new otl_p_generic_variable[temp_rvl_len];
+ int i;
+ for(i=0;i<rvl_len;++i)
+ temp_rvl[i]=rvl[i];
+ for(i=rvl_len+1;i<temp_rvl_len;++i)
+ temp_rvl[i]=0;
+ delete[] rvl;
+ rvl=temp_rvl;
+ rvl_len=temp_rvl_len;
+ }
+ rvl[vl_cur_len-1]=&v;
+ v.set_pos(column_num);
+ }
+
+ void bind(otl_generic_variable& v)
+ {
+ if(v.get_pos())
+ bind(v.get_pos(),v);
+ else if(v.get_name())
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::bind(v);
+ }
+
+ void bind
+ (const char* name,
+ otl_generic_variable& v)
+ {
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::bind(name,v);
+ }
+
+ int describe_select
+ (otl_column_desc* desc,
+ int& desc_len)
+ {int i,rc;
+ rc=obndrv
+ (&cursor_struct.cda,
+ OTL_RCAST(unsigned char*,cur_placeholder),
+ -1,
+ OTL_RCAST(ub1*,&sel_cur.get_cursor_struct_ref().cda),
+ sizeof(sel_cur.get_cursor_struct_ref().cda),
+ 102,-1,0,0,-1,-1);
+ if(rc!=0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_exception(cursor_struct,stm_label?stm_label:stm_text);
+ }
+// Executing the PLSQL master block
+ exec(1,0,otl_sql_exec_from_select_cursor_class);
+ sel_cur.set_connected(1);
+ cur_row=-2; // Special case -- describe_select() before first() or next()
+ desc_len=0;
+ for(i=1;sel_cur.describe_column(desc[i-1],i);++i)
+ ++desc_len;
+ return 1;
+ }
+
+
+protected:
+
+ otl_cursor sel_cur;
+ int rvl_len;
+ otl_p_generic_variable* rvl;
+ int vl_cur_len;
+ char cur_placeholder[64];
+ void* master_stream_ptr_;
+
+private:
+
+ otl_ref_cursor(const otl_ref_cursor&) :
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>(),
+ cur_row(-1),
+ cur_size(0),
+ row_count(0),
+ array_size(0),
+ local_override(),
+ sel_cur(),
+ rvl_len(0),
+ rvl(0),
+ vl_cur_len(0),
+ cur_placeholder(),
+ master_stream_ptr_(0)
+ {
+ }
+
+ otl_ref_cursor& operator=(const otl_ref_cursor&)
+ {
+ return *this;
+ }
+
+};
+
+class otl_stream;
+
+class otl_ref_select_stream: public otl_ref_cursor{
+private:
+
+ friend class otl_stream;
+ otl_select_struct_override* override;
+ long _rfc;
+
+public:
+
+ int get_select_row_count() const
+ {
+ return this->cur_row==-1?0:this->cur_size-this->cur_row;
+ }
+
+ void cleanup(void)
+ {int i;
+ delete[] sl;
+ for(i=0;i<vl_len;++i)
+ delete vl[i];
+ delete[] vl;
+ delete[] sl_desc;
+ }
+
+ otl_ref_select_stream
+ (otl_select_struct_override* aoverride,
+ const otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ const char* acur_placeholder,
+ otl_connect& db,
+ const char* sqlstm_label=0)
+ :otl_ref_cursor
+ (db,
+ acur_placeholder,
+ aoverride->get_master_stream_ptr(),
+ arr_size),
+ override(0),
+ _rfc(0),
+ sl_desc(0),
+ sl_len(0),
+ sl(0),
+ null_fetched(0),
+ ret_code(0),
+ cur_col(0),
+ cur_in(0),
+ executed(0),
+ var_info()
+ {
+ if(sqlstm_label!=0){
+ if(stm_label!=0){
+ delete[] stm_label;
+ stm_label=0;
+ }
+ size_t len=strlen(sqlstm_label)+1;
+ stm_label=new char[len];
+ OTL_STRCPY_S(stm_label,len,sqlstm_label);
+ }
+ _rfc=0;
+ init();
+ {
+ size_t len=strlen(sqlstm)+1;
+ stm_text=new char[len];
+ OTL_STRCPY_S(stm_text,len,sqlstm);
+ otl_select_struct_override* temp_local_override=&this->local_override;
+ otl_ext_hv_decl hvd
+ (this->stm_text,
+ 1,
+ this->stm_label,
+ &temp_local_override,
+ adb
+ );
+ hvd.alloc_host_var_list(vl,vl_len,*adb);
+ }
+ override=aoverride;
+ try{
+ parse();
+ if(vl_len==0){
+ rewind();
+ null_fetched=0;
+ }
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ cleanup();
+ if(this->adb)this->adb->increment_throw_count();
+ throw;
+ }
+
+ }
+
+ virtual ~otl_ref_select_stream()
+ {
+ cleanup();
+ }
+
+ void rewind(void)
+ {
+ OTL_TRACE_STREAM_EXECUTION
+ _rfc=0;
+ get_select_list();
+ ret_code=first();
+ null_fetched=0;
+ cur_col=-1;
+ cur_in=0;
+ executed=1;
+ }
+
+ void clean(void)
+ {
+ _rfc=0;
+ null_fetched=0;
+ cur_col=-1;
+ cur_in=0;
+ executed=0;
+ }
+
+ int is_null(void)
+ {
+ return null_fetched;
+ }
+
+ int eof(void)
+ {
+ return !ret_code;
+ }
+
+ void skip_to_end_of_row()
+ {
+ check_if_executed();
+ if(eof())return;
+ while(cur_col<sl_len-1){
+ ++cur_col;
+ null_fetched=sl[cur_col].is_null(this->cur_row);
+ }
+ ret_code=this->next();
+ cur_col=0;
+ if(!eof())
+ cur_col=-1;
+ ++_rfc;
+ }
+
+
+ otl_ref_select_stream& operator>>(otl_time0& t)
+ {
+ check_if_executed();
+ if(eof())return *this;
+ get_next();
+ if(check_type(otl_var_timestamp)&&!eof()){
+ otl_time0* tm=OTL_RCAST(otl_time0*,sl[cur_col].val(cur_row));
+ memcpy(OTL_RCAST(void*,&t),tm,otl_oracle_date_size);
+ look_ahead();
+ }
+ return *this;
+ }
+
+ otl_ref_select_stream& operator>>(char& c)
+ {
+ check_if_executed();
+ if(eof())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof()){
+ c=*OTL_RCAST(char*,sl[cur_col].val(cur_row));
+ look_ahead();
+ }
+ return *this;
+ }
+
+ otl_ref_select_stream& operator>>(unsigned char& c)
+ {
+ check_if_executed();
+ if(eof())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof()){
+ c=*OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row));
+ look_ahead();
+ }
+ return *this;
+ }
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ otl_ref_select_stream& operator>>(OTL_STRING_CONTAINER& s)
+ {
+ check_if_executed();
+ if(eof())return *this;
+ get_next();
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_char:
+ if(!eof()){
+#if defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,sl[cur_col].val(cur_row)),1);
+#else
+ s=OTL_RCAST(char*,sl[cur_col].val(cur_row));
+#endif
+ look_ahead();
+ }
+ break;
+#if defined(USER_DEFINED_STRING_CLASS) || \
+ defined(OTL_STL) || defined(OTL_ACE)
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ if(!eof()){
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row));
+ int len=sl[cur_col].get_len(cur_row);
+#if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_ACE)
+ s.assign(OTL_RCAST(char*,c),len);
+#elif defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,c),len,1);
+#endif
+ look_ahead();
+ }
+ break;
+#endif
+ default:
+ check_type(otl_var_char);
+ } // switch
+ return *this;
+ }
+#endif
+
+ otl_ref_select_stream& operator>>(char* s)
+ {
+ check_if_executed();
+ if(eof())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof()){
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,sl[cur_col].val(cur_row)));
+ look_ahead();
+ }
+ return *this;
+ }
+
+ otl_ref_select_stream& operator>>(unsigned char* s)
+ {
+ check_if_executed();
+ if(eof())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof()){
+ otl_strcpy2(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)),
+ sl[cur_col].get_len(cur_row)
+ );
+ look_ahead();
+ }
+ return *this;
+ }
+
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+#define OTL_D5(T,T_type) \
+ otl_ref_select_stream& operator>>(T& n) \
+ { \
+ check_if_executed(); \
+ if(eof())return *this; \
+ get_next(); \
+ if(!eof()){ \
+ int match_found=otl_numeric_convert_T<T,T_type> \
+ (sl[cur_col].get_ftype(), \
+ sl[cur_col].val(cur_row), \
+ n); \
+ if(!match_found) \
+ strict_check_throw(T_type); \
+ look_ahead(); \
+ } \
+ return *this; \
+ }
+#else
+#define OTL_D5(T,T_type) \
+ otl_ref_select_stream& operator>>(T& n) \
+ { \
+ check_if_executed(); \
+ if(eof())return *this; \
+ get_next(); \
+ if(!eof()){ \
+ int match_found=otl_numeric_convert_T \
+ (sl[cur_col].get_ftype(), \
+ sl[cur_col].val(cur_row), \
+ n); \
+ if(!match_found){ \
+ if(check_type(otl_var_double,T_type)) \
+ n=OTL_PCONV(T,double,sl[cur_col].val(cur_row)); \
+ } \
+ look_ahead(); \
+ } \
+ return *this; \
+ }
+#endif
+
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ OTL_D5(int,otl_var_int)
+ OTL_D5(unsigned,otl_var_unsigned_int)
+ OTL_D5(long,otl_var_long_int)
+ OTL_D5(short,otl_var_short)
+ OTL_D5(float,otl_var_float)
+ OTL_D5(double,otl_var_double)
+#else
+ template<OTL_TYPE_NAME T,const int T_type> OTL_D5(T,T_type)
+#endif
+
+ otl_ref_select_stream& operator>>(otl_long_string& s)
+ {
+ check_if_executed();
+ if(eof())return *this;
+ get_next();
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ {
+ if(!eof()){
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row));
+ int len=sl[cur_col].get_len(cur_row);
+ if(len>s.get_buf_size())
+ len=s.get_buf_size();
+ otl_memcpy(s.v,c,len,sl[cur_col].get_ftype());
+ if(sl[cur_col].get_ftype()==otl_var_varchar_long)
+ s.null_terminate_string(len);
+ s.set_len(len);
+ look_ahead();
+ }
+ }
+ break;
+ case otl_var_raw:
+ {
+ if(!eof()){
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row));
+ int len=OTL_SCAST(int,*OTL_RCAST(unsigned short*,c));
+ if(len>s.get_buf_size())
+ len=s.get_buf_size();
+ otl_memcpy(s.v,c+sizeof(short int),len,sl[cur_col].get_ftype());
+ s.set_len(len);
+ look_ahead();
+ }
+ }
+ break;
+ }
+ return *this;
+ }
+
+
+ otl_ref_select_stream& operator<<(const otl_time0& t)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_timestamp,otl_oracle_date_size)){
+ otl_time0* tm=OTL_RCAST(otl_time0*,vl[cur_in]->val());
+ memcpy(tm,OTL_RCAST(void*,OTL_CCAST(otl_time0*,&t)),otl_oracle_date_size);
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+
+
+ otl_ref_select_stream& operator<<(const otl_null& /* n */)
+ {
+ check_in_var();
+ this->vl[cur_in]->set_null(0);
+ get_in_next();
+ return *this;
+ }
+
+ otl_ref_select_stream& operator<<(const otl_long_string& s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_raw,1)){
+ unsigned char* c=OTL_RCAST(unsigned char*,vl[cur_in]->val());
+ int len=OTL_CCAST(otl_long_string*,&s)->len();
+ if(len>this->vl[cur_in]->actual_elem_size()){
+ otl_var_info_var
+ (this->vl[cur_in]->get_name(),
+ this->vl[cur_in]->get_ftype(),
+ otl_var_raw,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception
+ (otl_error_msg_5,
+ otl_error_code_5,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ this->vl[cur_in]->set_not_null(0);
+ otl_memcpy
+ (c+sizeof(unsigned short),
+ s.v,
+ len,
+ this->vl[cur_in]->get_ftype());
+ *OTL_RCAST(unsigned short*,
+ this->vl[cur_in]->val(0))=OTL_SCAST(unsigned short,len);
+ this->vl[cur_in]->set_len(len,0);
+ }
+ get_in_next();
+ return *this;
+ }
+
+
+ otl_ref_select_stream& operator<<(const char c)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+ char* tmp=OTL_RCAST(char*,vl[cur_in]->val());
+ tmp[0]=c;
+ tmp[1]=0;
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+
+ otl_ref_select_stream& operator<<(const unsigned char c)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+ unsigned char* tmp=OTL_RCAST(unsigned char*,vl[cur_in]->val());
+ tmp[0]=c;
+ tmp[1]=0;
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ otl_ref_select_stream& operator<<(const OTL_STRING_CONTAINER& s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy
+ (OTL_RCAST(unsigned char*,vl[cur_in]->val()),
+ OTL_RCAST(unsigned char*,OTL_CCAST(char*,s.c_str())),
+ overflow,
+ vl[cur_in]->get_elem_size(),
+ OTL_SCAST(int,s.length())
+ );
+ if(overflow){
+ char temp_var_info[256];
+ otl_var_info_var
+ (vl[cur_in]->get_name(),
+ vl[cur_in]->get_ftype(),
+ otl_var_char,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(this->adb)this->adb->increment_throw_count();
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception
+ (otl_error_msg_4,
+ otl_error_code_4,
+ stm_label?stm_label:stm_text,
+ temp_var_info);
+ }
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+#endif
+
+ otl_ref_select_stream& operator<<(const char* s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy
+ (OTL_RCAST(unsigned char*,vl[cur_in]->val()),
+ OTL_RCAST(unsigned char*,OTL_CCAST(char*,s)),
+ overflow,
+ vl[cur_in]->get_elem_size()
+ );
+ if(overflow){
+ char temp_var_info[256];
+ otl_var_info_var
+ (vl[cur_in]->get_name(),
+ vl[cur_in]->get_ftype(),
+ otl_var_char,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(this->adb)this->adb->increment_throw_count();
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception
+ (otl_error_msg_4,
+ otl_error_code_4,
+ stm_label?stm_label:stm_text,
+ temp_var_info);
+ }
+
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+
+ otl_ref_select_stream& operator<<(const unsigned char* s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy4
+ (OTL_RCAST(unsigned char*,vl[cur_in]->val()),
+ OTL_CCAST(unsigned char*,s),
+ overflow,
+ vl[cur_in]->get_elem_size()
+ );
+ if(overflow){
+ char temp_var_info[256];
+ otl_var_info_var
+ (vl[cur_in]->get_name(),
+ vl[cur_in]->get_ftype(),
+ otl_var_char,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception
+ (otl_error_msg_4,
+ otl_error_code_4,
+ stm_label?stm_label:stm_text,
+ temp_var_info);
+ }
+
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+
+#define OTL_D6(T,T_type) \
+ otl_ref_select_stream& operator<<(const T n) \
+ { \
+ check_in_var(); \
+ if(check_in_type(T_type,sizeof(T))){ \
+ *OTL_RCAST(T*,vl[cur_in]->val())=n; \
+ } \
+ this->vl[cur_in]->set_not_null(0); \
+ get_in_next(); \
+ return *this; \
+ }
+
+
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ OTL_D6(int,otl_var_int)
+ OTL_D6(unsigned,otl_var_unsigned_int)
+ OTL_D6(long,otl_var_long_int)
+ OTL_D6(short,otl_var_short)
+ OTL_D6(float,otl_var_float)
+ OTL_D6(double,otl_var_double)
+#else
+ template<OTL_TYPE_NAME T,const int T_type> OTL_D6(T,T_type)
+#endif
+
+
+ int select_list_len(void)
+ {
+ return sl_len;
+ }
+
+ int column_ftype(int ndx=0)
+ {
+ return sl[ndx].get_ftype();
+ }
+
+ int column_size(int ndx=0)
+ {
+ return sl[ndx].get_elem_size();
+ }
+
+protected:
+
+ otl_column_desc* sl_desc;
+ int sl_len;
+ otl_generic_variable* sl;
+ int null_fetched;
+ int ret_code;
+ int cur_col;
+ int cur_in;
+ int executed;
+ char var_info[256];
+
+ void init(void)
+ {
+ sl=0;
+ sl_len=0;
+ null_fetched=0;
+ ret_code=0;
+ sl_desc=0;
+ executed=0;
+ cur_in=0;
+ stm_text=0;
+ }
+
+ void get_next(void)
+ {
+ if(cur_col<sl_len-1){
+ ++cur_col;
+ null_fetched=sl[cur_col].is_null(cur_row);
+ }else{
+ ret_code=next();
+ cur_col=0;
+ }
+ }
+
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ void strict_check_throw(int type_code)
+ {
+ otl_var_info_col
+ (sl[cur_col].get_pos(),
+ sl[cur_col].get_ftype(),
+ type_code,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception
+ (otl_error_msg_0,
+ otl_error_code_0,
+ this->stm_label?
+ this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+#endif
+
+ int check_type_throw(int type_code,int actual_data_type)
+ {
+ int out_type_code;
+ if(actual_data_type!=0)
+ out_type_code=actual_data_type;
+ else
+ out_type_code=type_code;
+ otl_var_info_col
+ (sl[cur_col].get_pos(),
+ sl[cur_col].get_ftype(),
+ out_type_code,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_exception
+ (otl_error_msg_0,
+ otl_error_code_0,
+ stm_label?stm_label:stm_text,
+ var_info);
+ }
+
+ int check_type(int type_code, int actual_data_type=0)
+ {
+ if(sl[cur_col].get_ftype()==type_code)
+ return 1;
+ else
+ return check_type_throw(type_code,actual_data_type);
+ }
+
+ void look_ahead(void)
+ {
+ if(cur_col==sl_len-1){
+ ret_code=next();
+ cur_col=-1;
+ ++_rfc;
+ }
+ }
+
+ void get_select_list(void)
+ {int i,j,rc;
+
+ otl_auto_array_ptr<otl_column_desc> loc_ptr(otl_var_list_size);
+ otl_column_desc* sl_desc_tmp=loc_ptr.get_ptr();
+ int sld_tmp_len=0;
+ int ftype,elem_size;
+
+ rc=obndrv
+ (&cursor_struct.cda,
+ OTL_RCAST(unsigned char*,cur_placeholder),
+ -1,
+ OTL_RCAST(ub1*,&sel_cur.get_cursor_struct_ref().cda),
+ sizeof(sel_cur.get_cursor_struct_ref().cda),
+ 102,-1,0,0,-1,-1);
+ if(rc!=0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(cursor_struct,stm_label?stm_label:stm_text);
+ }
+ for(i=0;i<vl_len;++i)
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::bind(*vl[i]);
+ // Executing the PLSQL master block
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::exec(1,0,otl_sql_exec_from_select_cursor_class);
+ sel_cur.set_connected(1);
+ cur_row=-2;
+ sld_tmp_len=0;
+ for(i=1;sel_cur.describe_column(sl_desc_tmp[i-1],i);++i){
+ ++sld_tmp_len;
+ if(sld_tmp_len==loc_ptr.get_arr_size()){
+ loc_ptr.double_size();
+ sl_desc_tmp=loc_ptr.get_ptr();
+ }
+ }
+ sl_len=sld_tmp_len;
+ if(sl){
+ delete[] sl;
+ sl=0;
+ }
+ sl=new otl_generic_variable[sl_len==0?1:sl_len];
+ int max_long_size=this->adb->get_max_long_size();
+ for(j=0;j<sl_len;++j){
+ otl_generic_variable::map_ftype
+ (sl_desc_tmp[j],
+ max_long_size,
+ ftype,
+ elem_size,
+ this->local_override.getLen()>0?this->local_override:*override,
+ j+1,
+ adb->get_connect_struct().get_connection_type());
+ sl[j].copy_pos(j+1);
+ sl[j].init(true,ftype,
+ elem_size,
+ OTL_SCAST(otl_stream_buffer_size_type,array_size),
+ &adb->get_connect_struct()
+ );
+ }
+ if(sl_desc){
+ delete[] sl_desc;
+ sl_desc=0;
+ }
+ sl_desc=new otl_column_desc[sl_len==0?1:sl_len];
+ for(i=0;i<sl_len;++i)
+ sl_desc[i]=sl_desc_tmp[i];
+ for(i=0;i<sl_len;++i)sel_cur.bind(sl[i]);
+ }
+
+ void get_in_next(void)
+ {
+ if(cur_in==vl_len-1)
+ rewind();
+ else{
+ ++cur_in;
+ executed=0;
+ }
+ }
+
+ int check_in_type_throw(int type_code)
+ {
+ otl_var_info_var
+ (vl[cur_in]->get_name(),
+ vl[cur_in]->get_ftype(),
+ type_code,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+
+ throw otl_exception
+ (otl_error_msg_0,
+ otl_error_code_0,
+ stm_label?stm_label:stm_text,
+ var_info);
+ }
+
+ int check_in_type(int type_code,int tsize)
+ {
+ switch(vl[cur_in]->get_ftype()){
+ case otl_var_char:
+ if(type_code==otl_var_char)
+ return 1;
+ case otl_var_raw:
+ if(type_code==otl_var_raw)
+ return 1;
+ default:
+ if(vl[cur_in]->get_ftype()==type_code &&
+ vl[cur_in]->get_elem_size()==tsize)
+ return 1;
+ }
+ return check_in_type_throw(type_code);
+ }
+
+ void check_in_var_throw(void)
+ {
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception
+ (otl_error_msg_1,
+ otl_error_code_1,
+ stm_label?stm_label:stm_text,
+ 0);
+ }
+
+ void check_in_var(void)
+ {
+ if(vl_len==0)
+ check_in_var();
+ }
+
+ void check_if_executed_throw(void)
+ {
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception
+ (otl_error_msg_2,
+ otl_error_code_2,
+ stm_label?stm_label:stm_text,
+ 0);
+ }
+
+ void check_if_executed(void)
+ {
+ if(!executed)
+ check_if_executed_throw();
+ }
+
+private:
+
+ otl_ref_select_stream(const otl_ref_select_stream&):
+ otl_ref_cursor(),
+ override(0),
+ _rfc(0),
+ sl_desc(0),
+ sl_len(0),
+ sl(0),
+ null_fetched(0),
+ ret_code(0),
+ cur_col(0),
+ cur_in(0),
+ executed(0),
+ var_info()
+ {
+ }
+
+ otl_ref_select_stream& operator=(const otl_ref_select_stream&)
+ {
+ return *this;
+ }
+
+};
+
+const int otl_ora7_no_stream=0;
+const int otl_ora7_io_stream=1;
+const int otl_ora7_select_stream=2;
+const int otl_ora7_refcur_select_stream=3;
+
+class otl_stream_shell: public otl_stream_shell_generic{
+public:
+
+ otl_ref_select_stream* ref_ss;
+ otl_select_stream* ss;
+ otl_inout_stream* io;
+ otl_connect* adb;
+ bool lob_stream_flag;
+
+ int auto_commit_flag;
+
+ otl_var_desc* iov;
+ int iov_len;
+ int next_iov_ndx;
+
+ otl_var_desc* ov;
+ int ov_len;
+ int next_ov_ndx;
+
+ bool flush_flag;
+ int stream_type;
+
+ otl_select_struct_override override;
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ OTL_STRING_CONTAINER orig_sql_stm;
+#endif
+
+
+ otl_stream_shell():
+ otl_stream_shell_generic(),
+ ref_ss(0),
+ ss(0),
+ io(0),
+ adb(0),
+ lob_stream_flag(false),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ flush_flag(false),
+ stream_type(otl_ora7_no_stream),
+ override()
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ ,orig_sql_stm()
+#endif
+ {
+ }
+
+ otl_stream_shell(const int ashould_delete):
+ otl_stream_shell_generic(),
+ ref_ss(0),
+ ss(0),
+ io(0),
+ adb(0),
+ lob_stream_flag(false),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ flush_flag(true),
+ stream_type(otl_ora7_no_stream),
+ override()
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ ,orig_sql_stm()
+#endif
+ {
+ override.setLen(0);
+ should_delete=ashould_delete;
+ }
+
+ virtual ~otl_stream_shell()
+ {
+ if(should_delete){
+ delete[] iov;
+ delete[] ov;
+
+ iov=0; iov_len=0;
+ ov=0; ov_len=0;
+ next_iov_ndx=0;
+ next_ov_ndx=0;
+ override.setLen(0);
+ flush_flag=true;
+ stream_type=otl_ora7_no_stream;
+
+ delete ss;
+ delete io;
+ delete ref_ss;
+ ss=0; io=0; ref_ss=0;
+ adb=0;
+ }
+ }
+
+private:
+
+ otl_stream_shell(const otl_stream_shell&):
+ otl_stream_shell_generic(),
+ ref_ss(0),
+ ss(0),
+ io(0),
+ adb(0),
+ lob_stream_flag(false),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ flush_flag(false),
+ stream_type(otl_ora7_no_stream),
+ override()
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ ,orig_sql_stm()
+#endif
+ {
+ }
+
+ otl_stream_shell& operator=(const otl_stream_shell&)
+ {
+ return *this;
+ }
+
+};
+
+class otl_stream{
+private:
+
+ otl_stream_shell* shell;
+ otl_ptr<otl_stream_shell> shell_pt;
+ int connected;
+
+ otl_ref_select_stream** ref_ss;
+ otl_select_stream** ss;
+ otl_inout_stream** io;
+ otl_connect** adb;
+
+ int* auto_commit_flag;
+
+ otl_var_desc** iov;
+ int* iov_len;
+ int* next_iov_ndx;
+
+ otl_var_desc** ov;
+ int* ov_len;
+ int* next_ov_ndx;
+
+ otl_select_struct_override* override;
+
+ int end_marker;
+ int oper_int_called;
+ int last_eof_rc;
+ bool last_oper_was_read_op;
+
+protected:
+
+ void reset_end_marker(void)
+ {
+ last_eof_rc=0;
+ end_marker=-1;
+ oper_int_called=0;
+ }
+
+ int buf_size_;
+
+
+ void throw_end_of_row()
+#if defined(__GNUC__) && (__GNUC__>=4)
+ __attribute__ ((noreturn))
+#endif
+ {
+ throw otl_exception
+ (otl_error_msg_34,
+ otl_error_code_34,
+ this->get_stm_text());
+ }
+
+public:
+
+
+ void skip_to_end_of_row()
+ {
+ if(next_ov_ndx==0)
+ return;
+ if((*ov_len)==0)return;
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->skip_to_end_of_row();
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->skip_to_end_of_row();
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->skip_to_end_of_row();
+ break;
+ }
+ while ((*next_ov_ndx)<(*ov_len)-1)
+ ++(*next_ov_ndx);
+ }
+
+ void reset_to_last_valid_row()
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->reset_to_last_valid_row();
+ }
+ }
+
+ bool get_lob_stream_flag() const
+ {
+ if(!shell)
+ return false;
+ else
+ return shell->lob_stream_flag;
+ }
+
+ int get_adb_max_long_size() const
+ {
+ return this->shell->adb->get_max_long_size();
+ }
+
+
+ void check_end_of_row()
+ {
+ if(next_ov_ndx==0||(*next_ov_ndx)!=0)
+ throw_end_of_row();
+ if(next_iov_ndx==0||(*next_iov_ndx)!=0)
+ throw_end_of_row();
+ }
+
+ otl_stream_shell* get_shell(){return shell;}
+ int get_connected() const {return connected;}
+
+ int get_dirty_buf_len() const
+ {
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ return 0;
+ case otl_ora7_io_stream:
+ return (*io)->get_dirty_buf_len();
+ case otl_ora7_select_stream:
+ return (*ss)->get_select_row_count();
+ case otl_ora7_refcur_select_stream:
+ return (*ref_ss)->get_select_row_count();
+ default:
+ return 0;
+ }
+ }
+
+ const char* get_stm_text(void)
+ {
+ const char* no_stm_text=OTL_NO_STM_TEXT;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ return no_stm_text;
+ case otl_ora7_io_stream:
+ return (*io)->get_stm_label()?(*io)->get_stm_label():(*io)->get_stm_text();
+ case otl_ora7_select_stream:
+ return (*ss)->get_stm_label()?(*ss)->get_stm_label():(*ss)->get_stm_text();
+ case otl_ora7_refcur_select_stream:
+ return (*ref_ss)->get_stm_label()?
+ (*ref_ss)->get_stm_label():(*ref_ss)->get_stm_text();
+ default:
+ return no_stm_text;
+ }
+ }
+
+ void setBufSize(int buf_size)
+ {
+ buf_size_=buf_size;
+ }
+
+ int getBufSize(void) const
+ {
+ return buf_size_;
+ }
+
+ long get_rpc() OTL_THROWS_OTL_EXCEPTION
+ {
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ return 0;
+ case otl_ora7_io_stream:
+ (*adb)->reset_throw_count();
+ return (*io)->get_rpc();
+ case otl_ora7_select_stream:
+ (*adb)->reset_throw_count();
+ return (*ss)->get_rfc();
+ case otl_ora7_refcur_select_stream:
+ (*adb)->reset_throw_count();
+ return (*ref_ss)->_rfc;
+ default:
+ return 0;
+ }
+ }
+
+ operator int(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if(!last_oper_was_read_op){
+ if(this->adb&&*this->adb)(*this->adb)->increment_throw_count();
+ if(this->adb&&*this->adb&&(*this->adb)->get_throw_count()>1)return 0;
+ const char* stm_label=0;
+ const char* stm_text=0;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ stm_label=(*io)->get_stm_label();
+ stm_text=(*io)->get_stm_text();
+ break;
+ case otl_ora7_select_stream:
+ stm_label=(*ss)->get_stm_label();
+ stm_text=(*ss)->get_stm_text();
+ break;
+ case otl_ora7_refcur_select_stream:
+ stm_label=(*ref_ss)->get_stm_label();
+ stm_text=(*ref_ss)->get_stm_text();
+ break;
+ }
+ throw otl_exception
+ (otl_error_msg_18,
+ otl_error_code_18,
+ stm_label?stm_label:stm_text);
+ }
+ if(end_marker==1)return 0;
+ int rc=0;
+ int temp_eof=eof();
+ if(temp_eof && end_marker==-1 && oper_int_called==0){
+ end_marker=1;
+ if(last_eof_rc==1)
+ rc=0;
+ else
+ rc=1;
+ }else if(!temp_eof && end_marker==-1)
+ rc=1;
+ else if(temp_eof && end_marker==-1){
+ end_marker=0;
+ rc=1;
+ }else if(temp_eof && end_marker==0){
+ end_marker=1;
+ rc=0;
+ }
+ if(!oper_int_called)oper_int_called=1;
+ return rc;
+ }
+
+ void create_var_desc(void)
+ {int i;
+ delete[] (*iov);
+ delete[] (*ov);
+ (*iov)=0; (*iov_len)=0;
+ (*ov)=0; (*ov_len)=0;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ if((*io)->get_vl_len()>0){
+ (*iov)=new otl_var_desc[(*io)->get_vl_len()];
+ (*iov_len)=(*io)->get_vl_len();
+ for(i=0;i<(*io)->get_vl_len();++i)
+ (*io)->get_vl()[i]->copy_var_desc((*iov)[i]);
+ }
+ if((*io)->get_iv_len()>0){
+ (*ov)=new otl_var_desc[(*io)->get_iv_len()];
+ (*ov_len)=(*io)->get_iv_len();
+ for(i=0;i<(*io)->get_iv_len();++i)
+ (*io)->get_in_vl()[i]->copy_var_desc((*ov)[i]);
+ }
+ break;
+ case otl_ora7_select_stream:
+ if((*ss)->get_vl_len()>0){
+ (*iov)=new otl_var_desc[(*ss)->get_vl_len()];
+ (*iov_len)=(*ss)->get_vl_len();
+ for(i=0;i<(*ss)->get_vl_len();++i)
+ (*ss)->get_vl()[i]->copy_var_desc((*iov)[i]);
+ }
+ if((*ss)->get_sl_len()>0){
+ (*ov)=new otl_var_desc[(*ss)->get_sl_len()];
+ (*ov_len)=(*ss)->get_sl_len();
+ for(i=0;i<(*ss)->get_sl_len();++i){
+ (*ss)->get_sl()[i].copy_var_desc((*ov)[i]);
+ (*ov)[i].copy_name((*ss)->get_sl_desc()[i].name);
+ }
+ }
+ break;
+ case otl_ora7_refcur_select_stream:
+ if((*ref_ss)->vl_len>0){
+ (*iov)=new otl_var_desc[(*ref_ss)->vl_len];
+ (*iov_len)=(*ref_ss)->vl_len;
+ for(i=0;i<(*ref_ss)->vl_len;++i)
+ (*ref_ss)->vl[i]->copy_var_desc((*iov)[i]);
+ }
+ if((*ref_ss)->sl_len>0){
+ (*ov)=new otl_var_desc[(*ref_ss)->sl_len];
+ (*ov_len)=(*ref_ss)->sl_len;
+ for(i=0;i<(*ref_ss)->sl_len;++i){
+ (*ref_ss)->sl[i].copy_var_desc((*ov)[i]);
+ (*ov)[i].copy_name((*ref_ss)->sl_desc[i].name);
+ }
+ }
+ break;
+ }
+
+ }
+
+ void set_column_type(const int column_ndx,
+ const int col_type,
+ const int col_size=0)
+ OTL_NO_THROW
+ {
+ if(shell==0){
+ init_stream();
+ shell->flush_flag=true;
+ }
+ override->add_override(column_ndx,col_type,col_size);
+ }
+
+ void set_all_column_types(const unsigned mask=0)
+ OTL_NO_THROW
+ {
+ if(shell==0){
+ init_stream();
+ shell->flush_flag=true;
+ }
+ override->set_all_column_types(mask);
+ }
+
+ void set_flush(const bool flush_flag=true)
+ OTL_NO_THROW
+ {
+ if(shell==0)init_stream();
+ if(shell==0)return;
+ shell->flush_flag=flush_flag;
+ }
+
+
+ void inc_next_ov(void)
+ {
+ if((*ov_len)==0)return;
+ if((*next_ov_ndx)<(*ov_len)-1)
+ ++(*next_ov_ndx);
+ else
+ (*next_ov_ndx)=0;
+ }
+
+ void inc_next_iov(void)
+ {
+ if((*iov_len)==0)return;
+ if((*next_iov_ndx)<(*iov_len)-1)
+ ++(*next_iov_ndx);
+ else
+ (*next_iov_ndx)=0;
+ }
+
+ otl_var_desc* describe_in_vars(int& desc_len)
+ OTL_NO_THROW
+ {
+ desc_len=0;
+ if(shell==0)return 0;
+ if(shell->iov==0)return 0;
+ desc_len=shell->iov_len;
+ return shell->iov;
+ }
+
+ otl_var_desc* describe_out_vars(int& desc_len)
+ OTL_NO_THROW
+ {
+ desc_len=0;
+ if(shell==0)return 0;
+ if(shell->ov==0)return 0;
+ desc_len=shell->ov_len;
+ return shell->ov;
+ }
+
+ otl_var_desc* describe_next_in_var(void)
+ OTL_NO_THROW
+ {
+ if(shell==0)return 0;
+ if(shell->iov==0)return 0;
+ return &(shell->iov[shell->next_iov_ndx]);
+ }
+
+ otl_var_desc* describe_next_out_var(void)
+ OTL_NO_THROW
+ {
+ if(shell==0)return 0;
+ if(shell->ov==0)return 0;
+ return &(shell->ov[shell->next_ov_ndx]);
+ }
+
+ void init_stream(void)
+ {
+ buf_size_=1;
+ last_oper_was_read_op=false;
+ shell=0;
+ shell=new otl_stream_shell(0);
+ shell_pt.assign(&shell);
+ connected=0;
+
+ ref_ss=&(shell->ref_ss);
+ ss=&(shell->ss);
+ io=&(shell->io);
+ adb=&(shell->adb);
+ auto_commit_flag=&(shell->auto_commit_flag);
+ iov=&(shell->iov);
+ iov_len=&(shell->iov_len);
+ next_iov_ndx=&(shell->next_iov_ndx);
+ ov=&(shell->ov);
+ ov_len=&(shell->ov_len);
+ next_ov_ndx=&(shell->next_ov_ndx);
+ override=&(shell->override);
+
+ (*ref_ss)=0;
+ (*io)=0;
+ (*ss)=0;
+ (*adb)=0;
+ (*ov)=0;
+ (*ov_len)=0;
+ (*next_iov_ndx)=0;
+ (*next_ov_ndx)=0;
+ (*auto_commit_flag)=1;
+ (*iov)=0;
+ (*iov_len)=0;
+
+ }
+
+ otl_stream
+ (const otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ otl_connect& db,
+ const char* ref_cur_placeholder=0,
+ const char* sqlstm_label=0)
+ OTL_THROWS_OTL_EXCEPTION:
+ shell(0),
+ shell_pt(),
+ connected(0),
+ ref_ss(0),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ override(0),
+ end_marker(0),
+ oper_int_called(0),
+ last_eof_rc(0),
+ last_oper_was_read_op(0),
+ buf_size_(0)
+ {
+ init_stream();
+
+ (*io)=0; (*ss)=0; (*ref_ss)=0;
+ (*iov)=0; (*iov_len)=0;
+ (*ov)=0; (*ov_len)=0;
+ (*auto_commit_flag)=1;
+ (*next_iov_ndx)=0;
+ (*next_ov_ndx)=0;
+ (*adb)=&db;
+ shell->flush_flag=true;
+ open(arr_size,sqlstm,db,ref_cur_placeholder,sqlstm_label);
+ }
+
+ otl_stream() OTL_NO_THROW:
+ shell(0),
+ shell_pt(),
+ connected(0),
+ ref_ss(0),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ override(0),
+ end_marker(0),
+ oper_int_called(0),
+ last_eof_rc(0),
+ last_oper_was_read_op(0),
+ buf_size_(0)
+ {
+ init_stream();
+ shell->flush_flag=true;
+ }
+
+ virtual ~otl_stream()
+#if !defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ OTL_THROWS_OTL_EXCEPTION
+#endif
+ {
+ if(!connected)return;
+ try{
+ if((*io)!=0&&shell->flush_flag==false)
+ (*io)->set_flush_flag2(false);
+ close();
+ if(shell!=0){
+ if((*io)!=0)
+ (*io)->set_flush_flag2(true);
+ }
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ if(shell!=0){
+ if((*io)!=0)
+ (*io)->set_flush_flag2(true);
+ }
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ clean(1);
+ if(shell!=0)
+ shell->set_should_delete(1);
+ shell_pt.destroy();
+#else
+ shell_pt.destroy();
+#endif
+
+#if !defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ throw;
+#endif
+
+ }
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ if(adb && (*adb) && (*adb)->get_throw_count()>0
+#if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ || otl_uncaught_exception()
+#elif defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ || otl_uncaught_exception()
+#endif
+ ){
+ //
+ }
+#else
+ shell_pt.destroy();
+#endif
+ }
+
+ int eof(void) OTL_NO_THROW
+ {
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ return 1;
+ case otl_ora7_io_stream:
+ (*adb)->reset_throw_count();
+ return (*io)->eof();
+ case otl_ora7_select_stream:
+ (*adb)->reset_throw_count();
+ return (*ss)->eof();
+ case otl_ora7_refcur_select_stream:
+ (*adb)->reset_throw_count();
+ return (*ref_ss)->eof();
+ default:
+ return 0;
+ }
+ }
+
+ void flush(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->flush();
+ }
+ }
+
+ void clean(const int clean_up_error_flag=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ (*adb)->reset_throw_count();
+ (*io)->clean(clean_up_error_flag);
+ break;
+ case otl_ora7_select_stream:
+ (*adb)->reset_throw_count();
+ (*ss)->clean();
+ break;
+ case otl_ora7_refcur_select_stream:
+ (*adb)->reset_throw_count();
+ (*ref_ss)->clean();
+ break;
+ }
+ }
+
+ void rewind(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ (*adb)->reset_throw_count();
+ (*io)->rewind();
+ break;
+ case otl_ora7_select_stream:
+ (*adb)->reset_throw_count();
+ (*ss)->rewind();
+ break;
+ case otl_ora7_refcur_select_stream:
+ (*adb)->reset_throw_count();
+ (*ref_ss)->rewind();
+ break;
+ }
+ }
+
+ int is_null(void) OTL_NO_THROW
+ {
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ return 0;
+ case otl_ora7_io_stream:
+ return (*io)->is_null();
+ case otl_ora7_select_stream:
+ return (*ss)->is_null();
+ case otl_ora7_refcur_select_stream:
+ return (*ref_ss)->is_null();
+ default:
+ return 0;
+ }
+ }
+
+ void set_commit(int auto_commit=0)
+ OTL_NO_THROW
+ {
+ (*auto_commit_flag)=auto_commit;
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->set_commit(auto_commit);
+ }
+ }
+
+ void intern_cleanup(void)
+ {
+ delete[] (*iov);
+ delete[] (*ov);
+
+ (*iov)=0; (*iov_len)=0;
+ (*ov)=0; (*ov_len)=0;
+ (*next_iov_ndx)=0;
+ (*next_ov_ndx)=0;
+ override->setLen(0);
+
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ try{
+ (*io)->flush();
+ (*io)->close();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ clean(1);
+ (*io)->close();
+ delete (*io);
+ (*io)=0;
+ shell->stream_type=otl_ora7_no_stream;
+ throw;
+ }
+ delete (*io);
+ (*io)=0;
+ shell->stream_type=otl_ora7_no_stream;
+ break;
+ case otl_ora7_select_stream:
+ try{
+ (*ss)->close();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ delete (*ss);
+ (*ss)=0;
+ shell->stream_type=otl_ora7_no_stream;
+ throw;
+ }
+ delete (*ss);
+ (*ss)=0;
+ shell->stream_type=otl_ora7_no_stream;
+ break;
+ case otl_ora7_refcur_select_stream:
+ try{
+ (*ref_ss)->close();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ delete (*ref_ss);
+ (*ref_ss)=0;
+ shell->stream_type=otl_ora7_no_stream;
+ throw;
+ }
+ delete (*ref_ss);
+ (*ref_ss)=0;
+ shell->stream_type=otl_ora7_no_stream;
+ break;
+ }
+ (*ss)=0; (*io)=0; (*ref_ss)=0;
+ if(adb!=0)(*adb)=0;
+ adb=0;
+ }
+
+ void open
+ (const otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ otl_connect& db,
+ const char* ref_cur_placeholder=0,
+ const char* sqlstm_label=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ reset_end_marker();
+ if(this->good()){
+ const char* temp_stm_text=0;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ temp_stm_text=OTL_NO_STM_TEXT;
+ break;
+ case otl_ora7_io_stream:
+ temp_stm_text=(*io)->get_stm_label()?
+ (*io)->get_stm_label():(*io)->get_stm_text();
+ break;
+ case otl_ora7_select_stream:
+ temp_stm_text=(*ss)->get_stm_label()?
+ (*ss)->get_stm_label():(*ss)->get_stm_text();
+ case otl_ora7_refcur_select_stream:
+ temp_stm_text=(*ref_ss)->get_stm_label()?
+ (*ref_ss)->get_stm_label():(*ref_ss)->get_stm_text();
+ break;
+ default:
+ temp_stm_text=OTL_NO_STM_TEXT;
+ break;
+ }
+ throw otl_exception
+ (otl_error_msg_29,
+ otl_error_code_29,
+ temp_stm_text);
+ }
+ if(shell==0)
+ init_stream();
+ buf_size_=arr_size;
+ OTL_TRACE_STREAM_OPEN2
+
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ char temp_buf[128];
+ otl_itoa(arr_size,temp_buf);
+ OTL_STRING_CONTAINER sql_stm=OTL_STRING_CONTAINER(temp_buf)+
+ OTL_STRING_CONTAINER("===>")+sqlstm;
+ otl_stream_shell* temp_shell=OTL_RCAST(otl_stream_shell*,
+ db.sc.find(sql_stm));
+ if(temp_shell){
+ if(shell!=0)
+ shell_pt.destroy();
+ shell=temp_shell;
+ ref_ss=&(shell->ref_ss);
+ ss=&(shell->ss);
+ io=&(shell->io);
+ if((*io)!=0)(*io)->set_flush_flag2(true);
+ adb=&(shell->adb);
+ auto_commit_flag=&(shell->auto_commit_flag);
+ iov=&(shell->iov);
+ iov_len=&(shell->iov_len);
+ next_iov_ndx=&(shell->next_iov_ndx);
+ ov=&(shell->ov);
+ ov_len=&(shell->ov_len);
+ next_ov_ndx=&(shell->next_ov_ndx);
+ override=&(shell->override);
+ override->set_master_stream_ptr(OTL_RCAST(void*,this));
+ try{
+ if((*iov_len)==0)this->rewind();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ if((*adb))
+ (*adb)->sc.remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ throw;
+ }
+
+ connected=1;
+ return;
+ }
+ shell->orig_sql_stm=sql_stm;
+#endif
+
+ delete[] (*iov);
+ delete[] (*ov);
+
+ (*iov)=0; (*iov_len)=0;
+ (*ov)=0; (*ov_len)=0;
+ (*next_iov_ndx)=0;
+ (*next_ov_ndx)=0;
+
+ char tmp[7];
+ char* c=OTL_CCAST(char*,sqlstm);
+
+ while(otl_isspace(*c)||(*c)=='(')++c;
+ OTL_STRNCPY_S(tmp,sizeof(tmp),c,6);
+ tmp[6]=0;
+ c=tmp;
+ while(*c){
+ *c=OTL_SCAST(char,otl_to_upper(*c));
+ ++c;
+ }
+ if(adb==0)adb=&(shell->adb);
+ (*adb)=&db;
+ (*adb)->reset_throw_count();
+ try{
+ if((strncmp(tmp,"SELECT",6)==0||
+ strncmp(tmp,"WITH",4)==0)&&
+ ref_cur_placeholder==0){
+ override->set_master_stream_ptr(OTL_RCAST(void*,this));
+ (*ss)=new otl_select_stream
+ (override,
+ arr_size,
+ sqlstm,
+ db,
+ otl_explicit_select,
+ sqlstm_label);
+ shell->stream_type=otl_ora7_select_stream;
+ }else if(ref_cur_placeholder!=0){
+ override->set_master_stream_ptr(OTL_RCAST(void*,this));
+ (*ref_ss)=new otl_ref_select_stream
+ (override,arr_size,sqlstm,
+ ref_cur_placeholder,db,
+ sqlstm_label);
+ shell->stream_type=otl_ora7_refcur_select_stream;
+ }else{
+ (*io)=new otl_inout_stream
+ (arr_size,sqlstm,db,
+ OTL_RCAST(void*,this),
+ false,sqlstm_label);
+ (*io)->set_flush_flag(shell->flush_flag);
+ shell->stream_type=otl_ora7_io_stream;
+ }
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ shell_pt.destroy();
+ throw;
+ }
+ if((*io))(*io)->set_commit((*auto_commit_flag));
+ create_var_desc();
+ connected=1;
+ }
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ void close(const bool save_in_stream_pool=true)
+ OTL_THROWS_OTL_EXCEPTION
+#else
+ void close(void)
+ OTL_THROWS_OTL_EXCEPTION
+#endif
+ {
+ if(shell==0)return;
+ OTL_TRACE_FUNC(0x4,"otl_stream","close","")
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ if(save_in_stream_pool&&(*adb)&&
+#if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ !(otl_uncaught_exception())&&
+#elif defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ !(otl_uncaught_exception())&&
+#endif
+ (*adb)->get_throw_count()==0){
+ try{
+ this->flush();
+ this->clean(1);
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ this->clean(1);
+ throw;
+ }
+ if((*adb) && (*adb)->get_throw_count()>0){
+ (*adb)->sc.remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ return;
+ }
+#if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ if(otl_uncaught_exception()){
+ if((*adb))
+ (*adb)->sc.remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ return;
+ }
+#elif defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ if(otl_uncaught_exception()){
+ if((*adb))
+ (*adb)->sc.remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ return;
+ }
+#endif
+ (*adb)->sc.add(shell,shell->orig_sql_stm.c_str());
+ shell_pt.disconnect();
+ connected=0;
+ }else{
+ if((*adb))
+ (*adb)->sc.remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ }
+#else
+ intern_cleanup();
+ connected=0;
+#endif
+ }
+
+ otl_column_desc* describe_select(int& desc_len) OTL_NO_THROW
+ {
+ desc_len=0;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ return 0;
+ case otl_ora7_io_stream:
+ return 0;
+ case otl_ora7_select_stream:
+ (*adb)->reset_throw_count();
+ desc_len=(*ss)->get_sl_len();
+ return (*ss)->get_sl_desc();
+ case otl_ora7_refcur_select_stream:
+ (*adb)->reset_throw_count();
+ desc_len=(*ref_ss)->sl_len;
+ return (*ref_ss)->sl_desc;
+ default:
+ return 0;
+ }
+ }
+
+ int good(void) OTL_NO_THROW
+ {
+ if(!connected)return 0;
+ if((*io)||(*ss)||(*ref_ss)){
+ (*adb)->reset_throw_count();
+ return 1;
+ }else
+ return 0;
+ }
+
+ otl_stream& operator>>(otl_stream& (*pf) (otl_stream&))
+ {
+ (*pf)(*this);
+ return *this;
+ }
+
+ otl_stream& operator<<(otl_stream& (*pf) (otl_stream&))
+ {
+ (*pf)(*this);
+ return *this;
+ }
+
+ otl_stream& operator>>(otl_pl_tab_generic& tab)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ if((*io)){
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(tab);
+ OTL_TRACE_WRITE(", tab len="<<tab.len(),"operator >>","PL/SQL Tab&")
+ inc_next_ov();
+ }
+ return *this;
+ }
+
+ otl_stream& operator<<(otl_pl_tab_generic& tab)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ if((*io)){
+ OTL_TRACE_READ(", tab len="<<tab.len(),"operator <<","PL/SQL Tab&")
+ (*io)->operator<<(tab);
+ inc_next_iov();
+ }
+ return *this;
+ }
+
+#if defined(OTL_PL_TAB) && defined(OTL_STL)
+
+ otl_stream& operator>>(otl_pl_vec_generic& vec)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ if((*io)){
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(vec);
+ OTL_TRACE_WRITE(", tab len="<<vec.len(),"operator >>","PL/SQL Tab&")
+ inc_next_ov();
+ }
+ return *this;
+ }
+
+ otl_stream& operator<<(otl_pl_vec_generic& vec)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ if((*io)){
+ (*io)->operator<<(vec);
+ OTL_TRACE_READ(", tab len="<<vec.len(),"operator <<","PL/SQL Tab&")
+ inc_next_iov();
+ }
+ return *this;
+ }
+
+#endif
+
+ otl_stream& operator>>(otl_time0& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(s);
+ break;
+ }
+ return *this;
+ }
+
+ otl_stream& operator<<(const otl_time0& n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ (*io)->operator<<(n);
+ break;
+ case otl_ora7_select_stream:
+ (*ss)->operator<<(n);
+ break;
+ case otl_ora7_refcur_select_stream:
+ (*ref_ss)->operator<<(n);
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ return *this;
+ }
+
+ otl_stream& operator>>(otl_datetime& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+#if defined(OTL_ORA7) && defined(OTL_ORA7_STRING_TO_TIMESTAMP)
+ if(describe_next_out_var()->ftype==otl_var_char){
+ char tmp_str[100];
+ (*this)>>tmp_str;
+#if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_DATETIME_NULL_TO_VAL;
+ else
+ OTL_ORA7_STRING_TO_TIMESTAMP(tmp_str,s);
+#else
+ OTL_ORA7_STRING_TO_TIMESTAMP(tmp_str,s);
+#endif
+ OTL_TRACE_WRITE
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator >>",
+ "otl_datetime&");
+ return *this;
+ }else{
+ otl_time0 tmp;
+ (*this)>>tmp;
+#if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_DATETIME_NULL_TO_VAL;
+ else{
+ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100);
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour-1;
+ s.minute=tmp.minute-1;
+ s.second=tmp.second-1;
+ }
+#else
+ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100);
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour-1;
+ s.minute=tmp.minute-1;
+ s.second=tmp.second-1;
+#endif
+ OTL_TRACE_WRITE
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator >>",
+ "otl_datetime&")
+ inc_next_ov();
+ return *this;
+ }
+#else
+ otl_time0 tmp;
+ (*this)>>tmp;
+#if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_DATETIME_NULL_TO_VAL;
+ else{
+ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100);
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour-1;
+ s.minute=tmp.minute-1;
+ s.second=tmp.second-1;
+ }
+#else
+ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100);
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour-1;
+ s.minute=tmp.minute-1;
+ s.second=tmp.second-1;
+#endif
+ OTL_TRACE_WRITE
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator >>",
+ "otl_datetime&")
+ inc_next_ov();
+ return *this;
+#endif
+ }
+
+ otl_stream& operator<<(const otl_datetime& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+#if defined(OTL_ORA7) && defined(OTL_ORA7_TIMESTAMP_TO_STRING)
+ if(describe_next_in_var()->ftype==otl_var_char){
+ char tmp_str[100];
+ OTL_ORA7_TIMESTAMP_TO_STRING(s,tmp_str);
+ OTL_TRACE_READ
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator <<",
+ "otl_datetime&");
+ (*this)<<tmp_str;
+ return *this;
+ }else{
+ otl_time0 tmp;
+ tmp.year=OTL_SCAST(unsigned char, ((s.year%100)+100));
+ tmp.century=OTL_SCAST(unsigned char, ((s.year/100)+100));
+ tmp.month=OTL_SCAST(unsigned char, s.month);
+ tmp.day=OTL_SCAST(unsigned char, s.day);
+ tmp.hour=OTL_SCAST(unsigned char, (s.hour+1));
+ tmp.minute=OTL_SCAST(unsigned char, (s.minute+1));
+ tmp.second=OTL_SCAST(unsigned char, (s.second+1));
+ OTL_TRACE_READ
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator <<",
+ "otl_datetime&");
+ (*this)<<tmp;
+ inc_next_iov();
+ return *this;
+ }
+#else
+ otl_time0 tmp;
+ tmp.year=OTL_SCAST(unsigned char, ((s.year%100)+100));
+ tmp.century=OTL_SCAST(unsigned char, ((s.year/100)+100));
+ tmp.month=OTL_SCAST(unsigned char, s.month);
+ tmp.day=OTL_SCAST(unsigned char, s.day);
+ tmp.hour=OTL_SCAST(unsigned char, (s.hour+1));
+ tmp.minute=OTL_SCAST(unsigned char, (s.minute+1));
+ tmp.second=OTL_SCAST(unsigned char, (s.second+1));
+ OTL_TRACE_READ
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator <<",
+ "otl_datetime&");
+ (*this)<<tmp;
+ inc_next_iov();
+ return *this;
+#endif
+ }
+
+ otl_stream& operator>>(char& c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(c);
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(c);
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(c);
+ break;
+ }
+#if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL)
+ if((*this).is_null())
+ c=OTL_DEFAULT_CHAR_NULL_TO_VAL;
+#endif
+ OTL_TRACE_WRITE("'"<<c<<"'","operator >>","char&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(unsigned char& c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(c);
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(c);
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(c);
+ break;
+ }
+#if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL)
+ if((*this).is_null())
+ c=OTL_DEFAULT_CHAR_NULL_TO_VAL;
+#endif
+ OTL_TRACE_WRITE("'"<<c<<"'","operator >>","unsigned char&")
+ inc_next_ov();
+ return *this;
+ }
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ otl_stream& operator>>(OTL_STRING_CONTAINER& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(s);
+ break;
+ }
+
+#if defined(OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL)
+ if((*this).is_null()){
+ OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL(s);
+ }
+#elif defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_STRING_NULL_TO_VAL;
+#endif
+
+ OTL_TRACE_WRITE("\""<<s<<"\"","operator >>","OTL_STRING_CONTAINER&")
+ inc_next_ov();
+ return *this;
+ }
+#endif
+
+ otl_stream& operator>>(char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(s);
+ break;
+ }
+#if defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL)
+ );
+#endif
+ OTL_TRACE_WRITE("\""<<s<<"\"","operator >>","char*")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(unsigned char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(s);
+ break;
+ }
+#if defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL)
+ );
+#endif
+
+#if defined(OTL_UNICODE)
+ OTL_TRACE_WRITE
+ ("\""<<OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,s)<<"\"",
+ "operator >>",
+ OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*")
+#else
+ OTL_TRACE_WRITE("\""<<s<<"\"","operator >>","unsigned char*")
+#endif
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(int& n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(n);
+#else
+ (*io)->operator>><int,otl_var_int>(n);
+#endif
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(n);
+#else
+ (*ss)->operator>><int,otl_var_int>(n);
+#endif
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(n);
+#else
+ (*ref_ss)->operator>><int,otl_var_int>(n);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ n=OTL_SCAST(int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(n,"operator >>","int&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(unsigned& u)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(u);
+#else
+ (*io)->operator>><unsigned,otl_var_unsigned_int>(u);
+#endif
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(u);
+#else
+ (*ss)->operator>><unsigned,otl_var_unsigned_int>(u);
+#endif
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(u);
+#else
+ (*ref_ss)->operator>><unsigned,otl_var_unsigned_int>(u);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ u=OTL_SCAST(unsigned int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(u,"operator >>","unsigned&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(short& sh)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(sh);
+#else
+ (*io)->operator>><short,otl_var_short>(sh);
+#endif
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(sh);
+#else
+ (*ss)->operator>><short,otl_var_short>(sh);
+#endif
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(sh);
+#else
+ (*ref_ss)->operator>><short,otl_var_short>(sh);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ sh=OTL_SCAST(short int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(sh,"operator >>","short int&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(long int& l)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(l);
+#else
+ (*io)->operator>><long,otl_var_long_int>(l);
+#endif
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(l);
+#else
+ (*ss)->operator>><long,otl_var_long_int>(l);
+#endif
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(l);
+#else
+ (*ref_ss)->operator>><long,otl_var_long_int>(l);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ l=OTL_SCAST(long int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(l,"operator >>","long int&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(float& f)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(f);
+#else
+ (*io)->operator>><float,otl_var_float>(f);
+#endif
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(f);
+#else
+ (*ss)->operator>><float,otl_var_float>(f);
+#endif
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(f);
+#else
+ (*ref_ss)->operator>><float,otl_var_float>(f);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ f=OTL_SCAST(float,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(f,"operator >>","float&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(double& d)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator>>(d);
+#else
+ (*io)->operator>><double,otl_var_double>(d);
+#endif
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(d);
+#else
+ (*ss)->operator>><double,otl_var_double>(d);
+#endif
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(d);
+#else
+ (*ref_ss)->operator>><double,otl_var_double>(d);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ d=OTL_SCAST(double,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(d,"operator >>","double&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator>>(otl_long_string& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_ora7_select_stream:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ case otl_ora7_refcur_select_stream:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(s);
+ break;
+ }
+ OTL_TRACE_WRITE(" len="<<s.len(),"operator >>","otl_long_string&")
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const char c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("'"<<c<<"'","operator <<","char")
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ (*io)->operator<<(c);
+ break;
+ case otl_ora7_select_stream:
+ (*ss)->operator<<(c);
+ break;
+ case otl_ora7_refcur_select_stream:
+ (*ref_ss)->operator<<(c);
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const unsigned char c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("'"<<c<<"'","operator <<","unsigned char")
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ (*io)->operator<<(c);
+ break;
+ case otl_ora7_select_stream:
+ (*ss)->operator<<(c);
+ break;
+ case otl_ora7_refcur_select_stream:
+ (*ref_ss)->operator<<(c);
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ otl_stream& operator<<(const OTL_STRING_CONTAINER& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("\""<<s<<"\"","operator <<","OTL_STRING_CONTAINER&")
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ (*io)->operator<<(s);
+ break;
+ case otl_ora7_select_stream:
+ (*ss)->operator<<(s);
+ break;
+ case otl_ora7_refcur_select_stream:
+ (*ref_ss)->operator<<(s);
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+#endif
+
+
+ otl_stream& operator<<(const char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("\""<<s<<"\"","operator <<","char*")
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ (*io)->operator<<(s);
+ break;
+ case otl_ora7_select_stream:
+ (*ss)->operator<<(s);
+ break;
+ case otl_ora7_refcur_select_stream:
+ (*ref_ss)->operator<<(s);
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const unsigned char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+#if defined(OTL_UNICODE)
+ OTL_TRACE_READ
+ ("\""<<OTL_RCAST(const OTL_UNICODE_CHAR_TYPE*,s)<<"\"",
+ "operator <<",
+ OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*")
+#else
+ OTL_TRACE_READ("\""<<s<<"\"","operator <<","unsigned char*")
+#endif
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ (*io)->operator<<(s);
+ break;
+ case otl_ora7_select_stream:
+ (*ss)->operator<<(s);
+ break;
+ case otl_ora7_refcur_select_stream:
+ (*ref_ss)->operator<<(s);
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const int n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(n,"operator <<","int")
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(n);
+#else
+ (*io)->operator<<<int,otl_var_int>(n);
+#endif
+ break;
+ case otl_ora7_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(n);
+#else
+ (*ss)->operator<<<int,otl_var_int>(n);
+#endif
+ break;
+ case otl_ora7_refcur_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(n);
+#else
+ (*ref_ss)->operator<<<int,otl_var_int>(n);
+#endif
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const unsigned u)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(u,"operator <<","unsigned")
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(u);
+#else
+ (*io)->operator<<<unsigned,otl_var_unsigned_int>(u);
+#endif
+ break;
+ case otl_ora7_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(u);
+#else
+ (*ss)->operator<<<unsigned,otl_var_unsigned_int>(u);
+#endif
+ break;
+ case otl_ora7_refcur_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(u);
+#else
+ (*ref_ss)->operator<<<unsigned,otl_var_unsigned_int>(u);
+#endif
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const short sh)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(sh,"operator <<","short int")
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(sh);
+#else
+ (*io)->operator<<<short,otl_var_short>(sh);
+#endif
+ break;
+ case otl_ora7_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(sh);
+#else
+ (*ss)->operator<<<short,otl_var_short>(sh);
+#endif
+ break;
+ case otl_ora7_refcur_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(sh);
+#else
+ (*ref_ss)->operator<<<short,otl_var_short>(sh);
+#endif
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const long int l)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(l,"operator <<","long int")
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(l);
+#else
+ (*io)->operator<<<long,otl_var_long_int>(l);
+#endif
+ break;
+ case otl_ora7_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(l);
+#else
+ (*ss)->operator<<<long,otl_var_long_int>(l);
+#endif
+ break;
+ case otl_ora7_refcur_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(l);
+#else
+ (*ref_ss)->operator<<<long,otl_var_long_int>(l);
+#endif
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const float f)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(f,"operator <<","float")
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(f);
+#else
+ (*io)->operator<<<float,otl_var_float>(f);
+#endif
+ break;
+ case otl_ora7_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(f);
+#else
+ (*ss)->operator<<<float,otl_var_float>(f);
+#endif
+ break;
+ case otl_ora7_refcur_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(f);
+#else
+ (*ref_ss)->operator<<<float,otl_var_float>(f);
+#endif
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const double d)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(d,"operator <<","double")
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*io)->operator<<(d);
+#else
+ (*io)->operator<<<double,otl_var_double>(d);
+#endif
+ break;
+ case otl_ora7_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(d);
+#else
+ (*ss)->operator<<<double,otl_var_double>(d);
+#endif
+ break;
+ case otl_ora7_refcur_select_stream:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(d);
+#else
+ (*ref_ss)->operator<<<double,otl_var_double>(d);
+#endif
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const otl_null& n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("NULL","operator <<","otl_null&")
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ (*io)->operator<<(n);
+ break;
+ case otl_ora7_select_stream:
+ (*ss)->operator<<(n);
+ break;
+ case otl_ora7_refcur_select_stream:
+ (*ref_ss)->operator<<(n);
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const otl_long_string& d)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(" len="<<d.len(),"operator <<","otl_long_string&")
+ switch(shell->stream_type){
+ case otl_ora7_no_stream:
+ break;
+ case otl_ora7_io_stream:
+ (*io)->operator<<(d);
+ break;
+ case otl_ora7_select_stream:
+ (*ss)->operator<<(d);
+ break;
+ case otl_ora7_refcur_select_stream:
+ (*ref_ss)->operator<<(d);
+ if(!(*ov)&&(*ref_ss)->sl) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+private:
+
+ otl_stream& operator=(const otl_stream&)
+ {
+ return *this;
+ }
+
+ otl_stream(const otl_stream&):
+ shell(0),
+ shell_pt(),
+ connected(0),
+ ref_ss(0),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ override(0),
+ end_marker(0),
+ oper_int_called(0),
+ last_eof_rc(0),
+ last_oper_was_read_op(0),
+ buf_size_(0)
+ {
+ }
+
+#if !defined(OTL_STREAM_NO_PRIVATE_BOOL_OPERATORS)
+ otl_stream& operator>>(bool&)
+ OTL_NO_THROW
+ {
+ return *this;
+ }
+
+ otl_stream& operator<<(const bool)
+ OTL_NO_THROW
+ {
+ return *this;
+ }
+
+#endif
+
+#if !defined(OTL_STREAM_NO_PRIVATE_UNSIGNED_LONG_OPERATORS)
+ otl_stream& operator>>(unsigned long int&)
+ OTL_NO_THROW
+ {
+ return *this;
+ }
+
+ otl_stream& operator<<(const unsigned long int)
+ OTL_NO_THROW
+ {
+ return *this;
+ }
+#endif
+
+};
+
+inline otl_connect& operator>>(otl_connect& connect, otl_stream& s)
+{
+ const char* cmd=connect.getCmd();
+ const char* invalid_cmd="*** INVALID COMMAND ***";
+ if(!cmd)
+ cmd=invalid_cmd;
+ s.open(s.getBufSize(),cmd,connect);
+ return connect;
+}
+
+#if (defined(OTL_STL)||defined(OTL_VALUE_TEMPLATE_ON)) && defined(OTL_VALUE_TEMPLATE)
+template <OTL_TYPE_NAME TData>
+otl_stream& operator<<(otl_stream& s, const otl_value<TData>& var)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ if(var.ind)
+ s<<otl_null();
+ else
+ s<<var.v;
+ return s;
+}
+
+template <OTL_TYPE_NAME TData>
+otl_stream& operator>>(otl_stream& s, otl_value<TData>& var)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ s>>var.v;
+ if(s.is_null())
+ var.ind=true;
+ else
+ var.ind=false;
+ return s;
+}
+
+#endif
+
+typedef otl_tmpl_nocommit_stream
+<otl_stream,
+ otl_connect,
+ otl_exception> otl_nocommit_stream;
+
+#if defined(OTL_BIGINT) && defined(OTL_STR_TO_BIGINT) && \
+ defined(OTL_BIGINT_TO_STR)
+inline otl_stream& operator>>(otl_stream& s, OTL_BIGINT& n)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ char temp_val[otl_bigint_str_size];
+
+ s>>temp_val;
+ if(s.is_null()){
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if(s.is_null())
+ n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ return s;
+ }
+ OTL_STR_TO_BIGINT(temp_val,n)
+ return s;
+}
+
+inline otl_stream& operator<<(otl_stream& s, const OTL_BIGINT n)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ char temp_val[otl_bigint_str_size];
+ OTL_BIGINT_TO_STR(n,temp_val);
+ s<<temp_val;
+ return s;
+}
+#elif defined(OTL_BIGINT) && defined(OTL_ORA_MAP_BIGINT_TO_LONG)
+inline otl_stream& operator>>(otl_stream& s, OTL_BIGINT& n)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ long temp_val;
+
+ s>>temp_val;
+ if(s.is_null()){
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if(s.is_null())
+ n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ return s;
+ }
+ n=OTL_SCAST(OTL_BIGINT,temp_val);
+ return s;
+}
+
+inline otl_stream& operator<<(otl_stream& s, const OTL_BIGINT n)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ long temp_val=OTL_SCAST(long,n);
+ s<<temp_val;
+ return s;
+}
+
+#endif
+
+inline otl_stream& endr(otl_stream& s)
+{
+ s.check_end_of_row();
+ return s;
+}
+
+OTL_ORA7_NAMESPACE_END
+#endif
+
+// ==================== OTL-Adapter for Oracle 8 =====================
+#if defined(OTL_ORA8)
+#if defined(__STDC__)
+#define __STDC__DEFINED
+#else
+#define __STDC__ 1 // making OCI function prototypes show up in oci.h
+#endif
+#if defined(OTL_ORA_TEXT_ON)
+#define text OTL_ORA_TEXT
+#endif
+#include <oci.h>
+
+#if !defined(OTL_ORA_DOES_NOT_UNDEF_MIN_MAX)
+
+#if defined(min)
+#undef min
+#endif
+
+#if defined(max)
+#undef max
+#endif
+
+#endif
+
+#define OTL_UTF8_BYTES_PER_CHAR (4)
+
+#if defined(OTL_ORA8_PROC)
+extern "C" {
+#include <sql2oci.h>
+}
+#endif
+
+OTL_ORA8_NAMESPACE_BEGIN
+
+const int inVarChar2=1;
+const int inNumber=2;
+const int inLong=8;
+const int inRowId=104;
+const int inDate=12;
+const int inRaw=23;
+const int inLongRaw=24;
+const int inChar=96;
+#if defined(OTL_ORA10G)||defined(OTL_ORA10G_R2)
+const int inBFloat=SQLT_IBFLOAT;
+const int inBDouble=SQLT_IBDOUBLE;
+#endif
+const int inMslabel=105;
+const int inUserDefinedType=108;
+const int inRef=111;
+const int inCLOB=112;
+const int inBLOB=113;
+
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+const int inTimestamp=SQLT_TIMESTAMP;
+const int inTimestamp_TZ=SQLT_TIMESTAMP_TZ;
+const int inTimestamp_LTZ=SQLT_TIMESTAMP_LTZ;
+const int inIntervalYM=SQLT_INTERVAL_YM;
+const int inIntervalDS=SQLT_INTERVAL_DS;
+#endif
+
+const int extVarChar2=1;
+const int extNumber=2;
+const int extInt=3;
+const int extFloat=4;
+#if defined(OTL_ORA_MAP_STRINGS_TO_CHARZ)
+const int extCChar=97;
+#else
+const int extCChar=5;
+#endif
+const int extVarNum=6;
+const int extLong=8;
+const int extVarChar=9;
+const int extRowId=11;
+const int extDate=12;
+const int extVarRaw=15;
+const int extRaw=extVarRaw;
+const int extLongRaw=24;
+const int extUInt=68;
+const int extLongVarChar=94;
+const int extLongVarRaw=95;
+const int extChar=96;
+const int extCharZ=97;
+const int extMslabel=105;
+const int extCLOB=inCLOB;
+const int extBLOB=inBLOB;
+
+#if (defined(OTL_ORA10G)||defined(OTL_ORA10G_R2))&&!defined(OTL_ORA_LEGACY_NUMERIC_TYPES)
+const int extBFloat=SQLT_BFLOAT;
+const int extBDouble=SQLT_BDOUBLE;
+#endif
+
+
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+const int extTimestamp=SQLT_TIMESTAMP;
+const int extTimestamp_TZ=SQLT_TIMESTAMP_TZ;
+const int extTimestamp_LTZ=SQLT_TIMESTAMP_LTZ;
+#endif
+
+
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+typedef otl_datetime otl_time0;
+#else
+typedef otl_oracle_date otl_time0;
+#endif
+
+
+class otl_exc{
+public:
+ unsigned char msg[1000];
+ int code;
+ char sqlstate[32];
+
+#if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET)
+ int error_offset;
+#endif
+
+#if defined(OTL_EXTENDED_EXCEPTION)
+ char** msg_arr;
+ char** sqlstate_arr;
+ int* code_arr;
+ int arr_len;
+#endif
+
+ enum{disabled=0,enabled=1};
+
+ otl_exc():
+ msg(),
+ code(0),
+ sqlstate()
+#if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET)
+ ,error_offset(-1)
+#endif
+#if defined(OTL_EXTENDED_EXCEPTION)
+ ,msg_arr(0),
+ sqlstate_arr(0),
+ code_arr(0),
+ arr_len(0)
+#endif
+ {
+ sqlstate[0]=0;
+ msg[0]=0;
+ }
+
+ virtual ~otl_exc(){}
+
+ void init(const char* amsg, const int acode)
+ {
+ OTL_STRCPY_S(OTL_RCAST(char*,msg),sizeof(msg),amsg);
+ code=acode;
+#if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET)
+ error_offset=-1;
+#endif
+#if defined(OTL_EXTENDED_EXCEPTION)
+ msg_arr=0;
+ sqlstate_arr=0;
+ code_arr=0;
+ arr_len=0;
+#endif
+ }
+
+};
+
+class otl_cur;
+class otl_var;
+
+class otl_conn{
+private:
+
+ friend class otl_cur;
+ friend class otl_var;
+
+ OCIEnv *envhp; // OCI environment handle
+ OCIServer *srvhp; // OCI Server handle
+ OCIError *errhp; // OCI Error handle
+ OCISvcCtx *svchp; // OCI Service context handle
+ OCISession *authp; // OCI Session handle
+ int auto_commit;
+ int extern_lda;
+ int attached;
+ int in_session;
+ int char_set_;
+ int session_begin_count;
+ int session_mode_;
+ int ext_cred;
+ int last_status;
+ char* xa_server_external_name;
+ char* xa_server_internal_name;
+
+#if defined(OTL_ORA_OCI_ENV_CREATE)
+ bool threaded_mode;
+#endif
+
+public:
+
+#if defined(OTL_ORA_OCI_ENV_CREATE)
+ void set_threaded_mode(const bool athreaded_mode)
+ {
+ threaded_mode=athreaded_mode;
+ }
+#endif
+
+
+ void cleanup(void)
+ {
+ session_end();
+ server_detach();
+ }
+
+ int get_session_begin_count() const
+ {
+ return session_begin_count;
+ }
+
+ int get_extern_lda() const
+ {
+ return extern_lda;
+ }
+
+ int get_last_status() const
+ {
+ return last_status;
+ }
+
+ int get_auto_commit() const
+ {
+ return auto_commit;
+ }
+
+ OCIEnv* get_envhp()
+ {
+ return envhp;
+ }
+
+ OCIError* get_errhp()
+ {
+ return errhp;
+ }
+
+ OCISvcCtx* get_svchp()
+ {
+ return svchp;
+ }
+
+ OCIServer* get_srvhp()
+ {
+ return srvhp;
+ }
+
+ OCISession* get_authp()
+ {
+ return authp;
+ }
+
+ int get_char_set() const
+ {
+ return char_set_;
+ }
+
+ int get_connection_type(void)
+ {
+ return 0;
+ }
+
+#if !defined(OTL_ORA_OCI_ENV_CREATE)
+ static int initialize(const int threaded_mode=0)
+ {
+ int status;
+ int mode;
+ if(threaded_mode)
+ mode=OCI_THREADED;
+ else
+ mode=OCI_DEFAULT;
+ status=OCIInitialize
+ (OTL_SCAST(ub4,mode),
+ OTL_RCAST(dvoid *,0),
+ 0,
+ 0,
+ 0);
+ if(status!=OCI_SUCCESS)
+ return 0;
+ else
+ return 1;
+#else
+ static int initialize(const int /*threaded_mode*/)
+ {
+ return 1;
+#endif
+ }
+
+ otl_conn():
+ envhp(0),
+ srvhp(0),
+ errhp(0),
+ svchp(0),
+ authp(0),
+ auto_commit(0),
+ extern_lda(0),
+ attached(0),
+ in_session(0),
+ char_set_(SQLCS_IMPLICIT),
+ session_begin_count(0),
+ session_mode_(OCI_DEFAULT),
+ ext_cred(0),
+ last_status(OCI_SUCCESS),
+ xa_server_external_name(0),
+ xa_server_internal_name(0)
+#if defined(OTL_ORA_OCI_ENV_CREATE)
+ ,threaded_mode(false)
+#endif
+ {
+ }
+
+#if defined(OTL_ORA_OCI_ENV_CREATE)
+ void set_connect_mode(bool mode)
+ {
+ threaded_mode=mode;
+ }
+#endif
+
+ void set_char_set(const int char_set)
+ {
+ char_set_=char_set;
+ }
+
+ void set_xa_server_external_name(const char* name)
+ {
+ if(xa_server_external_name){
+ delete[] xa_server_external_name;
+ xa_server_external_name=0;
+ }
+ size_t len=strlen(name)+1;
+ xa_server_external_name=new char[len];
+ OTL_STRCPY_S(xa_server_external_name,len,name);
+ }
+
+ void set_xa_server_internal_name(const char* name)
+ {
+ if(xa_server_internal_name){
+ delete[] xa_server_internal_name;
+ xa_server_internal_name=0;
+ }
+ size_t len=strlen(name)+1;
+ xa_server_internal_name=new char[len];
+ OTL_STRCPY_S(xa_server_internal_name,len,name);
+ }
+
+ void delete_xa_strings(void )
+ {
+ if(xa_server_external_name){
+ delete[] xa_server_external_name;
+ xa_server_external_name=0;
+ }
+ if(xa_server_internal_name){
+ delete[] xa_server_internal_name;
+ xa_server_internal_name=0;
+ }
+ }
+
+ virtual ~otl_conn()
+ {
+ delete_xa_strings();
+ }
+
+ void set_timeout(const int /*atimeout*/=0){}
+ void set_cursor_type(const int /*acursor_type*/=0){}
+
+ int cancel(void)
+ {int status;
+ status=OCIBreak(srvhp,errhp);
+ if(status)
+ return 0;
+ else
+ return 1;
+ }
+
+ int server_attach(const char* tnsname)
+ {int& status=last_status;
+
+ envhp=0;
+ srvhp=0;
+ errhp=0;
+ svchp=0;
+ authp=0;
+ extern_lda=0;
+ attached=0;
+ in_session=0;
+ session_begin_count=0;
+
+#if !defined(OTL_ORA_OCI_ENV_CREATE)
+ status=OCIEnvInit
+ (OTL_RCAST(OCIEnv**,&envhp),
+ OCI_DEFAULT,
+ 0,
+ 0);
+#else
+ status=OCIEnvCreate
+ (OTL_RCAST(OCIEnv**,&envhp),
+#if defined(OTL_ORA_OCI_ENV_CREATE_MODE)
+ OTL_ORA_OCI_ENV_CREATE_MODE,
+#else
+ threaded_mode?OCI_THREADED:OCI_DEFAULT,
+#endif
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0);
+#endif
+
+ if(status)return 0;
+
+#if defined(__GNUC__) && (__GNUC__>=4)
+ void* temp_errhp=&errhp;
+#endif
+ status=OCIHandleAlloc
+ (OTL_RCAST(dvoid*,envhp),
+#if defined(__GNUC__) && (__GNUC__>=4)
+ OTL_RCAST(dvoid**,temp_errhp),
+#else
+ OTL_RCAST(dvoid**,&errhp),
+#endif
+ OCI_HTYPE_ERROR,
+ 0,
+ 0);
+ if(status)return 0;
+
+#if defined(__GNUC__) && (__GNUC__>=4)
+ void* temp_srvhp=&srvhp;
+#endif
+ status=OCIHandleAlloc
+ (OTL_RCAST(dvoid*,envhp),
+#if defined(__GNUC__) && (__GNUC__>=4)
+ OTL_RCAST(dvoid**,temp_srvhp),
+#else
+ OTL_RCAST(dvoid**,&srvhp),
+#endif
+ OCI_HTYPE_SERVER,
+ 0,
+ 0);
+ if(status)return 0;
+
+#if defined(__GNUC__) && (__GNUC__>=4)
+ void * temp_svchp=&svchp;
+#endif
+ status=OCIHandleAlloc
+ (OTL_RCAST(dvoid*,envhp),
+#if defined(__GNUC__) && (__GNUC__>=4)
+ OTL_RCAST(dvoid**,temp_svchp),
+#else
+ OTL_RCAST(dvoid**,&svchp),
+#endif
+ OCI_HTYPE_SVCCTX,
+ 0,
+ 0);
+ if(status)return 0;
+
+ status=OCIServerAttach
+ (srvhp,
+ errhp,
+ tnsname==0?OTL_RCAST(text*,OTL_CCAST(char*,"")):
+ OTL_RCAST(text*,OTL_CCAST(char*,tnsname)),
+ tnsname==0?0:OTL_SCAST(sb4,strlen(OTL_CCAST(char*,tnsname))),
+ 0);
+ if(status)return 0;
+ status=OCIAttrSet
+ (OTL_RCAST(dvoid*,svchp),
+ OCI_HTYPE_SVCCTX,
+ OTL_RCAST(dvoid*,srvhp),
+ 0,
+ OCI_ATTR_SERVER,
+ OTL_RCAST(OCIError*,errhp));
+ if(status)return 0;
+
+ if(xa_server_external_name!=0 && xa_server_internal_name!=0){
+ status=OCIAttrSet
+ (OTL_RCAST(dvoid*,srvhp),
+ OCI_HTYPE_SERVER,
+ OTL_RCAST(dvoid*,xa_server_external_name),
+ 0,
+ OCI_ATTR_EXTERNAL_NAME,
+ errhp);
+ if(status)return 0;
+
+ status=OCIAttrSet
+ (OTL_RCAST(dvoid*,srvhp),
+ OCI_HTYPE_SERVER,
+ OTL_RCAST(dvoid*,xa_server_internal_name),
+ 0,
+ OCI_ATTR_INTERNAL_NAME,
+ errhp);
+ if(status)return 0;
+ }
+
+#if defined(__GNUC__) && (__GNUC__>=4)
+ void* temp_authp=&authp;
+#endif
+ status=OCIHandleAlloc
+ (OTL_RCAST(dvoid*,envhp),
+#if defined(__GNUC__) && (__GNUC__>=4)
+ OTL_RCAST(dvoid **,temp_authp),
+#else
+ OTL_RCAST(dvoid **,&authp),
+#endif
+ OTL_SCAST(ub4,OCI_HTYPE_SESSION),
+ 0,
+ 0);
+ if(status)return 0;
+
+ attached=1;
+ return 1;
+
+ }
+
+ int session_begin(const int aauto_commit)
+ {int& status=last_status;
+ int cred_type;
+
+ if(!attached)return 0;
+ if(session_begin_count==0)return 0;
+
+ if(ext_cred)
+ cred_type=OCI_CRED_EXT;
+ else
+ cred_type=OCI_CRED_RDBMS;
+ status=OCISessionBegin
+ (svchp,
+ errhp,
+ authp,
+ cred_type,
+ OTL_SCAST(ub4,session_mode_));
+ if(status!=OCI_SUCCESS &&
+ status!=OCI_SUCCESS_WITH_INFO)
+ return 0;
+
+ in_session=1;
+ auto_commit=aauto_commit;
+ ++session_begin_count;
+ return 1;
+
+ }
+
+ int session_begin
+ (const char* userid,
+ const char* password,
+ const int aauto_commit,
+ const int session_mode=OCI_DEFAULT)
+ {int& status=last_status;
+ int cred_type;
+
+ if(!attached)return 0;
+
+ status=OCIAttrSet
+ (OTL_RCAST(dvoid*,authp),
+ OTL_SCAST(ub4,OCI_HTYPE_SESSION),
+ OTL_RCAST(dvoid*,OTL_CCAST(char*,userid)),
+ OTL_SCAST(ub4,strlen(OTL_CCAST(char*,userid))),
+ OTL_SCAST(ub4,OCI_ATTR_USERNAME),
+ errhp);
+ if(status)return 0;
+
+ status=OCIAttrSet
+ (OTL_RCAST(dvoid*,authp),
+ OTL_SCAST(ub4,OCI_HTYPE_SESSION),
+ OTL_RCAST(dvoid*,OTL_CCAST(char*,password)),
+ OTL_SCAST(ub4,strlen(OTL_CCAST(char*,password))),
+ OTL_SCAST(ub4,OCI_ATTR_PASSWORD),
+ errhp);
+ if(status)return 0;
+
+ cred_type=OCI_CRED_RDBMS;
+
+ if(userid[0]==0&&password[0]==0){
+ ext_cred=1;
+ cred_type=OCI_CRED_EXT;
+ }else{
+ ext_cred=0;
+ cred_type=OCI_CRED_RDBMS;
+ }
+
+ session_mode_=session_mode;
+ status=OCISessionBegin
+ (svchp,
+ errhp,
+ authp,
+ cred_type,
+ OTL_SCAST(ub4,session_mode_));
+ if(status!=OCI_SUCCESS &&
+ status!=OCI_SUCCESS_WITH_INFO)
+ return 0;
+
+ status=OCIAttrSet
+ (OTL_RCAST(dvoid*,svchp),
+ OTL_SCAST(ub4,OCI_HTYPE_SVCCTX),
+ OTL_RCAST(dvoid *,authp),
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_SESSION),
+ errhp);
+ if(status)return 0;
+
+ in_session=1;
+ auto_commit=aauto_commit;
+ ++session_begin_count;
+ return 1;
+
+ }
+
+#if defined(OTL_ORA8I) || defined(OTL_ORA9I)
+ int change_password
+ (const char* user_name,
+ const char* password,
+ const char* new_password)
+ {int& status=last_status;
+
+ OCIAttrSet
+ (OTL_RCAST(dvoid*,svchp),
+ OTL_SCAST(ub4,OCI_HTYPE_SVCCTX),
+ OTL_RCAST(dvoid *,authp),
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_SESSION),
+ errhp);
+
+ status=OCIPasswordChange
+ (svchp,
+ errhp,
+ OTL_RCAST(text*,OTL_CCAST(char*,user_name)),
+ OTL_SCAST(ub4,strlen(user_name)),
+ OTL_RCAST(text*,OTL_CCAST(char*,password)),
+ OTL_SCAST(ub4,strlen(password)),
+ OTL_RCAST(text*,OTL_CCAST(char*,new_password)),
+ OTL_SCAST(ub4,strlen(new_password)),
+ OCI_AUTH);
+ if(status)
+ return 0;
+ else
+ return 1;
+
+ }
+#endif
+
+ int server_detach(void)
+ {int rc=0;
+ if(attached){
+ OCIServerDetach(srvhp,errhp,OTL_SCAST(ub4,OCI_DEFAULT));
+ rc=1;
+ }
+ if(authp!=0)OCIHandleFree(OTL_RCAST(dvoid*,authp),
+ OTL_SCAST(ub4,OCI_HTYPE_SESSION));
+ if(errhp!=0)OCIHandleFree(OTL_RCAST(dvoid*,errhp),
+ OTL_SCAST(ub4,OCI_HTYPE_ERROR));
+ if(svchp!=0)OCIHandleFree(OTL_RCAST(dvoid*,svchp),
+ OTL_SCAST(ub4,OCI_HTYPE_SVCCTX));
+ if(srvhp!=0)OCIHandleFree(OTL_RCAST(dvoid*,srvhp),
+ OTL_SCAST(ub4,OCI_HTYPE_SERVER));
+ if(envhp!=0)OCIHandleFree(OTL_RCAST(dvoid*,envhp),
+ OTL_SCAST(ub4,OCI_HTYPE_ENV));
+ auto_commit=0;
+ attached=0;
+ in_session=0;
+ envhp=0;
+ srvhp=0;
+ errhp=0;
+ svchp=0;
+ authp=0;
+ delete_xa_strings();
+ return rc;
+ }
+
+ int session_end(void)
+ {int& status=last_status;
+ if(!in_session)return 0;
+ status=OCISessionEnd(svchp,errhp,authp,0);
+ if(status)return 0;
+
+ in_session=0;
+ auto_commit=0;
+ return 1;
+ }
+
+ int auto_commit_on(void)
+ {
+ auto_commit=1;
+ return 1;
+ }
+
+ int auto_commit_off(void)
+ {
+ auto_commit=0;
+ return 1;
+ }
+
+ int rlogon(const char* connect_str,const int aauto_commit)
+ {
+ int status;
+ char username[256];
+ char passwd[256];
+ char tnsname[1024];
+ char* tnsname_ptr=0;
+ char* username_ptr=username;
+ char* c=OTL_CCAST(char*,connect_str);
+ char* passwd_ptr=passwd;
+ char prev_c=' ';
+
+ auto_commit=aauto_commit;
+
+ username[0]=0;
+ passwd[0]=0;
+ tnsname[0]=0;
+
+ while(*c&&*c!='/'&&(OTL_SCAST(unsigned,username_ptr-username)<
+ sizeof(username)-1)){
+ *username_ptr=*c;
+ ++c;
+ ++username_ptr;
+ }
+ *username_ptr=0;
+ if(*c=='/')++c;
+ prev_c=' ';
+ while(*c && !(*c=='@' && prev_c!='\\') &&
+ (OTL_SCAST(unsigned,passwd_ptr-passwd)<sizeof(passwd)-1)){
+ if(prev_c=='\\')--passwd_ptr;
+ *passwd_ptr=*c;
+ prev_c=*c;
+ ++c;
+ ++passwd_ptr;
+ }
+ *passwd_ptr=0;
+
+ if(*c=='@'){
+ ++c;
+ tnsname_ptr=tnsname;
+ while(*c&&(OTL_SCAST(unsigned,tnsname_ptr-tnsname)<sizeof(tnsname)-1)){
+ *tnsname_ptr=*c;
+ ++c;
+ ++tnsname_ptr;
+ }
+ *tnsname_ptr=0;
+ }
+
+ envhp=0;
+ srvhp=0;
+ errhp=0;
+ svchp=0;
+ authp=0;
+ extern_lda=0;
+ attached=0;
+ in_session=0;
+
+ OTL_TRACE_RLOGON_ORA8
+ (0x1,
+ "otl_connect",
+ "rlogon",
+ tnsname,
+ username,
+ passwd,
+ auto_commit)
+
+ status=server_attach(tnsname);
+ if(!status)return 0;
+
+ status=session_begin(username,passwd,aauto_commit);
+ if(!status)return 0;
+
+ return 1;
+
+ }
+
+ int ext_logon(OCIEnv *a_envhp,OCISvcCtx *a_svchp,const int aauto_commit=0)
+ {int& status=last_status;
+
+ envhp=a_envhp;
+ svchp=a_svchp;
+ errhp=0;
+ srvhp=0;
+ authp=0;
+ extern_lda=1;
+ auto_commit=aauto_commit;
+
+#if defined(__GNUC__) && (__GNUC__>=4)
+ void* temp_errhp=&errhp;
+#endif
+ status=OCIHandleAlloc
+ (OTL_RCAST(dvoid*,envhp),
+#if defined(__GNUC__) && (__GNUC__>=4)
+ OTL_RCAST(dvoid**,temp_errhp),
+#else
+ OTL_RCAST(dvoid**,&errhp),
+#endif
+ OCI_HTYPE_ERROR,
+ 0,
+ 0);
+ if(status)return 0;
+
+ return 1;
+
+ }
+
+ int logoff(void)
+ {
+ int rc;
+ if(extern_lda){
+ OCIHandleFree(OTL_RCAST(dvoid*,errhp), OTL_SCAST(ub4,OCI_HTYPE_ERROR));
+ envhp=0;
+ svchp=0;
+ errhp=0;
+ extern_lda=0;
+ }else{
+ rc=session_end();
+ if(!rc)return 0;
+ rc=server_detach();
+ if(!rc)return 0;
+ }
+ auto_commit=0;
+ return 1;
+ }
+
+ void error(otl_exc& exception_struct)
+ {sb4 errcode;
+ size_t len;
+ OCIErrorGet
+ (OTL_RCAST(dvoid*,errhp),
+ OTL_SCAST(ub4,1),
+ 0,
+ &errcode,
+ OTL_RCAST(text*,exception_struct.msg),
+ OTL_SCAST(ub4,sizeof(exception_struct.msg)),
+ OCI_HTYPE_ERROR);
+ exception_struct.code=errcode;
+ len=strlen(OTL_RCAST(char*,exception_struct.msg));
+ exception_struct.msg[len]=0;
+ }
+
+ int commit(void)
+ {
+ last_status=OCITransCommit(svchp,errhp,OTL_SCAST(ub4,OCI_DEFAULT));
+ return !last_status;
+ }
+
+#if defined(OTL_ORA10G_R2)
+
+ int commit_nowait(void)
+ {
+#if defined(OCI_TRANS_WRITENOWAIT)
+ last_status=OCITransCommit
+ (svchp,
+ errhp,
+ OTL_SCAST(ub4,OCI_TRANS_WRITENOWAIT));
+#else
+ last_status=OCITransCommit
+ (svchp,
+ errhp,
+ OTL_SCAST(ub4,0x00000008));
+#endif
+ return !last_status;
+ }
+
+#endif
+
+ int rollback(void)
+ {
+ last_status=OCITransRollback(svchp,errhp,OTL_SCAST(ub4,OCI_DEFAULT));
+ return !last_status;
+ }
+
+private:
+
+ otl_conn(const otl_conn&):
+ envhp(0),
+ srvhp(0),
+ errhp(0),
+ svchp(0),
+ authp(0),
+ auto_commit(0),
+ extern_lda(0),
+ attached(0),
+ in_session(0),
+ char_set_(SQLCS_IMPLICIT),
+ session_begin_count(0),
+ session_mode_(OCI_DEFAULT),
+ ext_cred(0),
+ last_status(OCI_SUCCESS),
+ xa_server_external_name(0),
+ xa_server_internal_name(0)
+#if defined(OTL_ORA_OCI_ENV_CREATE)
+ ,threaded_mode(false)
+#endif
+ {
+ }
+
+ otl_conn& operator=(const otl_conn&)
+ {
+ return *this;
+ }
+
+};
+
+class otl_cur0{
+public:
+ virtual ~otl_cur0(){}
+};
+
+class otl_cur;
+class otl_inout_stream;
+class otl_refcur_stream;
+class otl_ref_select_stream;
+
+class otl_var{
+private:
+
+ friend class otl_cur;
+ friend class otl_inout_stream;
+ friend class otl_refcur_stream;
+ friend class otl_ref_select_stream;
+
+ ub1* p_v;
+ sb2* p_ind;
+ ub2* p_rlen;
+ ub2* p_rcode;
+ int ftype;
+ int array_size;
+ int elem_size;
+ bool nls_flag;
+ OCILobLocator** lob;
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ OCIDateTime** timestamp;
+#endif
+ OCIStmt* cda;
+ otl_conn* connect;
+ ub1* buf;
+ int buf_len;
+ int ext_buf_flag;
+ int act_elem_size;
+ ub4 max_tab_len;
+ ub4 cur_tab_len;
+ int pl_tab_flag;
+ int lob_stream_flag;
+ int vparam_type;
+ int lob_len;
+ int lob_pos;
+ int lob_ftype;
+ int otl_adapter;
+ bool lob_stream_mode;
+ sb4 unicode_var_len;
+ ub2 csid;
+ ub1 csfrm;
+ ub4 read_blob_amt;
+ ub4 total_read_blob_amt;
+ bool charz_flag;
+ bool select_stm_flag;
+
+public:
+
+ int get_otl_adapter() const {return otl_adapter;}
+ OCIStmt* get_cda(){return cda;}
+ OCIStmt** get_cda_ptr(){return &cda;}
+ void set_nls_flag(const bool anls_flag)
+ {
+ nls_flag=anls_flag;
+ }
+
+ void set_lob_stream_mode(const bool alob_stream_mode)
+ {
+ lob_stream_mode=alob_stream_mode;
+ }
+
+ void set_vparam_type(const int avparam_type)
+ {
+ vparam_type=avparam_type;
+ }
+
+ void set_charz_flag(const bool acharz_flag)
+ {
+ charz_flag=acharz_flag;
+ }
+
+ otl_var():
+ p_v(0),
+ p_ind(0),
+ p_rlen(0),
+ p_rcode(0),
+ ftype(0),
+ array_size(0),
+ elem_size(0),
+ nls_flag(false),
+ lob(0),
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ timestamp(0),
+#endif
+ cda(0),
+ connect(0),
+ buf(0),
+ buf_len(0),
+ ext_buf_flag(0),
+ act_elem_size(0),
+ max_tab_len(0),
+ cur_tab_len(0),
+ pl_tab_flag(0),
+ lob_stream_flag(0),
+ vparam_type(-1),
+ lob_len(0),
+ lob_pos(0),
+ lob_ftype(0),
+ otl_adapter(otl_ora8_adapter),
+ lob_stream_mode(false),
+ unicode_var_len(0),
+ csid(0),
+ csfrm(SQLCS_IMPLICIT),
+ read_blob_amt(0),
+ total_read_blob_amt(0),
+ charz_flag(false),
+ select_stm_flag(false)
+ {
+ }
+
+ virtual ~otl_var()
+ {int i;
+ if(ftype==otl_var_refcur&&cda!=0){
+ OCIHandleFree(OTL_RCAST(dvoid*,cda),OCI_HTYPE_STMT);
+ cda=0;
+ }
+ if(ftype==otl_var_blob||(ftype==otl_var_clob&&lob!=0)){
+ for(i=0;i<array_size;++i)
+ OCIDescriptorFree(OTL_RCAST(dvoid*,lob[i]),
+ OTL_SCAST(ub4,OCI_DTYPE_LOB));
+ }
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ if((ftype==otl_var_timestamp ||
+ ftype==otl_var_tz_timestamp ||
+ ((ftype==otl_var_ltz_timestamp)&&
+ timestamp!=0))){
+ ub4 dtype=0;
+ switch(ftype){
+ case otl_var_timestamp:
+ dtype=OCI_DTYPE_TIMESTAMP;
+ break;
+ case otl_var_ltz_timestamp:
+ dtype=OCI_DTYPE_TIMESTAMP_LTZ;
+ break;
+ case otl_var_tz_timestamp:
+ dtype=OCI_DTYPE_TIMESTAMP_TZ;
+ break;
+ }
+ for(i=0;i<array_size;++i)
+ OCIDescriptorFree(OTL_RCAST(dvoid*,timestamp[i]),dtype);
+ }
+#endif
+ delete[] p_v;
+ delete[] p_ind;
+ delete[] p_rlen;
+ delete[] p_rcode;
+ if(!ext_buf_flag)
+ delete[] buf;
+ }
+
+ int write_dt(void* trg,
+ const void* src,
+ const int
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+#else
+ sz
+#endif
+ )
+ {
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ OCIDateTime* trg_ptr=OTL_RCAST(OCIDateTime*,trg);
+ otl_datetime* src_ptr=OTL_RCAST(otl_datetime*,OTL_CCAST(void*,src));
+ int rc=0;
+ if(ftype!=otl_var_tz_timestamp){
+ rc=OCIDateTimeConstruct
+ (connect->envhp,
+ connect->errhp,
+ trg_ptr,
+ OTL_SCAST(sb2,src_ptr->year),
+ OTL_SCAST(ub1,src_ptr->month),
+ OTL_SCAST(ub1,src_ptr->day),
+ OTL_SCAST(ub1,src_ptr->hour),
+ OTL_SCAST(ub1,src_ptr->minute),
+ OTL_SCAST(ub1,src_ptr->second),
+ OTL_SCAST
+ (ub4,otl_to_fraction(src_ptr->fraction,
+ src_ptr->frac_precision)),
+ 0,
+ 0);
+ }else{
+ int tz_hour=src_ptr->tz_hour;
+ int tz_minute=src_ptr->tz_minute;
+ char tz_str[60];
+ char* tzc=otl_itoa(tz_hour,tz_str);
+ *tzc=':';
+ ++tzc;
+ tzc=otl_itoa(tz_minute,tzc);
+ size_t tz_len=tzc-tz_str;
+ rc=OCIDateTimeConstruct
+ (connect->envhp,
+ connect->errhp,
+ trg_ptr,
+ OTL_SCAST(sb2,src_ptr->year),
+ OTL_SCAST(ub1,src_ptr->month),
+ OTL_SCAST(ub1,src_ptr->day),
+ OTL_SCAST(ub1,src_ptr->hour),
+ OTL_SCAST(ub1,src_ptr->minute),
+ OTL_SCAST(ub1,src_ptr->second),
+ OTL_SCAST
+ (ub4,otl_to_fraction(src_ptr->fraction,
+ src_ptr->frac_precision)),
+ OTL_RCAST(text*,tz_str),
+ tz_len);
+ }
+ if(rc!=0)return 0;
+ return 1;
+#else
+ memcpy(trg,src,sz);
+ return 1;
+#endif
+ }
+
+ int read_dt(void* trg,
+ const void* src,
+ const int
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+#else
+ sz
+#endif
+ )
+ {
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ OCIDateTime* src_ptr=OTL_RCAST(OCIDateTime*,OTL_CCAST(void*,src));
+ otl_datetime* trg_ptr=OTL_RCAST(otl_datetime*,OTL_CCAST(void*,trg));
+ sb2 year;
+ ub1 month, day, hour, minute, sec;
+ ub4 fsec;
+ sb1 tz_hour;
+ sb1 tz_minute;
+ int rc=OCIDateTimeGetDate
+ (connect->envhp,
+ connect->errhp,
+ src_ptr,
+ &year,
+ &month,
+ &day);
+ if(rc!=0)return 0;
+ rc=OCIDateTimeGetTime
+ (connect->envhp,
+ connect->errhp,
+ src_ptr,
+ &hour,
+ &minute,
+ &sec,
+ &fsec);
+ if(rc!=0)return 0;
+ trg_ptr->year=year;
+ trg_ptr->month=month;
+ trg_ptr->day=day;
+ trg_ptr->hour=hour;
+ trg_ptr->minute=minute;
+ trg_ptr->second=sec;
+ trg_ptr->fraction=otl_from_fraction(fsec,trg_ptr->frac_precision);
+ trg_ptr->tz_hour=0;
+ trg_ptr->tz_minute=0;
+ if(ftype==otl_var_tz_timestamp ||
+ ftype==otl_var_ltz_timestamp){
+ rc=OCIDateTimeGetTimeZoneOffset
+ (connect->envhp,
+ connect->errhp,
+ src_ptr,
+ &tz_hour,
+ &tz_minute);
+ if(rc!=0)return 0;
+ trg_ptr->tz_hour=tz_hour;
+ trg_ptr->tz_minute=tz_minute;
+ }
+ return 1;
+#else
+ memcpy(trg,src,sz);
+ return 1;
+#endif
+ }
+
+
+ int actual_elem_size(void)
+ {
+ return act_elem_size;
+ }
+
+ void init
+ (const bool aselect_stm_flag,
+ const int aftype,
+ int& aelem_size,
+ const otl_stream_buffer_size_type aarray_size,
+ const void* connect_struct=0,
+ const int apl_tab_flag=0)
+ {
+ int i;
+ ub4 lobEmpty=0;
+ select_stm_flag=aselect_stm_flag;
+ connect=OTL_RCAST(otl_conn*,OTL_CCAST(void*,connect_struct));
+ ftype=aftype;
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ if(ftype==otl_var_nchar){
+ ftype=otl_var_char;
+ nls_flag=true;
+ }else if(ftype==otl_var_nclob){
+ ftype=otl_var_clob;
+ nls_flag=true;
+ }
+#endif
+ pl_tab_flag=apl_tab_flag;
+ act_elem_size=aelem_size;
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ if((ftype==otl_var_timestamp ||
+ ftype==otl_var_tz_timestamp ||
+ ftype==otl_var_ltz_timestamp) &&
+ apl_tab_flag)
+ act_elem_size=sizeof(otl_oracle_date);
+#endif
+ if(ftype==otl_var_refcur){
+ array_size=aarray_size;
+ elem_size=1;
+#if defined(__GNUC__) && (__GNUC__>=4)
+ void* temp_cda=&cda;
+#endif
+ OCIHandleAlloc
+ (OTL_RCAST(dvoid*,connect->get_envhp()),
+#if defined(__GNUC__) && (__GNUC__>=4)
+ OTL_RCAST(dvoid**,temp_cda),
+#else
+ OTL_RCAST(dvoid**,&cda),
+#endif
+ OCI_HTYPE_STMT,
+ 0,
+ 0);
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ }else if((ftype==otl_var_timestamp ||
+ ftype==otl_var_tz_timestamp ||
+ ftype==otl_var_ltz_timestamp) &&
+ !apl_tab_flag){
+ array_size=aarray_size;
+ elem_size=sizeof(OCIDateTime*);
+ act_elem_size=elem_size;
+ timestamp=new OCIDateTime*[array_size];
+ p_v=OTL_RCAST(ub1*,timestamp);
+ p_ind=new sb2[array_size];
+ p_rlen=new ub2[array_size];
+ p_rcode=new ub2[array_size];
+ for(i=0;i<array_size;++i){
+ p_ind[i]=OTL_SCAST(short,elem_size);
+ p_rlen[i]=OTL_SCAST(short,elem_size);
+ p_rcode[i]=0;
+ }
+ if(connect!=0){
+ otl_datetime dt;
+ ub4 dtype=0;
+ switch(ftype){
+ case otl_var_timestamp:
+ dtype=OCI_DTYPE_TIMESTAMP;
+ break;
+ case otl_var_ltz_timestamp:
+ dtype=OCI_DTYPE_TIMESTAMP_LTZ;
+ break;
+ case otl_var_tz_timestamp:
+ dtype=OCI_DTYPE_TIMESTAMP_TZ;
+ break;
+ }
+ for(i=0;i<array_size;++i){
+ OCIDescriptorAlloc
+ (OTL_RCAST(dvoid*,connect->envhp),
+ OTL_RCAST(dvoid**,×tamp[i]),
+ dtype,
+ 0,
+ 0);
+ write_dt(timestamp[i],&dt,1);
+ }
+ }else
+ timestamp=0;
+#endif
+ }else if(ftype==otl_var_blob||ftype==otl_var_clob){
+ array_size=aarray_size;
+ elem_size=aelem_size;
+ lob=new OCILobLocator*[array_size];
+ p_v=OTL_RCAST(ub1*,lob);
+ p_ind=new sb2[array_size];
+ p_rlen=0;
+ p_rcode=0;
+ if(connect!=0){
+ for(i=0;i<array_size;++i){
+ OCIDescriptorAlloc
+ (OTL_RCAST(dvoid*,connect->get_envhp()),
+ OTL_RCAST(dvoid**,&lob[i]),
+ OTL_SCAST(ub4,OCI_DTYPE_LOB),
+ 0,
+ 0);
+ lobEmpty=0;
+ OCIAttrSet
+ (OTL_RCAST(dvoid*,lob[i]),
+ OCI_DTYPE_LOB,
+ OTL_RCAST(dvoid*,&lobEmpty),
+ 0,
+ OCI_ATTR_LOBEMPTY,
+ OTL_RCAST(OCIError*,connect->get_errhp()));
+ }
+ }else
+ lob=0;
+ }else{
+ if(ftype==otl_var_varchar_long||ftype==otl_var_raw_long){
+ elem_size=aelem_size+sizeof(sb4);
+ array_size=1;
+ }else if(ftype==otl_var_raw){
+ elem_size=aelem_size+sizeof(short int);
+ array_size=aarray_size;
+ }else{
+ elem_size=aelem_size;
+ array_size=aarray_size;
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ if((ftype==otl_var_timestamp ||
+ ftype==otl_var_tz_timestamp ||
+ ftype==otl_var_ltz_timestamp) &&
+ apl_tab_flag){
+ elem_size=sizeof(otl_oracle_date);
+ aelem_size=elem_size; // sending feedback back to the template class
+ }
+#endif
+ }
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_char){
+ unsigned unicode_buffer_size=
+ elem_size*OTL_SCAST(unsigned,array_size)*sizeof(OTL_WCHAR);
+ p_v=new ub1[unicode_buffer_size];
+ memset(p_v,0,unicode_buffer_size);
+ } else if(ftype==otl_var_varchar_long){
+ unsigned unicode_buffer_size=elem_size;
+ p_v=new ub1[unicode_buffer_size];
+ memset(p_v,0,unicode_buffer_size);
+ }else{
+ p_v=new ub1[elem_size*OTL_SCAST(unsigned,array_size)];
+ memset(p_v,0,elem_size*OTL_SCAST(unsigned,array_size));
+ }
+#elif defined(OTL_ORA_UTF8)
+ if(ftype==otl_var_char){
+ unsigned buffer_size=elem_size*OTL_SCAST(unsigned,array_size);
+ if(select_stm_flag)
+ buffer_size*=OTL_UTF8_BYTES_PER_CHAR; // 3 bytes per UTF8 char on SELECT by default
+ p_v=new ub1[buffer_size];
+ memset(p_v,0,buffer_size);
+ } else if(ftype==otl_var_varchar_long){
+ p_v=new ub1[elem_size];
+ memset(p_v,0,elem_size);
+ }else{
+ p_v=new ub1[elem_size*OTL_SCAST(unsigned,array_size)];
+ memset(p_v,0,elem_size*OTL_SCAST(unsigned,array_size));
+ }
+#else
+ p_v=new ub1[elem_size*OTL_SCAST(unsigned,array_size)];
+ memset(p_v,0,elem_size*OTL_SCAST(unsigned,array_size));
+#endif
+ p_ind=new sb2[array_size];
+ p_rlen=new ub2[array_size];
+ p_rcode=new ub2[array_size];
+ if(ftype==otl_var_varchar_long||ftype==otl_var_raw_long){
+ if(aelem_size>32767)
+ p_ind[0]=0;
+ else
+ p_ind[0]=OTL_SCAST(short,aelem_size);
+ p_rcode[0]=0;
+ }else{
+ for(i=0;i<array_size;++i){
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_char){
+ p_ind[i]=OTL_SCAST(short,elem_size*sizeof(OTL_WCHAR));
+ p_rlen[i]=OTL_SCAST(short,elem_size*sizeof(OTL_WCHAR));
+ p_rcode[i]=0;
+ }else{
+ p_ind[i]=OTL_SCAST(short,elem_size);
+ p_rlen[i]=OTL_SCAST(short,elem_size);
+ p_rcode[i]=0;
+ }
+#else
+ if(ftype==otl_var_raw){
+ p_ind[i]=OTL_SCAST(short,elem_size);
+ p_rlen[i]=OTL_SCAST(short,elem_size);
+ p_rcode[i]=0;
+ }else{
+ p_ind[i]=OTL_SCAST(short,elem_size);
+ p_rlen[i]=OTL_SCAST(short,elem_size);
+ p_rcode[i]=0;
+ }
+#endif
+ }
+ }
+ }
+ max_tab_len=OTL_SCAST(ub4,array_size);
+ cur_tab_len=0;
+ }
+
+ void set_pl_tab_len(const int apl_tab_len)
+ {
+ max_tab_len=OTL_SCAST(ub4,array_size);
+ cur_tab_len=OTL_SCAST(ub4,apl_tab_len);
+ }
+
+ int get_pl_tab_len(void)
+ {
+ return OTL_SCAST(int,cur_tab_len);
+ }
+
+ int get_max_pl_tab_len(void)
+ {
+ return OTL_SCAST(int,max_tab_len);
+ }
+
+ int get_blob_len(const int ndx,int& alen)
+ {
+ ub4 blen;
+ int rc;
+ alen=0;
+ rc=OCILobGetLength
+ (connect->get_svchp(),
+ connect->get_errhp(),
+ lob[ndx],
+ &blen);
+ alen=OTL_SCAST(int,blen);
+ if(rc!=OCI_SUCCESS)return 0;
+ return 1;
+
+ }
+
+ int is_blob_initialized(const int ndx,int& is_init)
+ {
+ int rc;
+ is_init=0;
+ rc=OCILobLocatorIsInit
+ (connect->get_envhp(),
+ connect->get_errhp(),
+ lob[ndx],
+ &is_init);
+ if(rc!=OCI_SUCCESS)
+ return 0;
+ else
+ return 1;
+ }
+
+ int get_blob
+ (const int ndx,
+ unsigned char* abuf,
+ const int buf_size,
+ int& len)
+ {
+ int byte_buf_size=buf_size;
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_clob)
+ byte_buf_size=buf_size*sizeof(OTL_CHAR);
+#endif
+ ub4 amt=byte_buf_size;
+ ub4 offset=1;
+ int rc;
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_clob||ftype==otl_var_nclob)
+ memset(OTL_RCAST(void*,abuf),0,OTL_SCAST(size_t,buf_size));
+#endif
+ int is_init=0;
+ rc=OCILobLocatorIsInit
+ (connect->get_envhp(),
+ connect->get_errhp(),
+ lob[ndx],
+ &is_init);
+ if (rc!=0) return 0;
+ if (!is_init){
+ len=0;
+ return 1;
+ }
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_clob)
+ csid=OTL_UNICODE_ID;
+ else
+ csid=0;
+#else
+ csid=0;
+#endif
+ do{
+ rc=OCILobRead
+ (connect->get_svchp(),
+ connect->get_errhp(),
+ lob[ndx],
+ &amt,
+ offset,
+ OTL_RCAST(dvoid*,abuf+offset-1),
+ OTL_SCAST(ub4,byte_buf_size-offset+1),
+ 0,
+ 0,
+ csid,
+ OTL_SCAST(ub1,nls_flag?SQLCS_NCHAR:connect->get_char_set()));
+ offset+=amt;
+ }while(rc==OCI_NEED_DATA);
+ len=offset-1;
+ if(rc!=OCI_SUCCESS){
+ len=0;
+ return 0;
+ }
+ return 1;
+ }
+
+ void set_lob_stream_flag(const int flg=1)
+ {
+ lob_stream_flag=flg;
+ }
+
+ int close_lob(void)
+ {
+#if defined(OTL_ORA8I)||defined(OTL_ORA9I)
+ int rc;
+ boolean flag=0;
+ rc=OCILobIsOpen
+ (connect->get_svchp(),
+ connect->get_errhp(),
+ lob[0],
+ &flag);
+ if(rc!=OCI_SUCCESS)return 0;
+ if(flag!=TRUE)return 1;
+ rc=OCILobClose
+ (connect->get_svchp(),
+ connect->get_errhp(),
+ lob[0]);
+ if(rc!=OCI_SUCCESS)return 0;
+#endif
+ return 1;
+ }
+
+ int put_blob(void)
+ {
+ if((ftype!=otl_var_clob&&ftype!=otl_var_blob)||
+ lob_stream_flag||buf==0||buf_len==0)return 1;
+ int rc;
+ int byte_buf_len=buf_len;
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_clob)
+ byte_buf_len=buf_len*sizeof(OTL_CHAR);
+#endif
+ ub4 amt=OTL_SCAST(ub4,buf_len);
+ ub4 offset=1;
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_clob)
+ csid=OTL_UNICODE_ID;
+ else
+ csid=0;
+#else
+ csid=0;
+#endif
+ rc=OCILobWrite
+ (connect->get_svchp(),
+ connect->get_errhp(),
+ lob[0],
+ &amt,
+ offset,
+ OTL_RCAST(dvoid*,buf),
+ OTL_SCAST(ub4,byte_buf_len),
+ OCI_ONE_PIECE,
+ 0,
+ 0,
+ csid,
+ OTL_SCAST(ub1,nls_flag?SQLCS_NCHAR:connect->get_char_set()));
+ if(rc!=0)return 0;
+ return 1;
+ }
+
+ int read_blob
+ (otl_long_string& s,
+ const int andx,
+ int& aoffset,
+ int alob_len)
+ {
+ ub4 byte_buf_size=s.get_buf_size();
+
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_clob)
+ byte_buf_size=byte_buf_size*sizeof(OTL_CHAR);
+#endif
+
+ ub4& amt=read_blob_amt;
+ amt=0;
+ if(aoffset==1)total_read_blob_amt=0;
+ ub4& offset=total_read_blob_amt;
+ if(offset==0)offset=1;
+ int rc;
+ int is_init=0;
+ rc=OCILobLocatorIsInit
+ (connect->get_envhp(),
+ connect->get_errhp(),
+ lob[0],
+ &is_init);
+ if(rc!=OCI_SUCCESS)return 0;
+ if(!is_init){
+ s.set_len(0);
+ return 1;
+ }
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_clob)
+ csid=OTL_UNICODE_ID;
+ else
+ csid=0;
+#else
+ csid=0;
+#endif
+
+ rc=OCILobRead
+ (connect->get_svchp(),
+ connect->get_errhp(),
+ lob[andx],
+ &amt,
+ offset,
+ OTL_RCAST(dvoid*,s.v),
+ OTL_SCAST(ub4,byte_buf_size),
+ 0,
+ 0,
+ csid,
+ OTL_SCAST(ub1,nls_flag?SQLCS_NCHAR:connect->get_char_set()));
+
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_clob && aoffset>1 && amt==byte_buf_size)
+ amt/=sizeof(OTL_CHAR);
+#endif
+
+#if defined(OTL_ORA_UTF8)
+ switch(rc){
+ case OCI_SUCCESS:
+ s.set_len(amt);
+ offset+=amt;
+ if(ftype==otl_var_blob)
+ aoffset+=s.len();
+ else
+ aoffset=alob_len+1;
+ return 1;
+ case OCI_NEED_DATA:
+ s.set_len(amt);
+ offset+=amt;
+ if(ftype==otl_var_blob)
+ aoffset+=s.len();
+ else
+ aoffset=2;
+ return 1;
+ case OCI_ERROR:
+ default:
+ s.set_len(0);
+ return 0;
+ }
+#else
+ switch(rc){
+ case OCI_SUCCESS:
+ if(aoffset==1)
+ s.set_len(alob_len);
+ else
+ s.set_len(alob_len-aoffset+1);
+ break;
+ case OCI_NEED_DATA:
+ s.set_len(amt);
+ break;
+ case OCI_ERROR:
+ s.set_len(0);
+ break;
+ }
+ if(rc==OCI_NEED_DATA||rc==OCI_SUCCESS){
+ aoffset+=s.len();
+ return 1;
+ }else
+ return 0;
+#endif
+
+ }
+
+ int write_blob
+ (const otl_long_string& s,
+ const int alob_len,
+ int& aoffset,
+ otl_cur0& /* cur */)
+ {
+ if(!lob_stream_flag)return 1;
+ int rc;
+ int byte_s_length=s.len();
+#if defined(OTL_UNICODE)
+ int byte_lob_len;
+ if(ftype==otl_var_clob){
+ byte_lob_len=alob_len*sizeof(OTL_CHAR);
+ byte_s_length=s.len()*sizeof(OTL_CHAR);
+ }
+#endif
+ ub4 offset=aoffset;
+ ub4 amt=0;
+ ub1 mode;
+ if(aoffset==1 && alob_len>s.len())
+ mode=OCI_FIRST_PIECE;
+ else if(aoffset==1 && alob_len<=s.len()){
+ mode=OCI_ONE_PIECE;
+ amt=s.len();
+ }else if((aoffset-1)+s.len()<alob_len)
+ mode=OCI_NEXT_PIECE;
+ else
+ mode=OCI_LAST_PIECE;
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_clob)
+ csid=OTL_UNICODE_ID;
+ else
+ csid=0;
+#else
+ csid=0;
+#endif
+ if(mode==OCI_FIRST_PIECE || mode==OCI_ONE_PIECE){
+ rc=OCILobTrim
+ (connect->get_svchp(),
+ connect->get_errhp(),
+ lob[0],
+ 0);
+ if(rc!=OCI_SUCCESS)
+ return 0;
+ }
+ if(alob_len==0)return 1;
+ rc=OCILobWrite
+ (connect->get_svchp(),
+ connect->get_errhp(),
+ lob[0],
+ OTL_RCAST(ub4*,&amt),
+ offset,
+ OTL_RCAST(dvoid*,s.v),
+ OTL_SCAST(ub4,byte_s_length),
+ mode,
+ 0,
+ 0,
+ csid,
+ OTL_SCAST(ub1,nls_flag?SQLCS_NCHAR:connect->get_char_set()));
+ if(rc==OCI_NEED_DATA||
+ rc==OCI_SUCCESS||
+ rc==OCI_SUCCESS_WITH_INFO){
+ aoffset+=s.len();
+ return 1;
+ }
+ return 0;
+ }
+
+ int save_blob
+ (const unsigned char* abuf,
+ const int len,
+ const int extern_buffer_flag)
+ {
+ if(extern_buffer_flag){
+ ext_buf_flag=1;
+ buf_len=len;
+ buf=OTL_CCAST(unsigned char*,abuf);
+ }else{
+ if(buf!=0&&!ext_buf_flag){
+ delete[] buf;
+ buf=0;
+ }
+ ext_buf_flag=0;
+ buf_len=len;
+#if defined(OTL_UNICODE)
+ buf=new ub1[buf_len*sizeof(OTL_CHAR)];
+ memcpy(buf,abuf,buf_len*sizeof(OTL_CHAR));
+#else
+ buf=new ub1[buf_len];
+ memcpy(buf,abuf,buf_len);
+#endif
+ }
+ return 1;
+ }
+
+ void set_null(int ndx)
+ {
+ p_ind[ndx]=-1;
+ }
+
+ void set_not_null(int ndx, int pelem_size)
+ {
+ switch(ftype){
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ p_ind[0]=0;
+ break;
+ case otl_var_raw:
+ p_ind[ndx]=OTL_SCAST(short,pelem_size);
+ break;
+ case otl_var_clob:
+ case otl_var_blob:
+ if(lob_stream_flag==0){
+ ub4 lobEmpty=0;
+ OCIAttrSet
+ (OTL_RCAST(dvoid*,lob[ndx]),
+ OCI_DTYPE_LOB,
+ OTL_RCAST(dvoid*,&lobEmpty),
+ 0,
+ OCI_ATTR_LOBEMPTY,
+ OTL_RCAST(OCIError*,connect->get_errhp()));
+ }
+ break;
+ default:
+ p_ind[ndx]=OTL_SCAST(short,pelem_size);
+ break;
+ }
+ }
+
+ void set_len(int len, int ndx)
+ {
+ if(ftype==otl_var_varchar_long||ftype==otl_var_raw_long){
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_varchar_long)
+ *OTL_RCAST(sb4*,p_v)=len*sizeof(OTL_CHAR);
+ else
+ *OTL_RCAST(sb4*,p_v)=len;
+#else
+ *OTL_RCAST(sb4*,p_v)=len;
+#endif
+ }else
+ p_rlen[ndx]=OTL_SCAST(short,len);
+ }
+
+ int get_len(int ndx)
+ {
+ if(ftype==otl_var_varchar_long||ftype==otl_var_raw_long){
+ if(p_ind[0]==-1)
+ return 0;
+ else{
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_varchar_long)
+ return (*OTL_RCAST(sb4*,p_v))/sizeof(OTL_CHAR);
+ else
+ return *OTL_RCAST(sb4*,p_v);
+#else
+ return *OTL_RCAST(sb4*,p_v);
+#endif
+ }
+ }else
+ return p_rlen[ndx];
+ }
+
+ int is_null(int ndx)
+ {
+ return p_ind[ndx]==-1;
+ }
+
+ void* val(int ndx,int pelem_size)
+ {
+ switch(ftype){
+#if defined(OTL_UNICODE)
+ case otl_var_char:
+ return OTL_RCAST(void*,&p_v[OTL_SCAST(unsigned,ndx)*
+ pelem_size*sizeof(OTL_WCHAR)]);
+#endif
+#if defined(OTL_ORA_UTF8)
+ case otl_var_char:
+ if(select_stm_flag)
+ return OTL_RCAST(void*,&p_v[OTL_SCAST(unsigned,ndx)*
+ pelem_size*OTL_UTF8_BYTES_PER_CHAR]);
+ else
+ return OTL_RCAST(void*,&p_v[OTL_SCAST(unsigned,ndx)*pelem_size]);
+#endif
+ case otl_var_raw:
+ return OTL_RCAST(void*,&p_v[(OTL_SCAST(unsigned,ndx))*
+ (pelem_size+sizeof(short int))]);
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ return OTL_RCAST(void*,p_v+sizeof(sb4));
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ case otl_var_timestamp:
+ case otl_var_tz_timestamp:
+ case otl_var_ltz_timestamp:
+ if(!pl_tab_flag)
+ return OTL_RCAST(void*,timestamp[ndx]);
+#endif
+ default:
+ return OTL_RCAST(void*,&p_v[OTL_SCAST(unsigned,ndx)*pelem_size]);
+ }
+ }
+
+ static int int2ext(int int_type)
+ {
+ switch(int_type){
+ case inVarChar2: return extCChar;
+ case inNumber: return extFloat;
+ case inLong: return extLongVarChar;
+ case inRowId: return extCChar;
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ case inDate: return extTimestamp;
+ case inTimestamp:return extTimestamp;
+ case inTimestamp_TZ:return extTimestamp_TZ;
+ case inTimestamp_LTZ:return extTimestamp_LTZ;
+ case inIntervalYM:return extCChar;
+ case inIntervalDS:return extCChar;
+#else
+ case inDate: return extDate;
+#endif
+ case inRaw: return extRaw;
+ case inLongRaw: return extLongVarRaw;
+ case inChar: return extCChar;
+#if defined(OTL_ORA10G)||defined(OTL_ORA10G_R2)
+#if defined(OTL_ORA_NATIVE_TYPES) && !defined(OTL_ORA_LEGACY_NUMERIC_TYPES)
+ case inBFloat: return extBFloat;
+ case inBDouble: return extBDouble;
+#else
+ case inBFloat: return extFloat;
+ case inBDouble: return extFloat;
+#endif
+#endif
+ case inCLOB: return extCLOB;
+ case inBLOB: return extBLOB;
+ default:
+ return otl_unsupported_type;
+ }
+ }
+
+ static int datatype_size(int aftype,int maxsz,int int_type,int max_long_size)
+ {
+ switch(aftype){
+ case extCChar:
+ switch(int_type){
+#if defined(OTL_ORA_TIMESTAMP)
+ case inIntervalYM:
+ return 30;
+ case inIntervalDS:
+ return 30;
+#endif
+ case inRowId:
+ return 30;
+ case inDate:
+ return otl_oracle_date_size;
+ case inRaw:
+ return max_long_size;
+ default:
+ return maxsz+1;
+ }
+#if (defined(OTL_ORA10G)||defined(OTL_ORA10G_R2)) && defined(OTL_ORA_NATIVE_TYPES) \
+ && !defined(OTL_ORA_LEGACY_NUMERIC_TYPES)
+ case extBFloat:
+ case extBDouble:
+ return sizeof(double);
+#endif
+ case extLongVarChar:
+ return max_long_size;
+ case extLongVarRaw:
+ return max_long_size;
+ case extRaw:
+ return maxsz;
+ case extCLOB:
+ return max_long_size;
+ case extBLOB:
+ return max_long_size;
+ case extFloat:
+ return sizeof(double);
+
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ case extDate:
+ return sizeof(OCIDateTime*);
+ case extTimestamp:
+ case extTimestamp_TZ:
+ case extTimestamp_LTZ:
+ return sizeof(OCIDateTime*);
+#else
+ case extDate:
+ return otl_oracle_date_size;
+#endif
+ default:
+ return 0;
+ }
+ }
+
+ static void map_ftype
+ (otl_column_desc& desc,
+ const int max_long_size,
+ int& aftype,
+ int& aelem_size,
+ otl_select_struct_override& override,
+ const int column_ndx,
+ const int /*connection_type*/)
+ {int ndx=override.find(column_ndx);
+ if(ndx==-1){
+ aftype=int2ext(desc.dbtype);
+ aelem_size=datatype_size
+ (aftype,
+ OTL_SCAST(int,desc.dbsize),
+ desc.dbtype,
+ max_long_size);
+ switch(aftype){
+#if (defined(OTL_ORA10G)||defined(OTL_ORA10G_R2))&&defined(OTL_ORA_NATIVE_TYPES)\
+ &&!defined(OTL_ORA_LEGACY_NUMERIC_TYPES)
+ case extBFloat:
+ case extBDouble:
+ if(override.get_all_mask() & otl_all_num2str){
+ aftype=otl_var_char;
+ aelem_size=otl_num_str_size;
+ }else
+ aftype=otl_var_double;
+ break;
+#endif
+ case extCChar:
+ aftype=otl_var_char;
+ break;
+ case extRaw:
+ aftype=otl_var_raw;
+ break;
+ case extFloat:
+ if(override.get_all_mask() & otl_all_num2str){
+ aftype=otl_var_char;
+ aelem_size=otl_num_str_size;
+ }else
+ aftype=otl_var_double;
+ break;
+ case extLongVarChar:
+ aftype=otl_var_varchar_long;
+ break;
+ case extLongVarRaw:
+ aftype=otl_var_raw_long;
+ break;
+ case extCLOB:
+ aftype=otl_var_clob;
+ break;
+ case extBLOB:
+ aftype=otl_var_blob;
+ break;
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ case extDate:
+ case extTimestamp:
+ if(override.get_all_mask() & otl_all_date2str){
+ aftype=otl_var_char;
+ aelem_size=otl_date_str_size;
+ }else
+ aftype=otl_var_timestamp;
+ break;
+ case extTimestamp_TZ:
+ if(override.get_all_mask() & otl_all_date2str){
+ aftype=otl_var_char;
+ aelem_size=otl_date_str_size;
+ }else
+ aftype=otl_var_tz_timestamp;
+ break;
+ case extTimestamp_LTZ:
+ if(override.get_all_mask() & otl_all_date2str){
+ aftype=otl_var_char;
+ aelem_size=otl_date_str_size;
+ }else
+ aftype=otl_var_ltz_timestamp;
+ break;
+#else
+ case extDate:
+ if(override.get_all_mask() & otl_all_date2str){
+ aftype=otl_var_char;
+ aelem_size=otl_date_str_size;
+ }else
+ aftype=otl_var_timestamp;
+ break;
+#endif
+ }
+ }else{
+ aftype=override.get_col_type(ndx);
+ switch(aftype){
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ case otl_var_nchar:
+#endif
+ case otl_var_char:
+ aelem_size=override.get_col_size(ndx);
+ break;
+ case otl_var_raw:
+ aelem_size=override.get_col_size(ndx);
+ break;
+ case otl_var_double:
+ aelem_size=sizeof(double);
+ break;
+ case otl_var_float:
+ aelem_size=sizeof(float);
+ break;
+ case otl_var_int:
+ aelem_size=sizeof(int);
+ break;
+#if defined(OTL_BIGINT) && defined(OTL_ORA11G_R2)
+ case otl_var_bigint:
+ aelem_size=sizeof(OTL_BIGINT);
+ break;
+#endif
+ case otl_var_unsigned_int:
+ aelem_size=sizeof(unsigned);
+ break;
+ case otl_var_short:
+ aelem_size=sizeof(short);
+ break;
+ case otl_var_long_int:
+ aelem_size=sizeof(long);
+ break;
+ default:
+ aelem_size=override.get_col_size(ndx);
+ break;
+ }
+ }
+ desc.otl_var_dbtype=aftype;
+ }
+
+private:
+
+ otl_var(const otl_var&):
+ p_v(0),
+ p_ind(0),
+ p_rlen(0),
+ p_rcode(0),
+ ftype(0),
+ array_size(0),
+ elem_size(0),
+ nls_flag(false),
+ lob(0),
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ timestamp(0),
+#endif
+ cda(0),
+ connect(0),
+ buf(0),
+ buf_len(0),
+ ext_buf_flag(0),
+ act_elem_size(0),
+ max_tab_len(0),
+ cur_tab_len(0),
+ pl_tab_flag(0),
+ lob_stream_flag(0),
+ vparam_type(-1),
+ lob_len(0),
+ lob_pos(0),
+ lob_ftype(0),
+ otl_adapter(otl_ora8_adapter),
+ lob_stream_mode(false),
+ unicode_var_len(0),
+ csid(0),
+ csfrm(SQLCS_IMPLICIT),
+ read_blob_amt(0),
+ total_read_blob_amt(0),
+ charz_flag(false),
+ select_stm_flag(false)
+ {
+ }
+
+ otl_var& operator=(const otl_var&)
+ {
+ return *this;
+ }
+
+};
+
+class otl_sel;
+class otl_refcur_base_cursor;
+class otl_refcur_stream;
+class otl_ref_cursor;
+class otl_ref_select_stream;
+#if defined(OTL_ORA_SUBSCRIBE)
+ class otl_subscriber;
+#endif
+
+class otl_cur: public otl_cur0{
+private:
+
+#if defined(OTL_ORA_SUBSCRIBE)
+ friend class otl_subscriber;
+#endif
+
+ friend class otl_sel;
+ friend class otl_refcur_base_cursor;
+ friend class otl_refcur_stream;
+ friend class otl_ref_cursor;
+ friend class otl_ref_select_stream;
+
+ OCIStmt* cda; // Statement handle
+ OCIError* errhp; // Error handle
+ bool extern_cda;
+ int status;
+ int eof_status;
+ otl_conn* db;
+ int straight_select;
+ int pos_nbr;
+ int commit_on_success;
+ int last_param_data_token;
+ int last_sql_param_data_status;
+ int sql_param_data_count;
+ bool canceled;
+ int direct_exec_flag;
+ int parse_only_flag;
+ int stm_executed;
+
+public:
+
+ void set_canceled(const bool acanceld)
+ {
+ canceled=acanceld;
+ }
+
+ void reset_last_param_data_token()
+ {
+ last_param_data_token=0;
+ }
+
+ void reset_last_sql_param_data_status()
+ {
+ last_sql_param_data_status=0;
+ }
+
+ void reset_sql_param_data_count()
+ {
+ sql_param_data_count=0;
+ }
+
+ otl_cur():
+ cda(0),
+ errhp(0),
+ extern_cda(false),
+ status(0),
+ eof_status(0),
+ db(0),
+ straight_select(1),
+ pos_nbr(0),
+ commit_on_success(0),
+ last_param_data_token(0),
+ last_sql_param_data_status(0),
+ sql_param_data_count(0),
+ canceled(false),
+ direct_exec_flag(0),
+ parse_only_flag(0),
+ stm_executed(0)
+ {
+ }
+
+ virtual ~otl_cur(){}
+
+ void set_direct_exec(const int flag)
+ {
+ direct_exec_flag=flag;
+ }
+
+ void set_parse_only(const int flag)
+ {
+ parse_only_flag=flag;
+ }
+
+ ub4 rpc(void)
+ {
+ sb4 arpc;
+ status=OCIAttrGet
+ (OTL_RCAST(dvoid *,cda),
+ OTL_SCAST(ub4,OCI_HTYPE_STMT),
+ OTL_RCAST(dvoid *,&arpc),
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_ROW_COUNT),
+ errhp);
+ if(status)return 0;
+ return arpc;
+ }
+
+ int open(otl_conn& connect,otl_var* var=0)
+ {
+ db=&connect;
+ commit_on_success=db->get_auto_commit();
+ if(var!=0){
+ extern_cda=true;
+ cda=var->get_cda();
+ status=OCI_SUCCESS;
+ }else{
+#if defined(__GNUC__) && (__GNUC__>=4)
+ void* temp_cda=&cda;
+#endif
+ status=OCIHandleAlloc
+ (OTL_RCAST(dvoid *,db->get_envhp()),
+#if defined(__GNUC__) && (__GNUC__>=4)
+ OTL_RCAST(dvoid **,temp_cda),
+#else
+ OTL_RCAST(dvoid **,&cda),
+#endif
+ OCI_HTYPE_STMT,
+ 0,
+ 0);
+ if(status)return 0;
+ }
+#if defined(__GNUC__) && (__GNUC__>=4)
+ void* temp_errhp=&errhp;
+#endif
+ status=OCIHandleAlloc
+ (OTL_RCAST(dvoid *,db->get_envhp()),
+#if defined(__GNUC__) && (__GNUC__>=4)
+ OTL_RCAST(dvoid **,temp_errhp),
+#else
+ OTL_RCAST(dvoid **,&errhp),
+#endif
+ OCI_HTYPE_ERROR,
+ 0,
+ 0);
+ if(status)return 0;
+ straight_select=1;
+ pos_nbr=0;
+ return 1;
+ }
+
+ int close(void)
+ {
+ if(!extern_cda)
+ status=OCIHandleFree(OTL_RCAST(dvoid*,cda),OCI_HTYPE_STMT);
+ status=OCIHandleFree(OTL_RCAST(dvoid*,errhp),OCI_HTYPE_ERROR);
+ cda=0;
+ errhp=0;
+ commit_on_success=0;
+ return 1;
+ }
+
+ int parse(const char* stm_text)
+ {
+ status=OCIStmtPrepare
+ (cda,
+ errhp,
+ OTL_RCAST(text*,OTL_CCAST(char*,stm_text)),
+ OTL_SCAST(ub4,strlen(stm_text)),
+ OTL_SCAST(ub4,OCI_NTV_SYNTAX),
+ OTL_SCAST(ub4,OCI_DEFAULT));
+ if(status)return 0;
+
+ if(direct_exec_flag && parse_only_flag){
+#if !defined(OCI_PARSE_ONLY)
+ status=OCIStmtExecute
+ (db->svchp,
+ cda,
+ errhp,
+ OTL_SCAST(ub4,1),
+ OTL_SCAST(ub4,0),
+ 0,
+ 0,
+ 0x100);
+ #else
+ status=OCIStmtExecute
+ (db->get_svchp(),
+ cda,
+ errhp,
+ OTL_SCAST(ub4,0),
+ OTL_SCAST(ub4,0),
+ 0,
+ 0,
+ OCI_PARSE_ONLY);
+ #endif
+ if(status)
+ return 0;
+ else
+ return 1;
+ }else if(direct_exec_flag && !parse_only_flag){
+ ub4 mode;
+ if(commit_on_success)
+ mode=OCI_COMMIT_ON_SUCCESS;
+ else
+ mode=OCI_DEFAULT;
+
+ status=OCIStmtExecute
+ (db->get_svchp(),
+ cda,
+ errhp,
+ OTL_SCAST(ub4,1),
+ OTL_SCAST(ub4,0),
+ 0,
+ 0,
+ mode);
+ stm_executed=1;
+ if(status)
+ return 0;
+ else
+ return 1;
+ }
+ return 1;
+ }
+
+ int exec(const int iters,
+ const int rowoff,
+ const int /*otl_sql_exec_from_class*/)
+ {
+ if(parse_only_flag){
+ parse_only_flag=0;
+ return 1;
+ }else if(!stm_executed){
+ ub4 mode;
+ if(commit_on_success)
+ mode=OCI_COMMIT_ON_SUCCESS;
+ else
+ mode=OCI_DEFAULT;
+ status=OCIStmtExecute
+ (db->get_svchp(),
+ cda,
+ errhp,
+ OTL_SCAST(ub4,iters),
+ OTL_SCAST(ub4,rowoff),
+ 0,
+ 0,
+ mode);
+ stm_executed=0;
+ if(status!=OCI_SUCCESS)
+ return 0;
+ return 1;
+ }
+ return 1;
+ }
+
+ long get_rpc()
+ {
+ return rpc();
+ }
+
+ int fetch(const otl_stream_buffer_size_type iters,int& eof_data)
+ {
+ eof_data=0;
+ status=OCIStmtFetch
+ (cda,
+ errhp,
+ OTL_SCAST(ub4,iters),
+ OTL_SCAST(ub4,OCI_FETCH_NEXT),
+ OTL_SCAST(ub4,OCI_DEFAULT));
+ eof_status=status;
+ if(status!=OCI_SUCCESS&&
+ status!=OCI_SUCCESS_WITH_INFO&&
+ status!=OCI_NO_DATA)
+ return 0;
+ if(status==OCI_NO_DATA){
+ eof_data=1;
+ return 1;
+ }
+ return 1;
+ }
+
+ int tmpl_ftype2ora_ftype(const int ftype)
+ {
+ switch(ftype){
+ case otl_var_char:
+ return extCChar;
+#if (defined(OTL_ORA10G)||defined(OTL_ORA10G_R2))&&defined(OTL_ORA_NATIVE_TYPES)\
+ &&!defined(OTL_ORA_LEGACY_NUMERIC_TYPES)
+ case otl_var_double:
+ return extBDouble;
+ case otl_var_float:
+ return extBFloat;
+#else
+ case otl_var_double:
+ return extFloat;
+ case otl_var_float:
+ return extFloat;
+#endif
+ case otl_var_int:
+ return extInt;
+ case otl_var_unsigned_int:
+ return extUInt;
+ case otl_var_short:
+ return extInt;
+ case otl_var_long_int:
+ return extInt;
+#if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\
+ !defined(OTL_BIGINT_TO_STR))
+ case otl_var_bigint:
+ return extInt;
+#endif
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ case otl_var_timestamp:
+ return extTimestamp;
+ case otl_var_tz_timestamp:
+ return extTimestamp_TZ;
+ case otl_var_ltz_timestamp:
+ return extTimestamp_LTZ;
+#else
+ case otl_var_timestamp:
+ return extDate;
+#endif
+ case otl_var_varchar_long:
+ return extLongVarChar;
+ case otl_var_raw_long:
+ return extLongVarRaw;
+ case otl_var_raw:
+ return extRaw;
+ case otl_var_clob:
+ return SQLT_CLOB;
+ case otl_var_blob:
+ return SQLT_BLOB;
+ default:
+ return 0;
+ }
+ }
+
+ int bind
+ (const char* name,
+ otl_var& v,
+ const int elem_size,
+ const int ftype,
+ const int /*param_type*/,
+ const int /*name_pos*/,
+ const int /*connection_type*/,
+ const int apl_tab_flag)
+ {OCIBind* bindpp;
+
+ int db_ftype=0;
+
+ if(ftype==otl_var_refcur){
+ status=OCIBindByName
+ (cda,
+ &bindpp,
+ errhp,
+ OTL_RCAST(text*,OTL_CCAST(char*,name)),
+ OTL_SCAST(sb4,strlen(name)),
+ OTL_RCAST(dvoid*,v.get_cda_ptr()),
+ 0,
+ SQLT_RSET,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ OTL_SCAST(ub4,OCI_DEFAULT));
+ }else if(ftype!=otl_var_clob&&ftype!=otl_var_blob){
+ int var_elem_size;
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_char){
+ var_elem_size=elem_size*sizeof(OTL_WCHAR); // ###
+ }
+ else if(ftype==otl_var_varchar_long)
+ var_elem_size=elem_size;
+ else
+ var_elem_size=elem_size;
+#else
+ if(ftype==otl_var_varchar_long)
+ var_elem_size=elem_size+sizeof(sb4);
+ else
+ var_elem_size=elem_size;
+#endif
+ db_ftype=tmpl_ftype2ora_ftype(ftype);
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ if(ftype==otl_var_timestamp ||
+ ftype==otl_var_tz_timestamp ||
+ ftype==otl_var_ltz_timestamp){
+ if(!apl_tab_flag)
+ var_elem_size=sizeof(OCIDateTime*);
+ else if(db_ftype==extTimestamp)
+ db_ftype=extDate;
+ }
+#endif
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_char)
+ db_ftype=SQLT_VCS;
+#endif
+ if(apl_tab_flag){
+ if(ftype==otl_var_float||ftype==otl_var_double)
+ db_ftype=extFloat;
+ status=OCIBindByName
+ (cda,
+ &bindpp,
+ errhp,
+ OTL_RCAST(text*,OTL_CCAST(char*,name)),
+ OTL_SCAST(sb4,strlen(name)),
+ OTL_RCAST(dvoid*,v.p_v),
+ ftype==otl_var_raw?var_elem_size+sizeof(short):var_elem_size,
+ OTL_SCAST(ub2,v.charz_flag?extCharZ:db_ftype),
+ OTL_RCAST(dvoid*,v.p_ind),
+ 0,
+ 0,
+ OTL_SCAST(ub4,v.max_tab_len),
+ OTL_RCAST(ub4*,&v.cur_tab_len),
+ OTL_SCAST(ub4,OCI_DEFAULT));
+ }else{
+ status=OCIBindByName
+ (cda,
+ &bindpp,
+ errhp,
+ OTL_RCAST(text*,OTL_CCAST(char*,name)),
+ OTL_SCAST(sb4,strlen(name)),
+ OTL_RCAST(dvoid*,v.p_v),
+ ftype==otl_var_raw?var_elem_size+sizeof(short):var_elem_size,
+ OTL_SCAST(ub2,db_ftype),
+ OTL_RCAST(dvoid*,v.p_ind),
+ 0,
+ 0,
+ 0,
+ 0,
+ OTL_SCAST(ub4,OCI_DEFAULT));
+ }
+ if(status)return 0;
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_char||ftype==otl_var_varchar_long){
+ if(ftype!=otl_var_varchar_long){
+ if(v.nls_flag)
+ v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR);
+ else
+ v.csfrm=OTL_SCAST(ub1,db->char_set_);
+ status=OCIAttrSet
+ (bindpp,
+ OCI_HTYPE_BIND,
+ &v.csfrm,
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM),
+ errhp);
+ if(status)return 0;
+ }
+ v.csid=OTL_UNICODE_ID;
+ status=OCIAttrSet
+ (bindpp,
+ OCI_HTYPE_BIND,
+ &v.csid,
+ 0,
+ OCI_ATTR_CHARSET_ID,
+ errhp);
+ if(status)return 0;
+ if(ftype==otl_var_varchar_long)
+ v.unicode_var_len=elem_size-sizeof(sb4);
+ else{
+#if defined(OTL_ORA_MAX_UNICODE_VARCHAR_SIZE)
+ if(var_elem_size>OTL_ORA_MAX_UNICODE_VARCHAR_SIZE)
+ v.unicode_var_len=OTL_ORA_MAX_UNICODE_VARCHAR_SIZE;
+ else
+ v.unicode_var_len=var_elem_size;
+#else
+ v.unicode_var_len=var_elem_size;
+#endif
+ }
+ status=OCIAttrSet
+ (bindpp,
+ OCI_HTYPE_BIND,
+ &v.unicode_var_len,
+ 0,
+ OCI_ATTR_MAXDATA_SIZE,
+ errhp);
+ if(status)return 0;
+ }
+#endif
+
+#if defined(OTL_ORA_UTF8)
+ if(ftype==otl_var_char){
+ if(v.nls_flag)
+ v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR);
+ else
+ v.csfrm=OTL_SCAST(ub1,db->char_set_);
+ status=OCIAttrSet
+ (bindpp,
+ OCI_HTYPE_BIND,
+ &v.csfrm,
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM),
+ errhp);
+ if(status)return 0;
+ }
+#endif
+
+ return 1;
+ }else{
+ status=OCIBindByName
+ (cda,
+ &bindpp,
+ errhp,
+ OTL_RCAST(text*,OTL_CCAST(char*,name)),
+ OTL_SCAST(sb4,strlen(name)),
+ OTL_RCAST(dvoid*,v.p_v),
+ OTL_SCAST(sb4,-1),
+ OTL_SCAST(ub2,tmpl_ftype2ora_ftype(ftype)),
+ OTL_RCAST(dvoid*,v.p_ind),
+ 0,
+ 0,
+ 0,
+ 0,
+ OTL_SCAST(ub4,OCI_DEFAULT));
+ if(status)return 0;
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_clob){
+ v.csid=OTL_UNICODE_ID;
+ status=OCIAttrSet
+ (bindpp,
+ OCI_HTYPE_BIND,
+ &v.csid,
+ 0,
+ OCI_ATTR_CHARSET_ID,
+ errhp);
+ if(status)return 0;
+ if(v.nls_flag)
+ v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR);
+ else
+ v.csfrm=OTL_SCAST(ub1,db->char_set_);
+ status=OCIAttrSet
+ (bindpp,
+ OCI_HTYPE_BIND,
+ &v.csfrm,
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM),
+ errhp);
+ if(status)return 0;
+ }
+#endif
+
+#if defined(OTL_ORA_UTF8)
+ if(ftype==otl_var_clob){
+ if(v.nls_flag)
+ v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR);
+ else
+ v.csfrm=OTL_SCAST(ub1,db->char_set_);
+ status=OCIAttrSet
+ (bindpp,
+ OCI_HTYPE_BIND,
+ &v.csfrm,
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM),
+ errhp);
+ if(status)return 0;
+ }
+#endif
+ return 1;
+ }
+ if(status)return 0;
+ return 1;
+
+ }
+
+ int bind
+ (const int column_num,
+ otl_var& v,
+ const int elem_size,
+ const int ftype,
+ const int /*param_type*/)
+ {OCIDefine *defnp;
+ int db_ftype=0;
+
+ if(ftype!=otl_var_clob&&ftype!=otl_var_blob){
+ int var_elem_size;
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_char)
+ var_elem_size=elem_size*sizeof(OTL_WCHAR);
+ else if(ftype==otl_var_varchar_long)
+ var_elem_size=elem_size+sizeof(sb4);
+ else
+ var_elem_size=elem_size;
+#elif defined(OTL_ORA_UTF8)
+ if(ftype==otl_var_char && v.select_stm_flag)
+ var_elem_size=elem_size*OTL_UTF8_BYTES_PER_CHAR; // 3 bytes per UTF8 char
+ else if(ftype==otl_var_varchar_long)
+ var_elem_size=elem_size+sizeof(sb4);
+ else
+ var_elem_size=elem_size;
+#else
+ if(ftype==otl_var_varchar_long)
+ var_elem_size=elem_size+sizeof(sb4);
+ else
+ var_elem_size=elem_size;
+#endif
+ db_ftype=tmpl_ftype2ora_ftype(ftype);
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_char)
+ db_ftype=SQLT_VCS;
+#endif
+ status=OCIDefineByPos
+ (cda,
+ &defnp,
+ errhp,
+ OTL_SCAST(ub4,column_num),
+ OTL_RCAST(dvoid*,v.p_v),
+ OTL_SCAST(sb4,ftype==otl_var_raw?var_elem_size+sizeof(short):var_elem_size),
+ OTL_SCAST(ub2,db_ftype),
+ OTL_RCAST(dvoid*,v.p_ind),
+ OTL_RCAST(ub2*,v.p_rlen),
+ OTL_RCAST(ub2*,v.p_rcode),
+ OCI_DEFAULT);
+ if(status)return 0;
+
+#if defined(OTL_ORA_UTF8)
+ if(ftype==otl_var_char||ftype==otl_var_varchar_long){
+ if(v.nls_flag)
+ v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR);
+ else
+ v.csfrm=OTL_SCAST(ub1,db->char_set_);
+ status=OCIAttrSet
+ (defnp,
+ OCI_HTYPE_DEFINE,
+ OTL_RCAST(void*,&v.csfrm),
+ OTL_SCAST(ub4,0),
+ OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM),
+ errhp);
+ if(status)return 0;
+ }
+#endif
+
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_char||ftype==otl_var_varchar_long){
+ if(v.nls_flag)
+ v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR);
+ else
+ v.csfrm=OTL_SCAST(ub1,db->char_set_);
+ status=OCIAttrSet
+ (defnp,
+ OCI_HTYPE_DEFINE,
+ OTL_RCAST(void*,&v.csfrm),
+ OTL_SCAST(ub4,0),
+ OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM),
+ errhp);
+ if(status)return 0;
+ v.csid=OTL_UNICODE_ID;
+ status=OCIAttrSet
+ (defnp,
+ OCI_HTYPE_DEFINE,
+ &v.csid,
+ 0,
+ OCI_ATTR_CHARSET_ID,
+ errhp);
+ if(status)return 0;
+ }
+#endif
+ return 1;
+ }else{
+ status=OCIDefineByPos
+ (cda,
+ &defnp,
+ errhp,
+ OTL_SCAST(ub4,column_num),
+ OTL_RCAST(dvoid*,v.p_v),
+ OTL_SCAST(sb4,-1),
+ OTL_SCAST(ub2,tmpl_ftype2ora_ftype(ftype)),
+ OTL_RCAST(dvoid*,v.p_ind),
+ OTL_RCAST(ub2*,v.p_rlen),
+ OTL_RCAST(ub2*,v.p_rcode),
+ OCI_DEFAULT);
+ if(status)return 0;
+#if defined(OTL_UNICODE)
+ if(ftype==otl_var_char||ftype==otl_var_varchar_long){
+ v.csid=OTL_UNICODE_ID;
+ status=OCIAttrSet
+ (defnp,
+ OCI_HTYPE_DEFINE,
+ &v.csid,
+ 0,
+ OCI_ATTR_CHARSET_ID,
+ errhp);
+ if(status)return 0;
+ }
+#endif
+#if defined(OTL_ORA_UTF8)
+ if(ftype==otl_var_clob){
+ if(v.nls_flag)
+ v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR);
+ else
+ v.csfrm=OTL_SCAST(ub1,db->char_set_);
+ status=OCIAttrSet
+ (defnp,
+ OCI_HTYPE_DEFINE,
+ OTL_RCAST(void*,&v.csfrm),
+ OTL_SCAST(ub4,0),
+ OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM),
+ errhp);
+ if(status)return 0;
+ }
+#endif
+
+ return 1;
+ }
+ }
+
+ void set_select_type(const int select_type)
+ {
+ straight_select=select_type;
+ }
+
+ int describe_column
+ (otl_column_desc& col,
+ const int column_num,
+ int& eof_desc)
+ {
+ OCIParam* pard;
+ ub2 dtype;
+ ub2 dbsize;
+ sb2 prec;
+
+#if defined(OTL_ORA8_8I_DESC_COLUMN_SCALE)
+ ub1 scale;
+#else
+ sb2 scale;
+#endif
+
+ ub1 nullok;
+ text* col_name;
+ ub4 col_name_len;
+ ub4 pos_num;
+
+ eof_desc=0;
+ if(straight_select&&pos_nbr==0){
+ status=OCIStmtExecute
+ (db->get_svchp(),
+ cda,
+ errhp,
+ 0,
+ 0,
+ 0,
+ 0,
+ OCI_DESCRIBE_ONLY);
+ if(status!=OCI_SUCCESS)return 0;
+ status=OCIAttrGet
+ (cda,
+ OCI_HTYPE_STMT,
+ OTL_RCAST(ub4*,&pos_num),
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_PARAM_COUNT),
+ errhp);
+ if(status!=OCI_SUCCESS)return 0;
+ pos_nbr=OTL_SCAST(int,pos_num);
+ }
+ if(!straight_select&&pos_nbr==0){
+ status=OCIAttrGet
+ (cda,
+ OCI_HTYPE_STMT,
+ OTL_RCAST(ub4*,&pos_num),
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_PARAM_COUNT),
+ errhp);
+ if(status!=OCI_SUCCESS)return 0;
+ pos_nbr=OTL_SCAST(int,pos_num);
+ }
+ if(column_num<1||column_num>pos_nbr){
+ eof_desc=1;
+ return 0;
+ }
+#if defined(__GNUC__) && (__GNUC__>=4)
+ void* temp_pard=&pard;
+#endif
+ status=OCIParamGet
+ (cda,
+ OCI_HTYPE_STMT,
+ errhp,
+#if defined(__GNUC__) && (__GNUC__>=4)
+ OTL_RCAST(void**,temp_pard),
+#else
+ OTL_RCAST(void**,&pard),
+#endif
+ OTL_SCAST(ub4,column_num));
+ if(status!=OCI_SUCCESS&&status!=OCI_NO_DATA)
+ return 0;
+ if(status==OCI_NO_DATA){
+ eof_desc=1;
+ return 1;
+ }
+ status=OCIAttrGet
+ (OTL_RCAST(dvoid*,pard),
+ OTL_SCAST(ub4,OCI_DTYPE_PARAM),
+ OTL_RCAST(dvoid*,&dtype),
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_DATA_TYPE),
+ OTL_RCAST(OCIError*,errhp));
+ if(status!=OCI_SUCCESS)return 0;
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+#if !defined(OTL_ORA8I)
+ ub1 charset_form;
+ status=OCIAttrGet
+ (OTL_RCAST(dvoid*,pard),
+ OTL_SCAST(ub4,OCI_DTYPE_PARAM),
+ OTL_RCAST(dvoid*,&charset_form),
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM),
+ OTL_RCAST(OCIError*,errhp));
+ if(status!=OCI_SUCCESS)return 0;
+ col.charset_form=OTL_SCAST(int,charset_form);
+ ub2 char_size;
+ status=OCIAttrGet
+ (OTL_RCAST(dvoid*,pard),
+ OTL_SCAST(ub4,OCI_DTYPE_PARAM),
+ OTL_RCAST(dvoid*,&char_size),
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_CHAR_SIZE),
+ OTL_RCAST(OCIError*,errhp));
+ if(status!=OCI_SUCCESS)return 0;
+ col.char_size=OTL_SCAST(int,char_size);
+#else
+ col.char_size=0;
+#endif
+#endif
+ col.dbtype=dtype;
+#if defined(__GNUC__) && (__GNUC__>=4)
+ void* temp_col_name=&col_name;
+#endif
+ status=OCIAttrGet
+ (OTL_RCAST(dvoid*,pard),
+ OTL_SCAST(ub4,OCI_DTYPE_PARAM),
+#if defined(__GNUC__) && (__GNUC__>=4)
+ OTL_RCAST(dvoid**,temp_col_name),
+#else
+ OTL_RCAST(dvoid**,&col_name),
+#endif
+ OTL_RCAST(ub4*,&col_name_len),
+ OTL_SCAST(ub4,OCI_ATTR_NAME),
+ OTL_RCAST(OCIError*,errhp));
+ if(status!=OCI_SUCCESS)return 0;
+ col.set_name(OTL_RCAST(char*,col_name),col_name_len);
+ status=OCIAttrGet
+ (OTL_RCAST(dvoid*,pard),
+ OTL_SCAST(ub4,OCI_DTYPE_PARAM),
+ OTL_RCAST(dvoid*,&dbsize),
+ OTL_RCAST(ub4*,0),
+ OTL_SCAST(ub4,OCI_ATTR_DATA_SIZE),
+ OTL_RCAST(OCIError*,errhp));
+ if(status!=OCI_SUCCESS)return 0;
+ col.dbsize=dbsize;
+ status=OCIAttrGet
+ (OTL_RCAST(dvoid*,pard),
+ OTL_SCAST(ub4,OCI_DTYPE_PARAM),
+ OTL_RCAST(dvoid*,&prec),
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_PRECISION),
+ OTL_RCAST(OCIError*,errhp));
+ if(status!=OCI_SUCCESS)return 0;
+ col.prec=prec;
+ status=OCIAttrGet
+ (OTL_RCAST(dvoid*,pard),
+ OTL_SCAST(ub4,OCI_DTYPE_PARAM),
+ OTL_RCAST(dvoid*,&scale),
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_SCALE),
+ OTL_RCAST(OCIError*,errhp));
+ if(status!=OCI_SUCCESS)return 0;
+ col.scale=scale;
+ status=OCIAttrGet
+ (OTL_RCAST(dvoid*,pard),
+ OTL_SCAST(ub4,OCI_DTYPE_PARAM),
+ OTL_RCAST(dvoid*,&nullok),
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_IS_NULL),
+ OTL_RCAST(OCIError*,errhp));
+ if(status!=OCI_SUCCESS)return 0;
+ col.nullok=nullok;
+ return 1;
+ }
+
+ void error(otl_exc& exception_struct)
+ {sb4 errcode;
+ size_t len;
+
+ OTL_STRCPY_S(OTL_RCAST(char*,exception_struct.msg),
+ sizeof(exception_struct.msg),
+ "123456789");
+ OCIErrorGet
+ (OTL_RCAST(dvoid*,errhp),
+ OTL_SCAST(ub4,1),
+ 0,
+ &errcode,
+ OTL_RCAST(text*,exception_struct.msg),
+ OTL_SCAST(ub4,sizeof(exception_struct.msg)),
+ OCI_HTYPE_ERROR);
+ exception_struct.code=errcode;
+ len=strlen(OTL_RCAST(char*,exception_struct.msg));
+ exception_struct.msg[len]=0;
+#if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET)
+ ub2 error_offset;
+ if(OCIAttrGet
+ (cda,
+ OCI_HTYPE_STMT,
+ OTL_RCAST(ub2*,&error_offset),
+ 0,
+ OTL_SCAST(ub4,OCI_ATTR_PARSE_ERROR_OFFSET),
+ errhp)==OCI_SUCCESS)
+ exception_struct.error_offset=OTL_SCAST(int,error_offset);
+#endif
+ }
+
+private:
+
+ otl_cur(const otl_cur&):
+ otl_cur0(),
+ cda(0),
+ errhp(0),
+ extern_cda(false),
+ status(0),
+ eof_status(0),
+ db(0),
+ straight_select(1),
+ pos_nbr(0),
+ commit_on_success(0),
+ last_param_data_token(0),
+ last_sql_param_data_status(0),
+ sql_param_data_count(0),
+ canceled(false),
+ direct_exec_flag(0),
+ parse_only_flag(0),
+ stm_executed(0)
+ {
+ }
+
+ otl_cur& operator=(const otl_cur&)
+ {
+ return *this;
+ }
+
+
+};
+
+
+class otl_ref_cursor;
+
+class otl_sel{
+private:
+
+ friend class otl_ref_cursor;
+ int implicit_cursor;
+
+public:
+
+ int get_implicit_cursor() const {return implicit_cursor;}
+
+ void set_arr_size
+ (const int input_arr_size,
+ int& out_array_size,
+ int& out_prefetch_array_size)
+ {
+ out_array_size=input_arr_size;
+ out_prefetch_array_size=0;
+ }
+
+ void set_prefetch_size(const int /*aprefetch_array_size*/)
+ {
+ }
+
+ int close_select(otl_cur& /*cur*/)
+ {
+ int i=1;
+ return i;
+ }
+
+ otl_sel():
+ implicit_cursor(0)
+ {
+ }
+
+ virtual ~otl_sel(){}
+
+ void set_select_type(const int /*atype*/)
+ {
+ implicit_cursor=0;
+ }
+
+ void init(const int /*array_size*/){}
+
+ int first
+ (otl_cur& cur,
+ int& cur_row,
+ int& cur_size,
+ int& row_count,
+ int& eof_data,
+ const int array_size)
+ {int rc;
+ eof_data=0;
+ cur_row=-1;
+ cur.commit_on_success=0;
+ rc=cur.exec(0,0,otl_sql_exec_from_select_cursor_class);
+ if(rc==0)return 0;
+ rc=cur.fetch(OTL_SCAST(otl_stream_buffer_size_type,array_size),eof_data);
+ if(rc==0)return 0;
+ row_count=cur.rpc();
+ cur_size=row_count;
+ if(cur_size!=0)cur_row=0;
+ return 1;
+ }
+
+ int next
+ (otl_cur& cur,
+ int& cur_row,
+ int& cur_size,
+ int& row_count,
+ int& eof_data,
+ const int array_size)
+ {int rc;
+ if(cur_row<cur_size-1){
+ ++cur_row;
+ return 1;
+ }else{
+ if(eof_data){
+ cur_row=-1;
+ cur_size=0;
+ return 1;
+ }
+ cur.commit_on_success=0;
+ rc=cur.fetch(OTL_SCAST(otl_stream_buffer_size_type,array_size),eof_data);
+ if(rc==0)return 0;
+ int temp_rpc=cur.rpc();
+ cur_size=temp_rpc-row_count;
+ row_count=temp_rpc;
+ if(cur_size!=0)cur_row=0;
+ return 1;
+ }
+ }
+
+private:
+
+ otl_sel(const otl_sel&):
+ implicit_cursor(0)
+ {
+ }
+
+ otl_sel& operator=(const otl_sel&)
+ {
+ return *this;
+ }
+
+};
+
+
+typedef otl_tmpl_connect
+ <otl_exc,
+ otl_conn,
+ otl_cur> otl_ora8_connect;
+
+
+typedef otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var> otl_cursor;
+
+template <OTL_TYPE_NAME TExceptionStruct,
+ OTL_TYPE_NAME TConnectStruct,
+ OTL_TYPE_NAME TCursorStruct,
+ OTL_TYPE_NAME TVariableStruct>
+class otl_tmpl_lob_stream: public otl_lob_stream_generic{
+public:
+
+ typedef otl_tmpl_exception
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct> otl_exception;
+
+ typedef otl_tmpl_variable<TVariableStruct>* p_bind_var;
+ typedef otl_tmpl_connect
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>* p_connect;
+
+ typedef otl_tmpl_cursor
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct,
+ TVariableStruct>* p_cursor;
+
+private:
+
+ p_bind_var bind_var;
+ p_connect connect;
+ p_cursor cursor;
+ otl_long_string* temp_buf;
+ char* temp_char_buf;
+
+public:
+
+ void init
+ (void* avar,void* aconnect,void* acursor,
+ int andx,
+ int amode,
+ const int alob_is_null=0) OTL_NO_THROW
+ {
+ connect=OTL_RCAST(p_connect,aconnect);
+ bind_var=OTL_RCAST(p_bind_var,avar);
+ cursor=OTL_RCAST(p_cursor,acursor);
+ mode=amode;
+ retcode=0;
+ lob_is_null=alob_is_null;
+ ndx=andx;
+ offset=0;
+ if(amode==otl_lob_stream_write_mode)
+ lob_len=2147483647;
+ else
+ lob_len=0;
+ eof_flag=0;
+ in_destructor=0;
+ if(bind_var)
+ bind_var->get_var_struct().set_lob_stream_flag();
+ }
+
+ void set_len(const int new_len=0) OTL_NO_THROW
+ {
+ lob_len=new_len;
+ }
+
+ otl_tmpl_lob_stream() OTL_NO_THROW:
+ otl_lob_stream_generic(true),
+ bind_var(0),
+ connect(0),
+ cursor(0),
+ temp_buf(0),
+ temp_char_buf(0)
+ {
+ init(0,0,0,0,otl_lob_stream_zero_mode);
+ }
+
+ virtual ~otl_tmpl_lob_stream()
+#if !defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ OTL_THROWS_OTL_EXCEPTION
+#endif
+ {
+ in_destructor=1;
+ if(temp_buf){
+ delete temp_buf;
+ temp_buf=0;
+ }
+ if(temp_char_buf){
+ delete[] temp_char_buf;
+ temp_char_buf=0;
+ }
+#if defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ try{
+ close();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ }
+#else
+ close();
+#endif
+ }
+
+#if (defined(OTL_STL) || defined(OTL_ACE) || \
+ defined(OTL_USER_DEFINED_STRING_CLASS_ON)) && !defined(OTL_UNICODE)
+ otl_lob_stream_generic& operator<<(const OTL_STRING_CONTAINER& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ otl_long_string temp_s(s.c_str(),
+ OTL_SCAST(int,s.length()),
+ OTL_SCAST(int,s.length()));
+ (*this)<<temp_s;
+ return *this;
+ }
+
+ void setStringBuffer(const int chunk_size)
+ {
+ delete[] temp_char_buf;
+ temp_char_buf=0;
+ delete temp_buf;
+ temp_buf=0;
+ temp_char_buf=new char[chunk_size+1];
+ temp_buf=new otl_long_string(temp_char_buf,chunk_size);
+ }
+
+ otl_lob_stream_generic& operator>>(OTL_STRING_CONTAINER& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ const int TEMP_BUF_SIZE=4096;
+ if(!temp_char_buf)temp_char_buf=new char[TEMP_BUF_SIZE];
+ if(!temp_buf)temp_buf=new otl_long_string(temp_char_buf,TEMP_BUF_SIZE-1);
+ int iters=0;
+ while(!this->eof()){
+ ++iters;
+ (*this)>>(*temp_buf);
+ temp_char_buf[temp_buf->len()]=0;
+ if(iters>1)
+ s+=temp_char_buf;
+ else
+ s=temp_char_buf;
+ }
+ return *this;
+ }
+#endif
+
+
+ otl_lob_stream_generic& operator<<(const otl_long_string& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(mode!=otl_lob_stream_write_mode){
+ const char* stm=0;
+ char var_info[256];
+ var_info[0]=0;
+ if(cursor!=0){
+ if(cursor->get_stm_label())
+ stm=cursor->get_stm_label();
+ else
+ stm=cursor->get_stm_text();
+ }
+ if(bind_var!=0){
+ otl_var_info_var
+ (bind_var->get_name(),
+ bind_var->get_ftype(),
+ otl_var_long_string,
+ var_info,
+ sizeof(var_info));
+ }
+ char* vinfo=0;
+ if(var_info[0]!=0)
+ vinfo=&var_info[0];
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_tmpl_exception
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>
+ (otl_error_msg_9,
+ otl_error_code_9,
+ stm,
+ vinfo);
+ }
+ if(offset==0)offset=1;
+ if((offset-1)+s.len()>lob_len){
+ char var_info[256];
+ otl_var_info_var
+ (bind_var->get_name(),
+ bind_var->get_ftype(),
+ otl_var_long_string,
+ var_info,
+ sizeof(var_info));
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ char err_msg[1024];
+ char temp_num[64];
+ OTL_STRCPY_S(err_msg,sizeof(err_msg),otl_error_msg_7);
+ OTL_STRCAT_S(err_msg,sizeof(err_msg),", trying to store ");
+ otl_itoa(s.len(),temp_num);
+ OTL_STRCAT_S(err_msg,sizeof(err_msg),temp_num);
+#if defined(OTL_UNICODE)
+ OTL_STRCAT_S(err_msg,sizeof(err_msg)," Unicode characters at offset ");
+#else
+ OTL_STRCAT_S(err_msg,sizeof(err_msg)," bytes at offset ");
+#endif
+ otl_itoa(offset,temp_num);
+ OTL_STRCAT_S(err_msg,sizeof(err_msg),temp_num);
+ OTL_STRCAT_S(err_msg,sizeof(err_msg),". New length: ");
+ otl_itoa((offset-1)+s.len(),temp_num);
+ OTL_STRCAT_S(err_msg,sizeof(err_msg),temp_num);
+ OTL_STRCAT_S(err_msg,sizeof(err_msg)," would be bigger than length of lob: ");
+ otl_itoa(lob_len,temp_num);
+ OTL_STRCAT_S(err_msg,sizeof(err_msg),temp_num);
+ throw otl_tmpl_exception
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>
+ (err_msg,
+ otl_error_code_7,
+ cursor->get_stm_label()?cursor->get_stm_label():
+ cursor->get_stm_text(),
+ var_info);
+ }
+ if(s.is_last_piece())
+ lob_len=(offset+s.len()-1);
+ retcode=bind_var->get_var_struct().write_blob
+ (s,lob_len,offset,cursor->get_cursor_struct());
+ if(retcode){
+ if((offset-1)==lob_len)
+ close();
+ return *this;
+ }
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_tmpl_exception
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>(connect->get_connect_struct(),
+ cursor->get_stm_label()?cursor->get_stm_label():
+ cursor->get_stm_text());
+ }
+
+ otl_lob_stream_generic& operator>>(otl_long_string& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(mode!=otl_lob_stream_read_mode){
+ const char* stm=0;
+ char var_info[256];
+ var_info[0]=0;
+ if(cursor!=0){
+ if(cursor->get_stm_label())
+ stm=cursor->get_stm_label();
+ else
+ stm=cursor->get_stm_text();
+ }
+ if(bind_var!=0){
+ otl_var_info_var
+ (bind_var->get_name(),
+ bind_var->get_ftype(),
+ otl_var_long_string,
+ var_info,
+ sizeof(var_info));
+ }
+ char* vinfo=0;
+ if(var_info[0]!=0)
+ vinfo=&var_info[0];
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_tmpl_exception
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>
+ (otl_error_msg_10,
+ otl_error_code_10,
+ stm,
+ vinfo);
+ }
+ if(offset==0&&lob_len==0)
+ lob_len=len();
+ if(lob_len==0||(offset-1)==lob_len){
+ s.set_len(0);
+ eof_flag=1;
+ return *this;
+ }
+ if(offset==0)offset=1;
+ retcode=bind_var->get_var_struct().read_blob(s,ndx,offset,lob_len);
+ if((offset-1)==lob_len)eof_flag=1;
+ if(retcode){
+ if(eof()){
+ close();
+ eof_flag=1;
+ }
+ return *this;
+ }
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_tmpl_exception
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>(connect->get_connect_struct(),
+ cursor->get_stm_label()?cursor->get_stm_label():
+ cursor->get_stm_text());
+ }
+
+ int eof(void) OTL_NO_THROW
+ {
+ if(lob_is_null)return 1;
+ return eof_flag;
+ }
+
+ bool is_initialized(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if(cursor==0||connect==0||bind_var==0||lob_is_null)return false;
+ int is_init=0;
+ retcode=bind_var->get_var_struct().is_blob_initialized(ndx,is_init);
+ if(retcode) return is_init!=0;
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return false;
+ if(otl_uncaught_exception()) return false;
+ throw OTL_TMPL_EXCEPTION
+ (connect->get_connect_struct(),
+ cursor->get_stm_label()?cursor->get_stm_label():
+ cursor->get_stm_text());
+ }
+
+ int len(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if(cursor==0||connect==0||bind_var==0||lob_is_null)return 0;
+ int alen;
+ retcode=bind_var->get_var_struct().get_blob_len(ndx,alen);
+ if(retcode)return alen;
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_tmpl_exception
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>(connect->get_connect_struct(),
+ cursor->get_stm_label()?cursor->get_stm_label():
+ cursor->get_stm_text());
+ }
+
+ void close(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if(in_destructor){
+ if(mode==otl_lob_stream_read_mode){
+ bind_var->get_var_struct().set_lob_stream_flag(0);
+ bind_var->set_not_null(0);
+ }
+ return;
+ }
+ if(mode==otl_lob_stream_zero_mode)return;
+ if(mode==otl_lob_stream_read_mode){
+ if(offset<lob_len-1)
+ bind_var->get_var_struct().close_lob();
+ bind_var->get_var_struct().set_lob_stream_flag(0);
+ bind_var->set_not_null(0);
+ init(0,0,0,0,otl_lob_stream_zero_mode);
+ }else{
+ // write mode
+ if(!(offset==0&&lob_len==0)&&(offset-1)!=lob_len){
+ bind_var->get_var_struct().close_lob();
+ char var_info[256];
+ char msg_buf[1024];
+ OTL_STRCPY_S(msg_buf,sizeof(msg_buf),otl_error_msg_8);
+ otl_var_info_var
+ (bind_var->get_name(),
+ bind_var->get_ftype(),
+ otl_var_long_string,
+ var_info,
+ sizeof(var_info));
+ if(this->connect)this->connect->increment_throw_count();
+ if(this->connect&&this->connect->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_tmpl_exception
+ <TExceptionStruct,
+ TConnectStruct,
+ TCursorStruct>
+ (msg_buf,
+ otl_error_code_8,
+ cursor->get_stm_label()?cursor->get_stm_label():
+ cursor->get_stm_text(),
+ var_info);
+ }
+ bind_var->get_var_struct().set_lob_stream_flag(0);
+ bind_var->set_not_null(0);
+ }
+ }
+private:
+
+ otl_tmpl_lob_stream(const otl_tmpl_lob_stream&) OTL_NO_THROW:
+ otl_lob_stream_generic(true),
+ bind_var(0),
+ connect(0),
+ cursor(0),
+ temp_buf(0),
+ temp_char_buf(0)
+ {
+ }
+
+ otl_tmpl_lob_stream& operator=(const otl_tmpl_lob_stream&)
+ {
+ return *this;
+ }
+
+};
+
+typedef otl_tmpl_lob_stream
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var> otl_lob_stream;
+
+typedef otl_tmpl_exception
+ <otl_exc,
+ otl_conn,
+ otl_cur> otl_exception;
+
+typedef otl_tmpl_inout_stream
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var,
+ otl_time0> otl_ora8_inout_stream;
+
+typedef otl_tmpl_select_stream
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var,
+ otl_sel,
+ otl_time0> otl_select_stream;
+
+
+typedef otl_tmpl_ext_hv_decl
+ <otl_var,
+ otl_time0,
+ otl_exc,
+ otl_conn,
+ otl_cur> otl_ext_hv_decl;
+
+const int otl_no_stream_type=0;
+const int otl_inout_stream_type=1;
+const int otl_refcur_stream_type=2;
+const int otl_select_stream_type=3;
+const int otl_constant_sql_type=4;
+const int otl_mixed_refcur_stream_type=5;
+
+class otl_connect: public otl_ora8_connect{
+protected:
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ otl_stream_pool sc;
+#endif
+
+public:
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+
+ otl_stream_pool& get_sc(){return sc;}
+
+ void set_stream_pool_size(const int max_size=otl_max_default_pool_size)
+ {
+ sc.init(max_size);
+ }
+
+#endif
+
+public:
+
+ long direct_exec
+ (const char* sqlstm,
+ const int exception_enabled=1)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ return otl_cursor::direct_exec(*this,sqlstm,exception_enabled);
+ }
+
+ void syntax_check(const char* sqlstm)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ otl_cursor::syntax_check(*this,sqlstm);
+ }
+
+ otl_connect() OTL_NO_THROW:
+ otl_ora8_connect(),
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ sc(),
+#endif
+ cmd_(0)
+ {
+ }
+
+#if defined(OTL_ORA_OCI_ENV_CREATE)
+ void set_connect_mode(bool threaded_mode=false)
+ {
+ connect_struct.set_threaded_mode(threaded_mode);
+ }
+#endif
+
+#if defined(OTL_UNICODE) || defined(OTL_ORA_UTF8)
+ void set_character_set(const int char_set=SQLCS_IMPLICIT)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ connect_struct.set_char_set(char_set);
+ }
+#endif
+
+ otl_connect(const char* connect_str,
+ const int aauto_commit=0
+#if defined(OTL_ORA_OCI_ENV_CREATE)
+ ,bool threaded_mode=false
+#endif
+ )
+ OTL_THROWS_OTL_EXCEPTION
+ : otl_ora8_connect(),
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ sc(),
+#endif
+ cmd_(0)
+ {
+#if defined(OTL_ORA_OCI_ENV_CREATE)
+ set_connect_mode(threaded_mode);
+#endif
+ rlogon(connect_str,aauto_commit);
+ }
+
+ virtual ~otl_connect()
+#if !defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ OTL_THROWS_OTL_EXCEPTION
+#endif
+ {
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+#if defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ try{
+ logoff();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ }
+#else
+ logoff();
+#endif
+ }
+
+ const char* getCmd(void) const
+ {
+ return cmd_;
+ }
+
+ otl_connect& operator<<(const char* cmd)
+ {
+ if(!connected){
+ this->rlogon(cmd);
+ }else{
+ otl_cursor::direct_exec(*this,cmd);
+ }
+ return *this;
+ }
+
+ otl_connect& operator<<=(const char* cmd)
+ {
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+ size_t cmd_len=strlen(cmd);
+ cmd_=new char[cmd_len+1];
+ OTL_STRCPY_S(cmd_,cmd_len+1,cmd);
+ return *this;
+ }
+
+ static int otl_terminate(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+#if defined(OTL_ORA8)&&!defined(OTL_ORA8I)&&!defined(OTL_ORA9I)
+ return 1;
+#else
+ return OCITerminate(OCI_DEFAULT)==OCI_SUCCESS;
+#endif
+ }
+
+ void cancel(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(!connected)return;
+ retcode=connect_struct.cancel();
+ if(!retcode){
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+ }
+
+#if defined(OTL_ORA10G_R2)
+ void commit_nowait(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(!connected)return;
+ retcode=connect_struct.commit_nowait();
+ if(!retcode){
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+ }
+#endif
+
+#if defined(OTL_ORA8I) || defined(OTL_ORA9I)
+ void change_password
+ (const char* user_name,
+ const char* old_password,
+ const char* new_password)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ throw_count=0;
+ retcode=connect_struct.change_password
+ (user_name,
+ old_password,
+ new_password);
+ if(!retcode){
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+ }
+#endif
+
+ void auto_commit_off(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ otl_ora8_connect::auto_commit_off();
+ }
+
+ void auto_commit_on(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ otl_ora8_connect::auto_commit_on();
+ }
+
+ void rlogon(OCIEnv *envhp,OCISvcCtx *svchp)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(this->connected){
+ throw otl_exception(otl_error_msg_30,otl_error_code_30);
+ }
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+ connected=0;
+ long_max_size=32760;
+ retcode=connect_struct.ext_logon(envhp,svchp,0);
+ if(retcode)
+ connected=1;
+ else{
+ connected=0;
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+ }
+
+ void rlogon(const char* connect_str,
+ const int aauto_commit=0,
+ const char* xa_server_external_name=0,
+ const char* xa_server_internal_name=0
+#if defined(OTL_ORA_OCI_ENV_CREATE)
+ ,bool threaded_mode=false
+#endif
+ )
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(this->connected){
+ throw otl_exception(otl_error_msg_30,otl_error_code_30);
+ }
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+ if(xa_server_external_name!=0 && xa_server_internal_name!=0){
+ connect_struct.set_xa_server_external_name
+ (xa_server_external_name);
+ connect_struct.set_xa_server_internal_name
+ (xa_server_internal_name);
+ }
+#if defined(OTL_ORA_OCI_ENV_CREATE)
+ set_connect_mode(threaded_mode);
+#endif
+ otl_ora8_connect::rlogon(connect_str,aauto_commit);
+ if(connect_struct.get_last_status()==OCI_SUCCESS_WITH_INFO){
+ otl_exception ex(connect_struct);
+ if(ex.code!=0){
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw ex;
+ }
+ }
+ }
+
+ void logoff(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ if(connected)
+ sc.init(sc.get_max_size());
+#endif
+ if(!connected){
+ connect_struct.session_end();
+ connect_struct.server_detach();
+ }else{
+ OTL_TRACE_FUNC(0x1,"otl_connect","logoff","")
+ if(connect_struct.get_extern_lda())
+ connect_struct.logoff();
+ else{
+ session_end();
+ server_detach();
+ }
+ connected=0;
+ }
+ }
+
+ void server_attach(const char* tnsname=0,
+ const char* xa_server_external_name=0,
+ const char* xa_server_internal_name=0
+#if defined(OTL_ORA_OCI_ENV_CREATE)
+ ,bool threaded_mode=false
+#endif
+ )
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+ if(xa_server_external_name!=0 && xa_server_internal_name!=0){
+ connect_struct.set_xa_server_external_name
+ (xa_server_external_name);
+ connect_struct.set_xa_server_internal_name
+ (xa_server_internal_name);
+ }
+ connected=0;
+ long_max_size=32760;
+ throw_count=0;
+#if defined(OTL_ORA_OCI_ENV_CREATE)
+ set_connect_mode(threaded_mode);
+#endif
+ retcode=connect_struct.server_attach(tnsname);
+ if(!retcode){
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+ }
+
+ void server_detach(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ retcode=connect_struct.server_detach();
+ if(!retcode){
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+ }
+
+ void session_begin
+ (const char* username,
+ const char* password,
+ const int auto_commit=0,
+ const int session_mode=OCI_DEFAULT
+ // OCI_SYSDBA -- in this mode, the user is authenticated for SYSDBA
+ // access.
+ // OCI_SYSOPER -- in this mode, the user is authenticated
+ // for SYSOPER access.
+ ) OTL_THROWS_OTL_EXCEPTION
+ {
+ if(cmd_){
+ delete[] cmd_;
+ cmd_=0;
+ }
+ throw_count=0;
+ retcode=connect_struct.session_begin
+ (username,password,auto_commit,session_mode);
+ if(retcode)
+ connected=1;
+ else{
+ connected=0;
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+ if(connect_struct.get_last_status()==OCI_SUCCESS_WITH_INFO){
+ otl_exception ex(connect_struct);
+ if(ex.code!=0){
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw ex;
+ }
+ }
+ }
+
+ void session_reopen(const int auto_commit=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ throw_count=0;
+ if(connect_struct.get_session_begin_count()==0){
+ connected=0;
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(otl_error_msg_11,otl_error_code_11);
+ }
+ retcode=connect_struct.session_begin(auto_commit);
+ if(retcode)
+ connected=1;
+ else{
+ connected=0;
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+ if(connect_struct.get_last_status()==OCI_SUCCESS_WITH_INFO){
+ otl_exception ex(connect_struct);
+ if(ex.code!=0){
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw ex;
+ }
+ }
+ }
+
+ void session_end(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ if(connected)
+ sc.init(sc.get_max_size());
+#endif
+ connected=0;
+ retcode=connect_struct.session_end();
+ if(!retcode){
+ increment_throw_count();
+ if(get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(connect_struct);
+ }
+ }
+
+private:
+
+ char* cmd_;
+
+ otl_connect& operator=(const otl_connect&)
+ {
+ return *this;
+ }
+
+ otl_connect(const otl_connect&)
+ : otl_ora8_connect(),
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ sc(),
+#endif
+ cmd_(0)
+ {
+ }
+
+
+};
+
+typedef otl_tmpl_variable<otl_var> otl_generic_variable;
+typedef otl_generic_variable* otl_p_generic_variable;
+
+class otl_refcur_base_cursor: public
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var> {
+
+protected:
+
+ int cur_row;
+ int cur_size;
+ int row_count;
+ int array_size;
+
+public:
+
+ otl_refcur_base_cursor
+ (otl_connect& db,
+ otl_var* var,
+ const char* master_plsql_block,
+ const otl_stream_buffer_size_type arr_size=1)
+ :otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>(db,var),
+ cur_row(-1),
+ cur_size(0),
+ row_count(0),
+ array_size(arr_size)
+ {
+ size_t len=strlen(master_plsql_block)+1;
+ stm_text=new char[len];
+ OTL_STRCPY_S(stm_text,len,master_plsql_block);
+ }
+
+ otl_refcur_base_cursor():
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>(),
+ cur_row(-1),
+ cur_size(0),
+ row_count(0),
+ array_size(0)
+ {
+ }
+
+ virtual ~otl_refcur_base_cursor()
+ {
+ delete[] stm_text;
+ stm_text=0;
+ }
+
+ void open
+ (otl_connect& db,
+ otl_var* var,
+ const char* master_plsql_block,
+ const otl_stream_buffer_size_type arr_size=1)
+ {
+ cur_row=-1;
+ row_count=0;
+ cur_size=0;
+ array_size=arr_size;
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::open(db,var);
+ size_t len=strlen(master_plsql_block)+1;
+ stm_text=new char[len];
+ OTL_STRCPY_S(stm_text,len,master_plsql_block);
+ }
+
+ void close(void)
+ {
+ delete[] stm_text;
+ stm_text=0;
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::close();
+ }
+
+ int first(void)
+ {int rc;
+
+ cur_row=-1;
+ rc=cursor_struct.fetch(OTL_SCAST
+ (otl_stream_buffer_size_type,
+ array_size),
+ eof_data);
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_exception(cursor_struct,stm_label?stm_label:stm_text);
+ }
+ row_count=cursor_struct.rpc();
+ cur_size=row_count;
+ if(cur_size!=0)cur_row=0;
+ return cur_size!=0;
+ }
+
+ int next(void)
+ {int rc;
+ if(cur_row<0)return first();
+ if(cur_row<cur_size-1)
+ ++cur_row;
+ else{
+ if(otl_tmpl_cursor<otl_exc,otl_conn,otl_cur,otl_var>::eof()){
+ cur_row=-1;
+ return 0;
+ }
+ rc=cursor_struct.fetch(OTL_SCAST(otl_stream_buffer_size_type,
+ array_size),eof_data);
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_exception(cursor_struct,stm_label?stm_label:stm_text);
+ }
+ cur_size=cursor_struct.rpc()-row_count;
+ row_count=cursor_struct.rpc();
+ if(cur_size!=0)cur_row=0;
+ }
+ return cur_size!=0;
+ }
+
+ void bind_col
+ (const int column_num,
+ otl_generic_variable& v)
+ {
+ if(!connected)return;
+ v.set_pos(column_num);
+ otl_refcur_base_cursor::bind(column_num,v);
+ }
+
+ int describe_select
+ (otl_column_desc* desc,
+ int& desc_len)
+ {int i;
+ desc_len=0;
+ cursor_struct.straight_select=0;
+ for(i=1;describe_column(desc[i-1],i);++i)
+ ++desc_len;
+ return 1;
+ }
+
+private:
+
+ otl_refcur_base_cursor(const otl_refcur_base_cursor&):
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>(),
+ cur_row(-1),
+ cur_size(0),
+ row_count(0),
+ array_size(0)
+ {
+ }
+
+ otl_refcur_base_cursor& operator=(const otl_refcur_base_cursor&)
+ {
+ return *this;
+ }
+
+};
+
+#if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE)
+
+#define OTL_ORA_COMMON_READ_STREAM otl_read_stream_interface
+#define OTL_ORA_REFCUR_COMMON_READ_STREAM otl_read_stream_interface
+
+class otl_read_stream_interface{
+public:
+
+ virtual ~otl_read_stream_interface(){}
+
+ virtual int is_null(void) OTL_NO_THROW = 0;
+ virtual void rewind(void) OTL_THROWS_OTL_EXCEPTION = 0;
+ virtual int eof(void) OTL_NO_THROW = 0;
+ virtual void skip_to_end_of_row(void) OTL_NO_THROW = 0;
+
+ virtual otl_var_desc* describe_out_vars(int& desc_len) OTL_NO_THROW = 0;
+ virtual otl_var_desc* describe_next_out_var(void) OTL_NO_THROW = 0;
+
+ virtual otl_read_stream_interface&
+ operator>>(otl_datetime& s) OTL_THROWS_OTL_EXCEPTION = 0;
+
+#if !defined(OTL_UNICODE)
+ virtual otl_read_stream_interface&
+ operator>>(char& c) OTL_THROWS_OTL_EXCEPTION = 0;
+#endif
+
+ virtual otl_read_stream_interface&
+ operator>>(unsigned char& c) OTL_THROWS_OTL_EXCEPTION = 0;
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ virtual otl_read_stream_interface&
+ operator>>(OTL_STRING_CONTAINER& s) OTL_THROWS_OTL_EXCEPTION = 0;
+#endif
+
+#if defined(OTL_UNICODE_STRING_TYPE)
+ virtual otl_read_stream_interface&
+ operator>>(OTL_UNICODE_STRING_TYPE& s) OTL_THROWS_OTL_EXCEPTION = 0;
+#endif
+
+#if !defined(OTL_UNICODE)
+ virtual otl_read_stream_interface&
+ operator>>(char* s) OTL_THROWS_OTL_EXCEPTION = 0;
+#endif
+
+#if defined(OTL_UNICODE)
+
+ virtual otl_read_stream_interface&
+ operator>>(OTL_UNICODE_CHAR_TYPE* s) OTL_THROWS_OTL_EXCEPTION = 0;
+
+#endif
+
+ virtual otl_read_stream_interface&
+ operator>>(unsigned char* s) OTL_THROWS_OTL_EXCEPTION = 0;
+
+#if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\
+ !defined(OTL_BIGINT_TO_STR))
+ virtual otl_read_stream_interface&
+ operator>>(OTLBIGINT& f) OTL_THROWS_OTL_EXCEPTION = 0;
+#endif
+
+ virtual otl_read_stream_interface&
+ operator>>(int& n) OTL_THROWS_OTL_EXCEPTION = 0;
+
+ virtual otl_read_stream_interface&
+ operator>>(unsigned& u) OTL_THROWS_OTL_EXCEPTION = 0;
+
+ virtual otl_read_stream_interface&
+ operator>>(short& sh) OTL_THROWS_OTL_EXCEPTION = 0;
+
+ virtual otl_read_stream_interface&
+ operator>>(long int& l) OTL_THROWS_OTL_EXCEPTION = 0;
+
+ virtual otl_read_stream_interface&
+ operator>>(float& f) OTL_THROWS_OTL_EXCEPTION = 0;
+
+ virtual otl_read_stream_interface&
+ operator>>(double& d) OTL_THROWS_OTL_EXCEPTION = 0;
+
+ virtual otl_read_stream_interface&
+ operator>>(otl_long_string& s) OTL_THROWS_OTL_EXCEPTION = 0;
+
+ virtual otl_read_stream_interface&
+ operator>>(otl_lob_stream& s) OTL_THROWS_OTL_EXCEPTION = 0;
+
+ virtual otl_column_desc*
+ describe_select(int& desc_len) OTL_NO_THROW = 0;
+
+};
+#else
+
+#define OTL_ORA_COMMON_READ_STREAM otl_stream
+#define OTL_ORA_REFCUR_COMMON_READ_STREAM otl_refcur_stream
+
+#endif
+
+class otl_refcur_stream:
+#if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE)
+ public otl_read_stream_interface,
+#endif
+ public otl_refcur_base_cursor{
+
+protected:
+
+ int delay_next;
+ int same_sl_flag;
+ otl_select_struct_override override;
+
+ otl_var_desc* ov;
+ int ov_len;
+ int next_ov_ndx;
+
+
+public:
+
+ void skip_to_end_of_row()
+ {
+ check_if_executed();
+ if(eof())return;
+ while(cur_col<sl_len-1){
+ ++cur_col;
+ null_fetched=sl[cur_col].is_null(this->cur_row);
+ }
+ ret_code=this->next();
+ cur_col=0;
+ if(!eof())
+ cur_col=-1;
+ }
+
+
+ bool good() const
+ {
+ return get_connected()==1;
+ }
+
+ bool get_lob_stream_flag() const
+ {
+ return true;
+ }
+
+ int get_adb_max_long_size() const
+ {
+ return this->adb->get_max_long_size();
+ }
+
+ void inc_next_ov(void)
+ {
+ if(ov_len==0)return;
+ if(next_ov_ndx<ov_len-1)
+ ++next_ov_ndx;
+ else
+ next_ov_ndx=0;
+ }
+
+ void set_column_type(const int column_ndx,
+ const int col_type,
+ const int col_size=0)
+ OTL_NO_THROW
+ {
+ override.add_override(column_ndx,col_type,col_size);
+ }
+
+ void set_all_column_types(const unsigned mask=0)
+ OTL_NO_THROW
+ {
+ override.set_all_column_types(mask);
+ }
+
+ void cleanup(void)
+ {int i;
+ delete[] sl;
+ delete[] ov;
+ for(i=0;i<vl_len;++i)
+ delete vl[i];
+ delete[] vl;
+ delete[] sl_desc;
+ }
+
+ otl_refcur_stream() OTL_NO_THROW:
+ otl_refcur_base_cursor(),
+ delay_next(0),
+ same_sl_flag(0),
+ override(),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ sl_desc(0),
+ sl_len(),
+ sl(0),
+ null_fetched(0),
+ ret_code(0),
+ cur_col(0),
+ cur_in(0),
+ executed(0),
+ var_info()
+ {
+ init();
+ }
+
+ otl_refcur_stream
+ (const otl_stream_buffer_size_type arr_size,
+ const char* master_plsql_block,
+ otl_var* var,
+ otl_connect& db)
+ OTL_THROWS_OTL_EXCEPTION:
+ otl_refcur_base_cursor(db,var,master_plsql_block,arr_size),
+ delay_next(0),
+ same_sl_flag(0),
+ override(),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ sl_desc(0),
+ sl_len(),
+ sl(0),
+ null_fetched(0),
+ ret_code(0),
+ cur_col(0),
+ cur_in(0),
+ executed(0),
+ var_info()
+ {
+ init();
+ try{
+ rewind();
+ null_fetched=0;
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ cleanup();
+ if(this->adb)this->adb->increment_throw_count();
+ throw;
+ }
+ }
+
+ virtual ~otl_refcur_stream()
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ cleanup();
+ close();
+ }
+
+
+ int is_null(void) OTL_NO_THROW
+ {
+ return null_fetched;
+ }
+
+ int eof(void) OTL_NO_THROW
+ {
+ if(delay_next){
+ look_ahead();
+ delay_next=0;
+ }
+ return !ret_code;
+ }
+
+ int eof_intern(void)
+ {
+ return !ret_code;
+ }
+
+ void check_if_executed(void){}
+
+ void open
+ (otl_connect& db,
+ otl_var* var,
+ const char* master_plsql_block,
+ const otl_stream_buffer_size_type arr_size=1)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ otl_refcur_base_cursor::open(db,var,master_plsql_block,arr_size);
+ get_select_list();
+ rewind();
+ delete[] ov;
+ ov=new otl_var_desc[sl_len];
+ ov_len=sl_len;
+ for(int i=0;i<sl_len;++i){
+ sl[i].copy_var_desc(ov[i]);
+ if(sl_desc!=0)
+ ov[i].copy_name(sl_desc[i].name);
+ }
+ }
+
+ void close(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ override.reset();
+ otl_refcur_base_cursor::close();
+ }
+
+ otl_refcur_stream& operator>>(otl_time0& t)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_timestamp)&&!eof_intern()){
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ void* tm=OTL_RCAST(void*,sl[cur_col].val(this->cur_row));
+ int rc=sl[cur_col].get_var_struct().read_dt(&t,tm,sizeof(otl_time0));
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception(adb->get_connect_struct(),stm_label?stm_label:stm_text);
+ }
+#else
+ otl_time0* tm=OTL_RCAST(otl_time0*,sl[cur_col].val(cur_row));
+ memcpy(OTL_RCAST(void*,&t),tm,otl_oracle_date_size);
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ // already declared
+#else
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(otl_datetime& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {otl_time0 tmp;
+ (*this)>>tmp;
+#if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_DATETIME_NULL_TO_VAL;
+ else{
+ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100);
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour-1;
+ s.minute=tmp.minute-1;
+ s.second=tmp.second-1;
+ }
+#else
+ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100);
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour-1;
+ s.minute=tmp.minute-1;
+ s.second=tmp.second-1;
+#endif
+ inc_next_ov();
+ return *this;
+ }
+#endif
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(char& c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ c=*OTL_RCAST(char*,sl[cur_col].val(cur_row));
+#if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL)
+ if((*this).is_null())
+ c=OTL_DEFAULT_CHAR_NULL_TO_VAL;
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(unsigned char& c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ c=*OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row));
+#if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL)
+ if((*this).is_null())
+ c=OTL_DEFAULT_CHAR_NULL_TO_VAL;
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(OTL_STRING_CONTAINER& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_char:
+ if(!eof_intern()){
+#if defined(OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL)
+ if((*this).is_null()){
+ OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL(s);
+ }else
+#elif defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_STRING_NULL_TO_VAL;
+ else
+#endif
+#if defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,sl[cur_col].val(cur_row)),1);
+#else
+ s=OTL_RCAST(char*,sl[cur_col].val(cur_row));
+#endif
+ look_ahead();
+ }
+ break;
+#if defined(USER_DEFINED_STRING_CLASS) || \
+ defined(OTL_STL) || defined(OTL_ACE)
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ if(!eof_intern()){
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row));
+ int len=sl[cur_col].get_len(cur_row);
+#if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_ACE)
+ s.assign(OTL_RCAST(char*,c),len);
+#elif defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,c),len,1);
+#endif
+ look_ahead();
+ }
+ break;
+ case otl_var_blob:
+ case otl_var_clob:
+ if(!eof_intern()){
+ int len=0;
+ int max_long_sz=this->adb->get_max_long_size();
+ otl_auto_array_ptr<unsigned char> loc_ptr(max_long_sz);
+ unsigned char* temp_buf=loc_ptr.get_ptr();
+
+ int rc=sl[cur_col].get_var_struct().get_blob
+ (cur_row,
+ temp_buf,
+ max_long_sz,
+ len);
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception(adb->get_connect_struct(),
+ stm_label?stm_label:stm_text);
+ }
+#if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_ACE)
+ s.assign(OTL_RCAST(char*,temp_buf),len);
+#elif defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,temp_buf),len,1);
+#endif
+ look_ahead();
+ }
+ break;
+#endif
+ default:
+ check_type(otl_var_char);
+ } // switch
+ inc_next_ov();
+ return *this;
+ }
+#endif
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,sl[cur_col].val(cur_row)));
+#if defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL)
+ );
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+#if defined(OTL_UNICODE_STRING_TYPE)
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(OTL_UNICODE_STRING_TYPE& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+#if defined(OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR)
+ OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST
+ (OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(cur_row));
+ OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR(s,temp_s+1,*temp_s);
+#else
+ OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST
+ (OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(cur_row));
+ s.assign(temp_s+1,*temp_s);
+#endif
+
+#if defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,OTL_DEFAULT_STRING_NULL_TO_VAL);
+#endif
+
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+#endif
+
+#if defined(OTL_UNICODE)
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(OTL_UNICODE_CHAR_TYPE* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ otl_strcpy2(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)),
+ sl[cur_col].get_len(cur_row)
+ );
+#if defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL)
+ );
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+#endif
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(unsigned char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ otl_strcpy2(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)),
+ sl[cur_col].get_len(cur_row)
+ );
+#if defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL)
+ );
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(int& n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(!eof_intern()){
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T2
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ n);
+#else
+ int match_found=otl_numeric_convert_T
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ n);
+#endif
+ if(!match_found){
+ if(check_type(otl_var_double,otl_var_int))
+ n=OTL_PCONV(int,double,sl[cur_col].val(cur_row));
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ n=OTL_SCAST(int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+#if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\
+ !defined(OTL_BIGINT_TO_STR))
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(OTL_BIGINT& n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(!eof_intern()){
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T2
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ n);
+#else
+ int match_found=otl_numeric_convert_T
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ n);
+#endif
+ if(!match_found){
+ if(check_type(otl_var_double,otl_var_int))
+ n=OTL_PCONV(OTL_BIGINT,double,sl[cur_col].val(cur_row));
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+#endif
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(unsigned& u)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(!eof_intern()){
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T2
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ u);
+#else
+ int match_found=otl_numeric_convert_T
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ u);
+#endif
+ if(!match_found){
+ if(check_type(otl_var_double,otl_var_unsigned_int))
+ u=OTL_PCONV(unsigned,double,sl[cur_col].val(cur_row));
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ u=OTL_SCAST(unsigned int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(short& sh)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(!eof_intern()){
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T2
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ sh);
+#else
+ int match_found=otl_numeric_convert_T
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ sh);
+#endif
+ if(!match_found){
+ if(check_type(otl_var_double,otl_var_short))
+ sh=OTL_PCONV(short,double,sl[cur_col].val(cur_row));
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ sh=OTL_SCAST(short int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(long int& l)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(!eof_intern()){
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T2
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ l);
+#else
+ int match_found=otl_numeric_convert_T
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ l);
+#endif
+ if(!match_found){
+ if(check_type(otl_var_double,otl_var_long_int))
+ l=OTL_PCONV(long int,double,sl[cur_col].val(cur_row));
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ l=OTL_SCAST(long int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(float& f)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(!eof_intern()){
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T2
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ f);
+#else
+ int match_found=otl_numeric_convert_T
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ f);
+#endif
+ if(!match_found){
+ if(check_type(otl_var_double,otl_var_float))
+ f=OTL_PCONV(float,double,sl[cur_col].val(cur_row));
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ f=OTL_SCAST(float,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(double& d)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(!eof_intern()){
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T2
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ d);
+#else
+ int match_found=otl_numeric_convert_T
+ (sl[cur_col].get_ftype(),
+ sl[cur_col].val(cur_row),
+ d);
+#endif
+ if(!match_found){
+ if(check_type(otl_var_double,otl_var_double))
+ d=*OTL_RCAST(double*,sl[cur_col].val(cur_row));
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ d=OTL_SCAST(double,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ look_ahead();
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(otl_long_string& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(!eof_intern()){
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_raw_long:
+ case otl_var_varchar_long:
+ {
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row));
+ int len=sl[cur_col].get_len(cur_row);
+ if(len>s.get_buf_size())
+ len=s.get_buf_size();
+ otl_memcpy(s.v,c,len,sl[cur_col].get_ftype());
+ if(sl[cur_col].get_ftype()==otl_var_varchar_long)
+ s.null_terminate_string(len);
+ s.set_len(len);
+ look_ahead();
+ }
+ break;
+ case otl_var_blob:
+ case otl_var_clob:
+ {
+ int len;
+ int rc=sl[cur_col].get_var_struct().get_blob(cur_row,s.v,s.get_buf_size(),len);
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception(adb->get_connect_struct(),
+ stm_label?stm_label:stm_text);
+ }
+ s.set_len(len);
+ if(sl[cur_col].get_ftype()==otl_var_clob)
+ s.null_terminate_string(len);
+ look_ahead();
+ }
+ break;
+ case otl_var_raw:
+ {
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row));
+ int len2=OTL_SCAST(int,*OTL_RCAST(unsigned short*,c));
+ otl_memcpy(s.v,c+sizeof(short int),len2,sl[cur_col].get_ftype());
+ s.set_len(len2);
+ look_ahead();
+ }
+ break;
+ }
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(otl_lob_stream& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if((sl[cur_col].get_ftype()==otl_var_blob||
+ sl[cur_col].get_ftype()==otl_var_clob)&&
+ !eof_intern()){
+ s.init
+ (&sl[cur_col],
+ adb,
+ OTL_RCAST(otl_refcur_base_cursor*,this),
+ cur_row,
+ otl_lob_stream_read_mode,
+ this->is_null());
+ delay_next=1;
+ }
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_var_desc* describe_out_vars(int& desc_len)
+ OTL_NO_THROW
+ {
+ desc_len=0;
+ if(ov==0)return 0;
+ desc_len=ov_len;
+ return ov;
+ }
+
+ otl_var_desc* describe_next_out_var(void)
+ OTL_NO_THROW
+ {
+ if(ov==0)return 0;
+ return &ov[next_ov_ndx];
+ }
+
+ int select_list_len(void) OTL_NO_THROW
+ {
+ return sl_len;
+ }
+
+ int column_ftype(int ndx=0) OTL_NO_THROW
+ {
+ return sl[ndx].get_ftype();
+ }
+
+ int column_size(int ndx=0) OTL_NO_THROW
+ {
+ return sl[ndx].get_elem_size();
+ }
+
+ otl_column_desc* describe_select(int& desc_len)
+ OTL_NO_THROW
+ {
+ desc_len=0;
+ desc_len=sl_len;
+ return sl_desc;
+ }
+
+protected:
+
+ otl_column_desc* sl_desc;
+ int sl_len;
+ otl_generic_variable* sl;
+
+ int null_fetched;
+ int ret_code;
+ int cur_col;
+ int cur_in;
+ int executed;
+ char var_info[256];
+
+ void init(void)
+ {
+ ov=0;
+ ov_len=0;
+ next_ov_ndx=0;
+ same_sl_flag=0;
+ sl=0;
+ sl_len=0;
+ null_fetched=0;
+ ret_code=0;
+ sl_desc=0;
+ executed=0;
+ cur_in=0;
+ cur_col=-1;
+ executed=1;
+ stm_text=0;
+ delay_next=0;
+ }
+
+ void get_next(void)
+ {
+ if(cur_col<sl_len-1){
+ ++cur_col;
+ null_fetched=sl[cur_col].is_null(cur_row);
+ }else{
+ ret_code=next();
+ cur_col=0;
+ }
+ }
+
+ int check_type_throw(int type_code, int actual_data_type)
+ {
+ int out_type_code;
+ if(actual_data_type!=0)
+ out_type_code=actual_data_type;
+ else
+ out_type_code=type_code;
+ otl_var_info_col
+ (sl[cur_col].get_pos(),
+ sl[cur_col].get_ftype(),
+ out_type_code,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_exception
+ (otl_error_msg_0,
+ otl_error_code_0,
+ stm_label?stm_label:stm_text,
+ var_info);
+ }
+
+ int check_type(int type_code, int actual_data_type=0)
+ {
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_timestamp:
+ case otl_var_tz_timestamp:
+ case otl_var_ltz_timestamp:
+ if(type_code==otl_var_timestamp)
+ return 1;
+ default:
+ if(sl[cur_col].get_ftype()==type_code)
+ return 1;
+ }
+ return check_type_throw(type_code,actual_data_type);
+ }
+
+ void look_ahead(void)
+ {
+ if(cur_col==sl_len-1){
+ ret_code=next();
+ cur_col=-1;
+ }
+ }
+
+ void get_select_list(void)
+ {
+ int i,j;
+
+ otl_auto_array_ptr<otl_column_desc> loc_ptr(otl_var_list_size);
+ otl_column_desc* sl_desc_tmp=loc_ptr.get_ptr();
+ int sld_tmp_len=0;
+ int ftype,elem_size;
+
+ sld_tmp_len=0;
+ cursor_struct.straight_select=0;
+ for(i=1;describe_column(sl_desc_tmp[i-1],i);++i){
+ ++sld_tmp_len;
+ if(sld_tmp_len==loc_ptr.get_arr_size()){
+ loc_ptr.double_size();
+ sl_desc_tmp=loc_ptr.get_ptr();
+ }
+ }
+ sl_len=sld_tmp_len;
+ if(sl){
+ delete[] sl;
+ sl=0;
+ }
+ sl=new otl_generic_variable[sl_len==0?1:sl_len];
+ int max_long_size=this->adb->get_max_long_size();
+ for(j=0;j<sl_len;++j){
+ otl_generic_variable::map_ftype
+ (sl_desc_tmp[j],
+ max_long_size,
+ ftype,
+ elem_size,
+ override,
+ j+1,
+ this->adb->get_connect_struct().get_connection_type());
+ sl[j].copy_pos(j+1);
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ if(sl_desc_tmp[j].charset_form==2)
+ sl[j].get_var_struct().nls_flag=true;
+#endif
+ sl[j].init(true,
+ ftype,
+ elem_size,
+ OTL_SCAST(otl_stream_buffer_size_type,array_size),
+ &adb->get_connect_struct()
+ );
+ }
+ if(sl_desc){
+ delete[] sl_desc;
+ sl_desc=0;
+ }
+ sl_desc=new otl_column_desc[sl_len==0?1:sl_len];
+ for(i=0;i<sl_len;++i)
+ sl_desc[i]=sl_desc_tmp[i];
+ for(i=0;i<sl_len;++i)bind_col(i+1,sl[i]);
+ }
+
+private:
+
+ void rewind(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ ret_code=first();
+ null_fetched=0;
+ cur_col=-1;
+ cur_in=0;
+ executed=1;
+ delay_next=0;
+ }
+
+ otl_refcur_stream& operator=(const otl_refcur_stream&)
+ {
+ return *this;
+ }
+
+ otl_refcur_stream(const otl_refcur_stream&) :
+#if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE)
+ otl_read_stream_interface(),
+#endif
+ otl_refcur_base_cursor(),
+ delay_next(0),
+ same_sl_flag(0),
+ override(),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ sl_desc(0),
+ sl_len(),
+ sl(0),
+ null_fetched(0),
+ ret_code(0),
+ cur_col(0),
+ cur_in(0),
+ executed(0),
+ var_info()
+ {
+ }
+
+};
+
+class otl_inout_stream: public otl_ora8_inout_stream{
+public:
+
+ otl_inout_stream
+ (otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ otl_connect& db,
+ void* master_stream_ptr,
+ const bool alob_stream_mode=false,
+ const char* sqlstm_label=0)
+ : otl_ora8_inout_stream(arr_size,sqlstm,db,
+ master_stream_ptr,
+ alob_stream_mode,sqlstm_label),
+ adb2(&db)
+ {
+ }
+
+ otl_inout_stream& operator>>(otl_refcur_stream& str)
+ {
+ if(eof())return *this;
+ if(check_in_type(otl_var_refcur,1)){
+ if(str.get_connected())str.close();
+ str.open(*adb2,
+ &(in_vl[cur_in_x]->get_var_struct()),
+ stm_text,
+ OTL_SCAST
+ (const otl_stream_buffer_size_type,
+ in_vl[cur_in_x]->get_var_struct().array_size)
+ );
+ null_fetched=0;
+ }
+ get_in_next();
+ return *this;
+ }
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+
+ otl_inout_stream& operator>>(OTL_STRING_CONTAINER& s)
+ {
+ otl_ora8_inout_stream::operator>>(s);
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(const OTL_STRING_CONTAINER& s)
+ {
+ otl_ora8_inout_stream::operator<<(s);
+ return *this;
+ }
+
+#endif
+
+ otl_inout_stream& operator<<(const otl_null& n)
+ {
+ otl_ora8_inout_stream::operator<<(n);
+ return *this;
+ }
+
+
+#if defined(OTL_PL_TAB) && defined(OTL_STL)
+
+ otl_inout_stream& operator>>(otl_pl_vec_generic& tab)
+ {
+ otl_ora8_inout_stream::operator>>(tab);
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(otl_pl_vec_generic& tab)
+ {
+ otl_ora8_inout_stream::operator<<(tab);
+ return *this;
+ }
+
+#endif
+
+ otl_inout_stream& operator>>(otl_pl_tab_generic& tab)
+ {
+ otl_ora8_inout_stream::operator>>(tab);
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(otl_pl_tab_generic& tab)
+ {
+ otl_ora8_inout_stream::operator<<(tab);
+ return *this;
+ }
+
+
+ otl_inout_stream& operator>>(otl_time0& s)
+ {
+ otl_ora8_inout_stream::operator>>(s);
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(const otl_time0& s)
+ {
+ otl_ora8_inout_stream::operator<<(s);
+ return *this;
+ }
+
+ otl_inout_stream& operator>>(char& c)
+ {
+ otl_ora8_inout_stream::operator>>(c);
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(const char c)
+ {
+ otl_ora8_inout_stream::operator<<(c);
+ return *this;
+ }
+
+
+ otl_inout_stream& operator>>(unsigned char& c)
+ {
+ otl_ora8_inout_stream::operator>>(c);
+ return *this;
+ }
+
+#if defined(OTL_UNICODE_STRING_TYPE)
+ otl_inout_stream& operator>>(OTL_UNICODE_STRING_TYPE& s)
+ {
+ otl_ora8_inout_stream::operator>>(s);
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(const OTL_UNICODE_STRING_TYPE& s)
+ {
+ otl_ora8_inout_stream::operator<<(s);
+ return *this;
+ }
+#endif
+
+ otl_inout_stream& operator<<(const unsigned char c)
+ {
+ otl_ora8_inout_stream::operator<<(c);
+ return *this;
+ }
+
+
+ otl_inout_stream& operator>>(char* s)
+ {
+ otl_ora8_inout_stream::operator>>(s);
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(const char* s)
+ {
+ otl_ora8_inout_stream::operator<<(s);
+ return *this;
+ }
+
+ otl_inout_stream& operator>>(unsigned char* s)
+ {
+ otl_ora8_inout_stream::operator>>(s);
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(const unsigned char* s)
+ {
+ otl_ora8_inout_stream::operator<<(s);
+ return *this;
+ }
+
+#if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\
+ !defined(OTL_BIGINT_TO_STR))
+ otl_inout_stream& operator>>(OTL_BIGINT& n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator>>(n);
+#else
+ otl_ora8_inout_stream::operator>><OTL_BIGINT,otl_var_bigint>(n);
+#endif
+ return *this;
+ }
+#endif
+
+ otl_inout_stream& operator>>(int& n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator>>(n);
+#else
+ otl_ora8_inout_stream::operator>><int,otl_var_int>(n);
+#endif
+ return *this;
+ }
+
+#if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\
+ !defined(OTL_BIGINT_TO_STR))
+ otl_inout_stream& operator<<(const OTL_BIGINT n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator<<(n);
+#else
+ otl_ora8_inout_stream::operator<<<OTL_BIGINT,otl_var_bigint>(n);
+#endif
+ return *this;
+ }
+#endif
+
+ otl_inout_stream& operator<<(const int n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator<<(n);
+#else
+ otl_ora8_inout_stream::operator<<<int,otl_var_int>(n);
+#endif
+ return *this;
+ }
+
+ otl_inout_stream& operator>>(float& n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator>>(n);
+#else
+ otl_ora8_inout_stream::operator>><float,otl_var_float>(n);
+#endif
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(const float n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator<<(n);
+#else
+ otl_ora8_inout_stream::operator<<<float,otl_var_float>(n);
+#endif
+ return *this;
+ }
+
+ otl_inout_stream& operator>>(double& n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator>>(n);
+#else
+ otl_ora8_inout_stream::operator>><double,otl_var_double>(n);
+#endif
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(const double n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator<<(n);
+#else
+ otl_ora8_inout_stream::operator<<<double,otl_var_double>(n);
+#endif
+ return *this;
+ }
+
+
+ otl_inout_stream& operator>>(short int& n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator>>(n);
+#else
+ otl_ora8_inout_stream::operator>><short,otl_var_short>(n);
+#endif
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(const short int n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator<<(n);
+#else
+ otl_ora8_inout_stream::operator<<<short,otl_var_short>(n);
+#endif
+ return *this;
+ }
+
+ otl_inout_stream& operator>>(unsigned int& n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator>>(n);
+#else
+ otl_ora8_inout_stream::operator>><unsigned,otl_var_unsigned_int>(n);
+#endif
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(const unsigned int n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator<<(n);
+#else
+ otl_ora8_inout_stream::operator<<<unsigned,otl_var_unsigned_int>(n);
+#endif
+ return *this;
+ }
+
+
+ otl_inout_stream& operator>>(long int& n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator>>(n);
+#else
+ otl_ora8_inout_stream::operator>><long,otl_var_long_int>(n);
+#endif
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(const long int n)
+ {
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ otl_ora8_inout_stream::operator<<(n);
+#else
+ otl_ora8_inout_stream::operator<<<long,otl_var_long_int>(n);
+#endif
+ return *this;
+ }
+
+ otl_inout_stream& operator>>(otl_long_string& n)
+ {
+ otl_ora8_inout_stream::operator>>(n);
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(const otl_long_string& n)
+ {
+ otl_ora8_inout_stream::operator<<(n);
+ return *this;
+ }
+
+ otl_inout_stream& operator>>(otl_lob_stream& n)
+ {
+ otl_ora8_inout_stream::operator>>(n);
+ return *this;
+ }
+
+ otl_inout_stream& operator<<(otl_lob_stream& s)
+ {
+ otl_ora8_inout_stream::operator<<(s);
+ return *this;
+ }
+
+protected:
+
+ otl_connect* adb2;
+
+private:
+
+ otl_inout_stream(const otl_inout_stream&):
+ otl_ora8_inout_stream(),
+ adb2(0)
+ {
+ }
+
+ otl_inout_stream& operator=(const otl_inout_stream&)
+ {
+ return *this;
+ }
+
+
+};
+
+
+// ============ OTL Reference Cursor Streams for Oracle 8 =================
+
+class otl_cur;
+
+class otl_ref_cursor: public
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var> {
+
+protected:
+
+
+ friend class otl_cur;
+ int cur_row;
+ int cur_size;
+ int row_count;
+ int array_size;
+ otl_select_struct_override local_override;
+
+public:
+
+ otl_ref_cursor
+ (otl_connect& db,
+ const char* cur_placeholder_name,
+ void* master_stream_ptr,
+ const otl_stream_buffer_size_type arr_size=1)
+ :otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>(db),
+ cur_row(-1),
+ cur_size(0),
+ row_count(0),
+ array_size(arr_size),
+ local_override(),
+ sel_cur(),
+ rvl_len(otl_var_list_size),
+ rvl(new otl_p_generic_variable[rvl_len]),
+ vl_cur_len(0),
+ cur_placeholder(),
+ master_stream_ptr_(master_stream_ptr)
+ {int i;
+ local_override.reset();
+ for(i=0;i<rvl_len;++i)
+ rvl[i]=0;
+ OTL_STRCPY_S(cur_placeholder,sizeof(cur_placeholder),cur_placeholder_name);
+ }
+
+ otl_ref_cursor():
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>(),
+ cur_row(-1),
+ cur_size(0),
+ row_count(0),
+ array_size(0),
+ local_override(),
+ sel_cur(),
+ rvl_len(0),
+ rvl(),
+ vl_cur_len(0),
+ cur_placeholder(),
+ master_stream_ptr_(0)
+ {
+ local_override.reset();
+ }
+
+ virtual ~otl_ref_cursor()
+ {
+ delete[] rvl;
+ rvl=0;
+ }
+
+ void open
+ (otl_connect& db,
+ const char* cur_placeholder_name,
+ const otl_stream_buffer_size_type arr_size=1)
+ {int i;
+ local_override.reset();
+ cur_row=-1;
+ row_count=0;
+ cur_size=0;
+ array_size=arr_size;
+ rvl_len=otl_var_list_size;
+ vl_cur_len=0;
+ rvl=new otl_p_generic_variable[rvl_len];
+ for(i=0;i<rvl_len;++i)rvl[i]=0;
+ OTL_STRCPY_S(cur_placeholder,sizeof(cur_placeholder),cur_placeholder_name);
+ if(!sel_cur.get_connected())sel_cur.open(db);
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::open(db);
+ }
+
+ void release_sel_cur(void)
+ {
+#if defined(OTL_ORA8_8I_REFCUR)
+ return;
+#else
+ char tmp_buf[256];
+ OCIBind* bindpp;
+ int rc;
+
+ if(!sel_cur.get_connected())return;
+ OTL_STRCPY_S(tmp_buf,sizeof(tmp_buf),"begin close ");
+ OTL_STRCAT_S(tmp_buf,sizeof(tmp_buf),cur_placeholder);
+ OTL_STRCAT_S(tmp_buf,sizeof(tmp_buf),"; end;");
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::parse(tmp_buf);
+ rc=OCIBindByName
+ (cursor_struct.cda,
+ &bindpp,
+ cursor_struct.errhp,
+ OTL_RCAST(text*,cur_placeholder),
+ OTL_SCAST(sb4,strlen(cur_placeholder)),
+ OTL_RCAST(dvoid*,&sel_cur.get_cursor_struct().cda),
+ 0,
+ SQLT_RSET,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ OTL_SCAST(ub4,OCI_DEFAULT));
+ if(rc!=0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(cursor_struct,
+ stm_label?stm_label:stm_text);
+ }
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::exec(1,0,otl_sql_exec_from_select_cursor_class);
+#endif
+ }
+
+ void close(void)
+ {
+ local_override.reset();
+ delete[] rvl;
+ rvl=0;
+ release_sel_cur();
+ sel_cur.close();
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::close();
+ }
+
+ int first(void)
+ {int i,rc;
+ OCIBind* bindpp;
+
+ if(!sel_cur.get_connected()){
+ sel_cur.open(*adb);
+ rc=OCIBindByName
+ (cursor_struct.cda,
+ &bindpp,
+ cursor_struct.errhp,
+ OTL_RCAST(text*,cur_placeholder),
+ OTL_SCAST(sb4,strlen(cur_placeholder)),
+ OTL_RCAST(dvoid*,&sel_cur.get_cursor_struct().cda),
+ 0,
+ SQLT_RSET,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ OTL_SCAST(ub4,OCI_DEFAULT));
+ if(rc!=0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_exception(cursor_struct,
+ stm_label?stm_label:stm_text);
+ }
+ }
+
+ if(cur_row==-2)
+ ; // Special case -- calling describe_select() between parse() and first()
+ else{
+// Executing the PLSQL master block
+ exec(1,0,otl_sql_exec_from_select_cursor_class);
+ sel_cur.set_connected(1);
+ }
+ cur_row=-1;
+ for(i=0;i<vl_cur_len;++i)
+ sel_cur.bind(i+1,*rvl[i]);
+ rc=sel_cur.get_cursor_struct().fetch
+ (OTL_SCAST(otl_stream_buffer_size_type,
+ array_size),sel_cur.get_eof_data_ref());
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_exception(sel_cur.get_cursor_struct(),
+ stm_label?stm_label:stm_text);
+ }
+ row_count=sel_cur.get_cursor_struct().rpc();
+ OTL_TRACE_FIRST_FETCH
+ cur_size=row_count;
+ if(cur_size!=0)cur_row=0;
+ return cur_size!=0;
+ }
+
+ int next(void)
+ {int rc;
+ if(cur_row<0)return first();
+ if(cur_row<cur_size-1)
+ ++cur_row;
+ else{
+ if(sel_cur.eof()){
+ cur_row=-1;
+ return 0;
+ }
+ rc=sel_cur.get_cursor_struct().fetch
+ (OTL_SCAST(otl_stream_buffer_size_type,
+ array_size),sel_cur.get_eof_data_ref());
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_exception(sel_cur.get_cursor_struct(),
+ stm_label?stm_label:stm_text);
+ }
+ cur_size=sel_cur.get_cursor_struct().rpc()-row_count;
+ row_count=sel_cur.get_cursor_struct().rpc();
+ OTL_TRACE_NEXT_FETCH2
+ if(cur_size!=0)cur_row=0;
+ }
+ return cur_size!=0;
+ }
+
+ void bind
+ (const int column_num,
+ otl_generic_variable& v)
+ {
+ if(!connected)return;
+ ++vl_cur_len;
+ if(vl_cur_len==rvl_len){
+ int temp_rvl_len=rvl_len*2;
+ otl_p_generic_variable* temp_rvl=
+ new otl_p_generic_variable[temp_rvl_len];
+ int i;
+ for(i=0;i<rvl_len;++i)
+ temp_rvl[i]=rvl[i];
+ for(i=rvl_len+1;i<temp_rvl_len;++i)
+ temp_rvl[i]=0;
+ delete[] rvl;
+ rvl=temp_rvl;
+ rvl_len=temp_rvl_len;
+ }
+ rvl[vl_cur_len-1]=&v;
+ v.set_pos(column_num);
+ }
+
+ void bind(otl_generic_variable& v)
+ {
+ if(v.get_pos())
+ bind(v.get_pos(),v);
+ else if(v.get_name())
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::bind(v);
+ }
+
+ void bind
+ (const char* name,
+ otl_generic_variable& v)
+ {
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::bind(name,v);
+ }
+
+ int describe_select
+ (otl_column_desc* desc,
+ int& desc_len)
+ {int i,rc;
+ OCIBind* bindpp;
+
+ if(!sel_cur.get_connected()){
+ sel_cur.open(*adb);
+ rc=OCIBindByName
+ (cursor_struct.cda,
+ &bindpp,
+ cursor_struct.errhp,
+ OTL_RCAST(text*,cur_placeholder),
+ OTL_SCAST(sb4,strlen(cur_placeholder)),
+ OTL_RCAST(dvoid*,&sel_cur.get_cursor_struct().cda),
+ 0,
+ SQLT_RSET,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ OTL_SCAST(ub4,OCI_DEFAULT));
+ if(rc!=0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+ throw otl_exception(cursor_struct,
+ stm_label?stm_label:stm_text);
+ }
+ }
+// Executing the PLSQL master block
+ exec(1,0,otl_sql_exec_from_select_cursor_class);
+ sel_cur.set_connected(1);
+ cur_row=-2; // Special case -- describe_select() before first() or next()
+ desc_len=0;
+ sel_cur.get_cursor_struct().straight_select=0;
+ for(i=1;sel_cur.describe_column(desc[i-1],i);++i)
+ ++desc_len;
+ return 1;
+ }
+
+public:
+
+ otl_cursor sel_cur;
+
+protected:
+
+ int rvl_len;
+ otl_p_generic_variable* rvl;
+ int vl_cur_len;
+ char cur_placeholder[64];
+ void* master_stream_ptr_;
+
+private:
+
+ otl_ref_cursor(const otl_ref_cursor&)
+ :otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>(),
+ cur_row(-1),
+ cur_size(0),
+ row_count(0),
+ array_size(0),
+ local_override(),
+ sel_cur(),
+ rvl_len(0),
+ rvl(0),
+ vl_cur_len(0),
+ cur_placeholder(),
+ master_stream_ptr_(0)
+ {
+ }
+
+ otl_ref_cursor& operator=(const otl_ref_cursor&)
+ {
+ return *this;
+ }
+
+
+};
+
+class otl_ref_select_stream: public otl_ref_cursor{
+
+protected:
+
+ otl_select_struct_override *override;
+ int delay_next;
+ int same_sl_flag;
+ long _rfc;
+
+public:
+
+ void skip_to_end_of_row()
+ {
+ check_if_executed();
+ if(eof())return;
+ while(cur_col<sl_len-1){
+ ++cur_col;
+ null_fetched=sl[cur_col].is_null(this->cur_row);
+ }
+ ret_code=this->next();
+ cur_col=0;
+ if(!eof())
+ cur_col=-1;
+ ++_rfc;
+ }
+
+
+ int get_select_row_count() const
+ {
+ return this->cur_row==-1?0:this->cur_size-this->cur_row;
+ }
+
+ long get_rfc() const {return _rfc;}
+
+ void cleanup(void)
+ {int i;
+ delete[] sl;
+ for(i=0;i<vl_len;++i)
+ delete vl[i];
+ delete[] vl;
+ delete[] sl_desc;
+ }
+
+ otl_ref_select_stream
+ (otl_select_struct_override* aoverride,
+ const otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ const char* acur_placeholder,
+ otl_connect& db,
+ const char* sqlstm_label=0)
+ :otl_ref_cursor
+ (db,
+ acur_placeholder,
+ aoverride->get_master_stream_ptr(),
+ arr_size),
+ override(0),
+ delay_next(0),
+ same_sl_flag(0),
+ _rfc(0),
+ sl_desc(0),
+ sl_len(0),
+ sl(0),
+ null_fetched(0),
+ ret_code(0),
+ cur_col(0),
+ cur_in(0),
+ executed(0),
+ var_info()
+ {
+ if(sqlstm_label!=0){
+ if(stm_label!=0){
+ delete[] stm_label;
+ stm_label=0;
+ }
+ size_t len=strlen(sqlstm_label)+1;
+ stm_label=new char[len];
+ OTL_STRCPY_S(stm_label,len,sqlstm_label);
+ }
+
+ init();
+
+ override=aoverride;
+ {
+ size_t len=strlen(sqlstm)+1;
+ stm_text=new char[len];
+ OTL_STRCPY_S(stm_text,len,sqlstm);
+ otl_select_struct_override* temp_local_override=&this->local_override;
+ otl_ext_hv_decl hvd
+ (this->stm_text,
+ 1,
+ this->stm_label,
+ &temp_local_override,
+ adb
+ );
+ hvd.alloc_host_var_list(vl,vl_len,*adb);
+ }
+
+ try{
+
+ parse();
+ if(vl_len==0){
+ rewind();
+ null_fetched=0;
+ }
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ cleanup();
+ if(this->adb)this->adb->increment_throw_count();
+ throw;
+ }
+
+ }
+
+ virtual ~otl_ref_select_stream()
+ {
+ cleanup();
+ close();
+ }
+
+ void rewind(void)
+ {
+ OTL_TRACE_STREAM_EXECUTION
+ _rfc=0;
+ get_select_list();
+ ret_code=first();
+ null_fetched=0;
+ cur_col=-1;
+ cur_in=0;
+ executed=1;
+ delay_next=0;
+ }
+
+ void clean(void)
+ {
+ _rfc=0;
+ null_fetched=0;
+ cur_col=-1;
+ cur_in=0;
+ executed=0;
+ delay_next=0;
+ }
+
+ int is_null(void)
+ {
+ return null_fetched;
+ }
+
+ int eof(void)
+ {
+ if(delay_next){
+ look_ahead();
+ delay_next=0;
+ }
+ return !ret_code;
+ }
+
+ int eof_intern(void)
+ {
+ return !ret_code;
+ }
+
+
+ otl_ref_select_stream& operator>>(otl_time0& t)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_timestamp)&&!eof_intern()){
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ void* tm=OTL_RCAST(void*,sl[cur_col].val(this->cur_row));
+ int rc=sl[cur_col].get_var_struct().read_dt(&t,tm,sizeof(otl_time0));
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception(adb->get_connect_struct(),
+ stm_label?stm_label:stm_text);
+ }
+#else
+ otl_time0* tm=OTL_RCAST(otl_time0*,sl[cur_col].val(cur_row));
+ memcpy(OTL_RCAST(void*,&t),tm,otl_oracle_date_size);
+#endif
+ look_ahead();
+ }
+ return *this;
+ }
+
+ otl_ref_select_stream& operator<<(const otl_time0& t)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_timestamp,otl_oracle_date_size)){
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ void* tm=OTL_RCAST(void*,vl[cur_in]->val());
+ int rc=vl[cur_in]->get_var_struct().write_dt(tm,&t,sizeof(otl_time0));
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception(adb->get_connect_struct(),
+ stm_label?stm_label:stm_text);
+ }
+#else
+ otl_time0* tm=OTL_RCAST(otl_time0*,vl[cur_in]->val());
+ memcpy(tm,OTL_RCAST(void*,OTL_CCAST(otl_time0*,&t)),otl_oracle_date_size);
+#endif
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+
+ otl_ref_select_stream& operator<<(const otl_long_string& s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_raw,1)){
+ unsigned char* c=OTL_RCAST(unsigned char*,vl[cur_in]->val());
+ int len=OTL_CCAST(otl_long_string*,&s)->len();
+ if(len>this->vl[cur_in]->actual_elem_size()){
+ otl_var_info_var
+ (this->vl[cur_in]->get_name(),
+ this->vl[cur_in]->get_ftype(),
+ otl_var_raw,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception
+ (otl_error_msg_5,
+ otl_error_code_5,
+ this->stm_label?this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+ this->vl[cur_in]->set_not_null(0);
+ otl_memcpy
+ (c+sizeof(unsigned short),
+ s.v,
+ len,
+ this->vl[cur_in]->get_ftype());
+ *OTL_RCAST(unsigned short*,
+ this->vl[cur_in]->val(0))=OTL_SCAST(unsigned short,len);
+ this->vl[cur_in]->set_len(len,0);
+ }
+ get_in_next();
+ return *this;
+ }
+
+
+
+ otl_ref_select_stream& operator>>(char& c)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ c=*OTL_RCAST(char*,sl[cur_col].val(cur_row));
+ look_ahead();
+ }
+ return *this;
+ }
+
+ otl_ref_select_stream& operator>>(unsigned char& c)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ c=*OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row));
+ look_ahead();
+ }
+ return *this;
+ }
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ otl_ref_select_stream& operator>>(OTL_STRING_CONTAINER& s)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_char:
+ if(!eof_intern()){
+#if defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,sl[cur_col].val(cur_row)),1);
+#else
+ s=OTL_RCAST(char*,sl[cur_col].val(cur_row));
+#endif
+ look_ahead();
+ }
+ break;
+#if defined(USER_DEFINED_STRING_CLASS) || \
+ defined(OTL_STL) || defined(OTL_ACE)
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ if(!eof_intern()){
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row));
+ int len=sl[cur_col].get_len(cur_row);
+#if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_ACE)
+ s.assign(OTL_RCAST(char*,c),len);
+#elif defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,c),len,1);
+#endif
+ look_ahead();
+ }
+ break;
+ case otl_var_blob:
+ case otl_var_clob:
+ if(!eof_intern()){
+ int len=0;
+ int max_long_sz=this->adb->get_max_long_size();
+ otl_auto_array_ptr<unsigned char> loc_ptr(max_long_sz);
+ unsigned char* temp_buf=loc_ptr.get_ptr();
+
+ int rc=sl[cur_col].get_var_struct().get_blob
+ (cur_row,
+ temp_buf,
+ max_long_sz,
+ len);
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception(adb->get_connect_struct(),
+ stm_label?stm_label:stm_text);
+ }
+#if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_ACE)
+ s.assign(OTL_RCAST(char*,temp_buf),len);
+#elif defined(OTL_ACE)
+ s.set(OTL_RCAST(char*,temp_buf),len,1);
+#endif
+ look_ahead();
+ }
+ break;
+#endif
+ default:
+ check_type(otl_var_char);
+ } // switch
+ return *this;
+ }
+#endif
+
+ otl_ref_select_stream& operator>>(char* s)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,sl[cur_col].val(cur_row)));
+ look_ahead();
+ }
+ return *this;
+ }
+
+#if defined(OTL_UNICODE_STRING_TYPE)
+ otl_ref_select_stream& operator>>(OTL_UNICODE_STRING_TYPE& s)
+ {
+
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_char:
+ if(!eof_intern()){
+
+#if defined(OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR)
+ OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST
+ (OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row));
+ OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR(s,temp_s+1,*temp_s);
+#else
+ OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST
+ (OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row));
+ s.assign(temp_s+1,*temp_s);
+#endif
+
+ look_ahead();
+ }
+ break;
+ case otl_var_varchar_long:
+ if(!eof_intern()){
+ s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row));
+ look_ahead();
+ }
+ break;
+ case otl_var_clob:
+ if(!eof_intern()){
+ int len=0;
+ int max_long_sz=this->adb->get_max_long_size();
+ otl_auto_array_ptr<unsigned short> loc_ptr(max_long_sz);
+ unsigned char* temp_buf=OTL_RCAST(unsigned char*,loc_ptr.get_ptr());
+
+ int rc=sl[cur_col].get_var_struct().get_blob
+ (this->cur_row,
+ temp_buf,
+ max_long_sz,
+ len);
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception
+ (this->adb->get_connect_struct(),
+ this->stm_label?this->stm_label:
+ this->stm_text);
+ }
+ s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,temp_buf);
+ look_ahead();
+ }
+ break;
+ default:
+ check_type(otl_var_char);
+ }
+ return *this;
+ }
+#endif
+
+ otl_ref_select_stream& operator>>(unsigned char* s)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if(check_type(otl_var_char)&&!eof_intern()){
+ otl_strcpy2(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)),
+ sl[cur_col].get_len(cur_row)
+ );
+ look_ahead();
+ }
+ return *this;
+ }
+
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+#define OTL_D7(T,T_type) \
+ otl_ref_select_stream& operator>>(T& n) \
+ { \
+ check_if_executed(); \
+ if(eof_intern())return *this; \
+ get_next(); \
+ if(!eof_intern()){ \
+ int match_found=otl_numeric_convert_T<T,T_type> \
+ (sl[cur_col].get_ftype(), \
+ sl[cur_col].val(cur_row), \
+ n); \
+ if(!match_found) \
+ strict_check_throw(T_type); \
+ look_ahead(); \
+ } \
+ return *this; \
+ }
+#else
+#define OTL_D7(T,T_type) \
+ otl_ref_select_stream& operator>>(T& n) \
+ { \
+ check_if_executed(); \
+ if(eof_intern())return *this; \
+ get_next(); \
+ if(!eof_intern()){ \
+ int match_found=otl_numeric_convert_T \
+ (sl[cur_col].get_ftype(), \
+ sl[cur_col].val(cur_row), \
+ n); \
+ if(!match_found){ \
+ if(check_type(otl_var_double,T_type)) \
+ n=OTL_PCONV(T,double,sl[cur_col].val(cur_row)); \
+ } \
+ look_ahead(); \
+ } \
+ return *this; \
+ }
+#endif
+
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ OTL_D7(int,otl_var_int)
+ OTL_D7(unsigned,otl_var_unsigned_int)
+ OTL_D7(long,otl_var_long_int)
+ OTL_D7(short,otl_var_short)
+ OTL_D7(float,otl_var_float)
+ OTL_D7(double,otl_var_double)
+#if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\
+ !defined(OTL_BIGINT_TO_STR))
+ OTL_D7(OTL_BIGINT,otl_var_bigint)
+#endif
+#else
+ template<OTL_TYPE_NAME T,const int T_type> OTL_D7(T,T_type)
+#endif
+
+ otl_ref_select_stream& operator>>(otl_long_string& s)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ {
+ if(!eof_intern()){
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row));
+ int len=sl[cur_col].get_len(cur_row);
+ if(len>s.get_buf_size())
+ len=s.get_buf_size();
+ otl_memcpy(s.v,c,len,sl[cur_col].get_ftype());
+ s.v[len]=0;
+ s.set_len(len);
+ look_ahead();
+ }
+ }
+ break;
+ case otl_var_raw:
+ {
+ if(!eof_intern()){
+ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row));
+ int len=OTL_SCAST(int,*OTL_RCAST(unsigned short*,c));
+ if(len>s.get_buf_size())
+ len=s.get_buf_size();
+ otl_memcpy(s.v,c+sizeof(short int),len,sl[cur_col].get_ftype());
+ s.set_len(len);
+ look_ahead();
+ }
+ }
+ break;
+ case otl_var_blob:
+ case otl_var_clob:
+ {
+ if(!eof_intern()){
+ int len;
+ int rc=sl[cur_col].get_var_struct().get_blob
+ (cur_row,s.v,s.get_buf_size(),len);
+ if(rc==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception(adb->get_connect_struct(),
+ stm_label?stm_label:stm_text);
+ }
+ s.set_len(len);
+ if(sl[cur_col].get_ftype()==otl_var_clob)
+ s.null_terminate_string(len);
+ look_ahead();
+ }
+ }
+ break;
+ }
+ return *this;
+ }
+
+ otl_ref_select_stream& operator>>(otl_lob_stream& s)
+ {
+ check_if_executed();
+ if(eof_intern())return *this;
+ get_next();
+ if((sl[cur_col].get_ftype()==otl_var_blob||
+ sl[cur_col].get_ftype()==otl_var_clob)&&
+ !eof_intern()){
+ s.init
+ (&sl[cur_col],
+ adb,
+ OTL_RCAST(otl_ref_cursor*,this),
+ cur_row,
+ otl_lob_stream_read_mode,
+ this->is_null());
+ delay_next=1;
+ }
+ return *this;
+ }
+
+ otl_ref_select_stream& operator<<(const otl_null& /*n*/)
+ {
+ check_in_var();
+ this->vl[cur_in]->set_null(0);
+ get_in_next();
+ return *this;
+ }
+
+ otl_ref_select_stream& operator<<(const char c)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+ char* tmp=OTL_RCAST(char*,vl[cur_in]->val());
+ tmp[0]=c;
+ tmp[1]=0;
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+
+ otl_ref_select_stream& operator<<(const unsigned char c)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+ unsigned char* tmp=OTL_RCAST(unsigned char*,vl[cur_in]->val());
+ tmp[0]=c;
+ tmp[1]=0;
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ otl_ref_select_stream& operator<<(const OTL_STRING_CONTAINER& s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy
+ (OTL_RCAST(unsigned char*,vl[cur_in]->val()),
+ OTL_RCAST(unsigned char*,OTL_CCAST(char*,s.c_str())),
+ overflow,
+ vl[cur_in]->get_elem_size(),
+ OTL_SCAST(int,s.length())
+ );
+ if(overflow){
+ char temp_var_info[256];
+ otl_var_info_var
+ (vl[cur_in]->get_name(),
+ vl[cur_in]->get_ftype(),
+ otl_var_char,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception
+ (otl_error_msg_4,
+ otl_error_code_4,
+ stm_label?stm_label:stm_text,
+ temp_var_info);
+ }
+
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+#endif
+
+#if defined(OTL_UNICODE_STRING_TYPE)
+ otl_ref_select_stream& operator<<(const OTL_UNICODE_STRING_TYPE& s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy4
+ (OTL_RCAST(unsigned char*,vl[cur_in]->val()),
+ OTL_RCAST(unsigned char*,
+ OTL_CCAST(OTL_UNICODE_CHAR_TYPE*,s.c_str())),
+ overflow,
+ vl[cur_in]->get_elem_size(),
+ OTL_SCAST(int,s.length())
+ );
+ if(overflow){
+ char temp_var_info[256];
+ otl_var_info_var
+ (vl[cur_in]->get_name(),
+ vl[cur_in]->get_ftype(),
+ otl_var_char,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count())return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception
+ (otl_error_msg_4,
+ otl_error_code_4,
+ stm_label?stm_label:stm_text,
+ temp_var_info);
+ }
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+#endif
+
+ otl_ref_select_stream& operator<<(const char* s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy
+ (OTL_RCAST(unsigned char*,vl[cur_in]->val()),
+ OTL_RCAST(unsigned char*,OTL_CCAST(char*,s)),
+ overflow,
+ vl[cur_in]->get_elem_size()
+ );
+ if(overflow){
+ char temp_var_info[256];
+ otl_var_info_var
+ (vl[cur_in]->get_name(),
+ vl[cur_in]->get_ftype(),
+ otl_var_char,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception
+ (otl_error_msg_4,
+ otl_error_code_4,
+ stm_label?stm_label:stm_text,
+ temp_var_info);
+ }
+
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+
+ otl_ref_select_stream& operator<<(const unsigned char* s)
+ {
+ check_in_var();
+ if(check_in_type(otl_var_char,1)){
+
+ int overflow;
+ otl_strcpy4
+ (OTL_RCAST(unsigned char*,vl[cur_in]->val()),
+ OTL_CCAST(unsigned char*,s),
+ overflow,
+ vl[cur_in]->get_elem_size()
+ );
+ if(overflow){
+ char temp_var_info[256];
+ otl_var_info_var
+ (vl[cur_in]->get_name(),
+ vl[cur_in]->get_ftype(),
+ otl_var_char,
+ temp_var_info,
+ sizeof(temp_var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return *this;
+ if(otl_uncaught_exception()) return *this;
+ throw otl_exception
+ (otl_error_msg_4,
+ otl_error_code_4,
+ stm_label?stm_label:stm_text,
+ temp_var_info);
+ }
+
+ }
+ this->vl[cur_in]->set_not_null(0);
+ get_in_next();
+ return *this;
+ }
+
+#define OTL_D8(T,T_type) \
+ otl_ref_select_stream& operator<<(const T n) \
+ { \
+ check_in_var(); \
+ if(check_in_type(T_type,sizeof(T))){ \
+ *OTL_RCAST(T*,vl[cur_in]->val())=n; \
+ } \
+ this->vl[cur_in]->set_not_null(0); \
+ get_in_next(); \
+ return *this; \
+ }
+
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ OTL_D8(int,otl_var_int)
+ OTL_D8(unsigned,otl_var_unsigned_int)
+ OTL_D8(long,otl_var_long_int)
+ OTL_D8(short,otl_var_short)
+ OTL_D8(float,otl_var_float)
+ OTL_D8(double,otl_var_double)
+#if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\
+ !defined(OTL_BIGINT_TO_STR))
+ OTL_D8(OTL_BIGINT,otl_var_bigint)
+#endif
+#else
+ template<OTL_TYPE_NAME T,const int T_type> OTL_D8(T,T_type)
+#endif
+
+ int select_list_len(void) const
+ {
+ return sl_len;
+ }
+
+ int column_ftype(int ndx=0) const
+ {
+ return sl[ndx].get_ftype();
+ }
+
+ int column_size(int ndx=0) const
+ {
+ return sl[ndx].get_elem_size();
+ }
+
+ int get_sl_len() const {return sl_len; }
+ otl_generic_variable* get_sl() const {return sl;}
+ otl_column_desc* get_sl_desc() const {return sl_desc;}
+
+protected:
+
+ otl_column_desc* sl_desc;
+ int sl_len;
+ otl_generic_variable* sl;
+
+ int null_fetched;
+ int ret_code;
+ int cur_col;
+ int cur_in;
+ int executed;
+ char var_info[256];
+
+ void init(void)
+ {
+ same_sl_flag=0;
+ sl=0;
+ sl_len=0;
+ null_fetched=0;
+ ret_code=0;
+ sl_desc=0;
+ executed=0;
+ cur_in=0;
+ stm_text=0;
+ }
+
+ void get_next(void)
+ {
+ if(cur_col<sl_len-1){
+ ++cur_col;
+ null_fetched=sl[cur_col].is_null(cur_row);
+ }else{
+ ret_code=next();
+ cur_col=0;
+ }
+ }
+
+ int check_type_throw(int type_code, int actual_data_type)
+ {
+ int out_type_code;
+ if(actual_data_type!=0)
+ out_type_code=actual_data_type;
+ else
+ out_type_code=type_code;
+ otl_var_info_col
+ (sl[cur_col].get_pos(),
+ sl[cur_col].get_ftype(),
+ out_type_code,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+
+ throw otl_exception
+ (otl_error_msg_0,
+ otl_error_code_0,
+ stm_label?stm_label:stm_text,
+ var_info);
+ }
+
+ int check_type(int type_code, int actual_data_type=0)
+ {
+ switch(sl[cur_col].get_ftype()){
+ case otl_var_timestamp:
+ case otl_var_tz_timestamp:
+ case otl_var_ltz_timestamp:
+ if(type_code==otl_var_timestamp)
+ return 1;
+ default:
+ if(sl[cur_col].get_ftype()==type_code)
+ return 1;
+ }
+ return check_type_throw(type_code,actual_data_type);
+ }
+
+ void look_ahead(void)
+ {
+ if(cur_col==sl_len-1){
+ ret_code=next();
+ cur_col=-1;
+ ++_rfc;
+ }
+ }
+
+ void get_select_list(void)
+ {int i,j,rc;
+
+ otl_auto_array_ptr<otl_column_desc> loc_ptr(otl_var_list_size);
+ otl_column_desc* sl_desc_tmp=loc_ptr.get_ptr();
+ int sld_tmp_len=0;
+ int ftype,elem_size;
+ OCIBind* bindpp;
+
+ if(!sel_cur.get_connected()){
+ sel_cur.open(*adb);
+ rc=OCIBindByName
+ (cursor_struct.cda,
+ &bindpp,
+ cursor_struct.errhp,
+ OTL_RCAST(text*,cur_placeholder),
+ OTL_SCAST(sb4,strlen(cur_placeholder)),
+ OTL_RCAST(dvoid*,&sel_cur.get_cursor_struct().cda),
+ 0,
+ SQLT_RSET,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ OTL_SCAST(ub4,OCI_DEFAULT));
+ if(rc!=0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception(cursor_struct,
+ stm_label?stm_label:stm_text);
+ }
+ }
+
+ for(i=0;i<vl_len;++i)
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::bind(*vl[i]);
+// Executing the PLSQL master block
+ otl_tmpl_cursor
+ <otl_exc,
+ otl_conn,
+ otl_cur,
+ otl_var>::exec(1,0,otl_sql_exec_from_select_cursor_class);
+ sel_cur.set_connected(1);
+ cur_row=-2;
+ if(same_sl_flag && sl){
+ // assuming that ref.cur's select list is the same as
+ // in previous executions of the master block.
+ for(i=0;i<sl_len;++i)sel_cur.bind(sl[i]);
+ return;
+ }else{
+ sld_tmp_len=0;
+ sel_cur.get_cursor_struct().straight_select=0;
+ for(i=1;sel_cur.describe_column(sl_desc_tmp[i-1],i);++i){
+ ++sld_tmp_len;
+ if(sld_tmp_len==loc_ptr.get_arr_size()){
+ loc_ptr.double_size();
+ sl_desc_tmp=loc_ptr.get_ptr();
+ }
+ }
+ sl_len=sld_tmp_len;
+ if(sl){
+ delete[] sl;
+ sl=0;
+ }
+ sl=new otl_generic_variable[sl_len==0?1:sl_len];
+ int max_long_size=this->adb->get_max_long_size();
+ for(j=0;j<sl_len;++j){
+ otl_generic_variable::map_ftype
+ (sl_desc_tmp[j],
+ max_long_size,
+ ftype,
+ elem_size,
+ this->local_override.getLen()>0?this->local_override:*override,
+ j+1,
+ this->adb->get_connect_struct().get_connection_type());
+ sl[j].copy_pos(j+1);
+#if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8)
+ if(sl_desc_tmp[j].charset_form==2)
+ sl[j].get_var_struct().nls_flag=true;
+#endif
+ sl[j].init(true,
+ ftype,
+ elem_size,
+ OTL_SCAST(otl_stream_buffer_size_type,array_size),
+ &adb->get_connect_struct()
+ );
+ }
+ if(sl_desc){
+ delete[] sl_desc;
+ sl_desc=0;
+ }
+ sl_desc=new otl_column_desc[sl_len==0?1:sl_len];
+ for(i=0;i<sl_len;++i)
+ sl_desc[i]=sl_desc_tmp[i];
+ for(i=0;i<sl_len;++i)sel_cur.bind(sl[i]);
+ }
+ }
+
+ void get_in_next(void)
+ {
+ if(cur_in==vl_len-1)
+ rewind();
+ else{
+ ++cur_in;
+ executed=0;
+ }
+ }
+
+ int check_in_type_throw(int type_code)
+ {
+ otl_var_info_var
+ (vl[cur_in]->get_name(),
+ vl[cur_in]->get_ftype(),
+ type_code,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return 0;
+ if(otl_uncaught_exception()) return 0;
+
+ throw otl_exception
+ (otl_error_msg_0,
+ otl_error_code_0,
+ stm_label?stm_label:stm_text,
+ var_info);
+ }
+
+ int check_in_type(int type_code,int tsize)
+ {
+ switch(vl[cur_in]->get_ftype()){
+ case otl_var_char:
+ if(type_code==otl_var_char)
+ return 1;
+ case otl_var_raw:
+ if(type_code==otl_var_raw)
+ return 1;
+ case otl_var_timestamp:
+ case otl_var_tz_timestamp:
+ case otl_var_ltz_timestamp:
+ if(type_code==otl_var_timestamp)
+ return 1;
+ default:
+ if(vl[cur_in]->get_ftype()==type_code &&
+ vl[cur_in]->get_elem_size()==tsize)
+ return 1;
+ }
+ return check_in_type_throw(type_code);
+ }
+
+ void check_in_var(void)
+ {
+ if(vl_len==0){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception
+ (otl_error_msg_1,
+ otl_error_code_1,
+ stm_label?stm_label:stm_text,
+ 0);
+ }
+ }
+
+ void check_if_executed(void)
+ {
+ if(!executed){
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception
+ (otl_error_msg_2,
+ otl_error_code_2,
+ stm_label?stm_label:stm_text,
+ 0);
+ }
+ }
+
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ void strict_check_throw(int type_code)
+ {
+ otl_var_info_col
+ (sl[cur_col].get_pos(),
+ sl[cur_col].get_ftype(),
+ type_code,
+ var_info,
+ sizeof(var_info));
+ if(this->adb)this->adb->increment_throw_count();
+ if(this->adb&&this->adb->get_throw_count()>1)return;
+ if(otl_uncaught_exception()) return;
+ throw otl_exception
+ (otl_error_msg_0,
+ otl_error_code_0,
+ this->stm_label?
+ this->stm_label:
+ this->stm_text,
+ var_info);
+ }
+#endif
+
+private:
+
+ otl_ref_select_stream
+ (const otl_ref_select_stream&)
+ :otl_ref_cursor(),
+ override(0),
+ delay_next(0),
+ same_sl_flag(0),
+ _rfc(0),
+ sl_desc(0),
+ sl_len(0),
+ sl(0),
+ null_fetched(0),
+ ret_code(0),
+ cur_col(0),
+ cur_in(0),
+ executed(0),
+ var_info()
+ {
+ }
+
+ otl_ref_select_stream& operator=(const otl_ref_select_stream&)
+ {
+ return *this;
+ }
+
+};
+
+class otl_stream_shell: public otl_stream_shell_generic{
+public:
+
+ otl_ref_select_stream* ref_ss;
+ otl_select_stream* ss;
+ otl_inout_stream* io;
+ otl_connect* adb;
+
+ int auto_commit_flag;
+ bool lob_stream_flag;
+
+ otl_var_desc* iov;
+ int iov_len;
+ int next_iov_ndx;
+
+ otl_var_desc* ov;
+ int ov_len;
+ int next_ov_ndx;
+
+ bool flush_flag;
+ int stream_type;
+
+ otl_select_struct_override override;
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ OTL_STRING_CONTAINER orig_sql_stm;
+#endif
+
+ otl_stream_shell():
+ otl_stream_shell_generic(),
+ ref_ss(0),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ lob_stream_flag(false),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ flush_flag(false),
+ stream_type(otl_no_stream_type),
+ override()
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ ,orig_sql_stm()
+#endif
+ {
+ should_delete=0;
+ }
+
+ otl_stream_shell(const int ashould_delete):
+ otl_stream_shell_generic(),
+ ref_ss(0),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ lob_stream_flag(false),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ flush_flag(true),
+ stream_type(otl_no_stream_type),
+ override()
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ ,orig_sql_stm()
+#endif
+ {
+ should_delete=ashould_delete;
+ }
+
+ virtual ~otl_stream_shell()
+ {
+ if(should_delete){
+ delete[] iov;
+ delete[] ov;
+
+ iov=0; iov_len=0;
+ ov=0; ov_len=0;
+ next_iov_ndx=0;
+ next_ov_ndx=0;
+ override.setLen(0);
+ flush_flag=true;
+
+ delete ss;
+ delete io;
+ delete ref_ss;
+ ss=0; io=0; ref_ss=0;
+ adb=0;
+ }
+ }
+
+private:
+
+ otl_stream_shell(const otl_stream_shell&):
+ otl_stream_shell_generic(),
+ ref_ss(0),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ lob_stream_flag(false),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ flush_flag(false),
+ stream_type(otl_no_stream_type),
+ override()
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ ,orig_sql_stm()
+#endif
+ {
+ }
+
+ otl_stream_shell& operator=(const otl_stream_shell&)
+ {
+ return *this;
+ }
+
+};
+
+class otl_sp_parm_desc{
+public:
+
+ int position;
+ char arg_name[40];
+ char in_out[20];
+ char data_type[40];
+ char bind_var[128];
+
+ otl_sp_parm_desc():
+ position(-1),
+ arg_name(),
+ in_out(),
+ data_type(),
+ bind_var()
+ {
+ arg_name[0]=0;
+ in_out[0]=0;
+ data_type[0]=0;
+ bind_var[0]=0;
+ }
+
+ otl_sp_parm_desc(const otl_sp_parm_desc& r):
+ position(-1),
+ arg_name(),
+ in_out(),
+ data_type(),
+ bind_var()
+ {
+ copy(r);
+ }
+
+ otl_sp_parm_desc& operator=(const otl_sp_parm_desc& r)
+ {
+ copy(r);
+ return *this;
+ }
+
+ ~otl_sp_parm_desc(){}
+
+protected:
+
+ void copy(const otl_sp_parm_desc& r)
+ {
+ position=r.position;
+ OTL_STRCPY_S(arg_name,sizeof(arg_name),r.arg_name);
+ OTL_STRCPY_S(in_out,sizeof(in_out),r.in_out);
+ OTL_STRCPY_S(data_type,sizeof(data_type),r.data_type);
+ OTL_STRCPY_S(bind_var,sizeof(bind_var),r.bind_var);
+ }
+
+};
+
+class otl_stream
+#if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE)
+ : public otl_read_stream_interface
+#endif
+{
+protected:
+
+ otl_stream_shell* shell;
+ otl_ptr<otl_stream_shell> shell_pt;
+ int connected;
+
+ otl_ref_select_stream** ref_ss;
+ otl_select_stream** ss;
+ otl_inout_stream** io;
+ otl_connect** adb;
+
+ int* auto_commit_flag;
+
+ otl_var_desc** iov;
+ int* iov_len;
+ int* next_iov_ndx;
+
+ otl_var_desc** ov;
+ int* ov_len;
+ int* next_ov_ndx;
+ int end_marker;
+ int oper_int_called;
+ int last_eof_rc;
+ bool last_oper_was_read_op;
+
+ otl_select_struct_override* override;
+
+ int buf_size_;
+
+ void reset_end_marker(void)
+ {
+ last_eof_rc=0;
+ end_marker=-1;
+ oper_int_called=0;
+ }
+
+ static void convert_bind_var_datatype
+ (char* out_buf,
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400) // VC++ 8.0 or higher
+ const size_t out_buf_sz,
+#else
+ const size_t /*out_buf_sz*/,
+#endif
+#else
+ const size_t /*out_buf_sz*/,
+#endif
+ const char* datatype,
+ const int varchar_size,
+ const int all_num2type,
+ const int refcur_buf_size)
+ {
+ out_buf[0]=0;
+ if(strcmp(datatype,"BINARY_INTEGER")==0||
+ strcmp(datatype,"NATIVE INTEGER")==0||
+ strcmp(datatype,"FLOAT")==0||
+ strcmp(datatype,"NUMBER")==0){
+ switch(all_num2type){
+ case otl_var_char:
+ OTL_STRCPY_S(out_buf,out_buf_sz,"char[50]");
+ break;
+ case otl_var_double:
+ OTL_STRCPY_S(out_buf,out_buf_sz,"double");
+ break;
+ case otl_var_float:
+ OTL_STRCPY_S(out_buf,out_buf_sz,"float");
+ break;
+ case otl_var_long_int:
+ OTL_STRCPY_S(out_buf,out_buf_sz,"long");
+ break;
+ case otl_var_int:
+ OTL_STRCPY_S(out_buf,out_buf_sz,"int");
+ break;
+ case otl_var_unsigned_int:
+ OTL_STRCPY_S(out_buf,out_buf_sz,"unsigned");
+ break;
+ case otl_var_short:
+ OTL_STRCPY_S(out_buf,out_buf_sz,"short");
+ break;
+ default:
+ break;
+ }
+ }else if(strcmp(datatype,"DATE")==0)
+ OTL_STRCPY_S(out_buf,out_buf_sz,"timestamp");
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+else if(strcmp(datatype,"TIMESTAMP")==0)
+ OTL_STRCPY_S(out_buf,out_buf_sz,"timestamp");
+#endif
+ else if(strcmp(datatype,"VARCHAR2")==0)
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(out_buf,out_buf_sz,"char[%d]",varchar_size);
+#else
+ sprintf(out_buf,"char[%d]",varchar_size);
+#endif
+#else
+ sprintf(out_buf,"char[%d]",varchar_size);
+#endif
+ else if(strcmp(datatype,"CHAR")==0)
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(out_buf,out_buf_sz,"char[%d]",varchar_size);
+#else
+ sprintf(out_buf,"char[%d]",varchar_size);
+#endif
+#else
+ sprintf(out_buf,"char[%d]",varchar_size);
+#endif
+ else if(strcmp(datatype,"REF CURSOR")==0)
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(out_buf,out_buf_sz,"refcur,out[%d]",refcur_buf_size);
+#else
+ sprintf(out_buf,"refcur,out[%d]",refcur_buf_size);
+#endif
+#else
+ sprintf(out_buf,"refcur,out[%d]",refcur_buf_size);
+#endif
+
+ }
+
+ void throw_end_of_row()
+#if defined(__GNUC__) && (__GNUC__>=4)
+ __attribute__ ((noreturn))
+#endif
+ {
+ throw otl_exception
+ (otl_error_msg_34,
+ otl_error_code_34,
+ this->get_stm_text());
+ }
+
+public:
+
+ bool get_lob_stream_flag() const
+ {
+ if(!shell)
+ return false;
+ else
+ return shell->lob_stream_flag;
+ }
+
+ int get_adb_max_long_size() const
+ {
+ return this->shell->adb->get_max_long_size();
+ }
+
+
+ void check_end_of_row()
+ {
+ if(next_ov_ndx==0||(*next_ov_ndx)!=0)
+ throw_end_of_row();
+ if(next_iov_ndx==0||(*next_iov_ndx)!=0)
+ throw_end_of_row();
+ }
+
+ int get_dirty_buf_len() const
+ {
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ return 0;
+ case otl_inout_stream_type:
+ return (*io)->get_dirty_buf_len();
+ case otl_select_stream_type:
+ return (*ss)->get_select_row_count();
+ case otl_refcur_stream_type:
+ return (*ref_ss)->get_select_row_count();
+ default:
+ return 0;
+ }
+ }
+
+ otl_stream_shell* get_shell(){return shell;}
+
+ int get_connected() const {return connected;}
+
+
+ void setBufSize(int buf_size)
+ {
+ buf_size_=buf_size;
+ }
+
+ int getBufSize(void) const
+ {
+ return buf_size_;
+ }
+
+ operator int(void) OTL_THROWS_OTL_EXCEPTION
+ {
+ if(shell && shell->lob_stream_flag){
+ if(this->adb&&*this->adb)(*this->adb)->increment_throw_count();
+ if(this->adb&&*this->adb&&(*this->adb)->get_throw_count()>1)return 0;
+ const char* stm_label=0;
+ const char* stm_text=0;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ stm_label=(*io)->get_stm_label();
+ stm_text=(*io)->get_stm_text();
+ break;
+ case otl_select_stream_type:
+ stm_label=(*ss)->get_stm_label();
+ stm_text=(*ss)->get_stm_text();
+ break;
+ case otl_refcur_stream_type:
+ stm_label=(*ref_ss)->get_stm_label();
+ stm_text=(*ref_ss)->get_stm_text();
+ break;
+ }
+ throw otl_exception
+ (otl_error_msg_24,
+ otl_error_code_24,
+ stm_label?stm_label:stm_text);
+ }
+ if(!last_oper_was_read_op){
+ if(this->adb&&*this->adb)(*this->adb)->increment_throw_count();
+ if(this->adb&&*this->adb&&(*this->adb)->get_throw_count()>1)return 0;
+ const char* stm_label=0;
+ const char* stm_text=0;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ stm_label=(*io)->get_stm_label();
+ stm_text=(*io)->get_stm_text();
+ break;
+ case otl_select_stream_type:
+ stm_label=(*ss)->get_stm_label();
+ stm_text=(*ss)->get_stm_text();
+ break;
+ case otl_refcur_stream_type:
+ stm_label=(*ref_ss)->get_stm_label();
+ stm_text=(*ref_ss)->get_stm_text();
+ break;
+ }
+ throw otl_exception
+ (otl_error_msg_18,
+ otl_error_code_18,
+ stm_label?stm_label:stm_text);
+ }
+ if(end_marker==1)return 0;
+ int rc=0;
+ int temp_eof=eof();
+ if(temp_eof && end_marker==-1 && oper_int_called==0){
+ end_marker=1;
+ if(last_eof_rc==1)
+ rc=0;
+ else
+ rc=1;
+ }else if(!temp_eof && end_marker==-1)
+ rc=1;
+ else if(temp_eof && end_marker==-1){
+ end_marker=0;
+ rc=1;
+ }else if(temp_eof && end_marker==0){
+ end_marker=1;
+ rc=0;
+ }
+ if(!oper_int_called)oper_int_called=1;
+ return rc;
+ }
+
+#if !defined(OTL_UNICODE)
+ static void create_stored_proc_call
+ (otl_connect& db,
+ otl_stream& args_strm,
+ char* sql_stm,
+ int& stm_type,
+ char* refcur_placeholder,
+ const char* proc_name,
+ const char* package_name,
+ const char* schema_name=0,
+ const bool schema_name_included=false,
+ const int varchar_size=2001,
+ const int all_num2type=otl_var_double,
+ const int refcur_buf_size=1)
+ {
+ sql_stm[0]=0;
+ stm_type=otl_no_stream_type;
+ refcur_placeholder[0]=0;
+
+ char full_name[1024];
+ char temp_buf[1024];
+ char temp_buf2[1024];
+ int i;
+
+ if(package_name==0)
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(full_name,sizeof(full_name),"%s",proc_name);
+#else
+ sprintf(full_name,"%s",proc_name);
+#endif
+#else
+ sprintf(full_name,"%s",proc_name);
+#endif
+ else
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(full_name,sizeof(full_name),"%s.%s",package_name,proc_name);
+#else
+ sprintf(full_name,"%s.%s",package_name,proc_name);
+#endif
+#else
+ sprintf(full_name,"%s.%s",package_name,proc_name);
+#endif
+ if(schema_name_included&&schema_name!=0){
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf,sizeof(temp_buf),"%s.%s",schema_name,full_name);
+#else
+ sprintf(temp_buf,"%s.%s",schema_name,full_name);
+#endif
+#else
+ sprintf(temp_buf,"%s.%s",schema_name,full_name);
+#endif
+ OTL_STRCPY_S(full_name,sizeof(full_name),temp_buf);
+ }
+
+ if(!args_strm.good()){
+ args_strm.open
+ (50,
+ "select position, "
+ " lower(':'||nvl(argument_name,'rc__')) argument_name, "
+ " in_out, "
+ " nvl(data_type,'*') data_type, "
+ " ':'||lower(nvl(argument_name,'rc__'))|| "
+ " decode(data_type,'REF CURSOR',' ', "
+ " '<'||'%s,'|| "
+ " decode(in_out,'IN','in', "
+ " 'OUT','out', "
+ " 'IN/OUT','inout', "
+ " 'xxx') "
+ " ||'>' "
+ " ) || decode(position,0,' := ',' ') "
+ " bind_var "
+ "from all_arguments "
+ "where object_name=upper(:obj_name<char[50]>) "
+ " and (:pkg_name<char[50]> is null and package_name is null or "
+ " :pkg_name is not null "
+ " and (package_name=upper(:pkg_name) "
+ " or package_name = "
+ " (select package_name from "
+ " (select table_name as package_name "
+ " from user_synonyms "
+ " where synonym_name=upper(:pkg_name) "
+ " union all "
+ " select table_name as package_name "
+ " from all_synonyms "
+ " where synonym_name=upper(:pkg_name) "
+ " )"
+ " where rownum = 1)"
+ " )) "
+ " and ((:owner<char[50]> is null "
+ " and owner= "
+ " (select owner from "
+ " (select user as owner "
+ " from user_objects "
+ " where (:pkg_name is not null "
+ " and object_name = upper(:pkg_name) "
+ " and object_type = 'PACKAGE') "
+ " or (:pkg_name is null "
+ " and object_name = upper(:obj_name) "
+ " and object_type in ('FUNCTION','PROCEDURE')) "
+ " union all "
+ " select table_owner as owner "
+ " from user_synonyms "
+ " where (:pkg_name is not null "
+ " and synonym_name = upper(:pkg_name)) "
+ " or (:pkg_name is null "
+ " and synonym_name = upper(:obj_name)) "
+ " union all "
+ " select table_owner as owner "
+ " from all_synonyms "
+ " where (:pkg_name is not null "
+ " and synonym_name = upper(:pkg_name)) "
+ " or (:pkg_name is null "
+ " and synonym_name = upper(:obj_name)) "
+ " ) "
+ " where rownum = 1) "
+ " or "
+ " (:owner is not null and owner=upper(:owner))) "
+ " and data_level=0 )"
+ "order by position",
+ db);
+ }
+
+ otl_auto_array_ptr< otl_Tptr<otl_sp_parm_desc> > desc(otl_var_list_size);
+ int desc_len=0;
+ otl_sp_parm_desc parm;
+
+ args_strm<<proc_name;
+ if(package_name==0)
+ args_strm<<otl_null();
+ else
+ args_strm<<package_name;
+ if(schema_name==0)
+ args_strm<<otl_null();
+ else
+ args_strm<<schema_name;
+ while(!args_strm.eof()){
+ args_strm>>parm.position;
+ args_strm>>parm.arg_name;
+ args_strm>>parm.in_out;
+ args_strm>>parm.data_type;
+ args_strm>>parm.bind_var;
+ ++desc_len;
+ if(desc_len==desc.get_arr_size()){
+ int j;
+ for(j=0;j<desc.get_arr_size();++j)
+ desc.get_ptr()[j].set_do_not_destroy(true);
+ desc.double_size();
+ for(j=0;j<desc.get_arr_size();++j)
+ desc.get_ptr()[j].set_do_not_destroy(false);
+ }
+ desc.get_ptr()[desc_len-1].assign(new otl_sp_parm_desc(parm));
+ }
+
+ if(desc_len==0){
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s",full_name);
+#else
+ sprintf(temp_buf,"procedure %s",full_name);
+#endif
+#else
+ sprintf(temp_buf,"procedure %s",full_name);
+#endif
+ {
+ // last ditch attemp to identify a global SP with no parms
+ bool global_sp_no_parms=false;
+ if(schema_name==0){
+ // schema name is not specified
+ otl_stream s2
+ (1,
+ "select 1 cnt "
+ "from user_procedures "
+ "where object_name=UPPER(:obj_name<char[50]>) "
+ " and procedure_name is null "
+ " and object_type='PROCEDURE' "
+ "union all "
+ "select 1 cnt "
+ "from user_synonyms syn "
+ "where syn.synonym_name=UPPER(:obj_name) "
+ " and exists "
+ " (select 'x' "
+ " from all_procedures proc "
+ " where proc.owner=syn.table_owner "
+ " and proc.object_name=syn.table_name) "
+ "union all "
+ "select 1 cnt "
+ "from all_synonyms syn "
+ "where syn.synonym_name=UPPER(:obj_name) "
+ " and syn.owner='PUBLIC' "
+ " and exists "
+ " (select 'x' "
+ " from all_procedures proc "
+ " where proc.owner=syn.table_owner "
+ " and proc.object_name=syn.table_name)",
+ db);
+ s2<<proc_name;
+ global_sp_no_parms=!s2.eof();
+ }else{
+ // schema name is specified
+ otl_stream s2
+ (1,
+ "select object_name "
+ "from all_procedures "
+ "where object_name=UPPER(:obj_name<char[50]>) "
+ " and procedure_name is null "
+ " and object_type='PROCEDURE' "
+ " AND owner=UPPER(:owner<char[50]>) "
+ "union all "
+ "select synonym_name "
+ "from all_synonyms syn "
+ "where syn.synonym_name=UPPER(:obj_name) "
+ " AND syn.owner=UPPER(:owner) "
+ " and exists "
+ " (select 'x' "
+ " from all_procedures proc "
+ " where proc.owner=syn.table_owner "
+ " and proc.object_name=syn.table_name)",
+ db);
+ s2<<proc_name;
+ s2<<schema_name;
+ global_sp_no_parms=!s2.eof();
+ }
+ if(global_sp_no_parms){
+ // procedure without any parameters
+ otl_strcat(sql_stm,"BEGIN ");
+ otl_strcat(sql_stm,full_name);
+ otl_strcat(sql_stm,"; END;");
+ stm_type=otl_constant_sql_type;
+ return;
+ }else{
+ throw otl_exception
+ (otl_error_msg_13,
+ otl_error_code_13,
+ temp_buf);
+ }
+ }
+ }
+
+ if(desc_len==1){
+ if(desc.get_ptr()[0].get_ptr()->position==1
+ && desc.get_ptr()[0].get_ptr()->data_type[0]=='*'){
+ // procedure without any parameters
+ otl_strcat(sql_stm,"BEGIN ");
+ otl_strcat(sql_stm,full_name);
+ otl_strcat(sql_stm,"; END;");
+ stm_type=otl_constant_sql_type;
+ return;
+ }if(desc.get_ptr()[0].get_ptr()->position==1 &&
+ desc.get_ptr()[0].get_ptr()->data_type[0]!='*'){
+ // procedure with one parameter
+ if(strcmp(desc.get_ptr()[0].get_ptr()->data_type,"REF CURSOR")==0){
+ // procedure with one parameter of refcur type
+ if(strcmp(desc.get_ptr()[0].get_ptr()->in_out,"IN")==0){
+ // refcur parameter should be either OUT or IN OUT, not IN.
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s",full_name);
+#else
+ sprintf(temp_buf,"procedure %s",full_name);
+#endif
+#else
+ sprintf(temp_buf,"procedure %s",full_name);
+#endif
+ throw otl_exception
+ (otl_error_msg_15,
+ otl_error_code_15,
+ temp_buf,0);
+ }
+ otl_strcat(sql_stm,"BEGIN ");
+ otl_strcat(sql_stm,full_name);
+ otl_strcat(sql_stm,"(");
+ otl_strcat(sql_stm,desc.get_ptr()[0].get_ptr()->bind_var);
+ otl_strcat(sql_stm,"); END;");
+ stm_type=otl_refcur_stream_type;
+ otl_strcpy(OTL_RCAST(unsigned char*,refcur_placeholder),
+ OTL_RCAST(const unsigned char*,desc.get_ptr()[0].get_ptr()->arg_name));
+ return;
+ }else{
+ // procedure with one scalar parameter
+ convert_bind_var_datatype
+ (temp_buf,sizeof(temp_buf),desc.get_ptr()[0].get_ptr()->data_type,
+ varchar_size,all_num2type,refcur_buf_size);
+ if(temp_buf[0]==0){
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[0].get_ptr()->arg_name);
+#else
+ sprintf(temp_buf,"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[0].get_ptr()->arg_name);
+#endif
+#else
+ sprintf(temp_buf,"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[0].get_ptr()->arg_name);
+#endif
+ throw otl_exception
+ (otl_error_msg_14,
+ otl_error_code_14,
+ temp_buf,0);
+ }
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[0].get_ptr()->bind_var,temp_buf);
+#else
+ sprintf(temp_buf2,desc.get_ptr()[0].get_ptr()->bind_var,temp_buf);
+#endif
+#else
+ sprintf(temp_buf2,desc.get_ptr()[0].get_ptr()->bind_var,temp_buf);
+#endif
+ otl_strcat(sql_stm,"BEGIN ");
+ otl_strcat(sql_stm,full_name);
+ otl_strcat(sql_stm,"(");
+ otl_strcat(sql_stm,temp_buf2);
+ otl_strcat(sql_stm,"); END;");
+ stm_type=otl_inout_stream_type;
+ refcur_placeholder[0]=0;
+ return;
+ }
+ }else if(desc.get_ptr()[0].get_ptr()->position==0){
+ if(strcmp(desc.get_ptr()[0].get_ptr()->data_type,"REF CURSOR")==0){
+ // refcur function without any parameters
+ otl_strcat(sql_stm,"BEGIN ");
+ otl_strcat(sql_stm,desc.get_ptr()[0].get_ptr()->bind_var);
+ otl_strcat(sql_stm," ");
+ otl_strcat(sql_stm,full_name);
+ otl_strcat(sql_stm,"; END;");
+ stm_type=otl_refcur_stream_type;
+ otl_strcpy(OTL_RCAST(unsigned char*,refcur_placeholder),
+ OTL_RCAST(const unsigned char*,desc.get_ptr()[0].get_ptr()->arg_name));
+ return;
+ }else{
+ // scalar function without any parameters
+ convert_bind_var_datatype
+ (temp_buf,sizeof(temp_buf),desc.get_ptr()[0].get_ptr()->data_type,
+ varchar_size,all_num2type,refcur_buf_size);
+ if(temp_buf[0]==0){
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf,sizeof(temp_buf),
+ "procedure %s, parameter %s",
+ full_name,
+ desc.get_ptr()[0].get_ptr()->arg_name);
+#else
+ sprintf(temp_buf,
+ "procedure %s, parameter %s",
+ full_name,
+ desc.get_ptr()[0].get_ptr()->arg_name);
+#endif
+#else
+ sprintf(temp_buf,
+ "procedure %s, parameter %s",
+ full_name,
+ desc.get_ptr()[0].get_ptr()->arg_name);
+#endif
+ throw otl_exception
+ (otl_error_msg_14,
+ otl_error_code_14,
+ temp_buf,0);
+ }
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[0].get_ptr()->bind_var,temp_buf);
+#else
+ sprintf(temp_buf2,desc.get_ptr()[0].get_ptr()->bind_var,temp_buf);
+#endif
+#else
+ sprintf(temp_buf2,desc.get_ptr()[0].get_ptr()->bind_var,temp_buf);
+#endif
+ otl_strcat(sql_stm,"BEGIN ");
+ otl_strcat(sql_stm,temp_buf2);
+ otl_strcat(sql_stm," ");
+ otl_strcat(sql_stm,full_name);
+ otl_strcat(sql_stm,"; END;");
+ stm_type=otl_inout_stream_type;
+ refcur_placeholder[0]=0;
+ return;
+ }
+ }
+ }
+
+ // Checking if the procedure is of the "refcur" type
+ bool refcur_flag=false;
+ bool refcur_outpar=false;
+ int refcur_count=0;
+ bool inpar_only=true;
+ for(i=0;i<desc_len;++i){
+ if(inpar_only &&
+ strcmp(desc.get_ptr()[i].get_ptr()->in_out,"IN")!=0 &&
+ strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")!=0)
+ inpar_only=false;
+ if(strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")==0){
+ ++refcur_count;
+ refcur_flag=true;
+ if(refcur_count>1){
+ if(refcur_outpar)
+ refcur_outpar=strcmp(desc.get_ptr()[i].get_ptr()->in_out,"IN")!=0;
+ }else
+ refcur_outpar=strcmp(desc.get_ptr()[i].get_ptr()->in_out,"IN")!=0;
+ }
+ }
+ if(refcur_flag){
+ if(!refcur_outpar){
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s",full_name);
+#else
+ sprintf(temp_buf,"procedure %s",full_name);
+#endif
+#else
+ sprintf(temp_buf,"procedure %s",full_name);
+#endif
+ throw otl_exception
+ (otl_error_msg_15,
+ otl_error_code_15,
+ temp_buf,0);
+ }
+ stm_type=otl_refcur_stream_type;
+ if(!inpar_only||refcur_count>1)
+ stm_type=otl_mixed_refcur_stream_type;
+ refcur_placeholder[0]=0;
+ sql_stm[0]=0;
+ bool full_name_printed=false;
+ for(i=0;i<desc_len;++i){
+
+ if(i==0)otl_strcat(sql_stm,"BEGIN ");
+ if(stm_type==otl_refcur_stream_type){
+ // otl_refcur_stream_type
+ if(strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")==0)
+ otl_strcpy(OTL_RCAST(unsigned char*,refcur_placeholder),
+ OTL_RCAST(const unsigned char*,desc.get_ptr()[i].get_ptr()->arg_name));
+ }
+
+ // in case of a function, function's return code
+ if(desc.get_ptr()[i].get_ptr()->position==0){
+ convert_bind_var_datatype
+ (temp_buf,sizeof(temp_buf),desc.get_ptr()[i].get_ptr()->data_type,
+ varchar_size,all_num2type,refcur_buf_size);
+ if(temp_buf[0]==0&&
+ strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")!=0){
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[i].get_ptr()->arg_name);
+#else
+ sprintf(temp_buf,"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[i].get_ptr()->arg_name);
+#endif
+#else
+ sprintf(temp_buf,"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[i].get_ptr()->arg_name);
+#endif
+ throw otl_exception
+ (otl_error_msg_14,
+ otl_error_code_14,
+ temp_buf,0);
+ }
+ if(strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")==0&&
+ stm_type==otl_refcur_stream_type)
+ OTL_STRCPY_S(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[i].get_ptr()->bind_var);
+ else if(strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")==0&&
+ stm_type==otl_mixed_refcur_stream_type){
+ desc.get_ptr()[i].get_ptr()->bind_var[strlen(desc.get_ptr()[i].get_ptr()->bind_var)-5]=0;
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf2,sizeof(temp_buf2),
+ "%s<%s> := ",
+ desc.get_ptr()[i].get_ptr()->bind_var,
+ temp_buf);
+#else
+ sprintf(temp_buf2,
+ "%s<%s> := ",
+ desc.get_ptr()[i].get_ptr()->bind_var,
+ temp_buf);
+#endif
+#else
+ sprintf(temp_buf2,
+ "%s<%s> := ",
+ desc.get_ptr()[i].get_ptr()->bind_var,
+ temp_buf);
+#endif
+ }else
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[i].get_ptr()->bind_var,temp_buf);
+#else
+ sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf);
+#endif
+#else
+ sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf);
+#endif
+ otl_strcat(sql_stm,temp_buf2);
+ }
+
+ // procedure/function's name
+ if(!full_name_printed){
+ otl_strcat(sql_stm,full_name);
+ otl_strcat(sql_stm,"(");
+ full_name_printed=true;
+ }
+
+ if(desc.get_ptr()[i].get_ptr()->position!=0){
+ // normal parameters
+ convert_bind_var_datatype
+ (temp_buf,sizeof(temp_buf),desc.get_ptr()[i].get_ptr()->data_type,
+ varchar_size,all_num2type,refcur_buf_size);
+ if(temp_buf[0]==0&&
+ strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")!=0){
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[i].get_ptr()->arg_name);
+#else
+ sprintf(temp_buf,"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[i].get_ptr()->arg_name);
+#endif
+#else
+ sprintf(temp_buf,"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[i].get_ptr()->arg_name);
+#endif
+ throw otl_exception
+ (otl_error_msg_14,
+ otl_error_code_14,
+ temp_buf,0);
+ }
+ if(strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")==0&&
+ stm_type==otl_refcur_stream_type)
+ OTL_STRCPY_S(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[i].get_ptr()->bind_var);
+ else if(strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")==0&&
+ stm_type==otl_mixed_refcur_stream_type){
+ desc.get_ptr()[i].get_ptr()->bind_var[strlen(desc.get_ptr()[i].get_ptr()->bind_var)-2]=0;
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf2,sizeof(temp_buf2),
+ "%s<%s>",
+ desc.get_ptr()[i].get_ptr()->bind_var,
+ temp_buf);
+#else
+ sprintf(temp_buf2,
+ "%s<%s>",
+ desc.get_ptr()[i].get_ptr()->bind_var,
+ temp_buf);
+#endif
+#else
+ sprintf(temp_buf2,
+ "%s<%s>",
+ desc.get_ptr()[i].get_ptr()->bind_var,
+ temp_buf);
+#endif
+ }else
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[i].get_ptr()->bind_var,temp_buf);
+#else
+ sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf);
+#endif
+#else
+ sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf);
+#endif
+ otl_strcat(sql_stm,temp_buf2);
+ }
+
+ if(i<desc_len-1 && desc.get_ptr()[i].get_ptr()->position!=0)
+ otl_strcat(sql_stm,",");
+ else if(i==desc_len-1)
+ otl_strcat(sql_stm,"); ");
+
+ }
+ otl_strcat(sql_stm," END;");
+ return;
+ }
+
+ // The procedure is of the "general" type
+ stm_type=otl_inout_stream_type;
+ refcur_placeholder[0]=0;
+ sql_stm[0]=0;
+ bool full_name_printed=false;
+ for(i=0;i<desc_len;++i){
+ if(i==0)otl_strcat(sql_stm,"BEGIN ");
+ // in case of a function, function's return code
+ if(desc.get_ptr()[i].get_ptr()->position==0){
+ convert_bind_var_datatype
+ (temp_buf,sizeof(temp_buf),desc.get_ptr()[i].get_ptr()->data_type,
+ varchar_size,all_num2type,refcur_buf_size);
+ if(temp_buf[0]==0){
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[i].get_ptr()->arg_name);
+#else
+ sprintf(temp_buf,"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[i].get_ptr()->arg_name);
+#endif
+#else
+ sprintf(temp_buf,"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[i].get_ptr()->arg_name);
+#endif
+ throw otl_exception
+ (otl_error_msg_14,
+ otl_error_code_14,
+ temp_buf,0);
+ }
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[i].get_ptr()->bind_var,temp_buf);
+#else
+ sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf);
+#endif
+#else
+ sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf);
+#endif
+ otl_strcat(sql_stm,temp_buf2);
+ }
+ // procedure/function's name
+ if(!full_name_printed){
+ otl_strcat(sql_stm,full_name);
+ otl_strcat(sql_stm,"(");
+ full_name_printed=true;
+ }
+ if(desc.get_ptr()[i].get_ptr()->position!=0){
+ // normal parameters
+ convert_bind_var_datatype
+ (temp_buf,sizeof(temp_buf),desc.get_ptr()[i].get_ptr()->data_type,
+ varchar_size,all_num2type,refcur_buf_size);
+ if(temp_buf[0]==0){
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[i].get_ptr()->arg_name);
+#else
+ sprintf(temp_buf,"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[i].get_ptr()->arg_name);
+#endif
+#else
+ sprintf(temp_buf,"procedure %s, parameter %s",
+ full_name,desc.get_ptr()[i].get_ptr()->arg_name);
+#endif
+ throw otl_exception
+ (otl_error_msg_14,
+ otl_error_code_14,
+ temp_buf,0);
+ }
+#if defined(_MSC_VER)
+#if (_MSC_VER >= 1400)
+ sprintf_s(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[i].get_ptr()->bind_var,temp_buf);
+#else
+ sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf);
+#endif
+#else
+ sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf);
+#endif
+ otl_strcat(sql_stm,temp_buf2);
+ }
+ if(i<desc_len-1&&desc.get_ptr()[i].get_ptr()->position!=0)
+ otl_strcat(sql_stm,",");
+ else if(i==desc_len-1)
+ otl_strcat(sql_stm,"); ");
+ }
+ otl_strcat(sql_stm," END;");
+
+ }
+#endif
+
+ int get_stream_type(void) OTL_NO_THROW
+ {
+ if(shell==0)
+ return otl_no_stream_type;
+ else
+ return shell->stream_type;
+ }
+
+ void set_column_type(const int column_ndx,
+ const int col_type,
+ const int col_size=0) OTL_NO_THROW
+ {
+ if(shell==0){
+ init_stream();
+ shell->flush_flag=true;
+ }
+ override->add_override(column_ndx,col_type,col_size);
+ }
+
+
+ void set_all_column_types(const unsigned mask=0)
+ OTL_NO_THROW
+ {
+ if(shell==0){
+ init_stream();
+ shell->flush_flag=true;
+ }
+ override->set_all_column_types(mask);
+ }
+
+ void set_flush(const bool flush_flag=true)
+ OTL_NO_THROW
+ {
+ if(shell==0)init_stream();
+ shell->flush_flag=flush_flag;
+ }
+
+ void set_lob_stream_mode(const bool lob_stream_flag=false)
+ OTL_NO_THROW
+ {
+ if(shell==0)return;
+ shell->lob_stream_flag=lob_stream_flag;
+ }
+
+ void inc_next_ov(void)
+ {
+ if((*ov_len)==0)return;
+ if((*next_ov_ndx)<(*ov_len)-1)
+ ++(*next_ov_ndx);
+ else
+ (*next_ov_ndx)=0;
+ }
+
+ void inc_next_iov(void)
+ {
+ if((*iov_len)==0)return;
+ if((*next_iov_ndx)<(*iov_len)-1)
+ ++(*next_iov_ndx);
+ else
+ (*next_iov_ndx)=0;
+ }
+
+ otl_var_desc* describe_in_vars(int& desc_len)
+ OTL_NO_THROW
+ {
+ desc_len=0;
+ if(shell==0)return 0;
+ if(shell->iov==0)return 0;
+ desc_len=shell->iov_len;
+ return shell->iov;
+ }
+
+ otl_var_desc* describe_out_vars(int& desc_len)
+ OTL_NO_THROW
+ {
+ desc_len=0;
+ if(shell==0)return 0;
+ if(shell->ov==0)return 0;
+ desc_len=shell->ov_len;
+ return shell->ov;
+ }
+
+ otl_var_desc* describe_next_in_var(void)
+ OTL_NO_THROW
+ {
+ if(shell==0)return 0;
+ if(shell->iov==0)return 0;
+ return &(shell->iov[shell->next_iov_ndx]);
+ }
+
+ otl_var_desc* describe_next_out_var(void)
+ OTL_NO_THROW
+ {
+ if(shell==0)return 0;
+ if(shell->ov==0)return 0;
+ return &(shell->ov[shell->next_ov_ndx]);
+ }
+
+ const char* get_stm_text(void)
+ {
+ const char* no_stm_text=OTL_NO_STM_TEXT;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ return no_stm_text;
+ case otl_inout_stream_type:
+ return (*io)->get_stm_label()?(*io)->get_stm_label():(*io)->get_stm_text();
+ case otl_select_stream_type:
+ return (*ss)->get_stm_label()?(*ss)->get_stm_label():(*ss)->get_stm_text();
+ case otl_refcur_stream_type:
+ return (*ref_ss)->get_stm_label()?
+ (*ref_ss)->get_stm_label():(*ref_ss)->get_stm_text();
+ default:
+ return no_stm_text;
+ }
+ }
+
+ long get_rpc() OTL_THROWS_OTL_EXCEPTION
+ {
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ return 0;
+ case otl_inout_stream_type:
+ (*adb)->reset_throw_count();
+ return (*io)->get_rpc();
+ case otl_select_stream_type:
+ (*adb)->reset_throw_count();
+ return (*ss)->get_rfc();
+ case otl_refcur_stream_type:
+ (*adb)->reset_throw_count();
+ return (*ref_ss)->get_rfc();
+ default:
+ return 0;
+ }
+ }
+
+ void create_var_desc(void)
+ {int i;
+ delete[] (*iov);
+ delete[] (*ov);
+ (*iov)=0; (*iov_len)=0;
+ (*ov)=0; (*ov_len)=0;
+ if((*ss)){
+ if((*ss)->get_vl_len()>0){
+ (*iov)=new otl_var_desc[(*ss)->get_vl_len()];
+ (*iov_len)=(*ss)->get_vl_len();
+ for(i=0;i<(*ss)->get_vl_len();++i)
+ (*ss)->get_vl()[i]->copy_var_desc((*iov)[i]);
+ }
+ if((*ss)->get_sl_len()>0){
+ (*ov)=new otl_var_desc[(*ss)->get_sl_len()];
+ (*ov_len)=(*ss)->get_sl_len();
+ for(i=0;i<(*ss)->get_sl_len();++i){
+ (*ss)->get_sl()[i].copy_var_desc((*ov)[i]);
+ (*ov)[i].copy_name((*ss)->get_sl_desc()[i].name);
+ }
+ }
+ }else if((*io)){
+ if((*io)->get_vl_len()>0){
+ (*iov)=new otl_var_desc[(*io)->get_vl_len()];
+ (*iov_len)=(*io)->get_vl_len();
+ for(i=0;i<(*io)->get_vl_len();++i)
+ (*io)->get_vl()[i]->copy_var_desc((*iov)[i]);
+ }
+ if((*io)->get_iv_len()>0){
+ (*ov)=new otl_var_desc[(*io)->get_iv_len()];
+ (*ov_len)=(*io)->get_iv_len();
+ for(i=0;i<(*io)->get_iv_len();++i)
+ (*io)->get_in_vl()[i]->copy_var_desc((*ov)[i]);
+ }
+ }else if((*ref_ss)){
+ if((*ref_ss)->get_vl_len()>0){
+ (*iov)=new otl_var_desc[(*ref_ss)->get_vl_len()];
+ (*iov_len)=(*ref_ss)->get_vl_len();
+ for(i=0;i<(*ref_ss)->get_vl_len();++i)
+ (*ref_ss)->get_vl()[i]->copy_var_desc((*iov)[i]);
+ }
+ if((*ref_ss)->get_sl_len()>0){
+ (*ov)=new otl_var_desc[(*ref_ss)->get_sl_len()];
+ (*ov_len)=(*ref_ss)->get_sl_len();
+ for(i=0;i<(*ref_ss)->get_sl_len();++i){
+ (*ref_ss)->get_sl()[i].copy_var_desc((*ov)[i]);
+ (*ov)[i].copy_name((*ref_ss)->get_sl_desc()[i].name);
+ }
+ }
+ }
+ }
+
+ void init_stream(void)
+ {
+ buf_size_=1;
+ last_oper_was_read_op=false;
+ shell=0;
+ shell=new otl_stream_shell(0);
+ shell_pt.assign(&shell);
+ connected=0;
+
+ ref_ss=&(shell->ref_ss);
+ ss=&(shell->ss);
+ io=&(shell->io);
+ adb=&(shell->adb);
+ auto_commit_flag=&(shell->auto_commit_flag);
+ iov=&(shell->iov);
+ iov_len=&(shell->iov_len);
+ next_iov_ndx=&(shell->next_iov_ndx);
+ ov=&(shell->ov);
+ ov_len=&(shell->ov_len);
+ next_ov_ndx=&(shell->next_ov_ndx);
+ override=&(shell->override);
+
+ (*ref_ss)=0;
+ (*io)=0;
+ (*ss)=0;
+ (*adb)=0;
+ (*ov)=0;
+ (*ov_len)=0;
+ (*next_iov_ndx)=0;
+ (*next_ov_ndx)=0;
+ (*auto_commit_flag)=1;
+ (*iov)=0;
+ (*iov_len)=0;
+
+ }
+
+ otl_stream
+ (const otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ otl_connect& db,
+ const char* ref_cur_placeholder=0,
+ const char* sqlstm_label=0)
+ OTL_THROWS_OTL_EXCEPTION:
+ #if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE)
+ otl_read_stream_interface(),
+#endif
+ shell(0),
+ shell_pt(),
+ connected(0),
+ ref_ss(0),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ end_marker(0),
+ oper_int_called(0),
+ last_eof_rc(0),
+ last_oper_was_read_op(false),
+ override(0),
+ buf_size_(0)
+ {
+ init_stream();
+
+ (*io)=0; (*ss)=0; (*ref_ss)=0;
+ (*iov)=0; (*iov_len)=0;
+ (*ov)=0; (*ov_len)=0;
+ (*auto_commit_flag)=1;
+ (*next_iov_ndx)=0;
+ (*next_ov_ndx)=0;
+ (*adb)=&db;
+ shell->flush_flag=true;
+ open(arr_size,sqlstm,db,ref_cur_placeholder,sqlstm_label);
+ }
+
+ otl_stream() OTL_NO_THROW:
+ #if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE)
+ otl_read_stream_interface(),
+#endif
+ shell(0),
+ shell_pt(),
+ connected(0),
+ ref_ss(0),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ end_marker(0),
+ oper_int_called(0),
+ last_eof_rc(0),
+ last_oper_was_read_op(false),
+ override(0),
+ buf_size_(0)
+ {
+ init_stream();
+ shell->flush_flag=true;
+ }
+
+ virtual ~otl_stream()
+#if !defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ OTL_THROWS_OTL_EXCEPTION
+#endif
+ {
+ if(!connected)return;
+ try{
+ if((*io)!=0&&shell->flush_flag==false)
+ (*io)->set_flush_flag2(false);
+ close();
+ if(shell!=0){
+ if((*io)!=0)
+ (*io)->set_flush_flag2(true);
+ }
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ if(shell!=0){
+ if((*io)!=0)
+ (*io)->set_flush_flag2(true);
+ }
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ clean(1);
+ if(shell!=0)
+ shell->set_should_delete(1);
+ shell_pt.destroy();
+#else
+ shell_pt.destroy();
+#endif
+#if !defined(OTL_DESTRUCTORS_DO_NOT_THROW)
+ throw;
+#endif
+ }
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ if((adb && (*adb) && (*adb)->get_throw_count()>0)
+#if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ || otl_uncaught_exception()
+#elif defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ || otl_uncaught_exception()
+#endif
+ ){
+ //
+ }
+#else
+ shell_pt.destroy();
+#endif
+ }
+
+ int eof(void) OTL_NO_THROW
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ return (*io)->eof();
+ }else if((*ss)){
+ (*adb)->reset_throw_count();
+ return (*ss)->eof();
+ }else if((*ref_ss)){
+ (*adb)->reset_throw_count();
+ return (*ref_ss)->eof();
+ }else
+ return 1;
+ }
+
+ void skip_to_end_of_row()
+ {
+ if(next_ov_ndx==0)
+ return;
+ if((*ov_len)==0)return;
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->skip_to_end_of_row();
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->skip_to_end_of_row();
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->skip_to_end_of_row();
+ break;
+ }
+ while ((*next_ov_ndx)<(*ov_len)-1)
+ ++(*next_ov_ndx);
+ }
+
+
+ void reset_to_last_valid_row()
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->reset_to_last_valid_row();
+ }
+ }
+
+ void flush(const int rowoff=0,const bool force_flush=false)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->flush(rowoff,force_flush);
+ }
+ }
+
+ void clean(const int clean_up_error_flag=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->clean(clean_up_error_flag);
+ }else if(*ss){
+ (*adb)->reset_throw_count();
+ (*ss)->clean();
+ }else if(*ref_ss){
+ (*adb)->reset_throw_count();
+ (*ref_ss)->clean();
+ }
+ }
+
+ void rewind(void)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->rewind();
+ }else if((*ss)){
+ (*adb)->reset_throw_count();
+ (*ss)->rewind();
+ }else if((*ref_ss)){
+ (*adb)->reset_throw_count();
+ (*ref_ss)->rewind();
+ }
+ }
+
+ int is_null(void) OTL_NO_THROW
+ {
+ if((*io))
+ return (*io)->is_null();
+ else if((*ss))
+ return (*ss)->is_null();
+ else if((*ref_ss))
+ return (*ref_ss)->is_null();
+ else
+ return 0;
+ }
+
+ void set_commit(int auto_commit=0) OTL_NO_THROW
+ {
+ (*auto_commit_flag)=auto_commit;
+ if((*io)){
+ (*adb)->reset_throw_count();
+ (*io)->set_commit(auto_commit);
+ }
+ }
+
+ void open
+ (const otl_stream_buffer_size_type arr_size,
+ const char* sqlstm,
+ otl_connect& db,
+ const char* ref_cur_placeholder=0,
+ const char* sqlstm_label=0)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ reset_end_marker();
+ if(this->good()){
+ const char* temp_stm_text=0;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ temp_stm_text=OTL_NO_STM_TEXT;
+ break;
+ case otl_inout_stream_type:
+ temp_stm_text=(*io)->get_stm_label()?(*io)->get_stm_label():(*io)->get_stm_text();
+ break;
+ case otl_select_stream_type:
+ temp_stm_text=(*ss)->get_stm_label()?(*ss)->get_stm_label():(*ss)->get_stm_text();
+ break;
+ case otl_refcur_stream_type:
+ temp_stm_text=(*ref_ss)->get_stm_label()?
+ (*ref_ss)->get_stm_label():(*ref_ss)->get_stm_text();
+ break;
+ default:
+ temp_stm_text=OTL_NO_STM_TEXT;
+ break;
+ }
+ throw otl_exception
+ (otl_error_msg_29,
+ otl_error_code_29,
+ temp_stm_text);
+ }
+ if(shell==0)
+ init_stream();
+ buf_size_=arr_size;
+ OTL_TRACE_STREAM_OPEN2
+#if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON)
+ char temp_buf[128];
+ otl_itoa(arr_size,temp_buf);
+ OTL_STRING_CONTAINER sql_stm=
+ OTL_STRING_CONTAINER(temp_buf)+
+ OTL_STRING_CONTAINER("===>")+sqlstm;
+ otl_stream_shell_generic* temp_shell=db.get_sc().find(sql_stm);
+ if(temp_shell){
+ if(shell!=0)
+ shell_pt.destroy();
+ shell=OTL_RCAST(otl_stream_shell*,temp_shell);
+ ref_ss=&(shell->ref_ss);
+ ss=&(shell->ss);
+ io=&(shell->io);
+ if((*io)!=0)(*io)->set_flush_flag2(true);
+ adb=&(shell->adb);
+ auto_commit_flag=&(shell->auto_commit_flag);
+ iov=&(shell->iov);
+ iov_len=&(shell->iov_len);
+ next_iov_ndx=&(shell->next_iov_ndx);
+ ov=&(shell->ov);
+ ov_len=&(shell->ov_len);
+ next_ov_ndx=&(shell->next_ov_ndx);
+ override=&(shell->override);
+ override->set_master_stream_ptr(OTL_RCAST(void*,this));
+ try{
+ if((*iov_len)==0)this->rewind();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ if((*adb))
+ (*adb)->get_sc().remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ throw;
+ }
+ connected=1;
+ return;
+ }
+ shell->orig_sql_stm=sql_stm;
+#endif
+
+ delete[] (*iov);
+ delete[] (*ov);
+
+ (*iov)=0; (*iov_len)=0;
+ (*ov)=0; (*ov_len)=0;
+ (*next_iov_ndx)=0;
+ (*next_ov_ndx)=0;
+
+ char tmp[7];
+ char* c=OTL_CCAST(char*,sqlstm);
+
+ while(otl_isspace(*c)||(*c)=='(')++c;
+ OTL_STRNCPY_S(tmp,sizeof(tmp),c,6);
+ tmp[6]=0;
+ c=tmp;
+ while(*c){
+ *c=OTL_SCAST(char,otl_to_upper(*c));
+ ++c;
+ }
+ if(adb==0)adb=&(shell->adb);
+ (*adb)=&db;
+ (*adb)->reset_throw_count();
+ try{
+ if((strncmp(tmp,"SELECT",6)==0||
+ strncmp(tmp,"WITH",4)==0)&&
+ ref_cur_placeholder==0){
+ override->set_master_stream_ptr(OTL_RCAST(void*,this));
+ (*ss)=new otl_select_stream(override,arr_size,
+ sqlstm,db,otl_explicit_select,
+ sqlstm_label);
+ shell->stream_type=otl_select_stream_type;
+ }else if(ref_cur_placeholder!=0){
+ override->set_master_stream_ptr(OTL_RCAST(void*,this));
+ (*ref_ss)=new otl_ref_select_stream
+ (override,arr_size,sqlstm,ref_cur_placeholder,
+ db,sqlstm_label);
+ shell->stream_type=otl_refcur_stream_type;
+ }else{
+ (*io)=new otl_inout_stream
+ (arr_size,
+ sqlstm,
+ db,
+ OTL_RCAST(void*,this),
+ false,sqlstm_label);
+ (*io)->set_flush_flag(shell->flush_flag);
+ shell->stream_type=otl_inout_stream_type;
+ }
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ shell_pt.destroy();
+ throw;
+ }
+ if((*io))(*io)->set_commit((*auto_commit_flag));
+ create_var_desc();
+ connected=1;
+ }
+
+ void intern_cleanup(void)
+ {
+ delete[] (*iov);
+ delete[] (*ov);
+
+ (*iov)=0; (*iov_len)=0;
+ (*ov)=0; (*ov_len)=0;
+ (*next_iov_ndx)=0;
+ (*next_ov_ndx)=0;
+ override->setLen(0);
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ try{
+ (*io)->flush();
+ (*io)->close();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ clean(1);
+ (*io)->close();
+ delete (*io);
+ (*io)=0;
+ shell->stream_type=otl_no_stream_type;
+ throw;
+ }
+ delete (*io);
+ (*io)=0;
+ shell->stream_type=otl_no_stream_type;
+ break;
+ case otl_select_stream_type:
+ try{
+ (*ss)->close();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ delete (*ss);
+ (*ss)=0;
+ shell->stream_type=otl_no_stream_type;
+ throw;
+ }
+ delete (*ss);
+ (*ss)=0;
+ shell->stream_type=otl_no_stream_type;
+ break;
+ case otl_refcur_stream_type:
+ try{
+ (*ref_ss)->close();
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ delete (*ref_ss);
+ (*ref_ss)=0;
+ shell->stream_type=otl_no_stream_type;
+ throw;
+ }
+ delete (*ref_ss);
+ (*ref_ss)=0;
+ shell->stream_type=otl_no_stream_type;
+ break;
+ }
+ (*ss)=0; (*io)=0; (*ref_ss)=0;
+ if(adb!=0)(*adb)=0;
+ adb=0;
+ }
+
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ void close(const bool save_in_stream_pool=true)
+#else
+ void close(void)
+#endif
+ {
+ if(shell==0)return;
+ OTL_TRACE_FUNC(0x4,"otl_stream","close","")
+#if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON)
+ if(save_in_stream_pool&&(*adb)&&
+#if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ !otl_uncaught_exception()&&
+#elif defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ !otl_uncaught_exception()&&
+#endif
+ (*adb)->get_throw_count()==0){
+ try{
+ this->flush();
+ this->clean(1);
+ }catch(OTL_CONST_EXCEPTION otl_exception&){
+ this->clean(1);
+ throw;
+ }
+ if((*adb) && (*adb)->get_throw_count()>0){
+ (*adb)->get_sc().remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ return;
+ }
+#if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ if(otl_uncaught_exception()){
+ if((*adb))
+ (*adb)->get_sc().remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ return;
+ }
+#elif defined(OTL_UNCAUGHT_EXCEPTION_ON)
+ if(otl_uncaught_exception()){
+ if((*adb))
+ (*adb)->get_sc().remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ return;
+ }
+#endif
+ (*adb)->get_sc().add(shell,shell->orig_sql_stm.c_str());
+ shell_pt.disconnect();
+ connected=0;
+ }else{
+ if((*adb))
+ (*adb)->get_sc().remove(shell,shell->orig_sql_stm);
+ intern_cleanup();
+ shell_pt.destroy();
+ connected=0;
+ }
+#else
+ intern_cleanup();
+ connected=0;
+#endif
+ }
+
+ otl_column_desc* describe_select(int& desc_len)
+ OTL_NO_THROW
+ {
+ desc_len=0;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ return 0;
+ case otl_inout_stream_type:
+ return 0;
+ case otl_select_stream_type:
+ (*adb)->reset_throw_count();
+ desc_len=(*ss)->get_sl_len();
+ return (*ss)->get_sl_desc();
+ case otl_refcur_stream_type:
+ (*adb)->reset_throw_count();
+ desc_len=(*ref_ss)->get_sl_len();
+ return (*ref_ss)->get_sl_desc();
+ default:
+ return 0;
+ }
+ }
+
+ int good(void) OTL_NO_THROW
+ {
+ if(!connected)return 0;
+ if((*io)||(*ss)||(*ref_ss)){
+ (*adb)->reset_throw_count();
+ return 1;
+ }else
+ return 0;
+ }
+
+ otl_stream& operator>>(otl_stream& (*pf) (otl_stream&))
+ {
+ (*pf)(*this);
+ return *this;
+ }
+
+ otl_stream& operator<<(otl_stream& (*pf) (otl_stream&))
+ {
+ (*pf)(*this);
+ return *this;
+ }
+
+ otl_stream& operator>>(otl_pl_tab_generic& tab)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ if((*io)){
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(tab);
+ OTL_TRACE_WRITE(", tab len="<<tab.len(),"operator >>","PL/SQL Tab&")
+ inc_next_ov();
+ }
+ return *this;
+ }
+
+ otl_stream& operator>>(otl_refcur_stream& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ if((*io)){
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ OTL_TRACE_WRITE(" ref.cur.stream","operator >>","otl_refcur_stream&")
+ inc_next_ov();
+ }
+ return *this;
+ }
+
+ otl_stream& operator<<(otl_pl_tab_generic& tab)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ if((*io)){
+ (*io)->operator<<(tab);
+ OTL_TRACE_READ(", tab len="<<tab.len(),"operator <<","PL/SQL Tab&")
+ inc_next_iov();
+ }
+ return *this;
+ }
+
+#if defined(OTL_PL_TAB) && defined(OTL_STL)
+
+ otl_stream& operator>>(otl_pl_vec_generic& vec)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ if((*io)){
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(vec);
+ OTL_TRACE_WRITE(", tab len="<<vec.len(),"operator >>","PL/SQL Tab&")
+ inc_next_ov();
+ }
+ return *this;
+ }
+
+ otl_stream& operator<<(otl_pl_vec_generic& vec)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ if((*io)){
+ (*io)->operator<<(vec);
+ OTL_TRACE_READ(", tab len="<<vec.len(),"operator <<","PL/SQL Tab&")
+ inc_next_iov();
+ }
+ return *this;
+ }
+
+#endif
+
+ otl_stream& operator<<(otl_lob_stream& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ if((*io)){
+ (*io)->operator<<(s);
+ OTL_TRACE_READ(", lob stream","operator <<","PL/otl_lob_stream&")
+ inc_next_iov();
+ }
+ return *this;
+ }
+
+ otl_stream& operator>>(otl_time0& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ {
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+#if defined(OTL_ORA_TIMESTAMP)
+ OTL_TRACE_WRITE
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator >>",
+ "otl_datetime&");
+#endif
+ break;
+ }
+ case otl_select_stream_type:
+ {
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+#if defined(OTL_ORA_TIMESTAMP)
+ OTL_TRACE_WRITE
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator >>",
+ "otl_datetime&");
+#endif
+ break;
+ }
+ case otl_refcur_stream_type:
+ {
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(s);
+#if defined(OTL_ORA_TIMESTAMP)
+ OTL_TRACE_WRITE
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator >>",
+ "otl_datetime&");
+#endif
+ break;
+ }
+ }
+#if defined(OTL_ORA_TIMESTAMP)
+ inc_next_ov();
+#endif
+ return *this;
+ }
+
+ otl_stream& operator<<(const otl_time0& n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ {
+ (*io)->operator<<(n);
+#if defined(OTL_ORA_TIMESTAMP)
+ OTL_TRACE_READ(OTL_TRACE_FORMAT_DATETIME(n),
+ "operator <<",
+ "otl_datetime&");
+#endif
+ break;
+ }
+ case otl_select_stream_type:
+ {
+ (*ss)->operator<<(n);
+#if defined(OTL_ORA_TIMESTAMP)
+ OTL_TRACE_READ(OTL_TRACE_FORMAT_DATETIME(n),
+ "operator <<",
+ "otl_datetime&");
+#endif
+ break;
+ }
+ case otl_refcur_stream_type:
+ {
+ (*ref_ss)->operator<<(n);
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+#if defined(OTL_ORA_TIMESTAMP)
+ OTL_TRACE_READ(OTL_TRACE_FORMAT_DATETIME(n),
+ "operator <<",
+ "otl_datetime&");
+#endif
+ break;
+ }
+ }
+#if defined(OTL_ORA_TIMESTAMP)
+ inc_next_iov();
+#endif
+ return *this;
+ }
+
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ // already declared
+#else
+ OTL_ORA_COMMON_READ_STREAM& operator>>(otl_datetime& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+
+#if defined(OTL_ORA7_STRING_TO_TIMESTAMP)
+
+ if(describe_next_out_var()->ftype==otl_var_char){
+#if defined(OTL_UNICODE)
+ OTL_CHAR tmp_str[100];
+#elif defined(OTL_UNICODE) && defined(OTL_UNICODE_CHAR_TYPE)
+ OTL_UNICODE_CHAR_TYPE tmp_str[100];
+#else
+ char tmp_str[100];
+#endif
+ (*this)>>tmp_str;
+#if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_DATETIME_NULL_TO_VAL;
+ else
+ OTL_ORA7_STRING_TO_TIMESTAMP(tmp_str,s);
+#else
+ OTL_ORA7_STRING_TO_TIMESTAMP(tmp_str,s);
+#endif
+ OTL_TRACE_WRITE
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator >>",
+ "otl_datetime&");
+ return *this;
+ }else{
+ otl_time0 tmp;
+ (*this)>>tmp;
+#if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_DATETIME_NULL_TO_VAL;
+ else{
+ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100);
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour-1;
+ s.minute=tmp.minute-1;
+ s.second=tmp.second-1;
+ }
+#else
+ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100);
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour-1;
+ s.minute=tmp.minute-1;
+ s.second=tmp.second-1;
+#endif
+ OTL_TRACE_WRITE
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator >>",
+ "otl_datetime&")
+ inc_next_ov();
+ return *this;
+ }
+
+#else
+
+ otl_time0 tmp;
+ (*this)>>tmp;
+#if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_DATETIME_NULL_TO_VAL;
+ else{
+ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100);
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour-1;
+ s.minute=tmp.minute-1;
+ s.second=tmp.second-1;
+ }
+#else
+ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100);
+ s.month=tmp.month;
+ s.day=tmp.day;
+ s.hour=tmp.hour-1;
+ s.minute=tmp.minute-1;
+ s.second=tmp.second-1;
+#endif
+ OTL_TRACE_WRITE
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator >>",
+ "otl_datetime&");
+ inc_next_ov();
+ return *this;
+
+#endif
+
+ }
+#endif
+
+#if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP)
+ // already declared
+#else
+ otl_stream& operator<<(const otl_datetime& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+#if defined(OTL_ORA7_TIMESTAMP_TO_STRING)
+ if(describe_next_in_var()->ftype==otl_var_char){
+#if defined(OTL_UNICODE)
+ OTL_CHAR tmp_str[100];
+#elif defined(OTL_UNICODE) && defined(OTL_UNICODE_CHAR_TYPE)
+ OTL_UNICODE_CHAR_TYPE tmp_str[100];
+#else
+ char tmp_str[100];
+#endif
+ OTL_ORA7_TIMESTAMP_TO_STRING(s,tmp_str);
+ OTL_TRACE_READ
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator <<",
+ "otl_datetime&");
+ (*this)<<tmp_str;
+ return *this;
+ }else{
+ otl_time0 tmp;
+ tmp.year=OTL_SCAST(unsigned char, ((s.year%100)+100));
+ tmp.century=OTL_SCAST(unsigned char, ((s.year/100)+100));
+ tmp.month=OTL_SCAST(unsigned char, s.month);
+ tmp.day=OTL_SCAST(unsigned char, s.day);
+ tmp.hour=OTL_SCAST(unsigned char, (s.hour+1));
+ tmp.minute=OTL_SCAST(unsigned char, (s.minute+1));
+ tmp.second=OTL_SCAST(unsigned char, (s.second+1));
+ OTL_TRACE_READ
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator <<",
+ "otl_datetime&");
+ (*this)<<tmp;
+ inc_next_iov();
+ return *this;
+ }
+#else
+ otl_time0 tmp;
+ tmp.year=OTL_SCAST(unsigned char, ((s.year%100)+100));
+ tmp.century=OTL_SCAST(unsigned char, ((s.year/100)+100));
+ tmp.month=OTL_SCAST(unsigned char, s.month);
+ tmp.day=OTL_SCAST(unsigned char, s.day);
+ tmp.hour=OTL_SCAST(unsigned char, (s.hour+1));
+ tmp.minute=OTL_SCAST(unsigned char, (s.minute+1));
+ tmp.second=OTL_SCAST(unsigned char, (s.second+1));
+ OTL_TRACE_READ
+ (OTL_TRACE_FORMAT_DATETIME(s),
+ "operator <<",
+ "otl_datetime&");
+ (*this)<<tmp;
+ inc_next_iov();
+ return *this;
+#endif
+ }
+#endif
+
+#if !defined(OTL_UNICODE)
+ OTL_ORA_COMMON_READ_STREAM& operator>>(char& c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(c);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(c);
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(c);
+ break;
+ }
+#if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL)
+ if((*this).is_null())
+ c=OTL_DEFAULT_CHAR_NULL_TO_VAL;
+#endif
+ OTL_TRACE_WRITE("'"<<c<<"'","operator >>","char&")
+ inc_next_ov();
+ return *this;
+ }
+#endif
+
+ OTL_ORA_COMMON_READ_STREAM& operator>>(unsigned char& c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(c);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(c);
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(c);
+ break;
+ }
+#if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL)
+ if((*this).is_null())
+ c=OTL_DEFAULT_CHAR_NULL_TO_VAL;
+#endif
+ OTL_TRACE_WRITE("'"<<c<<"'","operator >>","unsigned char&")
+ inc_next_ov();
+ return *this;
+ }
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ OTL_ORA_COMMON_READ_STREAM& operator>>(OTL_STRING_CONTAINER& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(s);
+ break;
+ }
+
+#if defined(OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL)
+ if((*this).is_null()){
+ OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL(s);
+ }
+#elif defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_DEFAULT_STRING_NULL_TO_VAL;
+#endif
+
+ OTL_TRACE_WRITE("\""<<s<<"\"","operator >>","OTL_STRING_CONTAINER&")
+ inc_next_ov();
+ return *this;
+ }
+#endif
+
+#if !defined(OTL_UNICODE)
+ OTL_ORA_COMMON_READ_STREAM& operator>>(char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(s);
+ break;
+ }
+#if defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL));
+#endif
+ OTL_TRACE_WRITE("\""<<s<<"\"","operator >>","char*")
+ inc_next_ov();
+ return *this;
+ }
+#endif
+
+#if defined(OTL_UNICODE_STRING_TYPE)
+ OTL_ORA_COMMON_READ_STREAM& operator>>(OTL_UNICODE_STRING_TYPE& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(s);
+ break;
+ }
+#if defined(OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL)
+ if((*this).is_null()){
+ OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL(s);
+ }
+#elif defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ s=OTL_RCAST(const OTL_UNICODE_CHAR_TYPE*,
+ OTL_DEFAULT_STRING_NULL_TO_VAL);
+#endif
+
+ OTL_TRACE_WRITE
+ ("\""<<s.c_str()<<"\"",
+ "operator >>",
+ "OTL_UNICODE_STRING_TYPE&");
+ inc_next_ov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const OTL_UNICODE_STRING_TYPE& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("\""<<s.c_str()<<"\"","operator <<","OTL_UNICODE_STRING_TYPE&");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(s);
+ break;
+ case otl_select_stream_type:
+ (*ss)->operator<<(s);
+ break;
+ case otl_refcur_stream_type:
+ (*ref_ss)->operator<<(s);
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+#endif
+
+ OTL_ORA_COMMON_READ_STREAM& operator>>(unsigned char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(s);
+ break;
+ }
+#if defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL)
+ );
+#endif
+
+#if defined(OTL_UNICODE)
+ OTL_TRACE_WRITE
+ ("\""<<OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,s)<<"\"",
+ "operator >>",
+ OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*")
+#else
+ OTL_TRACE_WRITE("\""<<s<<"\"","operator >>","unsigned char*")
+#endif
+ inc_next_ov();
+ return *this;
+ }
+
+#if defined(OTL_UNICODE)
+
+ OTL_ORA_COMMON_READ_STREAM& operator>>(OTL_UNICODE_CHAR_TYPE* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(OTL_RCAST(unsigned char*,s));
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(OTL_RCAST(unsigned char*,s));
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(OTL_RCAST(unsigned char*,s));
+ break;
+ }
+#if defined(OTL_DEFAULT_STRING_NULL_TO_VAL)
+ if((*this).is_null())
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL));
+#endif
+ OTL_TRACE_WRITE(OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,s),
+ "operator >>",
+ OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*")
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_COMMON_READ_STREAM& operator>>(OTL_UNICODE_CHAR_TYPE& c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ OTL_UNICODE_CHAR_TYPE s[1024];
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(OTL_RCAST(unsigned char*,s));
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(OTL_RCAST(unsigned char*,s));
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(OTL_RCAST(unsigned char*,s));
+ break;
+ }
+ c=s[0];
+#if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL)
+ if((*this).is_null())
+ c=OTL_DEFAULT_CHAR_NULL_TO_VAL;
+#endif
+ OTL_TRACE_WRITE(c,"operator >>",
+ OTL_UNICODE_CHAR_TYPE_TRACE_NAME "")
+ inc_next_ov();
+ return *this;
+ }
+
+#endif
+
+#if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\
+ !defined(OTL_BIGINT_TO_STR))
+ OTL_ORA_COMMON_READ_STREAM& operator>>(OTL_BIGINT& n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(n);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(n);
+#else
+ (*ss)->operator>><OTL_BIGINT,otl_var_bigint>(n);
+#endif
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(n);
+#else
+ (*ref_ss)->operator>><OTL_BIGINT,otl_var_bigint>(n);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ n=OTL_SCAST(int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(n,"operator >>","OTL_BIGINT&")
+ inc_next_ov();
+ return *this;
+ }
+
+#endif
+
+ OTL_ORA_COMMON_READ_STREAM& operator>>(int& n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(n);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(n);
+#else
+ (*ss)->operator>><int,otl_var_int>(n);
+#endif
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(n);
+#else
+ (*ref_ss)->operator>><int,otl_var_int>(n);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ n=OTL_SCAST(int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(n,"operator >>","int&")
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_COMMON_READ_STREAM& operator>>(unsigned& u)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(u);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(u);
+#else
+ (*ss)->operator>><unsigned,otl_var_unsigned_int>(u);
+#endif
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(u);
+#else
+ (*ref_ss)->operator>><unsigned,otl_var_unsigned_int>(u);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ u=OTL_SCAST(unsigned int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(u,"operator >>","unsigned&")
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_COMMON_READ_STREAM& operator>>(short& sh)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(sh);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(sh);
+#else
+ (*ss)->operator>><short,otl_var_short>(sh);
+#endif
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(sh);
+#else
+ (*ref_ss)->operator>><short,otl_var_short>(sh);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ sh=OTL_SCAST(short int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(sh,"operator >>","short int&")
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_COMMON_READ_STREAM& operator>>(long int& l)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(l);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(l);
+#else
+ (*ss)->operator>><long,otl_var_long_int>(l);
+#endif
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(l);
+#else
+ (*ref_ss)->operator>><long,otl_var_long_int>(l);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ l=OTL_SCAST(long int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(l,"operator >>","long int&")
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_COMMON_READ_STREAM& operator>>(float& f)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(f);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(f);
+#else
+ (*ss)->operator>><float,otl_var_float>(f);
+#endif
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(f);
+#else
+ (*ref_ss)->operator>><float,otl_var_float>(f);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ f=OTL_SCAST(float,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(f,"operator >>","float&")
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_COMMON_READ_STREAM& operator>>(double& d)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(d);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator>>(d);
+#else
+ (*ss)->operator>><double,otl_var_double>(d);
+#endif
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator>>(d);
+#else
+ (*ref_ss)->operator>><double,otl_var_double>(d);
+#endif
+ break;
+ }
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if((*this).is_null())
+ d=OTL_SCAST(double,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ OTL_TRACE_WRITE(d,"operator >>","double&")
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_COMMON_READ_STREAM& operator>>(otl_long_string& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator>>(s);
+ break;
+ case otl_select_stream_type:
+ (*ss)->operator>>(s);
+ break;
+ case otl_refcur_stream_type:
+ (*ref_ss)->operator>>(s);
+ break;
+ }
+ OTL_TRACE_WRITE(" len="<<s.len(),"operator >>","otl_long_string&")
+ inc_next_ov();
+ return *this;
+ }
+
+ OTL_ORA_COMMON_READ_STREAM& operator>>(otl_lob_stream& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=true;
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ last_eof_rc=(*io)->eof();
+ (*io)->operator>>(s);
+ break;
+ case otl_select_stream_type:
+ last_eof_rc=(*ss)->eof();
+ (*ss)->operator>>(s);
+ break;
+ case otl_refcur_stream_type:
+ last_eof_rc=(*ref_ss)->eof();
+ (*ref_ss)->operator>>(s);
+ break;
+ }
+ shell->lob_stream_flag=true;
+ OTL_TRACE_WRITE(" lob stream","operator >>","otl_lob_stream&")
+ inc_next_ov();
+ return *this;
+ }
+
+#if !defined(OTL_UNICODE)
+ otl_stream& operator<<(const char c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("'"<<c<<"'","operator <<","char");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(c);
+ break;
+ case otl_select_stream_type:
+ (*ss)->operator<<(c);
+ break;
+ case otl_refcur_stream_type:
+ (*ref_ss)->operator<<(c);
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+#endif
+
+ otl_stream& operator<<(const unsigned char c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("'"<<c<<"'","operator <<","unsigned char");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(c);
+ break;
+ case otl_select_stream_type:
+ (*ss)->operator<<(c);
+ break;
+ case otl_refcur_stream_type:
+ (*ref_ss)->operator<<(c);
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ otl_stream& operator<<(const OTL_STRING_CONTAINER& s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("\""<<s<<"\"","operator <<","OTL_STRING_CONTAINER&");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(s);
+ break;
+ case otl_select_stream_type:
+ (*ss)->operator<<(s);
+ break;
+ case otl_refcur_stream_type:
+ (*ref_ss)->operator<<(s);
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+#endif
+
+#if !defined(OTL_UNICODE)
+ otl_stream& operator<<(const char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("\""<<s<<"\"","operator <<","char*");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(s);
+ break;
+ case otl_select_stream_type:
+ (*ss)->operator<<(s);
+ break;
+ case otl_refcur_stream_type:
+ (*ref_ss)->operator<<(s);
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+#endif
+
+ otl_stream& operator<<(const unsigned char* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+#if defined(OTL_UNICODE)
+ OTL_TRACE_READ
+ ("\""<<OTL_RCAST(const OTL_UNICODE_CHAR_TYPE*,s)<<"\"",
+ "operator <<",
+ OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*");
+#else
+ OTL_TRACE_READ("\""<<s<<"\"","operator <<","unsigned char*");
+#endif
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(s);
+ break;
+ case otl_select_stream_type:
+ (*ss)->operator<<(s);
+ break;
+ case otl_refcur_stream_type:
+ (*ref_ss)->operator<<(s);
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+#if defined(OTL_UNICODE)
+
+ otl_stream& operator<<(const OTL_UNICODE_CHAR_TYPE* s)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ
+ ("\""<<OTL_RCAST(const OTL_UNICODE_CHAR_TYPE*,s)<<"\"",
+ "operator <<",
+ OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(OTL_RCAST(const unsigned char*,s));
+ break;
+ case otl_select_stream_type:
+ (*ss)->operator<<(OTL_RCAST(const unsigned char*,s));
+ break;
+ case otl_refcur_stream_type:
+ (*ref_ss)->operator<<(OTL_RCAST(const unsigned char*,s));
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const OTL_UNICODE_CHAR_TYPE c)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ OTL_UNICODE_CHAR_TYPE s[2];
+ s[0]=c;
+ s[1]=0;
+ (*this)<<s;
+ return *this;
+ }
+
+#endif
+
+#if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\
+ !defined(OTL_BIGINT_TO_STR))
+ otl_stream& operator<<(const OTL_BIGINT n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(n,"operator <<","OTL_BIGINT");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(n);
+ break;
+ case otl_select_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(n);
+#else
+ (*ss)->operator<<<OTL_BIGINT,otl_var_bigint>(n);
+#endif
+ break;
+ case otl_refcur_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(n);
+#else
+ (*ref_ss)->operator<<<OTL_BIGINT,otl_var_bigint>(n);
+#endif
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+#endif
+
+ otl_stream& operator<<(const int n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(n,"operator <<","int");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(n);
+ break;
+ case otl_select_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(n);
+#else
+ (*ss)->operator<<<int,otl_var_int>(n);
+#endif
+ break;
+ case otl_refcur_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(n);
+#else
+ (*ref_ss)->operator<<<int,otl_var_int>(n);
+#endif
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const unsigned u)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(u,"operator <<","unsigned");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(u);
+ break;
+ case otl_select_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(u);
+#else
+ (*ss)->operator<<<unsigned,otl_var_unsigned_int>(u);
+#endif
+ break;
+ case otl_refcur_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(u);
+#else
+ (*ref_ss)->operator<<<unsigned,otl_var_unsigned_int>(u);
+#endif
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const short sh)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(sh,"operator <<","short int");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(sh);
+ break;
+ case otl_select_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(sh);
+#else
+ (*ss)->operator<<<short,otl_var_short>(sh);
+#endif
+ break;
+ case otl_refcur_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(sh);
+#else
+ (*ref_ss)->operator<<<short,otl_var_short>(sh);
+#endif
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const long int l)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(l,"operator <<","long int");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(l);
+ break;
+ case otl_select_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(l);
+#else
+ (*ss)->operator<<<long,otl_var_long_int>(l);
+#endif
+ break;
+ case otl_refcur_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(l);
+#else
+ (*ref_ss)->operator<<<long,otl_var_long_int>(l);
+#endif
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const float f)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(f,"operator <<","float");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(f);
+ break;
+ case otl_select_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(f);
+#else
+ (*ss)->operator<<<float,otl_var_float>(f);
+#endif
+ break;
+ case otl_refcur_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(f);
+#else
+ (*ref_ss)->operator<<<float,otl_var_float>(f);
+#endif
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const double d)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(d,"operator <<","double");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(d);
+ break;
+ case otl_select_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ss)->operator<<(d);
+#else
+ (*ss)->operator<<<double,otl_var_double>(d);
+#endif
+ break;
+ case otl_refcur_stream_type:
+#if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT)
+ (*ref_ss)->operator<<(d);
+#else
+ (*ref_ss)->operator<<<double,otl_var_double>(d);
+#endif
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const otl_null& n)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ("NULL","operator <<","otl_null&");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(n);
+ break;
+ case otl_select_stream_type:
+ (*ss)->operator<<(n);
+ break;
+ case otl_refcur_stream_type:
+ (*ref_ss)->operator<<(n);
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+ otl_stream& operator<<(const otl_long_string& d)
+ OTL_THROWS_OTL_EXCEPTION
+ {
+ last_oper_was_read_op=false;
+ reset_end_marker();
+ OTL_TRACE_READ(" len="<<d.len(),"operator <<","otl_long_string&");
+ switch(shell->stream_type){
+ case otl_no_stream_type:
+ break;
+ case otl_inout_stream_type:
+ (*io)->operator<<(d);
+ break;
+ case otl_select_stream_type:
+ (*ss)->operator<<(d);
+ break;
+ case otl_refcur_stream_type:
+ (*ref_ss)->operator<<(d);
+ if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc();
+ break;
+ }
+ inc_next_iov();
+ return *this;
+ }
+
+private:
+
+ otl_stream& operator=(const otl_stream&)
+ {
+ return *this;
+ }
+
+ otl_stream(const otl_stream&):
+ #if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE)
+ otl_read_stream_interface(),
+#endif
+ shell(0),
+ shell_pt(),
+ connected(0),
+ ref_ss(0),
+ ss(0),
+ io(0),
+ adb(0),
+ auto_commit_flag(0),
+ iov(0),
+ iov_len(0),
+ next_iov_ndx(0),
+ ov(0),
+ ov_len(0),
+ next_ov_ndx(0),
+ end_marker(0),
+ oper_int_called(0),
+ last_eof_rc(0),
+ last_oper_was_read_op(false),
+ override(0),
+ buf_size_(0)
+ {
+ }
+
+#if !defined(OTL_STREAM_NO_PRIVATE_BOOL_OPERATORS)
+ otl_stream& operator>>(bool&)
+ OTL_NO_THROW
+ {
+ return *this;
+ }
+
+ otl_stream& operator<<(const bool)
+ OTL_NO_THROW
+ {
+ return *this;
+ }
+
+#endif
+
+#if !defined(OTL_STREAM_NO_PRIVATE_UNSIGNED_LONG_OPERATORS)
+ otl_stream& operator>>(unsigned long int&)
+ OTL_NO_THROW
+ {
+ return *this;
+ }
+
+ otl_stream& operator<<(const unsigned long int)
+ OTL_NO_THROW
+ {
+ return *this;
+ }
+#endif
+
+};
+
+#if defined(OTL_ORA_SUBSCRIBE)
+#if !defined(OTL_ORA_OCI_ENV_CREATE)
+#error OTL_ORA_SUBSCRIBE requires #define OTL_ORA_OCI_ENV_CREATE to be enabled
+#endif
+#if !defined(OTL_ORA_OCI_ENV_CREATE_MODE)
+#error OTL_ORA_SUBSCRIBE requires #define OTL_ORA_OCI_ENV_CREATE_MODE to be \
+enabled and to have OCI_THREADED|OCI_OBJECT|OCI_EVENTS
+#endif
+
+class otl_subscriber{
+public:
+
+ otl_subscriber(otl_connect* adb=0):
+ db(adb),
+ subscrhp(0)
+ {
+ }
+
+ virtual ~otl_subscriber(void)
+ {
+ unsubscribe();
+ }
+
+ void subscribe(const char *name=0,int port=0,int timeout=1800)
+ {
+ if(subscrhp) unsubscribe();
+ if(!db||(db&&!db->connected))
+ throw otl_exception
+ (otl_error_msg_32,
+ otl_error_code_32);
+
+ OCIEnv *envhp=db->get_connect_struct().get_envhp();
+ OCIError *errhp=db->get_connect_struct().get_errhp();
+ OCISvcCtx *svchp=db->get_connect_struct().get_svchp();
+
+ if(port)
+ check(OCIAttrSet(OTL_RCAST(dvoid*,envhp),
+ OTL_SCAST(ub4,OCI_HTYPE_ENV),
+ OTL_RCAST(dvoid*,&port),
+ 0,
+ OCI_ATTR_SUBSCR_PORTNO,
+ errhp));
+
+ OCISubscription** temp_subscrhp=&subscrhp;
+ check(OCIHandleAlloc(OTL_RCAST(dvoid*,envhp),
+ OTL_RCAST(dvoid**,temp_subscrhp),
+ OCI_HTYPE_SUBSCRIPTION,
+ OTL_SCAST(size_t,0),
+ OTL_RCAST(dvoid**,0)));
+
+ if(name && *name)
+ check(OCIAttrSet(subscrhp,
+ OCI_HTYPE_SUBSCRIPTION,
+ OTL_RCAST(void*,OTL_CCAST(char*,name)),
+ OTL_SCAST(ub4,strlen(name)),
+ OCI_ATTR_SUBSCR_NAME,
+ errhp));
+
+ ub4 nspace = OCI_SUBSCR_NAMESPACE_DBCHANGE;
+ check(OCIAttrSet(subscrhp,
+ OCI_HTYPE_SUBSCRIPTION,
+ OTL_RCAST(dvoid*,&nspace),
+ sizeof(ub4),
+ OCI_ATTR_SUBSCR_NAMESPACE,
+ errhp));
+
+ check(OCIAttrSet(subscrhp,
+ OCI_HTYPE_SUBSCRIPTION,
+#if defined(__GNUC__) && (__GNUC__<4)
+ (void*)common_notification_callback,
+#else
+ OTL_RCAST(void*,common_notification_callback),
+#endif
+ 0,
+ OCI_ATTR_SUBSCR_CALLBACK,
+ errhp));
+
+ int rowids_needed=1;
+ check(OCIAttrSet(subscrhp,
+ OCI_HTYPE_SUBSCRIPTION,
+ OTL_RCAST(dvoid*,&rowids_needed),
+ sizeof(ub4),
+ OCI_ATTR_CHNF_ROWIDS,
+ errhp));
+
+ check(OCIAttrSet(subscrhp,
+ OTL_SCAST(ub4,OCI_HTYPE_SUBSCRIPTION),
+ OTL_RCAST(dvoid*,this),
+ 0,
+ OCI_ATTR_SUBSCR_CTX,
+ errhp));
+
+ if(timeout)
+ check(OCIAttrSet(subscrhp,
+ OCI_HTYPE_SUBSCRIPTION,
+ OTL_RCAST(dvoid*,&timeout),
+ 0,
+ OCI_ATTR_SUBSCR_TIMEOUT,
+ errhp));
+
+ check(OCISubscriptionRegister(svchp,&subscrhp,1,errhp,OCI_DEFAULT));
+
+ }
+
+ void unsubscribe(void)
+ {
+ if(!subscrhp) return;
+ if(!db||(db&&!db->connected))
+ throw otl_exception
+ (otl_error_msg_32,
+ otl_error_code_32);
+ OCIError *errhp=db->get_connect_struct().get_errhp();
+ OCISvcCtx *svchp=db->get_connect_struct().get_svchp();
+ OCISubscriptionUnRegister(svchp,subscrhp,errhp,OCI_DEFAULT);
+ OCIHandleFree(OTL_RCAST(dvoid*,subscrhp),OCI_HTYPE_SUBSCRIPTION);
+ subscrhp=0;
+ }
+
+ void associate_table(const char *table_name)
+ {
+ if(!db||(db&&!db->connected))
+ throw otl_exception
+ (otl_error_msg_32,
+ otl_error_code_32);
+ char sql_stmt[1024];
+ OTL_STRCPY_S(sql_stmt,sizeof(sql_stmt),"select :i<int> from ");
+ OTL_STRCAT_S(sql_stmt,sizeof(sql_stmt),table_name);
+ int arg=0;
+ otl_stream s(1,sql_stmt,*db);
+ if(!s.get_shell() || !s.get_shell()->ss)
+ throw otl_exception(db->get_connect_struct(),sql_stmt);
+ OCIError *errhp=db->get_connect_struct().get_errhp();
+ OCIStmt *stmthp=s.get_shell()->ss->get_cursor_struct().cda;
+ check(OCIAttrSet(stmthp,
+ OCI_HTYPE_STMT,
+ subscrhp,
+ 0,
+ OCI_ATTR_CHNF_REGHANDLE,
+ errhp));
+ s<<arg;
+ }
+
+ void associate_query(const char *stmt)
+ {
+ if(!db||(db&&!db->connected))
+ throw otl_exception
+ (otl_error_msg_32,
+ otl_error_code_32);
+ otl_stream s(1,stmt,*db);
+ if(!s.get_shell() || !s.get_shell()->ss)
+ throw otl_exception(db->get_connect_struct(),stmt);
+ OCIError *errhp=db->get_connect_struct().get_errhp();
+ OCIStmt *stmthp=s.get_shell()->ss->get_cursor_struct().cda;
+ check(OCIAttrSet(stmthp,
+ OCI_HTYPE_STMT,
+ subscrhp,
+ 0,
+ OCI_ATTR_CHNF_REGHANDLE,
+ errhp));
+ s<<0;
+ }
+
+protected:
+
+ void check(ub4 ret_code)
+ {
+ if(ret_code!=OCI_SUCCESS)
+ throw otl_exception(db->get_connect_struct());
+ }
+
+ virtual void OnException(OTL_CONST_EXCEPTION otl_exception& e) = 0;
+ virtual void OnDeRegistration(void) = 0;
+
+ //--- DB events:
+ virtual void OnStartup(void) = 0;
+ virtual void OnInstanceShutdown(void) = 0;
+ virtual void OnAnyInstanceShutdown(void) = 0;
+
+ //--- Table events:
+ virtual void OnTableInvalidate(text *table_name) = 0;
+ virtual void OnTableAlter(text *table_name, bool all_rows=false) = 0;
+ virtual void OnTableDrop(text *table_name, bool all_rows=false) = 0;
+ virtual void OnTableChange(text *table_name, bool all_rows=false) = 0;
+
+ //--- Row events:
+ virtual void OnRowInsert( text *table_name, text *row_id ) = 0;
+ virtual void OnRowUpdate( text *table_name, text *row_id ) = 0;
+ virtual void OnRowDelete( text *table_name, text *row_id ) = 0;
+
+protected:
+ otl_connect* db;
+
+private:
+
+ OCISubscription *subscrhp;
+
+ void notification_callback
+ (dvoid* /*payload*/, ub4 /*paylen*/, dvoid *desc, ub4 /*mode*/)
+ {
+ if(!db||(db&&!db->connected))
+ return;
+ ub4 num_rows = 0;
+ OCIColl *row_changes=0;
+ dvoid *row_desc, **row_descp;
+ dvoid*** temp_row_descp=&row_descp;
+ text *row_id;
+ ub4 rowid_size;
+ unsigned int j;
+ try{
+ OCIEnv *envhp=db->get_connect_struct().get_envhp();
+ OCIError *errhp=db->get_connect_struct().get_errhp();
+
+ //----------------
+ ub4 notify_type;
+ check(OCIAttrGet(desc,
+ OCI_DTYPE_CHDES,
+ ¬ify_type,
+ 0,
+ OCI_ATTR_CHDES_NFYTYPE,
+ errhp));
+
+ switch(notify_type){
+ case OCI_EVENT_STARTUP:
+ OnStartup();
+ return;
+ case OCI_EVENT_SHUTDOWN:
+ OnInstanceShutdown();
+ return;
+ case OCI_EVENT_SHUTDOWN_ANY:
+ OnAnyInstanceShutdown();
+ return;
+ case OCI_EVENT_DEREG:
+ OnDeRegistration();
+ return;
+ case OCI_EVENT_OBJCHANGE:
+ break;
+ default:
+ return;
+ }
+
+ OCIColl *table_changes=0;
+ check(OCIAttrGet(desc,
+ OCI_DTYPE_CHDES,
+ &table_changes,
+ 0,
+ OCI_ATTR_CHDES_TABLE_CHANGES,
+ errhp));
+ if(!table_changes)return;
+
+ ub4 num_tables=0;
+ check(OCICollSize(envhp,
+ errhp,
+ OTL_RCAST(CONST OCIColl*,table_changes),
+ OTL_RCAST(sb4*,&num_tables)));
+ if(!num_tables)return;
+
+ for(unsigned int i=0;i<num_tables;i++){
+ int exist;
+ dvoid *elemind=0, *table_desc, **table_descp;
+ dvoid*** temp_table_descp=&table_descp;
+ check(OCICollGetElem(envhp,
+ errhp,
+ table_changes,
+ i,
+ &exist,
+ OTL_RCAST(dvoid**,temp_table_descp),
+ &elemind));
+ table_desc=*table_descp;
+ text *table_name;
+ check(OCIAttrGet(table_desc,
+ OCI_DTYPE_TABLE_CHDES,
+ &table_name,
+ 0,
+ OCI_ATTR_CHDES_TABLE_NAME,
+ errhp));
+
+ ub4 table_op;
+ check(OCIAttrGet(table_desc,
+ OCI_DTYPE_TABLE_CHDES,
+ OTL_RCAST(dvoid*,&table_op),
+ 0,
+ OCI_ATTR_CHDES_TABLE_OPFLAGS,
+ errhp));
+ bool all_rows=table_op & OCI_OPCODE_ALLROWS;
+ switch(table_op){
+ case OCI_OPCODE_ALLROWS:
+ OnTableInvalidate(table_name);
+ continue;
+ case OCI_OPCODE_ALTER:
+ case (OCI_OPCODE_ALTER+OCI_OPCODE_ALLROWS):
+ OnTableAlter(table_name,all_rows);
+ continue;
+ case OCI_OPCODE_DROP:
+ case (OCI_OPCODE_DROP+OCI_OPCODE_ALLROWS):
+ OnTableDrop(table_name,all_rows);
+ continue;
+ case (OCI_OPCODE_INSERT+OCI_OPCODE_ALLROWS):
+ case (OCI_OPCODE_UPDATE+OCI_OPCODE_ALLROWS):
+ case (OCI_OPCODE_DELETE+OCI_OPCODE_ALLROWS):
+ OnTableChange(table_name,all_rows);
+ continue;
+ case OCI_OPCODE_INSERT:
+ case OCI_OPCODE_UPDATE:
+ case OCI_OPCODE_DELETE:
+ OnTableChange(table_name,all_rows);
+ break;
+ }
+
+ row_changes=0;
+ check(OCIAttrGet(table_desc,
+ OCI_DTYPE_TABLE_CHDES,
+ &row_changes,
+ 0,
+ OCI_ATTR_CHDES_TABLE_ROW_CHANGES,
+ errhp));
+ if(!row_changes)continue;
+ num_rows=0;
+ check(OCICollSize(envhp,errhp,row_changes,OTL_RCAST(sb4*,&num_rows)));
+ for(j=0;j<num_rows;j++){
+ elemind=0;
+ check(OCICollGetElem(envhp,
+ errhp,
+ row_changes,
+ j,
+ &exist,
+ OTL_RCAST(dvoid**,temp_row_descp),
+ &elemind));
+ row_desc=*row_descp;
+
+ check(OCIAttrGet(row_desc,
+ OCI_DTYPE_ROW_CHDES,
+ OTL_RCAST(dvoid*,&row_id),
+ &rowid_size,
+ OCI_ATTR_CHDES_ROW_ROWID,
+ errhp));
+ if(table_op&OCI_OPCODE_INSERT)OnRowInsert(table_name,row_id);
+ if(table_op&OCI_OPCODE_DELETE)OnRowDelete(table_name,row_id);
+ if(table_op&OCI_OPCODE_UPDATE)OnRowUpdate(table_name,row_id);
+ }
+ }
+ }catch(OTL_CONST_EXCEPTION otl_exception &e){
+ OnException(e);
+ }
+ }
+
+ static void common_notification_callback
+ (dvoid *ctx,
+ OCISubscription* /*subscrhp*/,
+ dvoid *payload,
+ ub4 paylen,
+ dvoid *desc,
+ ub4 mode)
+ {
+ if(!ctx) return;
+ (OTL_RCAST(otl_subscriber*,ctx))->notification_callback(payload,paylen,desc,mode);
+ }
+
+public:
+ bool is_online(void){ return subscrhp!=0; }
+
+private:
+
+ otl_subscriber(const otl_subscriber&):
+ db(0),
+ subscrhp(0)
+ {
+ }
+
+ otl_subscriber& operator=(const otl_subscriber&)
+ {
+ return *this;
+ }
+
+
+};
+
+#endif
+
+inline otl_connect& operator>>(otl_connect& connect, otl_stream& s)
+{
+ const char* cmd=connect.getCmd();
+ const char* invalid_cmd="*** INVALID COMMAND ***";
+ if(!cmd)
+ cmd=invalid_cmd;
+ s.open(s.getBufSize(),cmd,connect);
+ return connect;
+}
+
+#if (defined(OTL_STL)||defined(OTL_VALUE_TEMPLATE_ON)) \
+ && defined(OTL_VALUE_TEMPLATE)
+template <OTL_TYPE_NAME TData>
+otl_stream& operator<<(otl_stream& s, const otl_value<TData>& var)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ if(var.ind)
+ s<<otl_null();
+ else
+ s<<var.v;
+ return s;
+}
+
+template <OTL_TYPE_NAME TData>
+otl_stream& operator>>(otl_stream& s, otl_value<TData>& var)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ s>>var.v;
+ if(s.is_null())
+ var.ind=true;
+ else
+ var.ind=false;
+ return s;
+}
+
+template <OTL_TYPE_NAME TData>
+otl_refcur_stream& operator>>(otl_refcur_stream& s, otl_value<TData>& var)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ s>>var.v;
+ if(s.is_null())
+ var.ind=true;
+ else
+ var.ind=false;
+ return s;
+}
+
+#endif
+
+typedef otl_tmpl_nocommit_stream
+<otl_stream,
+ otl_connect,
+ otl_exception> otl_nocommit_stream;
+
+#if defined(OTL_BIGINT) && defined(OTL_STR_TO_BIGINT) && \
+ defined(OTL_BIGINT_TO_STR)
+
+inline otl_stream& operator>>(otl_stream& s, OTL_BIGINT& n)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ char temp_val[otl_bigint_str_size];
+#if defined(OTL_UNICODE)
+ OTL_CHAR unitemp_val[otl_bigint_str_size];
+ s>>OTL_RCAST(unsigned char*,unitemp_val);
+ OTL_CHAR* uc=unitemp_val;
+ char* c=temp_val;
+ while(*uc){
+ *c=OTL_SCAST(char,*uc);
+ ++uc; ++c;
+ }
+ *c=0;
+#else
+ s>>temp_val;
+#endif
+ if(s.is_null()){
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if(s.is_null())
+ n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ return s;
+ }
+ OTL_STR_TO_BIGINT(temp_val,n)
+ return s;
+}
+
+inline otl_refcur_stream& operator>>(otl_refcur_stream& s, OTL_BIGINT& n)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ char temp_val[otl_bigint_str_size];
+ s>>temp_val;
+ if(s.is_null()){
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if(s.is_null())
+ n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ return s;
+ }
+ OTL_STR_TO_BIGINT(temp_val,n)
+ return s;
+}
+
+inline otl_stream& operator<<(otl_stream& s, const OTL_BIGINT n)
+ OTL_THROWS_OTL_EXCEPTION
+{
+#if defined(OTL_UNICODE)
+ char temp_val[otl_bigint_str_size];
+ OTL_BIGINT_TO_STR(n,temp_val)
+ OTL_CHAR unitemp_val[otl_bigint_str_size];
+ OTL_CHAR* uc=unitemp_val;
+ char* c=temp_val;
+ while(*c){
+ *uc=OTL_SCAST(OTL_CHAR,*c);
+ ++uc; ++c;
+ }
+ *uc=0;
+ s<<OTL_RCAST(unsigned char*,unitemp_val);
+#else
+ char temp_val[otl_bigint_str_size];
+ OTL_BIGINT_TO_STR(n,temp_val)
+ s<<temp_val;
+#endif
+ return s;
+}
+
+#elif defined(OTL_BIGINT) && defined(OTL_ORA_MAP_BIGINT_TO_LONG)
+
+inline otl_stream& operator>>(otl_stream& s, OTL_BIGINT& n)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ long temp_val;
+ s>>temp_val;
+ if(s.is_null()){
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if(s.is_null())
+ n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ return s;
+ }
+ n=OTL_SCAST(OTL_BIGINT,temp_val);
+ return s;
+}
+
+inline otl_refcur_stream& operator>>(otl_refcur_stream& s, OTL_BIGINT& n)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ long temp_val;
+ s>>temp_val;
+ if(s.is_null()){
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if(s.is_null())
+ n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+#endif
+ return s;
+ }
+ n=OTL_SCAST(OTL_BIGINT,temp_val);
+ return s;
+}
+
+inline otl_stream& operator<<(otl_stream& s, const OTL_BIGINT n)
+ OTL_THROWS_OTL_EXCEPTION
+{
+ long temp_val=OTL_SCAST(long,n);
+ s<<temp_val;
+ return s;
+}
+
+#endif
+
+inline otl_stream& endr(otl_stream& s)
+{
+ s.check_end_of_row();
+ return s;
+}
+
+OTL_ORA8_NAMESPACE_END
+#ifndef __STDC__DEFINED
+#undef __STDC__
+#endif
+#endif
+
+#if defined(OTL_STL) && !defined(OTL_STLPORT)
+
+#define STL_INPUT_ITERATOR_TO_DERIVE_FROM
+#define STL_OUTPUT_ITERATOR_TO_DERIVE_FROM
+
+#elif defined(OTL_STLPORT)
+
+#define STL_INPUT_ITERATOR_TO_DERIVE_FROM \
+ : public STD_NAMESPACE_PREFIX iterator \
+ <STD_NAMESPACE_PREFIX input_iterator_tag, \
+ T,Distance,T*,T&>
+
+#define STL_OUTPUT_ITERATOR_TO_DERIVE_FROM \
+ : public STD_NAMESPACE_PREFIX iterator \
+ <STD_NAMESPACE_PREFIX output_iterator_tag, \
+ T,void,void,void>
+
+#endif
+
+#if defined(OTL_STL) || defined(OTL_STLPORT)
+
+#define OTL_ITERATORS \
+template <OTL_TYPE_NAME T, OTL_TYPE_NAME Distance=ptrdiff_t> \
+class otl_input_iterator STL_INPUT_ITERATOR_TO_DERIVE_FROM { \
+public: \
+ \
+ typedef STD_NAMESPACE_PREFIX input_iterator_tag iterator_category; \
+ typedef T value_type; \
+ typedef Distance difference_type; \
+ typedef const T* pointer; \
+ typedef const T& reference; \
+ \
+ otl_stream* stream; \
+ T value; \
+ int end_marker; \
+ \
+ void read() \
+ { \
+ if(!stream){ \
+ end_marker=-1; \
+ return; \
+ } \
+ if(stream->eof()){ \
+ end_marker=-1; \
+ return; \
+ } \
+ end_marker=stream->eof(); \
+ if(!end_marker)*stream>>value; \
+ if(stream->eof())end_marker=1; \
+ } \
+ \
+ otl_input_iterator() : stream(0), value(), end_marker(-1){} \
+ otl_input_iterator(otl_stream& s) : stream(&s), value(),end_marker(0){read();} \
+ \
+ const T& operator*() const { return value; } \
+ \
+ otl_input_iterator<T, Distance>& operator++(){read(); return *this;} \
+ \
+ otl_input_iterator<T, Distance> operator++(int) \
+ { \
+ otl_input_iterator<T, Distance> tmp = *this; \
+ read(); \
+ return tmp; \
+ } \
+ \
+ otl_input_iterator(const otl_input_iterator& src): \
+ stream(src.stream),value(src.value),end_marker(src.end_marker){} \
+ \
+ otl_input_iterator& operator=(const otl_input_iterator& src) \
+ { \
+ stream=src.stream; \
+ value=src.value; \
+ end_marker=src.end_marker; \
+ return *this; \
+ } \
+}; \
+ \
+template <OTL_TYPE_NAME T, OTL_TYPE_NAME Distance> \
+inline STD_NAMESPACE_PREFIX input_iterator_tag iterator_category( \
+ const otl_input_iterator<T, Distance>& \
+) \
+{ \
+ return STD_NAMESPACE_PREFIX input_iterator_tag(); \
+} \
+ \
+template <OTL_TYPE_NAME T, OTL_TYPE_NAME Distance> \
+inline T* value_type(const otl_input_iterator<T, Distance>&) \
+{ \
+ return 0; \
+} \
+ \
+template <OTL_TYPE_NAME T, OTL_TYPE_NAME Distance> \
+inline Distance* distance_type(const otl_input_iterator<T, Distance>&) \
+{ \
+ return 0; \
+} \
+ \
+template <OTL_TYPE_NAME T, OTL_TYPE_NAME Distance> \
+bool operator==(const otl_input_iterator<T, Distance>& x, \
+ const otl_input_iterator<T, Distance>& y) \
+{ \
+ return (x.stream == y.stream && x.end_marker == y.end_marker) || \
+ (x.end_marker == -1 && y.end_marker == -1); \
+} \
+ \
+template <OTL_TYPE_NAME T, OTL_TYPE_NAME Distance> \
+bool operator!=(const otl_input_iterator<T, Distance>& x, \
+ const otl_input_iterator<T, Distance>& y) \
+{ \
+ return !(x==y); \
+} \
+ \
+template <OTL_TYPE_NAME T> \
+class otl_output_iterator STL_OUTPUT_ITERATOR_TO_DERIVE_FROM { \
+protected: \
+ otl_stream* stream; \
+public: \
+ \
+ typedef STD_NAMESPACE_PREFIX output_iterator_tag iterator_category; \
+ typedef void value_type; \
+ typedef void difference_type; \
+ typedef void pointer; \
+ typedef void reference; \
+ \
+ otl_output_iterator(otl_stream& s) : stream(&s){} \
+ otl_output_iterator<T>& operator=(const T& value) \
+ { \
+ *stream << value; \
+ return *this; \
+ } \
+ otl_output_iterator<T>& operator*() { return *this; } \
+ otl_output_iterator<T>& operator++() { return *this; } \
+ otl_output_iterator<T> operator++(int) { return *this; } \
+ \
+}; \
+ \
+template <OTL_TYPE_NAME T> \
+inline STD_NAMESPACE_PREFIX output_iterator_tag \
+iterator_category(const otl_output_iterator<T>&) { \
+ return STD_NAMESPACE_PREFIX output_iterator_tag(); \
+}
+
+#if defined(OTL_ORA7)
+OTL_ORA7_NAMESPACE_BEGIN
+OTL_ITERATORS
+OTL_ORA7_NAMESPACE_END
+#endif
+
+#if defined(OTL_ORA8)
+OTL_ORA8_NAMESPACE_BEGIN
+OTL_ITERATORS
+OTL_ORA8_NAMESPACE_END
+#endif
+
+#if defined(OTL_ODBC)
+OTL_ODBC_NAMESPACE_BEGIN
+OTL_ITERATORS
+OTL_ODBC_NAMESPACE_END
+#endif
+
+#endif
+
+#if defined(OTL_STREAM_READ_ITERATOR_ON)
+
+#if defined(OTL_UNICODE)
+#error UNICODE is not supported when #define OTL_STREAM_READ_ITERATOR_ON is enabled
+#endif
+
+#if defined(OTL_STL)
+#include <map>
+#endif
+
+#if defined(OTL_ACE)
+#include <ace/SString.h>
+#include <ace/Array.h>
+#include <ace/Functor.h>
+#include <ace/RB_Tree.h>
+#include <ace/Null_Mutex.h>
+#endif
+
+#if defined(OTL_STL)||defined(OTL_ACE)
+class otl_ltcharstar{
+public:
+#if defined(OTL_STL)
+ bool
+#else
+ int
+#endif
+ operator()(const char* s1, const char* s2) const
+ {
+#if defined(__BORLANDC__) || defined(_MSC_VER)
+ return stricmp(s1,s2)<0;
+#else
+#if defined(__STRICT_ANSI__)
+ while(otl_to_upper(*s1)==otl_to_upper(*s2)&&*s1){
+ ++s1;
+ ++s2;
+ }
+ return *s1 < *s2;
+#else
+ return strcasecmp(s1,s2)<0;
+#endif
+#endif
+ }
+};
+#endif
+template<OTL_TYPE_NAME OTLStream,
+ OTL_TYPE_NAME OTLException
+#if !defined(OTL_ORA7)
+ ,OTL_TYPE_NAME OTLLobStream
+#endif
+ >
+class otl_stream_read_iterator{
+public:
+
+ otl_stream_read_iterator(OTLStream& s)
+ {
+ set();
+ attach(s);
+ }
+
+ otl_stream_read_iterator():
+ out_vars_(0),
+ out_vars_len_(0),
+ str_(0),
+ out_vars_arr_(0),
+ out_vars_null_arr_(0),
+ out_vars_constructed_(0),
+ lob_stream_mode_flag_(false)
+#if defined(OTL_STL)
+ ,var_name2pos_map_()
+#endif
+#if defined(OTL_ACE)
+ ,var_name2pos_map_()
+#endif
+ {
+ set();
+ }
+
+ ~otl_stream_read_iterator()
+ {
+ reset();
+ }
+
+ void attach(OTLStream& s)
+ {
+ reset();
+ str_=&s;
+ if(!str_->good()){
+ str_=0;
+ throw OTLException(otl_error_msg_19,otl_error_code_19);
+ }
+ out_vars_=str_->describe_out_vars(out_vars_len_);
+ if(!out_vars_){
+ throw OTLException(otl_error_msg_21,otl_error_code_21);
+ }
+ lob_stream_mode_flag_=str_->get_lob_stream_flag();
+ allocate_arrays();
+ }
+
+ void reattach()
+ {
+ if(!str_->good()){
+ reset();
+ throw OTLException(otl_error_msg_19,otl_error_code_19);
+ }
+ out_vars_=str_->describe_out_vars(out_vars_len_);
+ if(!out_vars_){
+ reset();
+ throw OTLException(otl_error_msg_21,otl_error_code_21);
+ }else{
+#if defined(OTL_STL)
+ var_name2pos_map_.clear();
+ for(int i=0;i<out_vars_len_;++i){
+ const otl_var_desc& curr_var=out_vars_[i];
+ var_name2pos_map_[curr_var.name]=i;
+ }
+#endif
+#if defined(OTL_ACE)
+ var_name2pos_map_.close();
+ for(int i=0;i<out_vars_len_;++i){
+ const otl_var_desc& curr_var=out_vars_[i];
+ var_name2pos_map_.bind(curr_var.name,i);
+ }
+#endif
+ }
+ lob_stream_mode_flag_=str_->get_lob_stream_flag();
+ }
+
+
+ void detach(void)
+ {
+ reset();
+ }
+
+ const otl_var_desc* describe(int& var_desc_len)
+ {
+ var_desc_len=out_vars_len_;
+ return out_vars_;
+ }
+
+ bool next_row(void)
+ {
+ if(str_->eof())return false;
+ for(int i=0;i<out_vars_len_;++i){
+ otl_var_desc& curr_var=out_vars_[i];
+ unsigned char* curr_ptr=out_vars_arr_[i];
+ switch(curr_var.ftype){
+ case otl_var_char:
+ (*str_)>>OTL_RCAST(char*,curr_ptr);
+ break;
+ case otl_var_double:
+ (*str_)>>*OTL_RCAST(double*,curr_ptr);
+ break;
+ case otl_var_float:
+ (*str_)>>*OTL_RCAST(float*,curr_ptr);
+ break;
+ case otl_var_int:
+ (*str_)>>*OTL_RCAST(int*,curr_ptr);
+ break;
+ case otl_var_unsigned_int:
+ (*str_)>>*OTL_RCAST(unsigned*,curr_ptr);
+ break;
+ case otl_var_short:
+ (*str_)>>*OTL_RCAST(short int*,curr_ptr);
+ break;
+ case otl_var_long_int:
+ (*str_)>>*OTL_RCAST(long int*,curr_ptr);
+ break;
+ case otl_var_raw:
+ (*str_)>>*OTL_RCAST(otl_long_string*,curr_ptr);
+ break;
+ case otl_var_timestamp:
+ case otl_var_db2time:
+ case otl_var_db2date:
+ case otl_var_tz_timestamp:
+ case otl_var_ltz_timestamp:
+ (*str_)>>*OTL_RCAST(otl_datetime*,curr_ptr);
+ break;
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ case otl_var_clob:
+ case otl_var_blob:
+#if !defined(OTL_ORA7)
+ if(lob_stream_mode_flag_)
+ (*str_)>>*OTL_RCAST(OTLLobStream*,curr_ptr);
+ else
+#endif
+ (*str_)>>*OTL_RCAST(otl_long_string*,curr_ptr);
+ break;
+#if defined(OTL_BIGINT)
+ case otl_var_bigint:
+ (*str_)>>*OTL_RCAST(OTL_BIGINT*,curr_ptr);
+ break;
+#endif
+ }
+ out_vars_null_arr_[i]=str_->is_null()==1;
+ }
+ return true;
+ }
+
+#if !defined(OTL_ORA7)
+ void get(const int pos, OTLLobStream*& s)
+ {
+ check_pos(pos);
+ check_type(pos,otl_var_long_string,true);
+ if(!lob_stream_mode_flag_){
+ char var_info[255];
+ otl_var_info_var3
+ (out_vars_[pos-1].name,
+ out_vars_[pos-1].ftype,
+ otl_var_lob_stream,
+ var_info,
+ sizeof(var_info));
+ throw OTLException
+ (otl_error_msg_25,
+ otl_error_code_25,
+ str_->get_stm_text(),
+ var_info);
+ }
+ unsigned char* curr_ptr=out_vars_arr_[pos-1];
+ s=OTL_RCAST(OTLLobStream*,curr_ptr);
+ }
+#endif
+
+#if defined(OTL_STL) && !defined(OTL_ORA7)
+ void get(const char* var_name,OTLLobStream*& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE) && !defined(OTL_ORA7)
+ void get(const char* var_name,OTLLobStream*& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+ void get(const int pos, char& c)
+ {
+ check_pos(pos);
+ check_type(pos,otl_var_char);
+ unsigned char* curr_ptr=out_vars_arr_[pos-1];
+ c=OTL_SCAST(char,*curr_ptr);
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, char& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, char& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+ void get(const int pos, unsigned char& c)
+ {
+ check_pos(pos);
+ check_type(pos,otl_var_char);
+ unsigned char* curr_ptr=out_vars_arr_[pos-1];
+ c=*curr_ptr;
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, unsigned char& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, unsigned char& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+ void get(const int pos, char* s)
+ {
+ check_pos(pos);
+ check_type(pos,otl_var_char);
+ unsigned char* curr_ptr=out_vars_arr_[pos-1];
+ otl_strcpy(OTL_RCAST(unsigned char*,s),
+ OTL_RCAST(const unsigned char*,curr_ptr));
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, char* n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, char* n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+ void get(const int pos, unsigned char* s)
+ {
+ check_pos(pos);
+ check_type(pos,otl_var_char);
+ unsigned char* curr_ptr=out_vars_arr_[pos-1];
+ otl_strcpy(OTL_RCAST(unsigned char*,s),OTL_RCAST(const unsigned char*,curr_ptr));
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, unsigned char* n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, unsigned char* n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+
+ void get(const int pos, unsigned int& n)
+ {
+ check_pos(pos);
+ void* curr_ptr=out_vars_arr_[pos-1];
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T<unsigned,otl_var_unsigned_int>
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#else
+ int match_found=otl_numeric_convert_T
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#endif
+ if(match_found)return;
+ check_type(pos,otl_var_unsigned_int);
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, unsigned int& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, unsigned int& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+ void get(const int pos, int& n)
+ {
+ check_pos(pos);
+ void* curr_ptr=out_vars_arr_[pos-1];
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T<int,otl_var_int>
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#else
+ int match_found=otl_numeric_convert_T
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#endif
+ if(match_found)return;
+ check_type(pos,otl_var_unsigned_int);
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, int& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, int& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+ void get(const int pos, short int& n)
+ {
+ check_pos(pos);
+ void* curr_ptr=out_vars_arr_[pos-1];
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T<short,otl_var_short>
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#else
+ int match_found=otl_numeric_convert_T
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#endif
+ if(match_found)return;
+ check_type(pos,otl_var_short);
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, short int& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, short int& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+ void get(const int pos, long int& n)
+ {
+ check_pos(pos);
+ void* curr_ptr=out_vars_arr_[pos-1];
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T<long int,otl_var_long_int>
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#else
+ int match_found=otl_numeric_convert_T
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#endif
+ if(match_found)return;
+ check_type(pos,otl_var_long_int);
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, long int& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, long int& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+ void get(const int pos, float& n)
+ {
+ check_pos(pos);
+ void* curr_ptr=out_vars_arr_[pos-1];
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T<float,otl_var_float>
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#else
+ int match_found=otl_numeric_convert_T
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#endif
+ if(match_found)return;
+ check_type(pos,otl_var_double);
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, float& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, float& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+ void get(const int pos, double& n)
+ {
+ check_pos(pos);
+ void* curr_ptr=out_vars_arr_[pos-1];
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T<double,otl_var_double>
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#else
+ int match_found=otl_numeric_convert_T
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#endif
+ if(match_found)return;
+ check_type(pos,otl_var_double);
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, double& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, double& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+
+#if defined(OTL_BIGINT)
+ void get(const int pos, OTL_BIGINT& n)
+ {
+ check_pos(pos);
+ void* curr_ptr=out_vars_arr_[pos-1];
+#if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT)
+ int match_found=otl_numeric_convert_T<OTL_BIGINT,otl_var_bigint>
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#else
+ int match_found=otl_numeric_convert_T
+ (out_vars_[pos-1].ftype,
+ curr_ptr,
+ n);
+#endif
+ if(match_found)return;
+#if defined(OTL_STR_TO_BIGINT) && defined(OTL_BIGINT_TO_STR)
+ if(out_vars_[pos-1].ftype==otl_var_char){
+ char* temp_val=OTL_RCAST(char*,curr_ptr);
+#if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL)
+ if(is_null(pos)){
+ n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL);
+ return;
+ }
+#endif
+ OTL_STR_TO_BIGINT(temp_val,n);
+ return;
+ }
+ check_type(pos,otl_var_bigint);
+#else
+ check_type(pos,otl_var_bigint);
+#endif
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, OTL_BIGINT& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, OTL_BIGINT& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+#endif
+
+ bool is_null(const int pos)
+ {
+ check_pos(pos);
+ return out_vars_null_arr_[pos-1];
+ }
+
+#if defined(OTL_STL)
+ bool is_null(const char* var_name)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ return is_null((*it).second+1);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ bool is_null(const char* var_name)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ return is_null(it->item()+1);
+ }
+#endif
+
+#if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)
+ void get(const int pos, OTL_STRING_CONTAINER& s)
+ {
+ check_pos(pos);
+ otl_var_desc& curr_var=out_vars_[pos-1];
+ unsigned char* curr_ptr=out_vars_arr_[pos-1];
+ switch(curr_var.ftype){
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ case otl_var_clob:
+ case otl_var_blob:
+ {
+ otl_long_string* ls=OTL_RCAST(otl_long_string*,curr_ptr);
+ int len=ls->len();
+ s.assign(OTL_RCAST(char*,ls->v),len);
+ }
+ break;
+ case otl_var_char:
+ s=OTL_RCAST(char*,curr_ptr);
+ break;
+ default:
+ {
+ char var_info[255];
+ otl_var_info_var3
+ (out_vars_[pos-1].name,
+ out_vars_[pos-1].ftype,
+ otl_var_char,
+ var_info,
+ sizeof(var_info));
+ throw OTLException
+ (otl_error_msg_23,
+ otl_error_code_23,
+ str_->get_stm_text(),
+ var_info);
+ }
+ }
+ }
+#endif
+
+#if defined(OTL_STL)
+ void get(const char* var_name, OTL_STRING_CONTAINER& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, OTL_STRING_CONTAINER& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+
+ void get(const int pos, otl_long_string& s)
+ {
+ check_pos(pos);
+ check_type(pos,otl_var_long_string);
+ unsigned char* curr_ptr=out_vars_arr_[pos-1];
+ s=*OTL_RCAST(otl_long_string*,curr_ptr);
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, otl_long_string& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, otl_long_string& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+ void get(const int pos, otl_long_string*& s)
+ {
+ check_pos(pos);
+ check_type(pos,otl_var_long_string);
+ unsigned char* curr_ptr=out_vars_arr_[pos-1];
+ s=OTL_RCAST(otl_long_string*,curr_ptr);
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, otl_long_string*& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, otl_long_string*& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+ void get(const int pos, otl_datetime& s)
+ {
+ check_pos(pos);
+ check_type(pos,otl_var_timestamp);
+ unsigned char* curr_ptr=out_vars_arr_[pos-1];
+ s=*OTL_RCAST(otl_datetime*,curr_ptr);
+ }
+
+#if defined(OTL_STL)
+ void get(const char* var_name, otl_datetime& n)
+ {
+ var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name);
+ check_name(it,var_name);
+ get((*it).second+1,n);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void get(const char* var_name, otl_datetime& n)
+ {
+ var_name2pos_map_type::ENTRY* it=0;
+ var_name2pos_map_.find(var_name,it);
+ check_name(it,var_name);
+ get(it->item()+1,n);
+ }
+#endif
+
+protected:
+
+ otl_var_desc* out_vars_;
+ int out_vars_len_;
+ OTLStream* str_;
+ unsigned char** out_vars_arr_;
+ bool* out_vars_null_arr_;
+ bool out_vars_constructed_;
+ bool lob_stream_mode_flag_;
+
+#if defined(OTL_STL)
+ typedef STD_NAMESPACE_PREFIX
+ map<const char*,int,otl_ltcharstar> var_name2pos_map_type;
+ var_name2pos_map_type var_name2pos_map_;
+#endif
+
+#if defined(OTL_ACE)
+ typedef
+ ACE_RB_Tree<const char*,
+ int,
+ otl_ltcharstar,
+ ACE_Null_Mutex> var_name2pos_map_type;
+ var_name2pos_map_type var_name2pos_map_;
+#endif
+
+ void check_pos(const int pos)
+ {
+ int actual_pos=pos-1;
+ if(actual_pos<0 || actual_pos>out_vars_len_-1){
+ throw OTLException
+ (otl_error_msg_22,
+ otl_error_code_22,
+ str_->get_stm_text());
+ }
+ }
+
+#if defined(OTL_STL)
+ void check_name(var_name2pos_map_type::iterator& it, const char* var_name)
+ {
+ if(it==var_name2pos_map_.end())
+ throw OTLException
+ (otl_error_msg_26,
+ otl_error_code_26,
+ str_->get_stm_text(),
+ var_name);
+ }
+#endif
+
+#if defined(OTL_ACE)
+ void check_name(var_name2pos_map_type::ENTRY* it,const char* var_name)
+ {
+ if(!it){
+ throw OTLException
+ (otl_error_msg_26,
+ otl_error_code_26,
+ str_->get_stm_text(),
+ var_name);
+ }
+ }
+#endif
+
+ void check_type(const int pos,
+ const int type_code,
+ const bool lob_stream_arg=false)
+ {
+ switch(out_vars_[pos-1].ftype){
+ case otl_var_timestamp:
+ case otl_var_tz_timestamp:
+ case otl_var_ltz_timestamp:
+ if(type_code==otl_var_timestamp)
+ return;
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ case otl_var_clob:
+ case otl_var_blob:
+ if(type_code==otl_var_long_string)
+ return;
+ case otl_var_raw:
+ if(type_code==otl_var_long_string &&
+ lob_stream_mode_flag_ &&
+ lob_stream_arg){
+ char var_info1[255];
+ otl_var_info_var4
+ (out_vars_[pos-1].name,
+ out_vars_[pos-1].ftype,
+ otl_var_lob_stream,
+ var_info1,
+ sizeof(var_info1));
+ throw OTLException
+ (otl_error_msg_28,
+ otl_error_code_28,
+ str_->get_stm_text(),
+ var_info1);
+ }else
+ return;
+ default:
+ if(out_vars_[pos-1].ftype==type_code)
+ return;
+ }
+ char var_info2[255];
+ otl_var_info_var3
+ (out_vars_[pos-1].name,
+ out_vars_[pos-1].ftype,
+ type_code,
+ var_info2,
+ sizeof(var_info2));
+ throw OTLException
+ (otl_error_msg_23,
+ otl_error_code_23,
+ str_->get_stm_text(),
+ var_info2);
+ }
+
+ void set(void)
+ {
+ out_vars_=0;
+ out_vars_len_=0;
+ str_=0;
+ out_vars_arr_=0;
+ out_vars_null_arr_=0;
+ out_vars_constructed_=false;
+ lob_stream_mode_flag_=false;
+ }
+
+ void reset(void)
+ {
+ if(out_vars_constructed_){
+ for(int i=0;i<out_vars_len_;++i){
+ switch(out_vars_[i].ftype){
+ case otl_var_char:
+ delete[] OTL_RCAST(char*,out_vars_arr_[i]);
+ break;
+ case otl_var_double:
+ delete OTL_RCAST(double*,out_vars_arr_[i]);
+ break;
+ case otl_var_float:
+ delete OTL_RCAST(float*,out_vars_arr_[i]);
+ break;
+ case otl_var_int:
+ delete OTL_RCAST(int*,out_vars_arr_[i]);
+ break;
+ case otl_var_unsigned_int:
+ delete OTL_RCAST(unsigned*,out_vars_arr_[i]);
+ break;
+ case otl_var_short:
+ delete OTL_RCAST(short int*,out_vars_arr_[i]);
+ break;
+ case otl_var_long_int:
+ delete OTL_RCAST(long int*,out_vars_arr_[i]);
+ break;
+#if defined(OTL_BIGINT)
+ case otl_var_bigint:
+ delete OTL_RCAST(OTL_BIGINT*,out_vars_arr_[i]);
+ break;
+#endif
+ case otl_var_raw:
+ delete OTL_RCAST(otl_long_string*,out_vars_arr_[i]);
+ break;
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ case otl_var_clob:
+ case otl_var_blob:
+#if !defined(OTL_ORA7)
+ if(lob_stream_mode_flag_)
+ delete OTL_RCAST(OTLLobStream*,out_vars_arr_[i]);
+ else
+#endif
+ delete OTL_RCAST(otl_long_string*,out_vars_arr_[i]);
+ break;
+ case otl_var_timestamp:
+ delete OTL_RCAST(otl_datetime*,out_vars_arr_[i]);
+ break;
+ default:
+ break;
+ }
+ out_vars_arr_[i]=0;
+ }
+ out_vars_constructed_=false;
+ }
+ delete[] out_vars_arr_;
+ delete[] out_vars_null_arr_;
+#if defined(OTL_STL)||defined(OTL_ACE)
+ var_name2pos_map_.clear();
+#endif
+ set();
+ }
+
+ int calculate_buffer_size
+ (const otl_var_desc* var,
+ const int vars_len)
+ {
+ for(int i=0;i<vars_len;++i){
+ const otl_var_desc& curr_var=var[i];
+ if(curr_var.ftype==otl_var_refcur||curr_var.pl_tab_flag)
+ throw OTLException(otl_error_msg_20,otl_error_code_20);
+ }
+ return vars_len;
+ }
+
+ void allocate_arrays(void)
+ {
+ if(out_vars_){
+ out_vars_null_arr_=new bool[out_vars_len_];
+ int buf_size=calculate_buffer_size(out_vars_,out_vars_len_);
+ out_vars_arr_=new unsigned char*[buf_size];
+ construct_elements();
+ }
+ }
+
+ void construct_elements(void)
+ {
+ for(int i=0;i<out_vars_len_;++i){
+ out_vars_null_arr_[i]=true;
+ const otl_var_desc& curr_var=out_vars_[i];
+ switch(curr_var.ftype){
+ case otl_var_char:
+ {
+ char* ptr=new char[curr_var.elem_size];
+ *ptr=0;
+ out_vars_arr_[i]=OTL_RCAST(unsigned char*,ptr);
+ }
+ break;
+ case otl_var_raw:
+ out_vars_arr_[i]=
+ OTL_RCAST(unsigned char*,new otl_long_string(curr_var.elem_size));
+ break;
+ case otl_var_double:
+ out_vars_arr_[i]=OTL_RCAST(unsigned char*,new double(0));
+ break;
+ case otl_var_float:
+ out_vars_arr_[i]=OTL_RCAST(unsigned char*,new float(0));
+ break;
+ case otl_var_int:
+ out_vars_arr_[i]=OTL_RCAST(unsigned char*,new int(0));
+ break;
+ case otl_var_unsigned_int:
+ out_vars_arr_[i]=OTL_RCAST(unsigned char*,new unsigned(0));
+ break;
+ case otl_var_short:
+ out_vars_arr_[i]=OTL_RCAST(unsigned char*,new short(0));
+ break;
+ case otl_var_long_int:
+ out_vars_arr_[i]=OTL_RCAST(unsigned char*,new long(0));
+ break;
+ case otl_var_timestamp:
+ case otl_var_db2time:
+ case otl_var_db2date:
+ case otl_var_tz_timestamp:
+ case otl_var_ltz_timestamp:
+ out_vars_arr_[i]=OTL_RCAST(unsigned char*,new otl_datetime);
+ break;
+ case otl_var_varchar_long:
+ case otl_var_raw_long:
+ case otl_var_clob:
+ case otl_var_blob:
+#if !defined(OTL_ORA7)
+ if(lob_stream_mode_flag_)
+ out_vars_arr_[i]=OTL_RCAST(unsigned char*,new OTLLobStream());
+ else
+#endif
+ out_vars_arr_[i]=
+ OTL_RCAST(unsigned char*,
+ new otl_long_string
+ (str_->get_adb_max_long_size()));
+ break;
+#if defined(OTL_BIGINT)
+ case otl_var_bigint:
+ out_vars_arr_[i]=OTL_RCAST(unsigned char*,new OTL_BIGINT(0));
+ break;
+#endif
+ }
+#if defined(OTL_STL)
+ var_name2pos_map_[curr_var.name]=i;
+#endif
+#if defined(OTL_ACE)
+ var_name2pos_map_.bind(curr_var.name,i);
+#endif
+ }
+ out_vars_constructed_=true;
+ }
+
+private:
+
+ otl_stream_read_iterator(const otl_stream_read_iterator&):
+ out_vars_(0),
+ out_vars_len_(0),
+ str_(0),
+ out_vars_arr_(0),
+ out_vars_null_arr_(0),
+ out_vars_constructed_(0),
+ lob_stream_mode_flag_(false)
+#if defined(OTL_STL)
+ ,var_name2pos_map_()
+#endif
+#if defined(OTL_ACE)
+ ,var_name2pos_map_()
+#endif
+ {
+ }
+
+ otl_stream_read_iterator& operator=(const otl_stream_read_iterator&)
+ {
+ return *this;
+ }
+
+};
+
+#endif
+
+#if defined(OTL_ORA_TEXT_ON)&&defined(text)
+#undef text
+#endif
+
+#endif
diff --git a/src/saga_core/saga_odbc/saga_odbc.cpp b/src/saga_core/saga_odbc/saga_odbc.cpp
new file mode 100644
index 0000000..d48f55e
--- /dev/null
+++ b/src/saga_core/saga_odbc/saga_odbc.cpp
@@ -0,0 +1,1540 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Module Library: //
+// saga_api //
+// //
+//-------------------------------------------------------//
+// //
+// odbc.cpp //
+// //
+// Copyright (C) 2009 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include "saga_odbc.h"
+
+//---------------------------------------------------------
+#define OTL_ODBC_MULTI_MODE
+#define OTL_STL // Turn on STL features
+#ifndef OTL_ANSI_CPP
+#define OTL_ANSI_CPP // Turn on ANSI C++ typecasts
+#endif
+
+#ifdef _SAGA_UNICODE
+//#define OTL_UNICODE
+#endif
+
+#ifdef _SAGA_LINUX
+#define OTL_ODBC_UNIX
+#endif
+
+#include "otlv4.h" // include the OTL 4 header file
+
+//---------------------------------------------------------
+using namespace std;
+
+//---------------------------------------------------------
+#include <sql.h>
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_ODBC_Connections g_Connections;
+
+//---------------------------------------------------------
+CSG_ODBC_Connections & SG_ODBC_Get_Connection_Manager(void)
+{
+ return( g_Connections );
+}
+
+//---------------------------------------------------------
+bool SG_ODBC_is_Supported(void)
+{
+ return( true );
+}
+
+//---------------------------------------------------------
+void _Error_Message(const CSG_String &Message, const CSG_String &Additional = SG_T(""))
+{
+ SG_UI_Msg_Add_Execution(Message, true, SG_UI_MSG_STYLE_FAILURE);
+
+ CSG_String s(Message);
+
+ s += SG_T(":\n");
+
+ if( Additional )
+ {
+ s += Additional;
+ s += SG_T("\n");
+ }
+
+ SG_UI_Msg_Add_Error(s);
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define m_Connection (*((otl_connect *)m_pConnection))
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_ODBC_Connection::CSG_ODBC_Connection(const CSG_String &Server, const CSG_String &User, const CSG_String &Password, bool bAutoCommit)
+{
+ CSG_String s;
+
+ m_DBMS = SG_ODBC_DBMS_Unknown;
+ m_Size_Buffer = 1;
+ m_bAutoCommit = bAutoCommit;
+
+ if( User.Length() > 0 )
+ {
+ s += CSG_String::Format(SG_T("UID=%s;"), User.c_str());
+ s += CSG_String::Format(SG_T("PWD=%s;"), Password.c_str());
+ }
+
+ s += CSG_String::Format(SG_T("DSN=%s;"), Server.c_str());
+
+ m_pConnection = new otl_connect();
+
+ try
+ {
+ m_Connection.rlogon(SG_STR_SGTOMB(s), m_bAutoCommit ? 1 : 0);
+ }
+ catch( otl_exception &e )
+ {
+ _Error_Message((const char *)e.msg, CSG_String::Format(SG_T("%s [%s]"), e.stm_text, e.var_info));
+ }
+
+ //-----------------------------------------------------
+ if( !m_Connection.connected )
+ {
+ delete(((otl_connect *)m_pConnection));
+
+ m_pConnection = NULL;
+ }
+ else
+ {
+ m_DSN = Server;
+
+ //-------------------------------------------------
+ s = Get_DBMS_Name();
+
+ if( !s.CmpNoCase(SG_T("PostgreSQL")) )
+ {
+ m_DBMS = SG_ODBC_DBMS_PostgreSQL;
+ }
+ else if( !s.CmpNoCase(SG_T("MySQL")) )
+ {
+ m_DBMS = SG_ODBC_DBMS_MySQL;
+ }
+ else if( !s.CmpNoCase(SG_T("Oracle")) )
+ {
+ m_DBMS = SG_ODBC_DBMS_Oracle;
+ }
+ else if( !s.CmpNoCase(SG_T("MSQL")) )
+ {
+ m_DBMS = SG_ODBC_DBMS_MSSQLServer;
+ }
+ else if( !s.CmpNoCase(SG_T("ACCESS")) )
+ {
+ m_DBMS = SG_ODBC_DBMS_Access;
+ }
+
+ //-------------------------------------------------
+ Set_Size_Buffer(is_Access() ? 1 : 50);
+
+ Set_Size_LOB_Max(4 * 32767);
+ }
+}
+
+//---------------------------------------------------------
+CSG_ODBC_Connection::~CSG_ODBC_Connection(void)
+{
+ if( is_Connected() )
+ {
+ delete(((otl_connect *)m_pConnection));
+
+ m_pConnection = NULL;
+ }
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Set_Size_Buffer(int Size)
+{
+ if( Size > 0 )
+ {
+ m_Size_Buffer = Size;
+
+ return( true );
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+int CSG_ODBC_Connection::Get_Size_LOB_Max(void) const
+{
+ return( is_Connected() ? m_Connection.get_max_long_size() : 0 );
+}
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Set_Size_LOB_Max(int Size)
+{
+ if( is_Connected() && Size > 0 )
+ {
+ m_Connection.set_max_long_size(Size);
+
+ return( true );
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_String CSG_ODBC_Connection::_Get_DBMS_Info(int What) const
+{
+ CSG_String Result;
+
+ if( is_Connected() )
+ {
+ SQLSMALLINT nBuffer;
+ SQLTCHAR Buffer[256];
+
+ SQLGetInfo(m_Connection.get_connect_struct().get_hdbc(), What, (SQLPOINTER)Buffer, 255, &nBuffer);
+
+ Result = (const SG_Char *)Buffer;
+ }
+
+ return( Result );
+}
+
+//---------------------------------------------------------
+CSG_String CSG_ODBC_Connection::Get_DBMS_Name(void) const
+{
+ return( _Get_DBMS_Info(SQL_DBMS_NAME) );
+}
+
+//---------------------------------------------------------
+CSG_String CSG_ODBC_Connection::Get_DBMS_Version(void) const
+{
+ return( _Get_DBMS_Info(SQL_DBMS_VER) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_String CSG_ODBC_Connection::Get_Tables(void) const
+{
+ CSG_String Tables;
+
+ if( is_Connected() )
+ {
+ try
+ {
+ otl_stream Stream(m_Size_Buffer, "$SQLTables", m_Connection); // get a list of all tables in the current database.
+
+ while( !Stream.eof() )
+ {
+ std::string Catalog, Schema, Table, Type, Remarks;
+
+ Stream >> Catalog >> Schema >> Table >> Type >> Remarks;
+
+ Tables += Table.c_str();
+ Tables += SG_T("|");
+ }
+ }
+ catch( otl_exception &e )
+ {
+ _Error_Message((const char *)e.msg, CSG_String::Format(SG_T("%s [%s]"), e.stm_text, e.var_info));
+ }
+ }
+
+ return( Tables );
+}
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Table_Exists(const CSG_String &Table_Name) const
+{
+ if( is_Connected() )
+ {
+ try
+ {
+ otl_stream Stream(m_Size_Buffer, "$SQLTables", m_Connection); // get a list of all tables in the current database.
+
+ while( !Stream.eof() )
+ {
+ std::string Catalog, Schema, Table, Type, Remarks;
+
+ Stream >> Catalog >> Schema >> Table >> Type >> Remarks;
+
+ if( !Table_Name.Cmp(CSG_String(Table.c_str())) )
+ {
+ return( true );
+ }
+ }
+ }
+ catch( otl_exception &e )
+ {
+ _Error_Message((const char *)e.msg, CSG_String::Format(SG_T("%s [%s]"), e.stm_text, e.var_info));
+ }
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+CSG_Table CSG_ODBC_Connection::Get_Field_Desc(const CSG_String &Table_Name) const
+{
+ CSG_Table Fields;
+
+ Fields.Set_Name(CSG_String::Format(SG_T("%s [%s]"), Table_Name.c_str(), LNG("Field Description")));
+
+ if( is_Connected() )
+ {
+ try
+ {
+ int i, n;
+ std::string s;
+ otl_column_desc *desc;
+ otl_stream Stream;
+
+ Stream.set_all_column_types(otl_all_num2str|otl_all_date2str);
+
+ Stream.open(m_Size_Buffer, SG_STR_SGTOMB(CSG_String::Format(SG_T("$SQLColumns $3:'%s'"), Table_Name.c_str())), m_Connection); // get a list of all columns.
+
+ desc = Stream.describe_select(n);
+
+ for(i=0; i<n; i++)
+ {
+ Fields.Add_Field(CSG_String(desc[i].name), SG_DATATYPE_String);
+ }
+
+ while( !Stream.eof() )
+ {
+ CSG_Table_Record *pField = Fields.Add_Record();
+
+ for(i=0; i<n; i++)
+ {
+ Stream >> s;
+
+ pField->Set_Value(i, CSG_String(s.c_str()));
+ }
+ }
+ }
+ catch( otl_exception &e )
+ {
+ _Error_Message((const char *)e.msg, CSG_String::Format(SG_T("%s [%s]"), e.stm_text, e.var_info));
+ }
+ }
+
+ return( Fields );
+}
+
+//---------------------------------------------------------
+CSG_String CSG_ODBC_Connection::Get_Field_Names(const CSG_String &Table_Name) const
+{
+ CSG_Table Fields = Get_Field_Desc(Table_Name);
+
+ CSG_String Names;
+
+ for(int i=0; i<Fields.Get_Count(); i++)
+ {
+ Names += Fields[i].asString(3);
+ Names += SG_T("|");
+ }
+
+ return( Names );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+int CSG_ODBC_Connection::_Get_Type_To_SQL(TSG_Data_Type Type)
+{
+ switch( Type )
+ {
+ case SG_DATATYPE_String: return( otl_var_char ); // strings
+
+ case SG_DATATYPE_Color:
+ case SG_DATATYPE_Char:
+ case SG_DATATYPE_Short:
+ case SG_DATATYPE_Int:
+ case SG_DATATYPE_Long: return( otl_var_int ); // non-floating point numbers
+
+ case SG_DATATYPE_Float: return( otl_var_float ); // 32-bit floating point numbers
+ case SG_DATATYPE_Double: return( otl_var_double ); // 64-bit floating point numbers
+
+ case SG_DATATYPE_Date: return( otl_var_char ); // dates
+
+ case SG_DATATYPE_Binary: return( otl_var_varchar_long ); // dates
+ }
+
+ return( -1 );
+}
+
+//---------------------------------------------------------
+TSG_Data_Type CSG_ODBC_Connection::_Get_Type_From_SQL(int Type)
+{
+ switch( Type )
+ {
+ case otl_var_char: return( SG_DATATYPE_String ); // 1 | null terminated string
+ case otl_var_short: return( SG_DATATYPE_Short ); // 6 | signed 16-bit integer
+ case otl_var_int: return( SG_DATATYPE_Int ); // 4 | signed 32-bit integer
+ case otl_var_unsigned_int: return( SG_DATATYPE_DWord ); // 5 | unsigned 32-bit integer
+ case otl_var_long_int: return( SG_DATATYPE_Long ); // 7 | signed 32-bit integer (for 32-bit, and LLP64 C++ compilers), signed 64-bit integer (for LP-64 C++ compilers)
+ case otl_var_bigint: return( SG_DATATYPE_Long ); // 20 | MS SQL Server, DB2, MySQL, PostgreSQL, etc. BIGINT (signed 64-bit integer) type
+ case otl_var_float: return( SG_DATATYPE_Float ); // 3 | 4-byte floating point number
+ case otl_var_double: return( SG_DATATYPE_Double ); // 2 | 8-byte floating point number
+
+ case otl_var_db2date: return( SG_DATATYPE_String ); // 17 | DB2 DATE data type
+ case otl_var_db2time: return( SG_DATATYPE_String ); // 16 | DB2 TIME data type
+ case otl_var_ltz_timestamp: return( SG_DATATYPE_String ); // 19 | Oracle 9i/10g/11g TIMESTAMP WITH LOCAL TIME ZONE type
+ case otl_var_timestamp: return( SG_DATATYPE_String ); // 8 | data type that is mapped into Oracle date/timestamp, DB2 timestamp, MS SQL datetime/datetime2/time/date, Sybase timestamp, etc.
+ case otl_var_tz_timestamp: return( SG_DATATYPE_String ); // 18 | Oracle timestamp with timezone type
+
+ case otl_var_varchar_long: return( SG_DATATYPE_String ); // 9 | data type that is mapped into LONG in Oracle 7/8/9/10/11, TEXT in MS SQL Server and Sybase, CLOB in DB2
+ case otl_var_raw: return( SG_DATATYPE_Binary ); // 23 | RAW, BINARY, VARBINARY, BYTEA, VARCHAR BYTE, CHAR BYTE, etc.
+ case otl_var_raw_long: return( SG_DATATYPE_Binary ); // 10 | data type that is mapped into LONG RAW in Oracle, IMAGE in MS SQL Server and Sybase, BLOB in DB2
+ case otl_var_clob: return( SG_DATATYPE_Binary ); // 11 | data type that is mapped into CLOB in Oracle 8/9/10/11
+ case otl_var_blob: return( SG_DATATYPE_Binary ); // 12 | data type that is mapped into BLOB in Oracle 8/9/10/11
+ }
+
+ return( SG_DATATYPE_Undefined );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Execute(const CSG_String &SQL, bool bCommit)
+{
+ if( !is_Connected() )
+ {
+ _Error_Message(LNG("no database connection"));
+
+ return( false );
+ }
+
+ try
+ {
+ m_Connection.direct_exec(SG_STR_SGTOMB(SQL));
+
+ return( bCommit ? Commit() : true );
+
+ // if( m_Connection.direct_exec(SG_STR_SGTOMB(SQL)) >= 0 )
+ // {
+ // return( bCommit ? Commit() : true );
+ // }
+
+ // _Error_Message(LNG("sql excution error"), SQL);
+ }
+ catch( otl_exception &e )
+ {
+ _Error_Message((const char *)e.msg, CSG_String::Format(SG_T("%s [%s]"), e.stm_text, e.var_info));
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+void CSG_ODBC_Connection::Set_Auto_Commit(bool bOn)
+{
+ if( is_Connected() && m_bAutoCommit != bOn )
+ {
+ m_bAutoCommit = bOn;
+
+ if( bOn )
+ {
+ m_Connection.auto_commit_on();
+ }
+ else
+ {
+ m_Connection.auto_commit_off();
+ }
+ }
+}
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Commit(void)
+{
+ if( !is_Connected() )
+ {
+ _Error_Message(LNG("no database connection"));
+
+ return( false );
+ }
+
+ try
+ {
+ m_Connection.commit();
+
+ return( true );
+ }
+ catch( otl_exception &e )
+ {
+ _Error_Message((const char *)e.msg, CSG_String::Format(SG_T("%s [%s]"), e.stm_text, e.var_info));
+ }
+
+ return( false );
+}
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Rollback(void)
+{
+ if( !is_Connected() )
+ {
+ _Error_Message(LNG("no database connection"));
+
+ return( false );
+ }
+
+ try
+ {
+ m_Connection.rollback();
+
+ return( true );
+ }
+ catch( otl_exception &e )
+ {
+ _Error_Message((const char *)e.msg, CSG_String::Format(SG_T("%s [%s]"), e.stm_text, e.var_info));
+ }
+
+ return( false );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Table_Create(const CSG_String &Table_Name, const CSG_Table &Table, const CSG_Buffer &Flags, bool bCommit)
+{
+ if( Table.Get_Field_Count() <= 0 )
+ {
+ _Error_Message(LNG("no attributes in table"));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ int iField;
+ CSG_String SQL;
+
+ SQL.Printf(SG_T("CREATE TABLE \"%s\"("), Table_Name.c_str());
+
+ for(iField=0; iField<Table.Get_Field_Count(); iField++)
+ {
+ CSG_String s;
+
+ switch( Table.Get_Field_Type(iField) )
+ {
+ default:
+ case SG_DATATYPE_String:
+ s = CSG_String::Format(SG_T("VARCHAR(%d)"), Table.Get_Field_Length(iField));
+ break;
+
+ case SG_DATATYPE_Char:
+ s = SG_T("SMALLINT");
+ break;
+
+ case SG_DATATYPE_Short:
+ s = SG_T("SMALLINT");
+ break;
+
+ case SG_DATATYPE_Int:
+ s = SG_T("INT");
+ break;
+
+ case SG_DATATYPE_Color:
+ s = SG_T("INT");
+ break;
+
+ case SG_DATATYPE_Long:
+ s = SG_T("INT");
+ break;
+
+ case SG_DATATYPE_Float:
+ s = SG_T("FLOAT");
+ break;
+
+ case SG_DATATYPE_Double:
+ s = is_PostgreSQL()
+ ? SG_T("DOUBLE PRECISION")
+ : SG_T("DOUBLE");
+ break;
+
+ case SG_DATATYPE_Binary:
+ s = SG_T("%s VARBINARY");
+ break;
+ }
+
+ //-------------------------------------------------
+ char Flag = (int)Flags.Get_Size() == Table.Get_Field_Count() ? Flags[iField] : 0;
+
+ if( (Flag & SG_ODBC_PRIMARY_KEY) == 0 )
+ {
+ if( (Flag & SG_ODBC_UNIQUE) != 0 )
+ {
+ s += SG_T(" UNIQUE");
+ }
+
+ if( (Flag & SG_ODBC_NOT_NULL) != 0 )
+ {
+ s += SG_T(" NOT NULL");
+ }
+ }
+
+ //-------------------------------------------------
+ if( iField > 0 )
+ {
+ SQL += SG_T(", ");
+ }
+
+ SQL += CSG_String::Format(SG_T("%s %s"), Table.Get_Field_Name(iField), s.c_str());
+ }
+
+ //-----------------------------------------------------
+ if( (int)Flags.Get_Size() == Table.Get_Field_Count() )
+ {
+ CSG_String s;
+
+ for(iField=0; iField<Table.Get_Field_Count(); iField++)
+ {
+ if( (Flags[iField] & SG_ODBC_PRIMARY_KEY) != 0 )
+ {
+ s += s.Length() == 0 ? SG_T(", PRIMARY KEY(") : SG_T(", ");
+ s += Table.Get_Field_Name(iField);
+ }
+ }
+
+ if( s.Length() > 0 )
+ {
+ SQL += s + SG_T(")");
+ }
+ }
+
+ //-----------------------------------------------------
+ SQL += SG_T(")");
+
+ //-----------------------------------------------------
+ return( Execute(SQL, bCommit) );
+}
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Table_Drop(const CSG_String &Table_Name, bool bCommit)
+{
+ if( !Table_Exists(Table_Name) )
+ {
+ _Error_Message(LNG("database table does not exist"));
+
+ return( false );
+ }
+
+ return( Execute(CSG_String::Format(SG_T("DROP TABLE \"%s\""), Table_Name.c_str()), bCommit) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Table_Insert(const CSG_String &Table_Name, const CSG_Table &Table, bool bCommit)
+{
+ //-----------------------------------------------------
+ if( !is_Connected() )
+ {
+ _Error_Message(LNG("no database connection"));
+
+ return( false );
+ }
+
+ if( !Table_Exists(Table_Name) )
+ {
+ return( false );
+ }
+
+ CSG_Table Fields = Get_Field_Desc(Table_Name);
+
+ if( Fields.Get_Count() != Table.Get_Field_Count() )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ try
+ {
+ bool bLOB = false;
+
+ int iField, iRecord;
+ CSG_String Insert;
+ otl_stream Stream;
+
+ //-------------------------------------------------
+ Insert.Printf(SG_T("INSERT INTO %s VALUES("), Table_Name.c_str());
+
+ for(iField=0; iField<Table.Get_Field_Count(); iField++)
+ {
+ if( iField > 0 )
+ {
+ Insert += SG_T(",");
+ }
+
+ Insert += CSG_String::Format(SG_T(":f%d"), 1 + iField);
+
+ switch( Table.Get_Field_Type(iField) )
+ {
+ default:
+ case SG_DATATYPE_String: Insert += SG_T("<varchar>"); break;
+ case SG_DATATYPE_Date: Insert += SG_T("<char[12]>"); break;
+ case SG_DATATYPE_Char: Insert += SG_T("<char>"); break;
+ case SG_DATATYPE_Short: Insert += SG_T("<short>"); break;
+ case SG_DATATYPE_Int: Insert += SG_T("<int>"); break;
+ case SG_DATATYPE_Color: Insert += SG_T("<long>"); break;
+ case SG_DATATYPE_Long: Insert += SG_T("<long>"); break;
+ case SG_DATATYPE_Float: Insert += SG_T("<float>"); break;
+ case SG_DATATYPE_Double: Insert += SG_T("<double>"); break;
+ }
+ }
+
+ Insert += SG_T(")");
+
+ Stream.set_all_column_types(otl_all_date2str);
+ Stream.set_lob_stream_mode(bLOB);
+ Stream.open(bLOB ? 1 : m_Size_Buffer, SG_STR_SGTOMB(Insert), m_Connection);
+
+ string valString;
+
+ //-------------------------------------------------
+ for(iRecord=0; iRecord<Table.Get_Count() && SG_UI_Process_Set_Progress(iRecord, Table.Get_Count()); iRecord++)
+ {
+ CSG_Table_Record *pRecord = Table.Get_Record(iRecord);
+
+ for(iField=0; iField<Table.Get_Field_Count(); iField++)
+ {
+ if( pRecord->is_NoData(iField) )
+ {
+ Stream << otl_null();
+ }
+ else switch( Table.Get_Field_Type(iField) )
+ {
+ default:
+ case SG_DATATYPE_String:
+ case SG_DATATYPE_Date:
+ valString = SG_STR_SGTOMB(pRecord->asString(iField));
+ Stream << valString;
+ break;
+
+ case SG_DATATYPE_Char: Stream << (char)pRecord->asChar (iField); break;
+ case SG_DATATYPE_Short: Stream << pRecord->asShort (iField); break;
+ case SG_DATATYPE_Int: Stream << pRecord->asInt (iField); break;
+ case SG_DATATYPE_Color:
+ case SG_DATATYPE_Long: Stream << (long)pRecord->asInt (iField); break;
+ case SG_DATATYPE_Float: Stream << pRecord->asFloat (iField); break;
+ case SG_DATATYPE_Double: Stream << pRecord->asDouble(iField); break;
+ }
+ }
+ }
+ }
+ //-----------------------------------------------------
+ catch( otl_exception &e )
+ {
+ _Error_Message((const char *)e.msg, CSG_String::Format(SG_T("%s [%s]"), e.stm_text, e.var_info));
+
+ return( false );
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Table_Save(const CSG_String &Table_Name, const CSG_Table &Table, const CSG_Buffer &Flags, bool bCommit)
+{
+ //-----------------------------------------------------
+ if( !is_Connected() )
+ {
+ _Error_Message(LNG("no database connection"));
+
+ return( false );
+ }
+
+ if( Table_Exists(Table_Name) && !Table_Drop(Table_Name, bCommit) )
+ {
+ return( false );
+ }
+
+ if( !Table_Create(Table_Name, Table, Flags, bCommit) )
+ {
+ return( false );
+ }
+
+ if( !Table_Insert(Table_Name, Table, bCommit) )
+ {
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::_Table_Load(CSG_Table &Table, const CSG_String &Select, const CSG_String &Name, bool bLOB)
+{
+ //-----------------------------------------------------
+ if( !is_Connected() )
+ {
+ _Error_Message(LNG("no database connection"));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ try
+ {
+ int valInt, iField, nFields;
+ long valLong;
+ float valFloat;
+ double valDouble;
+ string valString;
+ otl_long_string valRaw(m_Connection.get_max_long_size());
+ otl_column_desc *Fields;
+ otl_stream Stream;
+ CSG_Bytes BLOB;
+
+ Stream.set_all_column_types (otl_all_date2str);
+ Stream.set_lob_stream_mode (bLOB);
+ Stream.open (bLOB ? 1 : m_Size_Buffer, SG_STR_SGTOMB(Select), m_Connection);
+
+ Fields = Stream.describe_select(nFields);
+
+ if( Fields == NULL || nFields <= 0 )
+ {
+ _Error_Message(LNG("no fields in selection"));
+
+ return( false );
+ }
+
+ //-------------------------------------------------
+ Table.Destroy();
+ Table.Set_Name(Name);
+
+ for(iField=0; iField<nFields; iField++)
+ {
+ if( _Get_Type_From_SQL(Fields[iField].otl_var_dbtype) == SG_DATATYPE_Undefined )
+ {
+ return( false );
+ }
+
+ Table.Add_Field(Fields[iField].name, _Get_Type_From_SQL(Fields[iField].otl_var_dbtype));
+ }
+
+ //-------------------------------------------------
+ while( !Stream.eof() && SG_UI_Process_Get_Okay() ) // while not end-of-data
+ {
+ CSG_Table_Record *pRecord = Table.Add_Record();
+
+ for(iField=0; iField<nFields; iField++)
+ {
+ switch( Table.Get_Field_Type(iField) )
+ {
+ case SG_DATATYPE_String: Stream >> valString; if( Stream.is_null() ) pRecord->Set_NoData(iField); else pRecord->Set_Value(iField, CSG_String(valString.c_str())); break;
+ case SG_DATATYPE_Short:
+ case SG_DATATYPE_Int: Stream >> valInt; if( Stream.is_null() ) pRecord->Set_NoData(iField); else pRecord->Set_Value(iField, valInt); break;
+ case SG_DATATYPE_DWord:
+ case SG_DATATYPE_Long: Stream >> valLong; if( Stream.is_null() ) pRecord->Set_NoData(iField); else pRecord->Set_Value(iField, valLong); break;
+ case SG_DATATYPE_Float: Stream >> valFloat; if( Stream.is_null() ) pRecord->Set_NoData(iField); else pRecord->Set_Value(iField, valFloat); break;
+ case SG_DATATYPE_Double: Stream >> valDouble; if( Stream.is_null() ) pRecord->Set_NoData(iField); else pRecord->Set_Value(iField, valDouble); break;
+ case SG_DATATYPE_Binary:
+ Stream >> valRaw;
+
+ if( Stream.is_null() )
+ {
+ pRecord->Set_NoData(iField);
+ }
+ else
+ {
+ BLOB.Clear();
+
+ for(int i=0; i<valRaw.len(); i++)
+ {
+ BLOB.Add((BYTE)valRaw[i]);
+ }
+
+ pRecord->Set_Value(iField, BLOB);
+ }
+ break;
+ }
+ }
+ }
+ }
+ //-----------------------------------------------------
+ catch( otl_exception &e )
+ {
+ _Error_Message((const char *)e.msg, CSG_String::Format(SG_T("%s [%s]"), e.stm_text, e.var_info));
+
+ return( false );
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Table_Load(CSG_Table &Table, const CSG_String &Table_Name, bool bLOB)
+{
+ return( _Table_Load(Table, CSG_String::Format(SG_T("SELECT * FROM \"%s\""), Table_Name.c_str()), Table_Name, bLOB) );
+}
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Table_Load(CSG_Table &Table, const CSG_String &Tables, const CSG_String &Fields, const CSG_String &Where, const CSG_String &Group, const CSG_String &Having, const CSG_String &Order, bool bDistinct, bool bLOB)
+{
+ CSG_String Select;
+
+ Select.Printf(SG_T("SELECT %s %s FROM %s"), bDistinct ? SG_T("DISTINCT") : SG_T("ALL"), Fields.c_str(), Tables.c_str());
+
+ if( Where.Length() )
+ {
+ Select += SG_T(" WHERE ") + Where;
+ }
+
+ if( Group.Length() )
+ {
+ Select += SG_T(" GROUP BY ") + Group;
+
+ if( Having.Length() )
+ {
+ Select += SG_T(" HAVING ") + Having;
+ }
+ }
+
+ if( Order.Length() )
+ {
+ Select += SG_T(" ORDER BY ") + Order;
+ }
+
+ return( _Table_Load(Table, Select, Table.Get_Name(), bLOB) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connection::Table_Load_BLOBs(CSG_Bytes_Array &BLOBs, const CSG_String &Table_Name, const CSG_String &Field, const CSG_String &Where, const CSG_String &Order)
+{
+ //-----------------------------------------------------
+ if( !is_Connected() )
+ {
+ _Error_Message(LNG("no database connection"));
+
+ return( false );
+ }
+
+ //-----------------------------------------------------
+ try
+ {
+ bool bLOB = true;
+ int nFields;
+ otl_column_desc *Fields;
+ otl_long_string valRaw(m_Connection.get_max_long_size());
+ otl_stream Stream;
+ CSG_String Select;
+
+ //-------------------------------------------------
+ Select.Printf(SG_T("SELECT %s FROM %s"), Field.c_str(), Table_Name.c_str());
+
+ if( Where.Length() )
+ {
+ Select += SG_T(" WHERE ") + Where;
+ }
+
+ if( Order.Length() )
+ {
+ Select += SG_T(" ORDER BY ") + Order;
+ }
+
+ //-------------------------------------------------
+ Stream.set_lob_stream_mode (bLOB);
+ Stream.open (bLOB ? 1 : m_Size_Buffer, SG_STR_SGTOMB(Select), m_Connection);
+
+ Fields = Stream.describe_select(nFields);
+
+ if( Fields == NULL || nFields <= 0 )
+ {
+ _Error_Message(LNG("no fields in selection"));
+
+ return( false );
+ }
+
+ if( nFields != 1 )
+ {
+ _Error_Message(LNG("more than one field in selection"));
+
+ return( false );
+ }
+
+ if( _Get_Type_From_SQL(Fields[0].otl_var_dbtype) != SG_DATATYPE_Binary )//|| _Get_Type_From_SQL(Fields[0].otl_var_dbtype) != SG_DATATYPE_String )
+ {
+ _Error_Message(LNG("field cannot be mapped to binary object"));
+
+ return( false );
+ }
+
+ //-------------------------------------------------
+ BLOBs.Destroy();
+
+ while( !Stream.eof() && SG_UI_Process_Get_Okay() ) // while not end-of-data
+ {
+ CSG_Bytes *pBLOB = BLOBs.Add();
+
+ Stream >> valRaw;
+
+ if( !Stream.is_null() )
+ {
+ for(int i=0; i<valRaw.len(); i++)
+ {
+ pBLOB->Add((BYTE)valRaw[i]);
+ }
+ }
+ }
+ }
+ //-----------------------------------------------------
+ catch( otl_exception &e )
+ {
+ _Error_Message((const char *)e.msg, CSG_String::Format(SG_T("%s [%s]"), e.stm_text, e.var_info));
+
+ return( false );
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_ODBC_Connections::CSG_ODBC_Connections(void)
+{
+ otl_connect::otl_initialize(); // initialize ODBC environment
+
+ m_hEnv = SQL_NULL_HENV;
+ m_nConnections = 0;
+ m_pConnections = NULL;
+
+ Create();
+}
+
+//---------------------------------------------------------
+CSG_ODBC_Connections::~CSG_ODBC_Connections(void)
+{
+ Destroy();
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connections::Create(void)
+{
+ Destroy();
+
+#if ODBCVER >= 0x0300
+ SQLRETURN r = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_hEnv);
+#else
+ SQLRETURN r = SQLAllocEnv(&henv_);
+#endif
+
+ if( r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO )
+ {
+ SG_UI_Msg_Add_Error(SG_T("Failed to allocate environment handle"));
+
+ return( false );
+ }
+
+#if ODBCVER >= 0x0300
+ // this should immediately follow an AllocEnv per ODBC3
+ SQLSetEnvAttr(m_hEnv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_UINTEGER);
+#endif
+
+ return( true );
+}
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connections::Destroy(void)
+{
+ if( m_pConnections )
+ {
+ for(int i=0; i<m_nConnections; i++)
+ {
+ delete(m_pConnections[i]);
+ }
+
+ SG_Free(m_pConnections);
+
+ m_nConnections = 0;
+ m_pConnections = NULL;
+ }
+
+ if( m_hEnv != SQL_NULL_HENV )
+ {
+#if ODBCVER >= 0x0300
+ SQLRETURN r = SQLFreeHandle(SQL_HANDLE_ENV, m_hEnv);
+#else
+ SQLRETURN r = SQLFreeEnv(m_hEnv);
+#endif
+
+ if( r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO )
+ {
+ SG_UI_Msg_Add_Error(SG_T("Failed to close ODBC connection."));
+ }
+
+ m_hEnv = SQL_NULL_HENV;
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_ODBC_Connection * CSG_ODBC_Connections::Add_Connection(const CSG_String &Server, const CSG_String &User, const CSG_String &Password)
+{
+ CSG_ODBC_Connection *pConnection = new CSG_ODBC_Connection(Server, User, Password);
+
+ if( pConnection )
+ {
+ if( pConnection->is_Connected() )
+ {
+ m_pConnections = (CSG_ODBC_Connection **)SG_Realloc(m_pConnections, (m_nConnections + 1) * sizeof(CSG_ODBC_Connection *));
+
+ m_pConnections[m_nConnections++] = pConnection;
+ }
+ else
+ {
+ delete(pConnection);
+
+ pConnection = NULL;
+ }
+ }
+
+ return( pConnection );
+}
+
+//---------------------------------------------------------
+CSG_ODBC_Connection * CSG_ODBC_Connections::Get_Connection(const CSG_String &Server)
+{
+ for(int i=0; i<m_nConnections; i++)
+ {
+ if( m_pConnections[i]->Get_Server().Cmp(Server) == 0 )
+ {
+ return( m_pConnections[i] );
+ }
+ }
+
+ return( NULL );
+}
+
+//---------------------------------------------------------
+bool CSG_ODBC_Connections::Del_Connection(int Index, bool bCommit)
+{
+ if( Index >= 0 && Index < m_nConnections )
+ {
+ if( bCommit )
+ {
+ m_pConnections[Index]->Commit();
+ }
+ else
+ {
+ m_pConnections[Index]->Rollback();
+ }
+
+ delete(m_pConnections[Index]);
+
+ for(m_nConnections--; Index<m_nConnections; Index++)
+ {
+ m_pConnections[Index] = m_pConnections[Index + 1];
+ }
+
+ m_pConnections = (CSG_ODBC_Connection **)SG_Realloc(m_pConnections, m_nConnections * sizeof(CSG_ODBC_Connection *));
+
+ return( true );
+ }
+
+ return( false );
+}
+
+bool CSG_ODBC_Connections::Del_Connection(const CSG_String &Server, bool bCommit)
+{
+ for(int i=0; i<m_nConnections; i++)
+ {
+ if( m_pConnections[i]->Get_Server().Cmp(Server) == 0 )
+ {
+ return( Del_Connection(i, bCommit) );
+ }
+ }
+
+ return( false );
+}
+
+bool CSG_ODBC_Connections::Del_Connection(CSG_ODBC_Connection *pConnection, bool bCommit)
+{
+ return( !pConnection ? false : Del_Connection(pConnection->Get_Server(), bCommit) );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Strings CSG_ODBC_Connections::Get_Servers(void)
+{
+ CSG_Strings Servers;
+
+ SQLRETURN r;
+ SQLSMALLINT dsnlen, dsclen;
+ SQLTCHAR dsn[SQL_MAX_DSN_LENGTH + 1], dsc[256];
+
+ r = SQLDataSources(m_hEnv, SQL_FETCH_FIRST,
+ (SQLTCHAR *)dsn, SQL_MAX_DSN_LENGTH + 1, &dsnlen,
+ (SQLTCHAR *)dsc, 256, &dsclen
+ );
+
+ if( r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO )
+ {
+ SG_UI_Msg_Add_Error(SG_T("Unable to retrieve data source names!"));
+ }
+ else
+ {
+ do
+ {
+ Servers += CSG_String((SG_Char *)dsn);
+ SG_UI_Msg_Add_Execution(CSG_String::Format(SG_T("\n[%s] %s"), dsn, dsc), false);
+
+ r = SQLDataSources(m_hEnv, SQL_FETCH_NEXT,
+ (SQLTCHAR *)dsn, SQL_MAX_DSN_LENGTH + 1, &dsnlen,
+ (SQLTCHAR *)dsc, 256, &dsclen
+ );
+ }
+ while( r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO );
+ }
+
+ return( Servers );
+}
+
+//---------------------------------------------------------
+int CSG_ODBC_Connections::Get_Servers(CSG_String &Servers)
+{
+ CSG_Strings s = Get_Servers();
+
+ for(int i=0; i<s.Get_Count(); i++)
+ {
+ Servers += CSG_String::Format(SG_T("%s|"), s[i].c_str());
+ }
+
+ return( s.Get_Count() );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_Strings CSG_ODBC_Connections::Get_Connections(void)
+{
+ CSG_Strings Connections;
+
+ for(int i=0; i<m_nConnections; i++)
+ {
+ Connections.Add(m_pConnections[i]->Get_Server());
+ }
+
+ return( Connections );
+}
+
+//---------------------------------------------------------
+int CSG_ODBC_Connections::Get_Connections(CSG_String &Connections)
+{
+ CSG_Strings s = Get_Connections();
+
+ Connections.Clear();
+
+ for(int i=0; i<s.Get_Count(); i++)
+ {
+ Connections += CSG_String::Format(SG_T("%s|"), s[i].c_str());
+ }
+
+ return( s.Get_Count() );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+CSG_ODBC_Module::CSG_ODBC_Module(void)
+{
+ m_Connection_Choice.Create(this, LNG("Choose ODBC Connection"), LNG(""), SG_T("CONNECTIONS"));
+
+ m_Connection_Choice.Add_Choice(
+ NULL , "CONNECTIONS", LNG("Available Connections"),
+ LNG(""),
+ SG_T("")
+ );
+
+ if( !SG_UI_Get_Window_Main() )
+ {
+ Parameters.Add_String(
+ NULL , "ODBC_DSN" , LNG("DSN"),
+ LNG("Data Source Name"),
+ SG_T("")
+ );
+
+ Parameters.Add_String(
+ NULL , "ODBC_USR" , LNG("User"),
+ LNG("User Name"),
+ SG_T("")
+ );
+
+ Parameters.Add_String(
+ NULL , "ODBC_PWD" , LNG("Password"),
+ LNG("Password"),
+ SG_T("")
+ );
+ }
+
+ m_pConnection = NULL;
+}
+
+//---------------------------------------------------------
+bool CSG_ODBC_Module::On_Before_Execution(void)
+{
+ CSG_String s;
+
+ m_pConnection = NULL;
+
+ if( !SG_UI_Get_Window_Main() )
+ {
+ m_pConnection = SG_ODBC_Get_Connection_Manager().Add_Connection(
+ Parameters("ODBC_DSN")->asString(),
+ Parameters("ODBC_USR")->asString(),
+ Parameters("ODBC_PWD")->asString()
+ );
+ }
+ else
+ {
+ if( SG_ODBC_Get_Connection_Manager().Get_Connections(s) > 1 )
+ {
+ m_Connection_Choice("CONNECTIONS")->asChoice()->Set_Items(s);
+
+ if( SG_UI_Dlg_Parameters(&m_Connection_Choice, LNG("Choose ODBC Connection")) )
+ {
+ m_pConnection = SG_ODBC_Get_Connection_Manager().Get_Connection(m_Connection_Choice("CONNECTIONS")->asString());
+ }
+ }
+ else if( s.Length() )
+ {
+ m_pConnection = SG_ODBC_Get_Connection_Manager().Get_Connection(0);
+ }
+ }
+
+ if( m_pConnection == NULL )
+ {
+ Message_Dlg(
+ LNG("No ODBC connection available!"),
+ LNG("ODBC Database Connection Error")
+ );
+ }
+
+ return( m_pConnection != NULL );
+}
+
+//---------------------------------------------------------
+bool CSG_ODBC_Module::On_After_Execution(void)
+{
+ if( !SG_UI_Get_Window_Main() )
+ {
+ SG_ODBC_Get_Connection_Manager().Del_Connection(m_pConnection, true);
+ }
+
+ return( true );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+bool CSG_ODBC_Module::Set_Constraints(CSG_Parameters *pParameters, CSG_Table *pTable)
+{
+ if( !pParameters || !pTable )
+ {
+ return( false );
+ }
+
+ pParameters->Del_Parameters();
+
+ if( pTable )
+ {
+ CSG_Parameter *pP = pParameters->Add_Node(NULL, "P", LNG("Primary key)") , LNG(""));
+ CSG_Parameter *pN = pParameters->Add_Node(NULL, "N", LNG("Not Null") , LNG(""));
+ CSG_Parameter *pU = pParameters->Add_Node(NULL, "U", LNG("Unique") , LNG(""));
+
+ for(int i=0; i<pTable->Get_Field_Count(); i++)
+ {
+ pParameters->Add_Value(pP, CSG_String::Format(SG_T("P%d"), i), pTable->Get_Field_Name(i), LNG(""), PARAMETER_TYPE_Bool, false);
+ pParameters->Add_Value(pN, CSG_String::Format(SG_T("N%d"), i), pTable->Get_Field_Name(i), LNG(""), PARAMETER_TYPE_Bool, false);
+ pParameters->Add_Value(pU, CSG_String::Format(SG_T("U%d"), i), pTable->Get_Field_Name(i), LNG(""), PARAMETER_TYPE_Bool, false);
+ }
+ }
+
+ return( true );
+}
+
+//---------------------------------------------------------
+CSG_Buffer CSG_ODBC_Module::Get_Constraints(CSG_Parameters *pParameters, CSG_Table *pTable)
+{
+ CSG_Buffer Flags;
+
+ if( pParameters )
+ {
+ int nFields = pTable ? pTable->Get_Field_Count() : (pParameters->Get_Count() - 3) / 3;
+
+ if( nFields * 3 + 3 == pParameters->Get_Count() )
+ {
+ for(int i=0; i<nFields; i++)
+ {
+ char Flag = 0;
+
+ if( pParameters->Get_Parameter(CSG_String::Format(SG_T("P%d"), i))->asBool() )
+ {
+ Flag |= SG_ODBC_PRIMARY_KEY;
+ }
+
+ if( pParameters->Get_Parameter(CSG_String::Format(SG_T("N%d"), i))->asBool() )
+ {
+ Flag |= SG_ODBC_NOT_NULL;
+ }
+
+ if( pParameters->Get_Parameter(CSG_String::Format(SG_T("U%d"), i))->asBool() )
+ {
+ Flag |= SG_ODBC_UNIQUE;
+ }
+
+ Flags += Flag;
+ }
+ }
+ }
+
+ return( Flags );
+}
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
diff --git a/src/saga_core/saga_odbc/saga_odbc.h b/src/saga_core/saga_odbc/saga_odbc.h
new file mode 100644
index 0000000..c742134
--- /dev/null
+++ b/src/saga_core/saga_odbc/saga_odbc.h
@@ -0,0 +1,285 @@
+
+///////////////////////////////////////////////////////////
+// //
+// SAGA //
+// //
+// System for Automated Geoscientific Analyses //
+// //
+// Application Programming Interface //
+// //
+// Library: SAGA_ODBC //
+// //
+//-------------------------------------------------------//
+// //
+// saga_odbc.h //
+// //
+// Copyright (C) 2010 by //
+// Olaf Conrad //
+// //
+//-------------------------------------------------------//
+// //
+// This file is part of 'SAGA - System for Automated //
+// Geoscientific Analyses'. SAGA is free software; you //
+// can redistribute it and/or modify it under the terms //
+// of the GNU General Public License as published by the //
+// Free Software Foundation; version 2 of the License. //
+// //
+// SAGA is distributed in the hope that it will be //
+// useful, but WITHOUT ANY WARRANTY; without even the //
+// implied warranty of MERCHANTABILITY or FITNESS FOR A //
+// PARTICULAR PURPOSE. See the GNU General Public //
+// License for more details. //
+// //
+// You should have received a copy of the GNU General //
+// Public License along with this program; if not, //
+// write to the Free Software Foundation, Inc., //
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, //
+// USA. //
+// //
+//-------------------------------------------------------//
+// //
+// e-mail: oconrad at saga-gis.org //
+// //
+// contact: Olaf Conrad //
+// Institute of Geography //
+// University of Hamburg //
+// Germany //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#ifndef HEADER_INCLUDED__SAGA_ODBC_saga_odbc_H
+#define HEADER_INCLUDED__SAGA_ODBC_saga_odbc_H
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#include <saga_api/saga_api.h>
+
+#ifdef _SAGA_ODBC_EXPORTS
+ #define SG_ODBC_API_DLL_EXPORT _SAGA_DLL_EXPORT
+#else
+ #define SG_ODBC_API_DLL_EXPORT _SAGA_DLL_IMPORT
+#endif
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#define SG_ODBC_PRIMARY_KEY 0x01
+#define SG_ODBC_NOT_NULL 0x02
+#define SG_ODBC_UNIQUE 0x04
+
+//---------------------------------------------------------
+typedef enum ESG_ODBC_DBMS
+{
+ SG_ODBC_DBMS_PostgreSQL,
+ SG_ODBC_DBMS_MySQL,
+ SG_ODBC_DBMS_Oracle,
+ SG_ODBC_DBMS_MSSQLServer,
+ SG_ODBC_DBMS_Access,
+ SG_ODBC_DBMS_Unknown
+}
+TSG_ODBC_DBMS;
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class SG_ODBC_API_DLL_EXPORT CSG_ODBC_Connection
+{
+ friend class CSG_ODBC_Connections;
+
+public:
+
+ bool is_Connected (void) const { return( m_pConnection != NULL ); }
+
+ void Set_Auto_Commit (bool bOn);
+ bool Get_Auto_Commit (void) const { return( m_bAutoCommit ); }
+
+ int Get_Size_Buffer (void) const { return( m_Size_Buffer ); }
+ bool Set_Size_Buffer (int Size);
+
+ int Get_Size_LOB_Max (void) const;
+ bool Set_Size_LOB_Max (int Size);
+
+ CSG_String Get_DBMS_Name (void) const;
+ CSG_String Get_DBMS_Version (void) const;
+ TSG_ODBC_DBMS Get_DBMS (void) const { return( m_DBMS ); }
+
+ bool is_PostgreSQL (void) const { return( m_DBMS == SG_ODBC_DBMS_PostgreSQL ); }
+ bool is_MySQL (void) const { return( m_DBMS == SG_ODBC_DBMS_MySQL ); }
+ bool is_Oracle (void) const { return( m_DBMS == SG_ODBC_DBMS_Oracle ); }
+ bool is_MSSQLServer (void) const { return( m_DBMS == SG_ODBC_DBMS_MSSQLServer ); }
+ bool is_Access (void) const { return( m_DBMS == SG_ODBC_DBMS_Access ); }
+
+ CSG_String Get_Server (void) const { return( m_DSN ); }
+
+ CSG_String Get_Tables (void) const;
+ CSG_String Get_Field_Names (const CSG_String &Table_Name) const;
+ CSG_Table Get_Field_Desc (const CSG_String &Table_Name) const;
+
+ bool Execute (const CSG_String &SQL, bool bCommit = false);
+ bool Commit (void);
+ bool Rollback (void);
+
+ bool Table_Exists (const CSG_String &Table_Name) const;
+
+ bool Table_Create (const CSG_String &Table_Name, const CSG_Table &Table, const CSG_Buffer &Flags = 0, bool bCommit = true);
+ bool Table_Drop (const CSG_String &Table_Name , bool bCommit = true);
+ bool Table_Insert (const CSG_String &Table_Name, const CSG_Table &Table , bool bCommit = true);
+ bool Table_Save (const CSG_String &Table_Name, const CSG_Table &Table, const CSG_Buffer &Flags = 0, bool bCommit = true);
+
+ bool Table_Load (CSG_Table &Table , const CSG_String &Table_Name , bool bLOB = false);
+ bool Table_Load (CSG_Table &Table , const CSG_String &Table_Names, const CSG_String &Fields, const CSG_String &Where = SG_T(""), const CSG_String &Group = SG_T(""), const CSG_String &Having = SG_T(""), const CSG_String &Order = SG_T(""), bool bDistinct = false, bool bLOB = false);
+ bool Table_Load_BLOBs (CSG_Bytes_Array &BLOBs, const CSG_String &Table_Name , const CSG_String &Field , const CSG_String &Where = SG_T(""), const CSG_String &Order = SG_T(""));
+
+
+
+private:
+
+ CSG_ODBC_Connection(const CSG_String &Server, const CSG_String &User, const CSG_String &Password, bool bAutoCommit = false);
+ virtual ~CSG_ODBC_Connection(void);
+
+
+ TSG_ODBC_DBMS m_DBMS;
+
+ bool m_bAutoCommit;
+
+ int m_Size_Buffer;
+
+ void *m_pConnection;
+
+ CSG_String m_DSN;
+
+
+ CSG_String _Get_DBMS_Info (int What) const;
+
+ int _Get_Type_To_SQL (TSG_Data_Type Type);
+ TSG_Data_Type _Get_Type_From_SQL (int Type);
+
+ bool _Table_Load (CSG_Table &Table, const CSG_String &Select, const CSG_String &Name, bool bLOB);
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class SG_ODBC_API_DLL_EXPORT CSG_ODBC_Connections
+{
+public:
+ CSG_ODBC_Connections(void);
+ virtual ~CSG_ODBC_Connections(void);
+
+ bool Create (void);
+ bool Destroy (void);
+
+ int Get_Servers (CSG_String &Servers);
+ CSG_Strings Get_Servers (void);
+
+ int Get_Connections (CSG_String &Connections);
+ CSG_Strings Get_Connections (void);
+
+ int Get_Count (void) { return( m_nConnections ); }
+ CSG_ODBC_Connection * Get_Connection (int Index) { return( Index >= 0 && Index < m_nConnections ? m_pConnections[Index] : NULL ); }
+ CSG_ODBC_Connection * Get_Connection (const CSG_String &Server);
+ CSG_ODBC_Connection * Add_Connection (const CSG_String &Server, const CSG_String &User, const CSG_String &Password);
+ bool Del_Connection (int Index , bool bCommit);
+ bool Del_Connection (const CSG_String &Server , bool bCommit);
+ bool Del_Connection (CSG_ODBC_Connection *pConnection, bool bCommit);
+
+
+private:
+
+ void *m_hEnv;
+
+ int m_nConnections;
+
+ CSG_ODBC_Connection **m_pConnections;
+
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+class SG_ODBC_API_DLL_EXPORT CSG_ODBC_Module : public CSG_Module
+{
+public:
+ CSG_ODBC_Module(void);
+
+
+protected:
+
+ virtual bool On_Before_Execution (void);
+ virtual bool On_After_Execution (void);
+
+ CSG_ODBC_Connection * Get_Connection (void) { return( m_pConnection ); }
+
+ static bool Set_Constraints (CSG_Parameters *pParameters, CSG_Table *pTable);
+ static CSG_Buffer Get_Constraints (CSG_Parameters *pParameters, CSG_Table *pTable);
+
+
+private:
+
+ CSG_ODBC_Connection *m_pConnection;
+
+ CSG_Parameters m_Connection_Choice;
+
+
+};
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+SG_ODBC_API_DLL_EXPORT CSG_ODBC_Connections & SG_ODBC_Get_Connection_Manager (void);
+
+//---------------------------------------------------------
+SG_ODBC_API_DLL_EXPORT bool SG_ODBC_is_Supported (void);
+
+
+///////////////////////////////////////////////////////////
+// //
+// //
+// //
+///////////////////////////////////////////////////////////
+
+//---------------------------------------------------------
+#endif // #ifndef HEADER_INCLUDED__SAGA_ODBC_saga_odbc_H
--
Saga GIS
More information about the Pkg-grass-devel
mailing list